diff --git a/CMakeLists.txt b/CMakeLists.txt index 090fb23a4af79cd2bb7706d5b177e7e0b4e0be0a..17f2fa0976beecec847292506564d86b6819ceee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,8 +69,8 @@ ENDIF(WIN32) FIND_PACKAGE(Boost 1.64 REQUIRED COMPONENTS thread date_time - system filesystem + system program_options signals serialization diff --git a/README.md b/README.md index 436641842fbdf68ebc1fd92101d04d584092f916..857d3fdba11b09b4e4cc5bbb96b668113f5fd164 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,12 @@ developing applications (smart contracts). The public testnet described in the [wiki](https://github.com/EOSIO/eos/wiki/Testnet%3A%20Public) is running the `dawn-2.x` branch. The `master` branch is no longer compatible with the public testnet. Instructions are provided below for building either option. +### Supported Operating Systems +EOS.IO currently supports the following operating systems: +1. Ubuntu 16.04 and higher (Ubuntu 16.10 recommended). +2. MacOS Darwin 10.12 and higher (MacOS 10.13.x recommended). +3. Fedora 25 and higher (Fedora 27 recommended). + # Resources 1. [EOS.IO Website](https://eos.io) 2. [Documentation](https://eosio.github.io/eos/) @@ -27,10 +33,10 @@ The public testnet described in the [wiki](https://github.com/EOSIO/eos/wiki/Tes 1. [Getting Started](#gettingstarted) 2. [Setting up a build/development environment](#setup) 1. [Automated build script](#autobuild) - 1. [Clean install Ubuntu 16.10 for a local testnet](#autoubuntulocal) - 2. [Clean install Ubuntu 16.10 for the public testnet](#autoubuntupublic) - 3. [MacOS Sierra 10.12.6 for a local testnet](#automaclocal) - 4. [MacOS Sierra 10.12.6 for the public testnet](#automacpublic) + 1. [Clean install Linux (Ubuntu & Fedora) for a local testnet](#autoubuntulocal) + 2. [Clean install Linux (Ubuntu & Fedora) for the public testnet](#autoubuntupublic) + 3. [MacOS for a local testnet](#automaclocal) + 4. [MacOS for the public testnet](#automacpublic) 3. [Building EOS and running a node](#runanode) 1. [Getting the code](#getcode) 2. [Building from source code](#build) @@ -48,8 +54,9 @@ The public testnet described in the [wiki](https://github.com/EOSIO/eos/wiki/Tes 7. [Doxygen documentation](#doxygen) 8. [Running EOS in Docker](#docker) 9. [Manual installation of the dependencies](#manualdep) - 1. [Clean install Ubuntu 16.10](#ubuntu) - 2. [MacOS Sierra 10.12.6](#macos) + 1. [Clean install Ubuntu 16.04 and higher](#ubuntu) + 2. [MacOS Sierra 10.12 and higher](#macos) + 3. [Fedora 25 and higher](#fedora) ## Getting Started @@ -61,31 +68,34 @@ The following instructions detail the process of getting the software, building ### Automated build script -For Ubuntu 16.10 and MacOS Sierra, there is an automated build script that can install all dependencies and builds EOS. +Supported Operating Systems: +1. Ubuntu 16.04 and higher. +2. MacOS Darwin 10.12 and higher. +3. Fedora 25 and higher. -It is called eosio-build.sh with the following inputs. -- architecture [ubuntu|darwin] -- optional mode [full|build] +For Ubuntu, MacOS and Fedora there is an automated build script that can install all dependencies and builds EOS. +We are working on supporting Centos, Amazon Linux & Red Hat in future releases. -The second optional input can be `full` or `build` where `full` implies that it installs dependencies and builds eos. If you omit this input then the build script installs dependencies and then builds eos. +It is called eosio_build.sh ```bash -./eosio-build.sh +cd eos +./eosio_build.sh ``` -Choose whether you will be building for a local testnet or for the public testnet and jump to the appropriate section below. Clone the EOS repository recursively as described and run eosio-build.sh located in the root `eos` folder. +Choose whether you will be building for a local testnet or for the public testnet and jump to the appropriate section below. Clone the EOS repository recursively as described and run eosio_build.sh located in the root `eos` folder. :warning: **As of February 2018, `master` is under heavy development and is not suitable for experimentation.** :warning: We strongly recommend following the instructions for building the public testnet version for [Ubuntu](#autoubuntupublic) or [Mac OS X](#automacpublic). `master` is in pieces on the garage floor while we rebuild this hotrod. This notice will be removed when `master` is usable again. Your patience is appreciated. -#### :no_entry: Clean install Ubuntu 16.10 for a local testnet :no_entry: +#### :no_entry: Clean install Linux (Ubuntu & Fedora) for a local testnet :no_entry: ```bash git clone https://github.com/eosio/eos --recursive cd eos -./eosio-build.sh ubuntu +./eosio_build.sh ``` For ease of contract development, one further step is required: @@ -97,14 +107,15 @@ sudo make install Now you can proceed to the next step - [Creating and launching a single-node testnet](#singlenode) -#### Clean install Ubuntu 16.10 for the public testnet +#### Clean install Linux (Ubuntu & Fedora) for the public testnet ```bash git clone https://github.com/eosio/eos --recursive cd eos -git checkout dawn-2.x -./build.sh ubuntu + +git checkout DAWN-2018-01-25 +./eosio_build.sh ``` For ease of contract development, one further step is required: @@ -116,22 +127,18 @@ sudo make install Now you can proceed to the next step - [Running a node on the public testnet](#publictestnet) -#### :no_entry: MacOS Sierra for a local testnet :no_entry: +#### :no_entry: MacOS for a local testnet :no_entry: -Before running the script make sure you have updated XCode and brew: +Before running the script make sure you have installed/updated XCode. Note: The build script +will install homebrew if it is not already installed on you system. [Homebrew Website](https://brew.sh) -```bash -xcode-select --install -ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -``` - -Then clone the EOS repository recursively and run eosio-build.sh in the root `eos` folder. +Then clone the EOS repository recursively and run eosio_build.sh in the root `eos` folder. ```bash git clone https://github.com/eosio/eos --recursive cd eos -./eosio-build.sh darwin +./eosio_build.sh ``` For ease of contract development, one further step is required: @@ -143,23 +150,20 @@ make install Now you can proceed to the next step - [Creating and launching a single-node testnet](#singlenode) -#### MacOS Sierra for the public testnet - -Before running the script make sure you have updated XCode and brew: +#### MacOS for the public testnet -```bash -xcode-select --install -ruby -e "$(curl -fsSl https://raw.githubusercontent.com/Homebrew/install/master/install)" -``` +Before running the script make sure you have installed/updated XCode. Note: The build script +will install homebrew if it is not already installed on you system. [Homebrew Website](https://brew.sh) -Then clone the EOS repository recursively, checkout the branch that is compatible with the public testnet, and run eosio-build.sh in the root `eos` folder. +Then clone the EOS repository recursively, checkout the branch that is compatible with the public testnet, and run eosio_build.sh in the root `eos` folder. ```bash git clone https://github.com/eosio/eos --recursive cd eos -git checkout dawn-2.x -./build.sh darwin + +git checkout DAWN-2018-01-25 +./eosio_build.sh ``` For ease of contract development, one further step is required: @@ -199,7 +203,7 @@ cd ~ git clone https://github.com/eosio/eos --recursive mkdir -p ~/eos/build && cd ~/eos/build cmake -DBINARYEN_BIN=~/binaryen/bin -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib .. -make -j4 +make -j$( nproc ) ``` Out-of-source builds are also supported. To override clang's default choice in compiler, add these flags to the CMake command: @@ -557,7 +561,7 @@ Dependencies: * Clang 4.0.0 * CMake 3.5.1 -* Boost 1.64 +* Boost 1.66 * OpenSSL * LLVM 4.0 * [secp256k1-zkp (Cryptonomex branch)](https://github.com/cryptonomex/secp256k1-zkp.git) @@ -578,14 +582,14 @@ sudo apt-get install clang-4.0 lldb-4.0 libclang-4.0-dev cmake make \ autoconf libtool git ``` -Install Boost 1.64: +Install Boost 1.66: ```bash cd ~ -wget -c 'https://sourceforge.net/projects/boost/files/boost/1.64.0/boost_1_64_0.tar.bz2/download' -O boost_1.64.0.tar.bz2 -tar xjf boost_1.64.0.tar.bz2 -cd boost_1_64_0/ -echo "export BOOST_ROOT=$HOME/opt/boost_1_64_0" >> ~/.bash_profile +wget -c 'https://sourceforge.net/projects/boost/files/boost/1.64.0/boost_1_66_0.tar.bz2/download' -O boost_1.64.0.tar.bz2 +tar xjf boost_1.66.0.tar.bz2 +cd boost_1_66_0/ +echo "export BOOST_ROOT=$HOME/boost_1_66_0" >> ~/.bash_profile source ~/.bash_profile ./bootstrap.sh "--prefix=$BOOST_ROOT" ./b2 install @@ -636,6 +640,13 @@ cd build cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=.. -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../ make -j4 install ``` +Add `WASM_LLVM_CONFIG` and `LLVM_DIR` to your `.bash_profile`: + +```bash +echo "export WASM_LLVM_CONFIG=~/wasm-compiler/llvm/bin/llvm-config" >> ~/.bash_profile +echo "export LLVM_DIR=~/wasm-compiler/lib/cmake/llvm" >> ~/.bash_profile +source ~/.bash_profile +``` Your environment is set up. Now you can build EOS and run a node. @@ -696,7 +707,6 @@ echo "export BINARYEN_ROOT=~/binaryen" >> ~/.bash_profile source ~/.bash_profile ``` - Build LLVM and clang for WASM: ```bash @@ -709,13 +719,94 @@ cd .. mkdir build cd build cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=.. -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../ -make -j4 install +make -j$( nproc ) install +``` + +Add `WASM_LLVM_CONFIG` and `LLVM_DIR` to your `.bash_profile`: + +```bash +echo "export WASM_LLVM_CONFIG=~/wasm-compiler/llvm/bin/llvm-config" >> ~/.bash_profile +echo "export LLVM_DIR=/usr/local/Cellar/llvm@4/4.0.1/lib/cmake/llvm/" >> ~/.bash_profile +source ~/.bash_profile +``` + + +### Clean install Fedora 25 and higher + +Install the development toolkit: + +```bash +sudo yum update +sudo yum install git gcc.x86_64 gcc-c++.x86_64 autoconf automake libtool make cmake.x86_64 \ + bzip2 bzip2-devel.x86_64 openssl-devel.x86_64 gmp-devel.x86_64 \ + libstdc++-devel.x86_64 python3-devel.x86_64 libedit.x86_64 \ + ncurses-devel.x86_64 swig.x86_64 gettext-devel.x86_64 + +``` + +Install Boost 1.66: + +```bash +cd ~ +curl -L https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.bz2 > boost_1.66.0.tar.bz2 +tar xf boost_1.66.0.tar.bz2 +echo "export BOOST_ROOT=$HOME/boost_1_66_0" >> ~/.bash_profile +source ~/.bash_profile +cd boost_1_66_0/ +./bootstrap.sh "--prefix=$BOOST_ROOT" +./b2 install +``` + +Install [secp256k1-zkp (Cryptonomex branch)](https://github.com/cryptonomex/secp256k1-zkp.git): + +```bash +cd ~ +git clone https://github.com/cryptonomex/secp256k1-zkp.git +cd secp256k1-zkp +./autogen.sh +./configure +make +sudo make install +``` + +To use the WASM compiler, EOS has an external dependency on [binaryen](https://github.com/WebAssembly/binaryen.git): + +```bash +cd ~ +git clone https://github.com/WebAssembly/binaryen.git +cd ~/binaryen +git checkout tags/1.37.14 +cmake . && make + +``` + +Add `BINARYEN_ROOT` to your .bash_profile: + +```bash +echo "export BINARYEN_ROOT=~/binaryen" >> ~/.bash_profile +source ~/.bash_profile +``` + +By default LLVM and clang do not include the WASM build target, so you will have to build it yourself: + +```bash +mkdir ~/wasm-compiler +cd ~/wasm-compiler +git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git +cd llvm/tools +git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git +cd .. +mkdir build +cd build +cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=.. -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../ +make -j$( nproc ) install ``` Add `WASM_LLVM_CONFIG` and `LLVM_DIR` to your `.bash_profile`: ```bash echo "export WASM_LLVM_CONFIG=~/wasm-compiler/llvm/bin/llvm-config" >> ~/.bash_profile -echo "export LLVM_DIR=/usr/local/Cellar/llvm\@4/4.0.1/lib/cmake/llvm" >> ~/.bash_profile +echo "export LLVM_DIR=~/wasm-compiler/lib/cmake/llvm" >> ~/.bash_profile source ~/.bash_profile ``` +Your environment is set up. Now you can build EOS and run a node. diff --git a/contracts/eosio.system/eosio.system.hpp b/contracts/eosio.system/eosio.system.hpp index 42022efd05fac57ef24e84ad1ebc0df5a6c45cb2..655a4c7ff86b9aad42ce966fe2c6e0777eec6d4f 100644 --- a/contracts/eosio.system/eosio.system.hpp +++ b/contracts/eosio.system/eosio.system.hpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace eosiosystem { @@ -21,12 +22,15 @@ namespace eosiosystem { static const account_name system_account = SystemAccount; typedef eosio::generic_currency< eosio::token > currency; - struct total_bandwidth { + struct total_resources { account_name owner; typename currency::token_type total_net_weight; typename currency::token_type total_cpu_weight; + uint32_t total_ram = 0; uint64_t primary_key()const { return owner; } + + EOSLIB_SERIALIZE( total_resources, (owner)(total_net_weight)(total_cpu_weight)(total_ram) ); }; @@ -50,10 +54,15 @@ namespace eosiosystem { uint64_t primary_key()const { return to; } + + EOSLIB_SERIALIZE( delegated_bandwidth, (from)(to)(net_weight)(cpu_weight) + (start_pending_net_withdraw)(pending_net_withdraw)(deferred_net_withdraw_handler) + (start_pending_cpu_withdraw)(pending_cpu_withdraw)(deferred_cpu_withdraw_handler) ); + }; - typedef eosio::multi_index< N(totalband), total_bandwidth > total_bandwidth_index_type; + typedef eosio::multi_index< N(totalband), total_resources> total_resources_index_type; typedef eosio::multi_index< N(delband), delegated_bandwidth> del_bandwidth_index_type; @@ -80,7 +89,7 @@ namespace eosiosystem { typename currency::token_type stake_quantity; - EOSLIB_SERIALIZE( delnetbw, (delegator)(receiver)(stake_quantity) ) + EOSLIB_SERIALIZE( delnetbw, (from)(receiver)(stake_quantity) ) }; ACTION( SystemAccount, undelnetbw ) { @@ -105,14 +114,15 @@ namespace eosiosystem { require_auth( del.from ); del_bandwidth_index_type del_index( SystemAccount, del.from ); - total_bandwidth_index_type total_index( SystemAccount, del.to ); - // require_account( receiver ); + total_resources_index_type total_index( SystemAccount, del.receiver ); + + //eosio_assert( is_account( del.receiver ), "can only delegate resources to an existing account" ); - auto itr = del_index.find( del.to ); - if( itr == del_index.end() ) { + auto itr = del_index.find( del.receiver); + if( itr != nullptr ) { del_index.emplace( del.from, [&]( auto& dbo ){ dbo.from = del.from; - dbo.to = del.to; + dbo.to = del.receiver; dbo.net_weight = del.stake_quantity; }); } @@ -122,10 +132,10 @@ namespace eosiosystem { }); } - auto tot_itr = total_index.find( del.to ); - if( tot_itr == total_index.end() ) { - total_index.emplace( del.from, [&]( auto& tot ) { - tot.owner = del.to; + auto tot_itr = total_index.find( del.receiver ); + if( tot_itr == nullptr ) { + tot_itr = &total_index.emplace( del.from, [&]( auto& tot ) { + tot.owner = del.receiver; tot.total_net_weight += del.stake_quantity; }); } else { @@ -134,6 +144,8 @@ namespace eosiosystem { }); } + set_resource_limits( tot_itr->owner, tot_itr->total_ram, tot_itr->total_net_weight.quantity, tot_itr->total_cpu_weight.quantity, 0 ); + currency::inline_transfer( del.from, SystemAccount, del.stake_quantity, "stake bandwidth" ); } // delnetbw @@ -150,7 +162,7 @@ namespace eosiosystem { static void apply( account_name code, action_name act ) { - if( !eosio::dispatch( code, act) ) { + if( !eosio::dispatch( code, act) ) { if ( !eosio::dispatch( code, act ) ) { eosio::print("Unexpected action: ", eosio::name(act), "\n"); eosio_assert( false, "received unexpected action"); diff --git a/contracts/eosiolib/db.h b/contracts/eosiolib/db.h index a74f7e2b80c7456186506c21027fbaccb67a6019..5bf6ea18b483f73ea2a36053a06b917014df98c5 100644 --- a/contracts/eosiolib/db.h +++ b/contracts/eosiolib/db.h @@ -1027,6 +1027,36 @@ int32_t store_i64i64i64( account_name scope, table_name table, account_name bta, * @return 1 if the record was updated, 0 if no record with key was found */ int32_t update_i64i64i64( account_name scope, table_name table, account_name bta, const void* data, uint32_t len ); +///@} dbi64i64i64 + +int32_t db_store_i64(account_name scope, table_name table, account_name payer, uint64_t id, const void* data, uint32_t len); +void db_update_i64(int32_t iterator, account_name payer, const void* data, uint32_t len); +void db_remove_i64(int32_t iterator); +int32_t db_get_i64(int32_t iterator, const void* data, uint32_t len); +int32_t db_next_i64(int32_t iterator, uint64_t* primary); +int32_t db_previous_i64(int32_t iterator, uint64_t* primary); +int32_t db_find_i64(account_name code, account_name scope, table_name table, uint64_t id); +int32_t db_lowerbound_i64( account_name code, account_name scope, table_name table, uint64_t id); +int32_t db_upperbound_i64( account_name code, account_name scope, table_name table, uint64_t id); + +int32_t db_idx64_store(account_name scope, table_name table, account_name payer, uint64_t id, const uint64_t* secondary); +void db_idx64_update(int32_t iterator, account_name payer, const uint64_t* secondary); +void db_idx64_remove(int32_t iterator); +int32_t db_idx64_next(int32_t iterator, uint64_t* primary); +int32_t db_idx64_previous(int32_t iterator, uint64_t* primary); +int32_t db_idx64_find_primary(account_name code, account_name scope, table_name table, uint64_t* secondary, uint64_t primary); +int32_t db_idx64_find_secondary(account_name code, account_name scope, table_name table, const uint64_t* secondary, uint64_t* primary); +int32_t db_idx64_lowerbound(account_name code, account_name scope, table_name table, uint64_t* secondary, uint64_t* primary); +int32_t db_idx64_upperbound(account_name code, account_name scope, table_name table, uint64_t* secondary, uint64_t* primary); + +int32_t db_idx128_store(account_name scope, table_name table, account_name payer, uint64_t id, const uint128_t* secondary); +void db_idx128_update(int32_t iterator, account_name payer, const uint128_t* secondary); +void db_idx128_remove(int32_t iterator); +int32_t db_idx128_next(int32_t iterator, uint64_t* primary); +int32_t db_idx128_previous(int32_t iterator, uint64_t* primary); +int32_t db_idx128_find_primary(account_name code, account_name scope, table_name table, uint128_t* secondary, uint64_t primary); +int32_t db_idx128_find_secondary(account_name code, account_name scope, table_name table, const uint128_t* secondary, uint64_t* primary); +int32_t db_idx128_lowerbound(account_name code, account_name scope, table_name table, uint128_t* secondary, uint64_t* primary); +int32_t db_idx128_upperbound(account_name code, account_name scope, table_name table, uint128_t* secondary, uint64_t* primary); -///@} dbi64i64i64 } diff --git a/contracts/eosiolib/multi_index.hpp b/contracts/eosiolib/multi_index.hpp index 6cfa1e253e98de0ebf04c094847938284397ec87..63f3ad81d9aed9b70a241da02db3e36964c948ee 100644 --- a/contracts/eosiolib/multi_index.hpp +++ b/contracts/eosiolib/multi_index.hpp @@ -11,36 +11,9 @@ #include #include #include +#include -extern "C" { - int db_store_i64( uint64_t scope, uint64_t table, uint64_t payer, uint64_t id, char* buffer, size_t buffer_size ); - void db_update_i64( int iterator, uint64_t payer, char* buffer, size_t buffer_size ); - int db_find_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id ); - int db_lowerbound_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id ); - int db_get_i64( int iterator, char* buffer, size_t buffer_size ); - void db_remove_i64( int iterator ); - int db_next_i64( int iterator, uint64_t* pk ); - int db_previous_i64( int iterator, uint64_t* pk ); - - int db_idx64_next( int iterator, uint64_t* primary ); - int db_idx64_prev( int iterator, uint64_t* primary ); - int db_idx64_find_primary( uint64_t code, uint64_t scope, uint64_t table, uint64_t* secondary, uint64_t primary ); - int db_idx64_find_secondary( uint64_t code, uint64_t scope, uint64_t table, uint64_t* secondary, uint64_t* primary ); - int db_idx64_lowerbound( uint64_t code, uint64_t scope, uint64_t table, uint64_t* secondary, uint64_t* primary ); - int db_idx64_upperbound( uint64_t code, uint64_t scope, uint64_t table, uint64_t* secondary, uint64_t* primary ); - void db_idx64_remove( int iterator ); - void db_idx64_update( int iterator, uint64_t payer, const uint64_t* secondary ); - - int db_idx128_next( int iterator, uint64_t* primary ); - int db_idx128_prev( int iterator, uint64_t* primary ); - int db_idx128_find_primary( uint64_t code, uint64_t scope, uint64_t table, uint128_t* secondary, uint64_t primary ); - int db_idx128_find_secondary( uint64_t code, uint64_t scope, uint64_t table, uint128_t* secondary, uint64_t* primary ); - int db_idx128_lowerbound( uint64_t code, uint64_t scope, uint64_t table, uint128_t* secondary, uint64_t* primary ); - int db_idx128_upperbound( uint64_t code, uint64_t scope, uint64_t table, uint128_t* secondary, uint64_t* primary ); - void db_idx128_remove( int iterator ); - void db_idx128_update( int iterator, uint64_t payer, const uint128_t* secondary ); -} namespace eosio { @@ -54,14 +27,14 @@ struct secondary_iterator; template<> struct secondary_iterator { static int db_idx_next( int iterator, uint64_t* primary ) { return db_idx64_next( iterator, primary ); } - static int db_idx_prev( int iterator, uint64_t* primary ) { return db_idx64_prev( iterator, primary ); } + static int db_idx_prev( int iterator, uint64_t* primary ) { return db_idx64_previous( iterator, primary ); } static void db_idx_remove( int iterator ) { db_idx64_remove( iterator ); } }; template<> struct secondary_iterator { static int db_idx_next( int iterator, uint64_t* primary ) { return db_idx128_next( iterator, primary ); } - static int db_idx_prev( int iterator, uint64_t* primary ) { return db_idx128_prev( iterator, primary ); } + static int db_idx_prev( int iterator, uint64_t* primary ) { return db_idx128_previous( iterator, primary ); } static void db_idx_remove( int iterator ) { db_idx128_remove( iterator ); } }; @@ -436,7 +409,6 @@ class multi_index auto secondary_keys = boost::hana::transform( _indicies, [&]( auto& idx ) { return idx.extract_secondary_key( obj ); }); - boost::hana::at_c<0>(secondary_keys); auto mutableobj = const_cast(obj); updater( mutableobj ); diff --git a/contracts/eosiolib/privileged.h b/contracts/eosiolib/privileged.h new file mode 100644 index 0000000000000000000000000000000000000000..990da41c81a76fc68594f3cbbd659387454adf62 --- /dev/null +++ b/contracts/eosiolib/privileged.h @@ -0,0 +1,24 @@ +#pragma once + +extern "C" { + + /** + * @defgroup privilegedapi Privileged API + * @ingroup systemapi + * @brief Defines an API for accessing configuration of the chain that can only be done by privileged accounts + */ + + /** + * @defgroup privilegedcapi Privileged C API + * @ingroup privilegedapi + * @brief Define C Privileged API + * + * @{ + */ + + void set_resource_limits( account_name account, int64_t ram_bytes, int64_t net_weight, int64_t cpu_weight, int64_t ignored); + + void set_active_producers( char *producer_data, size_t producer_data_size ); + + ///@ } privilegedcapi +} diff --git a/contracts/eosiolib/system.h b/contracts/eosiolib/system.h index b3d72b7d004dd7cf020a3ef29b796b153ef3abd1..dca3af7f30cfb1e4042d931ff0180a72a03d6db8 100644 --- a/contracts/eosiolib/system.h +++ b/contracts/eosiolib/system.h @@ -39,25 +39,6 @@ extern "C" { time now(); ///@ } systemcapi - /** - * @defgroup privilegedapi Privileged API - * @ingroup systemapi - * @brief Defines an API for accessing configuration of the chain that can only be done by privileged accounts - */ - - /** - * @defgroup privilegedcapi Privileged C API - * @ingroup privilegedapi - * @brief Define C Privileged API - * - * @{ - */ - - void set_resource_limits( account_name account, int64_t ram_bytes, int64_t net_weight, int64_t cpu_weight, int64_t ignored); - - void set_active_producers( char *producer_data, size_t producer_data_size ); - - ///@ } privilegedcapi } diff --git a/contracts/test.system/test.system.cpp b/contracts/test.system/test.system.cpp index e03b83cfeb112c93544183fa61b38ba4f6abd104..488f1919c921593857910295bc0f512aece31d9b 100644 --- a/contracts/test.system/test.system.cpp +++ b/contracts/test.system/test.system.cpp @@ -7,6 +7,7 @@ #include #include #include +#include using namespace eosio; diff --git a/contracts/test_api/test_api.cpp b/contracts/test_api/test_api.cpp index 19bdb6347dea56b0617d6892942e004beb089879..b3b6f98c2aa22ef11663b91e3af845d778924a66 100644 --- a/contracts/test_api/test_api.cpp +++ b/contracts/test_api/test_api.cpp @@ -17,6 +17,7 @@ //#include "test_real.cpp" //#include "test_transaction.cpp" //#include "test_types.cpp" +#include "test_db.cpp" extern "C" { @@ -91,7 +92,14 @@ extern "C" { // WASM_TEST_HANDLER(test_db, key_i64i64i64_under_limit); // WASM_TEST_HANDLER(test_db, key_i64i64i64_available_space_exceed_limit); // WASM_TEST_HANDLER(test_db, key_i64i64i64_another_under_limit); -// + + WASM_TEST_HANDLER(test_db, primary_i64_general); + WASM_TEST_HANDLER(test_db, primary_i64_lowerbound); + WASM_TEST_HANDLER(test_db, primary_i64_upperbound); + WASM_TEST_HANDLER(test_db, idx64_general); + WASM_TEST_HANDLER(test_db, idx64_lowerbound); + WASM_TEST_HANDLER(test_db, idx64_upperbound); + // //test crypto // WASM_TEST_HANDLER(test_crypto, test_sha256); // WASM_TEST_HANDLER(test_crypto, sha256_no_data); diff --git a/contracts/test_api/test_api.hpp b/contracts/test_api/test_api.hpp index 0107bbf2e2920ce8e1664ded9461de58a7efa2ab..a344a25fb4a4bbb29c88f7c0016ae86243f9ecff 100644 --- a/contracts/test_api/test_api.hpp +++ b/contracts/test_api/test_api.hpp @@ -117,6 +117,13 @@ struct test_db { static unsigned int key_i64i64i64_under_limit(); static unsigned int key_i64i64i64_available_space_exceed_limit(); static unsigned int key_i64i64i64_another_under_limit(); + + static void primary_i64_general(); + static void primary_i64_lowerbound(); + static void primary_i64_upperbound(); + static void idx64_general(); + static void idx64_lowerbound(); + static void idx64_upperbound(); }; struct test_crypto { diff --git a/contracts/test_api/test_db.cpp b/contracts/test_api/test_db.cpp index 9186c369fd8b3deb7e5353bcbab133b9be57b849..da780b2db843ca18c26612e07e3da6a99305b885 100644 --- a/contracts/test_api/test_db.cpp +++ b/contracts/test_api/test_db.cpp @@ -68,6 +68,8 @@ extern "C" { bool my_memcmp(void *s1, void *s2, uint32_t n); } +#if 0 + unsigned int test_db::key_str_table() { const char* keys[] = { "alice", "bob", "carol", "dave" }; @@ -76,95 +78,99 @@ unsigned int test_db::key_str_table() { const char* atr[] = { "atr", "atr", "atr", "atr" }; const char* ztr[] = { "ztr", "ztr", "ztr", "ztr" }; - eosio::var_table StringTableAtr; - eosio::var_table StringTableZtr; - eosio::var_table StringTableStr; + eosio::var_table StringTableAtr; + eosio::var_table StringTableZtr; + eosio::var_table StringTableStr; uint32_t res = 0; // fill some data in contiguous tables for( int ii = 0; ii < 4; ++ii ) { res = StringTableAtr.store( (char*)keys[ii], STRLEN(keys[ii]), (char*)atr[ii], STRLEN(atr[ii]) ); - WASM_ASSERT( res != 0, "atr" ); + eos_assert( res != 0, "atr" ); res = StringTableZtr.store( (char*)keys[ii], STRLEN(keys[ii]), (char*)ztr[ii], STRLEN(ztr[ii]) ); - WASM_ASSERT(res != 0, "ztr" ); + eos_assert(res != 0, "ztr" ); } char tmp[64]; res = StringTableStr.store ((char *)keys[0], STRLEN(keys[0]), (char *)vals[0], STRLEN(vals[0])); - WASM_ASSERT(res != 0, "store alice" ); + eos_assert(res != 0, "store alice" ); res = StringTableStr.store((char *)keys[1], STRLEN(keys[1]), (char *)vals[1], STRLEN(vals[1]) ); - WASM_ASSERT(res != 0, "store bob" ); + eos_assert(res != 0, "store bob" ); res = StringTableStr.store((char *)keys[2], STRLEN(keys[2]), (char *)vals[2], STRLEN(vals[2]) ); - WASM_ASSERT(res != 0, "store carol" ); + eos_assert(res != 0, "store carol" ); res = StringTableStr.store((char *)keys[3], STRLEN(keys[3]), (char *)vals[3], STRLEN(vals[3]) ); - WASM_ASSERT(res != 0, "store dave" ); + eos_assert(res != 0, "store dave" ); res = StringTableStr.load((char *)keys[0], STRLEN(keys[0]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[0]) && my_memcmp((void *)vals[0], (void *)tmp, res), "load alice"); + eos_assert(res == STRLEN(vals[0]) && my_memcmp((void *)vals[0], (void *)tmp, res), "load alice"); res = StringTableStr.load((char *)keys[1], STRLEN(keys[1]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[1]) && my_memcmp((void *)vals[1], (void *)tmp, res), "load bob"); + eos_assert(res == STRLEN(vals[1]) && my_memcmp((void *)vals[1], (void *)tmp, res), "load bob"); res = StringTableStr.load((char *)keys[2], STRLEN(keys[2]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[2]) && my_memcmp((void *)vals[2], (void *)tmp, res), "load carol"); + eos_assert(res == STRLEN(vals[2]) && my_memcmp((void *)vals[2], (void *)tmp, res), "load carol"); res = StringTableStr.load((char *)keys[3], STRLEN(keys[3]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[3]) && my_memcmp((void *)vals[3], (void *)tmp, res), "load dave"); + eos_assert(res == STRLEN(vals[3]) && my_memcmp((void *)vals[3], (void *)tmp, res), "load dave"); res = StringTableStr.previous((char *)keys[3], STRLEN(keys[3]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[2]) && my_memcmp((void *)vals[2], (void *)tmp, res), "back carol"); + eos_assert(res == STRLEN(vals[2]) && my_memcmp((void *)vals[2], (void *)tmp, res), "back carol"); res = StringTableStr.previous((char *)keys[2], STRLEN(keys[2]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[1]) && my_memcmp((void *)vals[1], (void *)tmp, res), "back dave"); + eos_assert(res == STRLEN(vals[1]) && my_memcmp((void *)vals[1], (void *)tmp, res), "back dave"); res = StringTableStr.previous((char *)keys[1], STRLEN(keys[1]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[0]) && my_memcmp((void *)vals[0], (void *)tmp, res), "back alice"); + eos_assert(res == STRLEN(vals[0]) && my_memcmp((void *)vals[0], (void *)tmp, res), "back alice"); res = StringTableStr.previous((char *)keys[0], STRLEN(keys[0]), tmp, 64); - WASM_ASSERT(res == -1, "no prev"); + eos_assert(res == -1, "no prev"); res = StringTableStr.next((char *)keys[0], STRLEN(keys[0]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[1]) && my_memcmp((void *)vals[1], (void *)tmp, res), "next bob"); + eos_assert(res == STRLEN(vals[1]) && my_memcmp((void *)vals[1], (void *)tmp, res), "next bob"); res = StringTableStr.next((char *)keys[1], STRLEN(keys[1]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[2]) && my_memcmp((void *)vals[2], (void *)tmp, res), "next carol"); + eos_assert(res == STRLEN(vals[2]) && my_memcmp((void *)vals[2], (void *)tmp, res), "next carol"); res = StringTableStr.next((char *)keys[2], STRLEN(keys[2]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[3]) && my_memcmp((void *)vals[3], (void *)tmp, res), "next dave"); + eos_assert(res == STRLEN(vals[3]) && my_memcmp((void *)vals[3], (void *)tmp, res), "next dave"); res = StringTableStr.next((char *)keys[3], STRLEN(keys[3]), tmp, 64); - WASM_ASSERT(res == -1, "no next"); + eos_assert(res == -1, "no next"); res = StringTableStr.next((char *)keys[0], STRLEN(keys[0]), tmp, 0); - WASM_ASSERT(res == 0, "next 0"); + eos_assert(res == 0, "next 0"); res = StringTableStr.front(tmp, 64); - WASM_ASSERT(res == STRLEN(vals[0]) && my_memcmp((void *)vals[0], (void *)tmp, res), "front alice"); + eos_assert(res == STRLEN(vals[0]) && my_memcmp((void *)vals[0], (void *)tmp, res), "front alice"); res = StringTableStr.back(tmp, 64); - WASM_ASSERT(res == STRLEN(vals[3]) && my_memcmp((void *)vals[3], (void *)tmp, res), "back dave"); + eos_assert(res == STRLEN(vals[3]) && my_memcmp((void *)vals[3], (void *)tmp, res), "back dave"); res = StringTableStr.lower_bound((char *)keys[0], STRLEN(keys[0]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[0]) && my_memcmp((void *)vals[0], (void *)tmp, res), "lowerbound alice"); + eos_assert(res == STRLEN(vals[0]) && my_memcmp((void *)vals[0], (void *)tmp, res), "lowerbound alice"); res = StringTableStr.upper_bound((char *)keys[0], STRLEN(keys[0]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[1]) && my_memcmp((void *)vals[1], (void *)tmp, res), "upperbound bob"); + eos_assert(res == STRLEN(vals[1]) && my_memcmp((void *)vals[1], (void *)tmp, res), "upperbound bob"); res = StringTableStr.lower_bound((char *)keys[3], STRLEN(keys[3]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[3]) && my_memcmp((void *)vals[3], (void *)tmp, res), "upperbound dave"); + eos_assert(res == STRLEN(vals[3]) && my_memcmp((void *)vals[3], (void *)tmp, res), "upperbound dave"); res = StringTableStr.upper_bound((char *)keys[3], STRLEN(keys[3]), tmp, 64); - WASM_ASSERT(res == -1, "no upper_bound"); + eos_assert(res == -1, "no upper_bound"); - return WASM_TEST_PASS; + return 1; // WASM_TEST_PASS; } +#endif + +#if 0 + unsigned int test_db::key_str_general() { const char* keys[] = { "alice", "bob", "carol", "dave" }; @@ -178,86 +184,90 @@ unsigned int test_db::key_str_general() { //fill some data in contiguous tables for(int i=0; i < 4; ++i) { res = store_str(current_receiver(), N(atr), (char *)keys[i], STRLEN(keys[i]), (char *)atr[i], STRLEN(atr[i]) ); - WASM_ASSERT(res != 0, "atr" ); + eos_assert(res != 0, "atr" ); res = store_str(current_receiver(), N(ztr), (char *)keys[i], STRLEN(keys[i]), (char *)ztr[i], STRLEN(ztr[i]) ); - WASM_ASSERT(res != 0, "ztr" ); + eos_assert(res != 0, "ztr" ); } char tmp[64]; res = store_str(current_receiver(), N(str), (char *)keys[0], STRLEN(keys[0]), (char *)vals[0], STRLEN(vals[0]) ); - WASM_ASSERT(res != 0, "store alice" ); + eos_assert(res != 0, "store alice" ); res = store_str(current_receiver(), N(str), (char *)keys[1], STRLEN(keys[1]), (char *)vals[1], STRLEN(vals[1]) ); - WASM_ASSERT(res != 0, "store bob" ); + eos_assert(res != 0, "store bob" ); res = store_str(current_receiver(), N(str), (char *)keys[2], STRLEN(keys[2]), (char *)vals[2], STRLEN(vals[2]) ); - WASM_ASSERT(res != 0, "store carol" ); + eos_assert(res != 0, "store carol" ); res = store_str(current_receiver(), N(str), (char *)keys[3], STRLEN(keys[3]), (char *)vals[3], STRLEN(vals[3]) ); - WASM_ASSERT(res != 0, "store dave" ); + eos_assert(res != 0, "store dave" ); res = load_str(current_receiver(), current_receiver(), N(str), (char *)keys[0], STRLEN(keys[0]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[0]) && my_memcmp((void *)vals[0], (void *)tmp, res), "load alice"); + eos_assert(res == STRLEN(vals[0]) && my_memcmp((void *)vals[0], (void *)tmp, res), "load alice"); res = load_str(current_receiver(), current_receiver(), N(str), (char *)keys[1], STRLEN(keys[1]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[1]) && my_memcmp((void *)vals[1], (void *)tmp, res), "load bob"); + eos_assert(res == STRLEN(vals[1]) && my_memcmp((void *)vals[1], (void *)tmp, res), "load bob"); res = load_str(current_receiver(), current_receiver(), N(str), (char *)keys[2], STRLEN(keys[2]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[2]) && my_memcmp((void *)vals[2], (void *)tmp, res), "load carol"); + eos_assert(res == STRLEN(vals[2]) && my_memcmp((void *)vals[2], (void *)tmp, res), "load carol"); res = load_str(current_receiver(), current_receiver(), N(str), (char *)keys[3], STRLEN(keys[3]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[3]) && my_memcmp((void *)vals[3], (void *)tmp, res), "load dave"); + eos_assert(res == STRLEN(vals[3]) && my_memcmp((void *)vals[3], (void *)tmp, res), "load dave"); res = previous_str(current_receiver(), current_receiver(), N(str), (char *)keys[3], STRLEN(keys[3]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[2]) && my_memcmp((void *)vals[2], (void *)tmp, res), "back carol"); + eos_assert(res == STRLEN(vals[2]) && my_memcmp((void *)vals[2], (void *)tmp, res), "back carol"); res = previous_str(current_receiver(), current_receiver(), N(str), (char *)keys[2], STRLEN(keys[2]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[1]) && my_memcmp((void *)vals[1], (void *)tmp, res), "back dave"); + eos_assert(res == STRLEN(vals[1]) && my_memcmp((void *)vals[1], (void *)tmp, res), "back dave"); res = previous_str(current_receiver(), current_receiver(), N(str), (char *)keys[1], STRLEN(keys[1]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[0]) && my_memcmp((void *)vals[0], (void *)tmp, res), "back alice"); + eos_assert(res == STRLEN(vals[0]) && my_memcmp((void *)vals[0], (void *)tmp, res), "back alice"); res = previous_str(current_receiver(), current_receiver(), N(str), (char *)keys[0], STRLEN(keys[0]), tmp, 64); - WASM_ASSERT(res == -1, "no prev"); + eos_assert(res == -1, "no prev"); res = next_str(current_receiver(), current_receiver(), N(str), (char *)keys[0], STRLEN(keys[0]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[1]) && my_memcmp((void *)vals[1], (void *)tmp, res), "next bob"); + eos_assert(res == STRLEN(vals[1]) && my_memcmp((void *)vals[1], (void *)tmp, res), "next bob"); res = next_str(current_receiver(), current_receiver(), N(str), (char *)keys[1], STRLEN(keys[1]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[2]) && my_memcmp((void *)vals[2], (void *)tmp, res), "next carol"); + eos_assert(res == STRLEN(vals[2]) && my_memcmp((void *)vals[2], (void *)tmp, res), "next carol"); res = next_str(current_receiver(), current_receiver(), N(str), (char *)keys[2], STRLEN(keys[2]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[3]) && my_memcmp((void *)vals[3], (void *)tmp, res), "next dave"); + eos_assert(res == STRLEN(vals[3]) && my_memcmp((void *)vals[3], (void *)tmp, res), "next dave"); res = next_str(current_receiver(), current_receiver(), N(str), (char *)keys[3], STRLEN(keys[3]), tmp, 64); - WASM_ASSERT(res == -1, "no next"); + eos_assert(res == -1, "no next"); res = next_str(current_receiver(), current_receiver(), N(str), (char *)keys[0], STRLEN(keys[0]), tmp, 0); - WASM_ASSERT(res == 0, "next 0"); + eos_assert(res == 0, "next 0"); res = front_str(current_receiver(), current_receiver(), N(str), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[0]) && my_memcmp((void *)vals[0], (void *)tmp, res), "front alice"); + eos_assert(res == STRLEN(vals[0]) && my_memcmp((void *)vals[0], (void *)tmp, res), "front alice"); res = back_str(current_receiver(), current_receiver(), N(str), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[3]) && my_memcmp((void *)vals[3], (void *)tmp, res), "back dave"); + eos_assert(res == STRLEN(vals[3]) && my_memcmp((void *)vals[3], (void *)tmp, res), "back dave"); res = lower_bound_str(current_receiver(), current_receiver(), N(str), (char *)keys[0], STRLEN(keys[0]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[0]) && my_memcmp((void *)vals[0], (void *)tmp, res), "lowerbound alice"); + eos_assert(res == STRLEN(vals[0]) && my_memcmp((void *)vals[0], (void *)tmp, res), "lowerbound alice"); res = upper_bound_str(current_receiver(), current_receiver(), N(str), (char *)keys[0], STRLEN(keys[0]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[1]) && my_memcmp((void *)vals[1], (void *)tmp, res), "upperbound bob"); + eos_assert(res == STRLEN(vals[1]) && my_memcmp((void *)vals[1], (void *)tmp, res), "upperbound bob"); res = lower_bound_str(current_receiver(), current_receiver(), N(str), (char *)keys[3], STRLEN(keys[3]), tmp, 64); - WASM_ASSERT(res == STRLEN(vals[3]) && my_memcmp((void *)vals[3], (void *)tmp, res), "upperbound dave"); + eos_assert(res == STRLEN(vals[3]) && my_memcmp((void *)vals[3], (void *)tmp, res), "upperbound dave"); res = upper_bound_str(current_receiver(), current_receiver(), N(str), (char *)keys[3], STRLEN(keys[3]), tmp, 64); - WASM_ASSERT(res == -1, "no upper_bound"); + eos_assert(res == -1, "no upper_bound"); - return WASM_TEST_PASS; + return 1;//WASM_TEST_PASS; } +#endif + +#if 0 + unsigned int test_db::key_i64_general() { uint32_t res = 0; @@ -268,16 +278,16 @@ unsigned int test_db::key_i64_general() { test_model dave { N(dave), 46, 6535354}; res = store_i64(current_receiver(), N(test_table), &dave, sizeof(test_model)); - WASM_ASSERT(res != 0, "store dave" ); + eos_assert(res != 0, "store dave" ); res = store_i64(current_receiver(), N(test_table), &carol, sizeof(test_model)); - WASM_ASSERT(res != 0, "store carol" ); + eos_assert(res != 0, "store carol" ); res = store_i64(current_receiver(), N(test_table), &bob, sizeof(test_model)); - WASM_ASSERT(res != 0, "store bob" ); + eos_assert(res != 0, "store bob" ); res = store_i64(current_receiver(), N(test_table), &alice, sizeof(test_model)); - WASM_ASSERT(res != 0, "store alice" ); + eos_assert(res != 0, "store alice" ); //fill with different ages in adjacent tables dave.age=123; store_i64(current_receiver(), N(test_tabld), &dave, sizeof(test_model)); @@ -292,56 +302,56 @@ unsigned int test_db::key_i64_general() { test_model tmp; res = front_i64( current_receiver(), current_receiver(), N(test_table), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(alice) && tmp.age == 20 && tmp.phone == 4234622, "front_i64 1"); + eos_assert(res == sizeof(test_model) && tmp.name == N(alice) && tmp.age == 20 && tmp.phone == 4234622, "front_i64 1"); my_memset(&tmp, 0, sizeof(test_model)); res = back_i64( current_receiver(), current_receiver(), N(test_table), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(dave) && tmp.age == 46 && tmp.phone == 6535354, "front_i64 2"); + eos_assert(res == sizeof(test_model) && tmp.name == N(dave) && tmp.age == 46 && tmp.phone == 6535354, "front_i64 2"); res = previous_i64( current_receiver(), current_receiver(), N(test_table), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(carol) && tmp.age == 30 && tmp.phone == 545342453, "carol previous"); + eos_assert(res == sizeof(test_model) && tmp.name == N(carol) && tmp.age == 30 && tmp.phone == 545342453, "carol previous"); res = previous_i64( current_receiver(), current_receiver(), N(test_table), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(bob) && tmp.age == 15 && tmp.phone == 11932435, "bob previous"); + eos_assert(res == sizeof(test_model) && tmp.name == N(bob) && tmp.age == 15 && tmp.phone == 11932435, "bob previous"); res = previous_i64( current_receiver(), current_receiver(), N(test_table), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(alice) && tmp.age == 20 && tmp.phone == 4234622, "alice previous"); + eos_assert(res == sizeof(test_model) && tmp.name == N(alice) && tmp.age == 20 && tmp.phone == 4234622, "alice previous"); res = previous_i64( current_receiver(), current_receiver(), N(test_table), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == -1, "previous null"); + eos_assert(res == -1, "previous null"); res = next_i64( current_receiver(), current_receiver(), N(test_table), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(bob) && tmp.age == 15 && tmp.phone == 11932435, "bob next"); + eos_assert(res == sizeof(test_model) && tmp.name == N(bob) && tmp.age == 15 && tmp.phone == 11932435, "bob next"); res = next_i64( current_receiver(), current_receiver(), N(test_table), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(carol) && tmp.age == 30 && tmp.phone == 545342453, "carol next"); + eos_assert(res == sizeof(test_model) && tmp.name == N(carol) && tmp.age == 30 && tmp.phone == 545342453, "carol next"); res = next_i64( current_receiver(), current_receiver(), N(test_table), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(dave) && tmp.age == 46 && tmp.phone == 6535354, "dave next"); + eos_assert(res == sizeof(test_model) && tmp.name == N(dave) && tmp.age == 46 && tmp.phone == 6535354, "dave next"); res = next_i64( current_receiver(), current_receiver(), N(test_table), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == -1, "next null"); + eos_assert(res == -1, "next null"); my_memset(&alice, 0, sizeof(test_model)); - WASM_ASSERT(alice.name == 0 && alice.age == 0 && alice.phone == 0, "my_memset"); + eos_assert(alice.name == 0 && alice.age == 0 && alice.phone == 0, "my_memset"); alice.name = N(alice); res = load_i64(current_receiver(), current_receiver(), N(test_table), &alice, sizeof(test_model)); - WASM_ASSERT(res == sizeof(test_model) && alice.age == 20 && alice.phone == 4234622, "alice error 1"); + eos_assert(res == sizeof(test_model) && alice.age == 20 && alice.phone == 4234622, "alice error 1"); alice.age = 21; alice.phone = 1234; res = store_i64(current_receiver(), N(test_table), &alice, sizeof(test_model)); - WASM_ASSERT(res == 0, "store alice 2" ); + eos_assert(res == 0, "store alice 2" ); my_memset(&alice, 0, sizeof(test_model)); alice.name = N(alice); res = load_i64(current_receiver(), current_receiver(), N(test_table), &alice, sizeof(test_model)); - WASM_ASSERT(res == sizeof(test_model) && alice.age == 21 && alice.phone == 1234, "alice error 2"); + eos_assert(res == sizeof(test_model) && alice.age == 21 && alice.phone == 1234, "alice error 2"); my_memset(&bob, 0, sizeof(test_model)); bob.name = N(bob); @@ -353,72 +363,72 @@ unsigned int test_db::key_i64_general() { dave.name = N(dave); res = load_i64(current_receiver(), current_receiver(), N(test_table), &bob, sizeof(test_model)); - WASM_ASSERT(res == sizeof(test_model) && bob.age == 15 && bob.phone == 11932435, "bob error 1"); + eos_assert(res == sizeof(test_model) && bob.age == 15 && bob.phone == 11932435, "bob error 1"); res = load_i64(current_receiver(), current_receiver(), N(test_table), &carol, sizeof(test_model)); - WASM_ASSERT(res == sizeof(test_model) && carol.age == 30 && carol.phone == 545342453, "carol error 1"); + eos_assert(res == sizeof(test_model) && carol.age == 30 && carol.phone == 545342453, "carol error 1"); res = load_i64(current_receiver(), current_receiver(), N(test_table), &dave, sizeof(test_model)); - WASM_ASSERT(res == sizeof(test_model) && dave.age == 46 && dave.phone == 6535354, "dave error 1"); + eos_assert(res == sizeof(test_model) && dave.age == 46 && dave.phone == 6535354, "dave error 1"); res = load_i64(current_receiver(), N(other_code), N(test_table), &alice, sizeof(test_model)); - WASM_ASSERT(res == -1, "other_code"); + eos_assert(res == -1, "other_code"); res = load_i64(current_receiver(), current_receiver(), N(other_table), &alice, sizeof(test_model)); - WASM_ASSERT(res == -1, "other_table"); + eos_assert(res == -1, "other_table"); test_model_v2 alicev2; alicev2.name = N(alice); res = load_i64(current_receiver(), current_receiver(), N(test_table), &alicev2, sizeof(test_model_v2)); - WASM_ASSERT(res == sizeof(test_model) && alicev2.age == 21 && alicev2.phone == 1234, "alicev2 load"); + eos_assert(res == sizeof(test_model) && alicev2.age == 21 && alicev2.phone == 1234, "alicev2 load"); alicev2.new_field = 66655444; res = store_i64(current_receiver(), N(test_table), &alicev2, sizeof(test_model_v2)); - WASM_ASSERT(res == 0, "store alice 3" ); + eos_assert(res == 0, "store alice 3" ); my_memset(&alicev2, 0, sizeof(test_model_v2)); alicev2.name = N(alice); res = load_i64(current_receiver(), current_receiver(), N(test_table), &alicev2, sizeof(test_model_v2)); - WASM_ASSERT(res == sizeof(test_model_v2) && alicev2.age == 21 && alicev2.phone == 1234 && alicev2.new_field == 66655444, "alice model v2"); + eos_assert(res == sizeof(test_model_v2) && alicev2.age == 21 && alicev2.phone == 1234 && alicev2.new_field == 66655444, "alice model v2"); my_memset(&tmp, 0, sizeof(test_model)); tmp.name = N(bob); res = lower_bound_i64( current_receiver(), current_receiver(), N(test_table), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(bob), "lower_bound_i64 bob" ); + eos_assert(res == sizeof(test_model) && tmp.name == N(bob), "lower_bound_i64 bob" ); my_memset(&tmp, 0, sizeof(test_model)); tmp.name = N(boc); res = lower_bound_i64( current_receiver(), current_receiver(), N(test_table), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(carol), "lower_bound_i64 carol" ); + eos_assert(res == sizeof(test_model) && tmp.name == N(carol), "lower_bound_i64 carol" ); my_memset(&tmp, 0, sizeof(test_model)); tmp.name = N(dave); res = lower_bound_i64( current_receiver(), current_receiver(), N(test_table), &tmp, sizeof(uint64_t) ); - WASM_ASSERT(res == sizeof(uint64_t) && tmp.name == N(dave), "lower_bound_i64 dave" ); + eos_assert(res == sizeof(uint64_t) && tmp.name == N(dave), "lower_bound_i64 dave" ); my_memset(&tmp, 0, sizeof(test_model)); tmp.name = N(davf); res = lower_bound_i64( current_receiver(), current_receiver(), N(test_table), &tmp, sizeof(uint64_t) ); - WASM_ASSERT(res == -1, "lower_bound_i64 fail" ); + eos_assert(res == -1, "lower_bound_i64 fail" ); my_memset(&tmp, 0, sizeof(test_model)); tmp.name = N(alice); res = upper_bound_i64( current_receiver(), current_receiver(), N(test_table), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.age == 15 && tmp.name == N(bob), "upper_bound_i64 bob" ); + eos_assert(res == sizeof(test_model) && tmp.age == 15 && tmp.name == N(bob), "upper_bound_i64 bob" ); my_memset(&tmp, 0, sizeof(test_model)); tmp.name = N(dave); res = upper_bound_i64( current_receiver(), current_receiver(), N(test_table), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == -1, "upper_bound_i64 dave" ); + eos_assert(res == -1, "upper_bound_i64 dave" ); test_model_v3 tmp2; tmp2.name = N(alice); res = load_i64(current_receiver(), current_receiver(), N(test_table), &tmp2, sizeof(test_model_v3)); - WASM_ASSERT(res == sizeof(test_model_v2) && + eos_assert(res == sizeof(test_model_v2) && tmp2.age == 21 && tmp2.phone == 1234 && tmp2.new_field == 66655444, @@ -426,10 +436,10 @@ unsigned int test_db::key_i64_general() { tmp2.another_field = 221122; res = update_i64(current_receiver(), N(test_table), &tmp2, sizeof(test_model_v3)); - WASM_ASSERT(res == 1, "update_i64"); + eos_assert(res == 1, "update_i64"); res = load_i64(current_receiver(), current_receiver(), N(test_table), &tmp2, sizeof(test_model_v3)); - WASM_ASSERT(res == sizeof(test_model_v3) && + eos_assert(res == sizeof(test_model_v3) && tmp2.age == 21 && tmp2.phone == 1234 && tmp2.new_field == 66655444 && @@ -438,10 +448,10 @@ unsigned int test_db::key_i64_general() { tmp2.age = 11; res = update_i64(current_receiver(), N(test_table), &tmp2, sizeof(uint64_t)+1 ); - WASM_ASSERT(res == 1, "update_i64 small"); + eos_assert(res == 1, "update_i64 small"); res = load_i64(current_receiver(), current_receiver(), N(test_table), &tmp2, sizeof(test_model_v3)); - WASM_ASSERT(res == sizeof(test_model_v3) && + eos_assert(res == sizeof(test_model_v3) && tmp2.age == 11 && tmp2.phone == 1234 && tmp2.new_field == 66655444 && @@ -460,6 +470,10 @@ unsigned int test_db::key_i64_general() { return WASM_TEST_PASS; } +#endif + +#if 0 + unsigned int test_db::key_i64_remove_all() { uint32_t res = 0; @@ -467,47 +481,51 @@ unsigned int test_db::key_i64_remove_all() { key = N(alice); res = remove_i64(current_receiver(), N(test_table), &key); - WASM_ASSERT(res == 1, "remove alice"); + eos_assert(res == 1, "remove alice"); key = N(bob); res = remove_i64(current_receiver(), N(test_table), &key); - WASM_ASSERT(res == 1, "remove bob"); + eos_assert(res == 1, "remove bob"); key = N(carol); res = remove_i64(current_receiver(), N(test_table), &key); - WASM_ASSERT(res == 1, "remove carol"); + eos_assert(res == 1, "remove carol"); key = N(dave); res = remove_i64(current_receiver(), N(test_table), &key); - WASM_ASSERT(res == 1, "remove dave"); + eos_assert(res == 1, "remove dave"); test_model tmp; res = front_i64( current_receiver(), current_receiver(), N(test_table), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == -1, "front_i64 remove"); + eos_assert(res == -1, "front_i64 remove"); res = back_i64( current_receiver(), current_receiver(), N(test_table), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == -1, "back_i64_i64 remove"); + eos_assert(res == -1, "back_i64_i64 remove"); key = N(alice); res = remove_i64(current_receiver(), N(test_table), &key); - WASM_ASSERT(res == 0, "remove alice 1"); + eos_assert(res == 0, "remove alice 1"); key = N(bob); res = remove_i64(current_receiver(), N(test_table), &key); - WASM_ASSERT(res == 0, "remove bob 1"); + eos_assert(res == 0, "remove bob 1"); key = N(carol); res = remove_i64(current_receiver(), N(test_table), &key); - WASM_ASSERT(res == 0, "remove carol 1"); + eos_assert(res == 0, "remove carol 1"); key = N(dave); res = remove_i64(current_receiver(), N(test_table), &key); - WASM_ASSERT(res == 0, "remove dave 1"); + eos_assert(res == 0, "remove dave 1"); return WASM_TEST_PASS; } +#endif + +#if 0 + unsigned int test_db::key_i64_small_load() { uint64_t dummy = 0; load_i64(current_receiver(), current_receiver(), N(just_uint64), &dummy, sizeof(uint64_t)-1); @@ -536,10 +554,10 @@ unsigned int test_db::key_i64_not_found() { uint64_t dummy = 1000; auto res = load_i64(current_receiver(), current_receiver(), N(just_uint64), &dummy, sizeof(uint64_t)); - WASM_ASSERT(res == -1, "i64_not_found load"); + eos_assert(res == -1, "i64_not_found load"); res = remove_i64(current_receiver(), N(just_uint64), &dummy); - WASM_ASSERT(res == 0, "i64_not_found remove"); + eos_assert(res == 0, "i64_not_found remove"); return WASM_TEST_PASS; } @@ -561,65 +579,65 @@ unsigned int test_db::key_i64_front_back() { my_memset(&tmp, 0, sizeof(test_model)); res = front_i64( current_receiver(), current_receiver(), N(a), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(alice) && tmp.age == 20 && tmp.phone == 4234622, "key_i64_front 1"); + eos_assert(res == sizeof(test_model) && tmp.name == N(alice) && tmp.age == 20 && tmp.phone == 4234622, "key_i64_front 1"); my_memset(&tmp, 0, sizeof(test_model)); res = back_i64( current_receiver(), current_receiver(), N(a), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(bob) && tmp.age == 15 && tmp.phone == 11932435, "key_i64_front 2"); + eos_assert(res == sizeof(test_model) && tmp.name == N(bob) && tmp.age == 15 && tmp.phone == 11932435, "key_i64_front 2"); my_memset(&tmp, 0, sizeof(test_model)); res = front_i64( current_receiver(), current_receiver(), N(b), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(carol) && tmp.age == 30 && tmp.phone == 545342453, "key_i64_front 3"); + eos_assert(res == sizeof(test_model) && tmp.name == N(carol) && tmp.age == 30 && tmp.phone == 545342453, "key_i64_front 3"); my_memset(&tmp, 0, sizeof(test_model)); res = back_i64( current_receiver(), current_receiver(), N(b), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(dave) && tmp.age == 46 && tmp.phone == 6535354, "key_i64_front 4"); + eos_assert(res == sizeof(test_model) && tmp.name == N(dave) && tmp.age == 46 && tmp.phone == 6535354, "key_i64_front 4"); uint64_t key = N(carol); remove_i64(current_receiver(), N(b), &key); my_memset(&tmp, 0, sizeof(test_model)); res = front_i64( current_receiver(), current_receiver(), N(b), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(dave) && tmp.age == 46 && tmp.phone == 6535354, "key_i64_front 5"); + eos_assert(res == sizeof(test_model) && tmp.name == N(dave) && tmp.age == 46 && tmp.phone == 6535354, "key_i64_front 5"); my_memset(&tmp, 0, sizeof(test_model)); res = back_i64( current_receiver(), current_receiver(), N(b), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(dave) && tmp.age == 46 && tmp.phone == 6535354, "key_i64_front 6"); + eos_assert(res == sizeof(test_model) && tmp.name == N(dave) && tmp.age == 46 && tmp.phone == 6535354, "key_i64_front 6"); my_memset(&tmp, 0, sizeof(test_model)); res = front_i64( current_receiver(), current_receiver(), N(a), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(alice) && tmp.age == 20 && tmp.phone == 4234622, "key_i64_front 7"); + eos_assert(res == sizeof(test_model) && tmp.name == N(alice) && tmp.age == 20 && tmp.phone == 4234622, "key_i64_front 7"); my_memset(&tmp, 0, sizeof(test_model)); res = back_i64( current_receiver(), current_receiver(), N(a), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(bob) && tmp.age == 15 && tmp.phone == 11932435, "key_i64_front 8"); + eos_assert(res == sizeof(test_model) && tmp.name == N(bob) && tmp.age == 15 && tmp.phone == 11932435, "key_i64_front 8"); key = N(dave); remove_i64(current_receiver(), N(b), &key); res = front_i64( current_receiver(), current_receiver(), N(b), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == -1, "key_i64_front 9"); + eos_assert(res == -1, "key_i64_front 9"); res = back_i64( current_receiver(), current_receiver(), N(b), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == -1, "key_i64_front 10"); + eos_assert(res == -1, "key_i64_front 10"); key = N(bob); remove_i64(current_receiver(), N(a), &key); my_memset(&tmp, 0, sizeof(test_model)); res = front_i64( current_receiver(), current_receiver(), N(a), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(alice) && tmp.age == 20 && tmp.phone == 4234622, "key_i64_front 11"); + eos_assert(res == sizeof(test_model) && tmp.name == N(alice) && tmp.age == 20 && tmp.phone == 4234622, "key_i64_front 11"); my_memset(&tmp, 0, sizeof(test_model)); res = back_i64( current_receiver(), current_receiver(), N(a), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == sizeof(test_model) && tmp.name == N(alice) && tmp.age == 20 && tmp.phone == 4234622, "key_i64_front 12"); + eos_assert(res == sizeof(test_model) && tmp.name == N(alice) && tmp.age == 20 && tmp.phone == 4234622, "key_i64_front 12"); key = N(alice); remove_i64(current_receiver(), N(a), &key); res = front_i64( current_receiver(), current_receiver(), N(a), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == -1, "key_i64_front 13"); + eos_assert(res == -1, "key_i64_front 13"); res = back_i64( current_receiver(), current_receiver(), N(a), &tmp, sizeof(test_model) ); - WASM_ASSERT(res == -1, "key_i64_front 14"); + eos_assert(res == -1, "key_i64_front 14"); return WASM_TEST_PASS; } @@ -635,16 +653,16 @@ unsigned int store_set_in_table(uint64_t table_name) TestModel128x2 alice22{2, 200, N(alice22), table_name}; res = store_i128i128(current_receiver(), table_name, &alice0, sizeof(TestModel128x2)); - WASM_ASSERT(res == 1, "store alice0" ); + eos_assert(res == 1, "store alice0" ); res = store_i128i128(current_receiver(), table_name, &alice1, sizeof(TestModel128x2)); - WASM_ASSERT(res == 1, "store alice1" ); + eos_assert(res == 1, "store alice1" ); res = store_i128i128(current_receiver(), table_name, &alice2, sizeof(TestModel128x2)); - WASM_ASSERT(res == 1, "store alice2" ); + eos_assert(res == 1, "store alice2" ); res = store_i128i128(current_receiver(), table_name, &alice22, sizeof(TestModel128x2)); - WASM_ASSERT(res == 1, "store alice22" ); + eos_assert(res == 1, "store alice22" ); TestModel128x2 bob0{10, 1, N(bob0), table_name}; TestModel128x2 bob1{11, 2, N(bob1), table_name}; @@ -652,16 +670,16 @@ unsigned int store_set_in_table(uint64_t table_name) TestModel128x2 bob3{13, 4, N(bob3), table_name}; res = store_i128i128(current_receiver(), table_name, &bob0, sizeof(TestModel128x2)); - WASM_ASSERT(res == 1, "store bob0" ); + eos_assert(res == 1, "store bob0" ); res = store_i128i128(current_receiver(), table_name, &bob1, sizeof(TestModel128x2)); - WASM_ASSERT(res == 1, "store bob1" ); + eos_assert(res == 1, "store bob1" ); res = store_i128i128(current_receiver(), table_name, &bob2, sizeof(TestModel128x2)); - WASM_ASSERT(res == 1, "store bob2" ); + eos_assert(res == 1, "store bob2" ); res = store_i128i128(current_receiver(), table_name, &bob3, sizeof(TestModel128x2)); - WASM_ASSERT(res == 1, "store bob3" ); + eos_assert(res == 1, "store bob3" ); TestModel128x2 carol0{20, 900, N(carol0), table_name}; TestModel128x2 carol1{21, 800, N(carol1), table_name}; @@ -669,16 +687,16 @@ unsigned int store_set_in_table(uint64_t table_name) TestModel128x2 carol3{23, 600, N(carol3), table_name}; res = store_i128i128(current_receiver(), table_name, &carol0, sizeof(TestModel128x2)); - WASM_ASSERT(res == 1, "store carol0" ); + eos_assert(res == 1, "store carol0" ); res = store_i128i128(current_receiver(), table_name, &carol1, sizeof(TestModel128x2)); - WASM_ASSERT(res == 1, "store carol1" ); + eos_assert(res == 1, "store carol1" ); res = store_i128i128(current_receiver(), table_name, &carol2, sizeof(TestModel128x2)); - WASM_ASSERT(res == 1, "store carol2" ); + eos_assert(res == 1, "store carol2" ); res = store_i128i128(current_receiver(), table_name, &carol3, sizeof(TestModel128x2)); - WASM_ASSERT(res == 1, "store carol3" ); + eos_assert(res == 1, "store carol3" ); TestModel128x2 dave0{30, 8, N(dave0), table_name}; TestModel128x2 dave1{31, 7, N(dave1), table_name}; @@ -686,16 +704,16 @@ unsigned int store_set_in_table(uint64_t table_name) TestModel128x2 dave3{33, 4, N(dave3), table_name}; res = store_i128i128(current_receiver(), table_name, &dave0, sizeof(TestModel128x2)); - WASM_ASSERT(res == 1, "store dave0" ); + eos_assert(res == 1, "store dave0" ); res = store_i128i128(current_receiver(), table_name, &dave1, sizeof(TestModel128x2)); - WASM_ASSERT(res == 1, "store dave1" ); + eos_assert(res == 1, "store dave1" ); res = store_i128i128(current_receiver(), table_name, &dave2, sizeof(TestModel128x2)); - WASM_ASSERT(res == 1, "store dave2" ); + eos_assert(res == 1, "store dave2" ); res = store_i128i128(current_receiver(), table_name, &dave3, sizeof(TestModel128x2)); - WASM_ASSERT(res == 1, "store dave3" ); + eos_assert(res == 1, "store dave3" ); return WASM_TEST_PASS; } @@ -706,11 +724,15 @@ unsigned int store_set_in_table(TestModel3xi64* records, int len, uint64_t table TestModel3xi64 *tmp = records+i; tmp->table = table_name; res = store_i64i64i64(current_receiver(), table_name, tmp, sizeof(TestModel3xi64)); - WASM_ASSERT(res == 1, "store_set_in_table" ); + eos_assert(res == 1, "store_set_in_table" ); } return res; } +#endif + +#if 0 + unsigned int test_db::key_i64i64i64_general() { uint32_t res = 0; @@ -750,7 +772,7 @@ unsigned int test_db::key_i64i64i64_general() { eosio::print(msg, " : ", res, " a:", V.a, " b:", V.b, " c:", V.c, " t:", V.table, "inx:", uint64_t(I), " ("); \ eosio::print(BS(res == sizeof(V)), " ", BS(records[I].a == V.a), " ", BS(records[I].b == V.b), " ", BS(records[I].c == V.c), " => ", N(table2), ")\n"); \ } \ - WASM_ASSERT( res == sizeof(V) && records[I].a == V.a && records[I].b == V.b && \ + eos_assert( res == sizeof(V) && records[I].a == V.a && records[I].b == V.b && \ records[I].c == V.c /*&& records[I].table == uint64_t(N(table2))*/, msg); #define LOAD_OK(I, O, T, INX, MSG) \ @@ -761,7 +783,7 @@ unsigned int test_db::key_i64i64i64_general() { #define LOAD_ER(I, O, T, MSG) \ {eosio::remove_reference::type tmp; my_memset(&tmp, 0, sizeof(tmp));tmp = V; \ res = LOAD(I, O, T, tmp); \ - WASM_ASSERT(res == -1, MSG)} + eos_assert(res == -1, MSG)} #define FRONT_OK(I, O, T, INX, MSG) \ {eosio::remove_reference::type tmp; my_memset(&tmp, 0, sizeof(tmp));tmp = V; \ @@ -812,7 +834,7 @@ unsigned int test_db::key_i64i64i64_general() { eosio::remove_reference::type tmp = records[I[j]]; \ res = NEXT(I, i64i64i64, N(table2), tmp);\ if(j+1::type tmp = records[I[j]]; \ res = PREV(I, i64i64i64, N(table2), tmp);\ if(j>0){ TABLE1_ASSERT(I[j-1], tmp, "i64x3 PREV " #I " ok "); } \ - else { WASM_ASSERT(res == -1, "i64x3 PREV " #I " fail "); }\ + else { eos_assert(res == -1, "i64x3 PREV " #I " fail "); }\ } while(--j>0); \ } @@ -866,7 +888,7 @@ unsigned int test_db::key_i64i64i64_general() { do { \ eosio::remove_reference::type tmp = records[j]; \ res = UPPER(I, i64i64i64, N(table2), tmp);\ - if(res == -1) { WASM_ASSERT(I##_ub[j]==-1,"i64x3 UPPER " #I " fail ") } \ + if(res == -1) { eos_assert(I##_ub[j]==-1,"i64x3 UPPER " #I " fail ") } \ else { TABLE1_ASSERT(I##_ub[j], tmp, "i64x3 UPPER " #I " ok "); } \ } while(++j 2 ]]; then - echo "" - echo "Error: too many arguments" - exit 1 -fi - -if [[ $# < 1 ]]; then - echo "" - echo "Usage: bash build.sh TARGET [full|build]" - echo "" - echo "Targets: $TARGET_ARCHS" - exit 1 -fi - -if [[ $ARCH =~ [[:space:]] || ! $TARGET_ARCHS =~ (^|[[:space:]])$ARCH([[:space:]]|$) ]]; then - echo "" - echo ">>> WRONG ARCHITECTURE \"$ARCH\"" - exit 1 -fi - -if [ -z "$2" ]; then - INSTALL_DEPS=1 -else - if [ "$2" == "full" ]; then - INSTALL_DEPS=1 - elif [ "$2" == "build" ]; then - INSTALL_DEPS=0 - else - echo ">>> WRONG mode use full or build" - exit 1 - fi -fi - -echo "" -echo ">>> ARCHITECTURE \"$ARCH\"" - -if [ $ARCH == "ubuntu" ]; then - BOOST_ROOT=${HOME}/opt/boost_1_64_0 - BINARYEN_BIN=${HOME}/opt/binaryen/bin - OPENSSL_ROOT_DIR=/usr/local/opt/openssl - OPENSSL_LIBRARIES=/usr/local/opt/openssl/lib - WASM_LLVM_CONFIG=${HOME}/opt/wasm/bin/llvm-config -fi - -if [ $ARCH == "darwin" ]; then - OPENSSL_ROOT_DIR=/usr/local/opt/openssl - OPENSSL_LIBRARIES=/usr/local/opt/openssl/lib - BINARYEN_BIN=/usr/local/binaryen/bin/ - WASM_LLVM_CONFIG=/usr/local/wasm/bin/llvm-config -fi - -# Debug flags -COMPILE_EOS=1 -COMPILE_CONTRACTS=1 - -# Define default arguments. -CMAKE_BUILD_TYPE=RelWithDebugInfo - -# Install dependencies -if [ ${INSTALL_DEPS} == "1" ]; then - - echo ">> Install dependencies" - . ${WORK_DIR}/scripts/install_dependencies.sh - -fi - -# Create the build dir -cd ${WORK_DIR} -mkdir -p ${BUILD_DIR} -cd ${BUILD_DIR} - -CXX_COMPILER=clang++-4.0 -C_COMPILER=clang-4.0 - -if [ $ARCH == "darwin" ]; then - CXX_COMPILER=clang++ - C_COMPILER=clang -fi - -# Build EOS -cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_CXX_COMPILER=${CXX_COMPILER} -DCMAKE_C_COMPILER=${C_COMPILER} -DWASM_LLVM_CONFIG=${WASM_LLVM_CONFIG} -DBINARYEN_BIN=${BINARYEN_BIN} -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} -DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES} .. -make -j10 diff --git a/eosio_build.sh b/eosio_build.sh new file mode 100755 index 0000000000000000000000000000000000000000..a05b8cc1518ebc080d1eb32987c0cc1b2e12c57e --- /dev/null +++ b/eosio_build.sh @@ -0,0 +1,129 @@ +#!/bin/bash +########################################################################## +# This is EOS bootstrapper script for Linux and OS X. +# This file was downloaded from https://github.com/EOSIO/eos +# +# Copyright (c) 2017, Respective Authors all rights reserved. +# +# After June 1, 2018 this software is available under the following terms: +# +# The MIT License +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +# https://github.com/EOSIO/eos/blob/master/LICENSE.txt +########################################################################## + + VERSION=1.1 + ULIMIT=$( ulimit -u ) + + # Define directories. + WORK_DIR=$PWD + BUILD_DIR=${WORK_DIR}/build + TEMP_DIR=/tmp + ARCH=$(uname) + + txtbld=$(tput bold) + bldred=${txtbld}$(tput setaf 1) + txtrst=$(tput sgr0) + + printf "\n\tARCHITECTURE ${ARCH}\n" + + if [ $ARCH == "Linux" ]; then + + if [ ! -e /etc/os-release ]; then + printf "EOSIO currently supports Ubuntu, Red Hat & Fedora Linux only.\n" + printf "Please install on the latest version of one of these Linux distributions.\n" + printf "https://www.ubuntu.com/\n" + printf "https://start.fedoraproject.org/en/\n" + printf "Exiting now.\n" + exit 1 + fi + + OS_NAME=$( cat /etc/os-release | grep ^NAME | cut -d'=' -f2 | sed 's/\"//gI' ) + + case $OS_NAME in + "Ubuntu") + FILE=${WORK_DIR}/scripts/eosio_build_ubuntu.sh + CXX_COMPILER=clang++-4.0 + C_COMPILER=clang-4.0 + ;; + "Fedora") + FILE=${WORK_DIR}/scripts/eosio_build_fedora.sh + CXX_COMPILER=g++ + C_COMPILER=gcc + ;; + *) + printf "\n\tUnsupported Linux Distribution. Exiting now.\n\n" + exit 1 + esac + + export BOOST_ROOT=${HOME}/opt/boost_1_66_0 + export BINARYEN_BIN=${HOME}/opt/binaryen/bin + export OPENSSL_ROOT_DIR=/usr/include/openssl + export OPENSSL_LIBRARIES=/usr/include/openssl + export WASM_LLVM_CONFIG=${HOME}/opt/wasm/bin/llvm-config + + . $FILE + + fi + + if [ $ARCH == "Darwin" ]; then + OPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1 + OPENSSL_LIBRARIES=/usr/local/opt/openssl@1.1/lib + BINARYEN_BIN=/usr/local/binaryen/bin/ + WASM_LLVM_CONFIG=/usr/local/wasm/bin/llvm-config + CXX_COMPILER=clang++ + C_COMPILER=clang + + . scripts/eosio_build_darwin.sh + fi + + printf "\n\n>>>>>>>> ALL dependencies sucessfully found or installed . Installing EOS.IO\n\n" + + # Debug flags + COMPILE_EOS=1 + COMPILE_CONTRACTS=1 + + # Define default arguments. + CMAKE_BUILD_TYPE=RelWithDebugInfo + + # Create the build dir + cd ${WORK_DIR} + mkdir -p ${BUILD_DIR} + cd ${BUILD_DIR} + + # Build EOS + cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_CXX_COMPILER=${CXX_COMPILER} \ + -DCMAKE_C_COMPILER=${C_COMPILER} -DWASM_LLVM_CONFIG=${WASM_LLVM_CONFIG} \ + -DBINARYEN_BIN=${BINARYEN_BIN} -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} \ + -DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES} .. + if [ $? -ne 0 ]; then + printf "\n\t>>>>>>>>>>>>>>>>>>>> CMAKE building EOSIO has exited with the above error.\n\n" + exit -1 + fi + + make -j$(nproc) VERBOSE=1 + + if [ $? -ne 0 ]; then + printf "\n\t>>>>>>>>>>>>>>>>>>>> MAKE building EOSIO has exited with the above error.\n\n" + exit -1 + fi + + printf "\n\t>>>>>>>>>>>>>>>>>>>> EOSIO has been successfully installed.\n\n" diff --git a/libraries/appbase b/libraries/appbase index a0cf75ad7c39137ebf03b0f3b0b4e5b7f731296b..ef2b0c8d64f770d80ce537ec04d0de4bdc4d3585 160000 --- a/libraries/appbase +++ b/libraries/appbase @@ -1 +1 @@ -Subproject commit a0cf75ad7c39137ebf03b0f3b0b4e5b7f731296b +Subproject commit ef2b0c8d64f770d80ce537ec04d0de4bdc4d3585 diff --git a/libraries/chain/apply_context.cpp b/libraries/chain/apply_context.cpp index 149e7939cf8d7bdeeda1a36f567961d3defba0fd..244484a53fac0fbc2e46e221ff3bbc8aa925b747 100644 --- a/libraries/chain/apply_context.cpp +++ b/libraries/chain/apply_context.cpp @@ -370,8 +370,7 @@ void apply_context::db_remove_i64( int iterator ) { int apply_context::db_get_i64( int iterator, char* buffer, size_t buffer_size ) { const key_value_object& obj = keyval_cache.get( iterator ); - if( buffer_size >= obj.value.size() ) - memcpy( buffer, obj.value.data(), obj.value.size() ); + memcpy( buffer, obj.value.data(), std::min(obj.value.size(), buffer_size) ); return obj.value.size(); } diff --git a/libraries/chain/contracts/abi_serializer.cpp b/libraries/chain/contracts/abi_serializer.cpp index 625a936720e7b986910692fb0c989830f250cef7..768891341614f7030a7ae0c25a1649e83a24ef6c 100644 --- a/libraries/chain/contracts/abi_serializer.cpp +++ b/libraries/chain/contracts/abi_serializer.cpp @@ -131,17 +131,6 @@ namespace eosio { namespace chain { namespace contracts { FC_ASSERT( tables.size() == abi.tables.size() ); } - void abi_serializer::append_system_abi(account_name account, abi_def& abi) { - if ( account == eosio::chain::config::system_account_name ) { - abi_def eos_abi = chain_initializer::eos_contract_abi(); - abi.actions.insert(abi.actions.end(), eos_abi.actions.cbegin(), eos_abi.actions.cend()); - abi.structs.insert(abi.structs.end(), eos_abi.structs.cbegin(), eos_abi.structs.cend()); - abi.tables.insert(abi.tables.end(), eos_abi.tables.cbegin(), eos_abi.tables.cend()); - abi.types.insert(abi.types.end(), eos_abi.types.cbegin(), eos_abi.types.cend()); - } - } - - bool abi_serializer::is_builtin_type(const type_name& type)const { return built_in_types.find(type) != built_in_types.end(); } diff --git a/libraries/chain/contracts/chain_initializer.cpp b/libraries/chain/contracts/chain_initializer.cpp index 3343883795cdb9edd8635307101438dca818b160..5fb5ef6fd88e2a943b4ead882067fa8a5ce7dd90 100644 --- a/libraries/chain/contracts/chain_initializer.cpp +++ b/libraries/chain/contracts/chain_initializer.cpp @@ -50,9 +50,9 @@ void chain_initializer::register_types(chain_controller& chain, chainbase::datab } -abi_def chain_initializer::eos_contract_abi() +abi_def chain_initializer::eos_contract_abi(const abi_def& eosio_system_abi) { - abi_def eos_abi; + abi_def eos_abi(eosio_system_abi); eos_abi.types.push_back( type_def{"account_name","name"} ); eos_abi.types.push_back( type_def{"share_type","int64"} ); eos_abi.types.push_back( type_def{"onerror","bytes"} ); diff --git a/libraries/chain/contracts/eosio_contract.cpp b/libraries/chain/contracts/eosio_contract.cpp index 41cec9e23315518a45db77358d185094a6fb4df0..ea0339ac40095ca1eb1edbdbf2fb994464e5cc29 100644 --- a/libraries/chain/contracts/eosio_contract.cpp +++ b/libraries/chain/contracts/eosio_contract.cpp @@ -142,10 +142,15 @@ void apply_eosio_setabi(apply_context& context) { context.require_authorization(act.account); + // if system account append native abi + if ( act.account == eosio::chain::config::system_account_name ) { + act.abi = chain_initializer::eos_contract_abi(act.abi); + } + /// if an ABI is specified make sure it is well formed and doesn't /// reference any undefined types abi_serializer(act.abi).validate(); - // todo: figure out abi serilization location + // todo: figure out abi serialization location const auto& account = db.get(act.account); db.modify( account, [&]( auto& a ) { @@ -306,7 +311,7 @@ void apply_eosio_onerror(apply_context& context) { static const abi_serializer& get_abi_serializer() { static optional _abi_serializer; if (!_abi_serializer) { - _abi_serializer.emplace(chain_initializer::eos_contract_abi()); + _abi_serializer.emplace(chain_initializer::eos_contract_abi(abi_def())); } return *_abi_serializer; diff --git a/libraries/chain/include/eosio/chain/apply_context.hpp b/libraries/chain/include/eosio/chain/apply_context.hpp index 51724a4fc800ac998e066e949933a3d7b8809db8..b7d2f935e691a74dd1e537ee2a5864b09aad943f 100644 --- a/libraries/chain/include/eosio/chain/apply_context.hpp +++ b/libraries/chain/include/eosio/chain/apply_context.hpp @@ -134,7 +134,7 @@ class apply_context { }); } - int find_secondary( uint64_t code, uint64_t scope, uint64_t table, secondary_key_type& secondary, uint64_t& primary ) { + int find_secondary( uint64_t code, uint64_t scope, uint64_t table, const secondary_key_type& secondary, uint64_t& primary ) { auto tab = context.find_table( context.receiver, scope, table ); if( !tab ) return -1; @@ -142,7 +142,6 @@ class apply_context { if( !obj ) return -1; primary = obj->primary_key; - secondary = obj->secondary_key; itr_cache.cache_table( *tab ); return itr_cache.add( *obj ); @@ -209,7 +208,6 @@ class apply_context { primary = itr->primary_key; return itr_cache.add(*itr); } - int find_primary( uint64_t code, uint64_t scope, uint64_t table, secondary_key_type& secondary, uint64_t primary ) { diff --git a/libraries/chain/include/eosio/chain/contracts/abi_serializer.hpp b/libraries/chain/include/eosio/chain/contracts/abi_serializer.hpp index 9b4239261b4c63d90791bed5f3c662f80b345d1f..ef5059e0661745ed70cdc324637b723229823603 100644 --- a/libraries/chain/include/eosio/chain/contracts/abi_serializer.hpp +++ b/libraries/chain/include/eosio/chain/contracts/abi_serializer.hpp @@ -73,12 +73,11 @@ struct abi_serializer { } template - static bool to_abi(account_name account, const Vec& abi_vec, abi_def& abi) + static bool to_abi(const Vec& abi_vec, abi_def& abi) { - if( !is_empty_abi(abi_vec) || account == eosio::chain::config::system_account_name ) { /// 4 == packsize of empty Abi + if( !is_empty_abi(abi_vec) ) { /// 4 == packsize of empty Abi fc::datastream ds( abi_vec.data(), abi_vec.size() ); fc::raw::unpack( ds, abi ); - append_system_abi(account, abi); return true; } return false; @@ -86,7 +85,6 @@ struct abi_serializer { private: void binary_to_variant(const type_name& type, fc::datastream& stream, fc::mutable_variant_object& obj)const; - static void append_system_abi(account_name account, abi_def& abi); }; namespace impl { diff --git a/libraries/chain/include/eosio/chain/contracts/chain_initializer.hpp b/libraries/chain/include/eosio/chain/contracts/chain_initializer.hpp index 041e754c2b7f85ee32064bad0cdf40dc9106aa19..15079b02ec5021692bb283d82fce39c285ea5072 100644 --- a/libraries/chain/include/eosio/chain/contracts/chain_initializer.hpp +++ b/libraries/chain/include/eosio/chain/contracts/chain_initializer.hpp @@ -24,7 +24,7 @@ namespace eosio { namespace chain { namespace contracts { void prepare_database(chain::chain_controller& chain, chainbase::database& db); - static abi_def eos_contract_abi(); + static abi_def eos_contract_abi(const abi_def& eosio_system_abi); private: genesis_state_type genesis; diff --git a/libraries/chain/wasm_interface.cpp b/libraries/chain/wasm_interface.cpp index 917b53cabec998e40896d2571abd2ce0922dff0c..a7ff3e77edd27229b91b51bc097210234ea675b4 100644 --- a/libraries/chain/wasm_interface.cpp +++ b/libraries/chain/wasm_interface.cpp @@ -646,7 +646,7 @@ class database_api : public context_aware_api { return context.db_lowerbound_i64( code, scope, table, id ); } int db_upperbound_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id ) { - return context.db_lowerbound_i64( code, scope, table, id ); + return context.db_upperbound_i64( code, scope, table, id ); } int db_idx64_store( uint64_t scope, uint64_t table, uint64_t payer, uint64_t id, const uint64_t& secondary ) { @@ -658,13 +658,12 @@ class database_api : public context_aware_api { void db_idx64_remove( int iterator ) { return context.idx64.remove( iterator ); } - int db_idx64_find_secondary( uint64_t code, uint64_t scope, uint64_t table, uint64_t& secondary, uint64_t& primary ) { + int db_idx64_find_secondary( uint64_t code, uint64_t scope, uint64_t table, const uint64_t& secondary, uint64_t& primary ) { return context.idx64.find_secondary(code, scope, table, secondary, primary); } int db_idx64_find_primary( uint64_t code, uint64_t scope, uint64_t table, uint64_t& secondary, uint64_t primary ) { - return context.idx64.find_secondary(code, scope, table, secondary, primary); + return context.idx64.find_primary(code, scope, table, secondary, primary); } - int db_idx64_lowerbound( uint64_t code, uint64_t scope, uint64_t table, uint64_t& secondary, uint64_t& primary ) { return context.idx64.lowerbound_secondary(code, scope, table, secondary, primary); } @@ -678,22 +677,6 @@ class database_api : public context_aware_api { return context.idx64.previous_secondary(iterator, primary); } - /* - int db_idx64_next( int iterator, uint64_t& primary ) { - } - int db_idx64_prev( int iterator, uint64_t& primary ) { - } - int db_idx64_find_primary( uint64_t code, uint64_t scope, uint64_t table, uint64_t& secondary, uint64_t primary ) { - } - int db_idx64_find_secondary( uint64_t code, uint64_t scope, uint64_t table, uint64_t& secondary, uint64_t& primary ) { - } - int db_idx64_lowerbound( uint64_t code, uint64_t scope, uint64_t table, uint64_t& secondary, uint64_t& primary ) { - } - int db_idx64_upperbound( uint64_t code, uint64_t scope, uint64_t table, uint64_t& secondary, uint64_t& primary ) { - } - */ - - int db_idx128_store( uint64_t scope, uint64_t table, uint64_t payer, uint64_t id, const uint128_t& secondary ) { return context.idx128.store( scope, table, payer, id, secondary ); } @@ -706,7 +689,7 @@ class database_api : public context_aware_api { int db_idx128_find_primary( uint64_t code, uint64_t scope, uint64_t table, uint128_t& secondary, uint64_t primary ) { return context.idx128.find_primary( code, scope, table, secondary, primary ); } - int db_idx128_find_secondary( uint64_t code, uint64_t scope, uint64_t table, uint128_t& secondary, uint64_t& primary ) { + int db_idx128_find_secondary( uint64_t code, uint64_t scope, uint64_t table, const uint128_t& secondary, uint64_t& primary ) { return context.idx128.find_secondary(code, scope, table, secondary, primary); } int db_idx128_lowerbound( uint64_t code, uint64_t scope, uint64_t table, uint128_t& secondary, uint64_t& primary ) { diff --git a/libraries/chainbase b/libraries/chainbase index d48ebabf56b4115753fcabb7648a0ffcf3b0f5e9..664fdd9e79263a894794f96959612ec2d1d013d0 160000 --- a/libraries/chainbase +++ b/libraries/chainbase @@ -1 +1 @@ -Subproject commit d48ebabf56b4115753fcabb7648a0ffcf3b0f5e9 +Subproject commit 664fdd9e79263a894794f96959612ec2d1d013d0 diff --git a/libraries/testing/include/eosio/testing/tester.hpp b/libraries/testing/include/eosio/testing/tester.hpp index bd89e5414a15d42a72c31247607806f7e4b4ce66..91ff7d75d4330ded78a3e58c904b9673c5c401f4 100644 --- a/libraries/testing/include/eosio/testing/tester.hpp +++ b/libraries/testing/include/eosio/testing/tester.hpp @@ -85,7 +85,7 @@ namespace eosio { namespace testing { try { const auto &accnt = control->get_database().get(name); contracts::abi_def abi; - if (contracts::abi_serializer::to_abi(accnt.name, accnt.abi, abi)) { + if (contracts::abi_serializer::to_abi(accnt.abi, abi)) { return contracts::abi_serializer(abi); } return optional(); diff --git a/plugins/account_history_plugin/account_history_plugin.cpp b/plugins/account_history_plugin/account_history_plugin.cpp index 217a94b3a083a93c5dfbc4227a5d448613872221..a39dce2ddd521d1cdd8ce05c45fb520a4b1805db 100644 --- a/plugins/account_history_plugin/account_history_plugin.cpp +++ b/plugins/account_history_plugin/account_history_plugin.cpp @@ -413,7 +413,7 @@ fc::variant account_history_plugin_impl::transaction_to_variant(const packed_tra const auto* accnt = database.find( name ); if (accnt != nullptr) { abi_def abi; - if (abi_serializer::to_abi(accnt->name, accnt->abi, abi)) { + if (abi_serializer::to_abi(accnt->abi, abi)) { return abi_serializer(abi); } } diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index 6f728d1049997fa1adefc78fc6c7aab8feef4d88..86e0f61a314aa23f116b7d81c5e39a0482fa1d62 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -284,7 +284,7 @@ abi_def get_abi( const chain_controller& db, const name& account ) { const auto& code_accnt = d.get( account ); abi_def abi; - abi_serializer::to_abi(code_accnt.name, code_accnt.abi, abi); + abi_serializer::to_abi(code_accnt.abi, abi); return abi; } @@ -365,7 +365,7 @@ struct resolver_factory { const auto *accnt = api->db.get_database().template find(name); if (accnt != nullptr) { abi_def abi; - if (abi_serializer::to_abi(accnt->name, accnt->abi, abi)) { + if (abi_serializer::to_abi(accnt->abi, abi)) { return abi_serializer(abi); } } @@ -450,7 +450,7 @@ read_only::get_code_results read_only::get_code( const get_code_params& params ) } abi_def abi; - if( abi_serializer::to_abi(accnt.name, accnt.abi, abi) ) { + if( abi_serializer::to_abi(accnt.abi, abi) ) { result.abi = std::move(abi); } @@ -492,7 +492,7 @@ read_only::abi_json_to_bin_result read_only::abi_json_to_bin( const read_only::a abi_json_to_bin_result result; const auto& code_account = db.get_database().get( params.code ); abi_def abi; - if( abi_serializer::to_abi(code_account.name, code_account.abi, abi) ) { + if( abi_serializer::to_abi(code_account.abi, abi) ) { abi_serializer abis( abi ); result.binargs = abis.variant_to_binary( abis.get_action_type( params.action ), params.args ); } @@ -503,7 +503,7 @@ read_only::abi_bin_to_json_result read_only::abi_bin_to_json( const read_only::a abi_bin_to_json_result result; const auto& code_account = db.get_database().get( params.code ); abi_def abi; - if( abi_serializer::to_abi(code_account.name, code_account.abi, abi) ) { + if( abi_serializer::to_abi(code_account.abi, abi) ) { abi_serializer abis( abi ); result.args = abis.binary_to_variant( abis.get_action_type( params.action ), params.binargs ); } diff --git a/plugins/mongo_db_plugin/mongo_db_plugin.cpp b/plugins/mongo_db_plugin/mongo_db_plugin.cpp index 7c3ea51a85b04f3602f9a63aa19aa98061a4146f..989530fb35fa8bf03316ea08ceba67ef17fe87b3 100644 --- a/plugins/mongo_db_plugin/mongo_db_plugin.cpp +++ b/plugins/mongo_db_plugin/mongo_db_plugin.cpp @@ -73,7 +73,6 @@ public: void consum_blocks(); - bool is_scope_relevant(const vector& scope); void update_account(const chain::action& msg); static const account_name newaccount; @@ -90,8 +89,6 @@ public: static const std::string accounts_col; }; -abi_def mongo_db_plugin_impl::eos_abi; - const account_name mongo_db_plugin_impl::newaccount = "newaccount"; const account_name mongo_db_plugin_impl::transfer = "transfer"; const account_name mongo_db_plugin_impl::lock = "lock"; @@ -181,14 +178,13 @@ namespace { { using bsoncxx::builder::basic::kvp; try { + auto from_account = find_account(accounts, msg.account); + auto abi = fc::json::from_string(bsoncxx::to_json(from_account.view()["abi"].get_document())).as(); abi_serializer abis; if (msg.account == chain::config::system_account_name) { - abis.set_abi(mongo_db_plugin_impl::eos_abi); - } else { - auto from_account = find_account(accounts, msg.account); - auto abi = fc::json::from_string(bsoncxx::to_json(from_account.view()["abi"].get_document())).as(); - abis.set_abi(abi); + abi = chain::contracts::chain_initializer::eos_contract_abi(abi); } + abis.set_abi(abi); auto v = abis.binary_to_variant(abis.get_action_type(msg.name), msg.data); auto json = fc::json::to_string(v); try { @@ -264,15 +260,10 @@ void mongo_db_plugin_impl::_process_irreversible_block(const signed_block& block auto block_num = block.block_num(); if (processed == 0) { - if (startup) { + if (wipe_database_on_startup) { // verify on start we have no previous blocks verify_no_blocks(blocks); FC_ASSERT(block_num < 2, "Expected start of block, instead received block_num: ${bn}", ("bn", block_num)); - // Currently we are creating a 'fake' block in chain_controller::initialize_chain() since initial accounts - // and producers are not written to the block log. If this is the fake block, indicate it as block_num 0. - if (block_num == 1 && block.producer == chain::config::system_account_name) { - block_num = 0; - } } else { // verify on restart we have previous block verify_last_block(blocks, prev_block_id_str); @@ -403,17 +394,22 @@ void mongo_db_plugin_impl::update_account(const chain::action& msg) { if (msg.name == transfer) { auto now = std::chrono::duration_cast( std::chrono::microseconds{fc::time_point::now().time_since_epoch().count()}); - /* todo need to follow eosio.system transfer - auto transfer = msg.as(); - auto from_name = transfer.from.to_string(); - auto to_name = transfer.to.to_string(); - auto from_account = find_account(accounts, transfer.from); - auto to_account = find_account(accounts, transfer.to); + + abi_serializer abis; + auto eosio_account = find_account(accounts, msg.account); + auto abi = fc::json::from_string(bsoncxx::to_json(eosio_account.view()["abi"].get_document())).as(); + abis.set_abi(abi); + auto transfer = abis.binary_to_variant(abis.get_action_type(msg.name), msg.data); + auto from_name = transfer["from"].as().to_string(); + auto to_name = transfer["to"].as().to_string(); + auto from_account = find_account(accounts, from_name); + auto to_account = find_account(accounts, to_name); asset from_balance = asset::from_string(from_account.view()["eos_balance"].get_utf8().value.to_string()); asset to_balance = asset::from_string(to_account.view()["eos_balance"].get_utf8().value.to_string()); - from_balance -= asset(chain::share_type(transfer.amount)); - to_balance += asset(chain::share_type(transfer.amount)); + auto asset_quantity = transfer["quantity"].as(); + from_balance -= asset_quantity; + to_balance += asset_quantity; document update_from{}; update_from << "$set" << open_document << "eos_balance" << from_balance.to_string() @@ -426,7 +422,7 @@ void mongo_db_plugin_impl::update_account(const chain::action& msg) { accounts.update_one(document{} << "_id" << from_account.view()["_id"].get_oid() << finalize, update_from.view()); accounts.update_one(document{} << "_id" << to_account.view()["_id"].get_oid() << finalize, update_to.view()); -*/ + } else if (msg.name == newaccount) { auto now = std::chrono::duration_cast( std::chrono::microseconds{fc::time_point::now().time_since_epoch().count()}); @@ -496,8 +492,6 @@ void mongo_db_plugin_impl::init() { // Create the native contract accounts manually; sadly, we can't run their contracts to make them create themselves // See native_contract_chain_initializer::prepare_database() - eos_abi = chain::contracts::chain_initializer::eos_contract_abi(); - accounts = mongo_conn[db_name][accounts_col]; // Accounts bsoncxx::builder::stream::document doc{}; if (accounts.count(doc.view()) == 0) { @@ -507,7 +501,6 @@ void mongo_db_plugin_impl::init() { << "eos_balance" << asset(chain::config::initial_token_supply).to_string() << "staked_balance" << asset().to_string() << "unstaking_balance" << asset().to_string() - << "abi" << bsoncxx::from_json(fc::json::to_string(eos_abi)) << "createdAt" << b_date{now} << "updatedAt" << b_date{now}; diff --git a/programs/eosioc/main.cpp b/programs/eosioc/main.cpp index 22a4c50c0e8efc3d291fd3f595f081a7bd1f8dcf..6dc05f2fd1d394b811e1dadfffd216826d066868 100644 --- a/programs/eosioc/main.cpp +++ b/programs/eosioc/main.cpp @@ -54,8 +54,8 @@ Usage: ./eosc create account [OPTIONS] creator name OwnerKey ActiveKey Positionals: creator TEXT The name of the account creating the new account name TEXT The name of the new account - OwnerKey TEXT The owner public key for the account - ActiveKey TEXT The active public key for the account + OwnerKey TEXT The owner public key for the new account + ActiveKey TEXT The active public key for the new account Options: -s,--skip-signature Specify that unlocked wallet keys should not be used to sign transaction @@ -458,8 +458,8 @@ int main( int argc, char** argv ) { auto createAccount = create->add_subcommand("account", localized("Create a new account on the blockchain"), false); createAccount->add_option("creator", creator, localized("The name of the account creating the new account"))->required(); createAccount->add_option("name", account_name, localized("The name of the new account"))->required(); - createAccount->add_option("OwnerKey", owner_key_str, localized("The owner public key for the account"))->required(); - createAccount->add_option("ActiveKey", active_key_str, localized("The active public key for the account"))->required(); + createAccount->add_option("OwnerKey", owner_key_str, localized("The owner public key for the new account"))->required(); + createAccount->add_option("ActiveKey", active_key_str, localized("The active public key for the new account"))->required(); createAccount->add_flag("-s,--skip-signature", skip_sign, localized("Specify that unlocked wallet keys should not be used to sign transaction")); add_standard_transaction_options(createAccount); createAccount->set_callback([&] { diff --git a/scripts/eosio_build_darwin.sh b/scripts/eosio_build_darwin.sh new file mode 100644 index 0000000000000000000000000000000000000000..5e0418ee03684961d21b10dc2aff3dda3c1faed2 --- /dev/null +++ b/scripts/eosio_build_darwin.sh @@ -0,0 +1,224 @@ + OS_VER=`sw_vers -productVersion` + OS_MAJ=`echo "${OS_VER}" | cut -d'.' -f1` + OS_MIN=`echo "${OS_VER}" | cut -d'.' -f2` + OS_PATCH=`echo "${OS_VER}" | cut -d'.' -f3` + + MEM_GIG=`bc <<< "($(sysctl -in hw.memsize) / 1024000000)"` + + CPU_SPEED=`bc <<< "scale=2; ($(sysctl -in hw.cpufrequency) / 100000000) / 10"` + CPU_CORE=$( sysctl -in machdep.cpu.core_count ) + + DISK_TOTAL=`df -H $PWD | grep /dev | tr -s ' ' | cut -d\ -f2 | sed 's/[^0-9]//'` + DISK_AVAIL=`df -H $PWD | grep /dev | tr -s ' ' | cut -d\ -f4 | sed 's/[^0-9]//'` + + printf "\n\tOS name: $ARCH\n" + printf "\tOS Version: ${OS_VER}\n" + printf "\tCPU speed: ${CPU_SPEED}Ghz\n" + printf "\tCPU cores: $CPU_CORE\n" + printf "\tPhysical Memory: $MEM_GIG Gbytes\n" + printf "\tDisk space total: ${DISK_TOTAL}G\n" + printf "\tDisk space available: ${DISK_AVAIL}G\n\n" + + if [ $MEM_GIG -lt 8 ]; then + printf "\tYour system must have 8 or more Gigabytes of physical memory installed.\n" + printf "\tExiting now.\n" + exit 1 + fi + + if [ $OS_MIN -lt 12 ]; then + printf "\tYou must be running Mac OS 10.12.x or higher to install EOSIO.\n" + printf "\tExiting now.\n" + exit 1 + fi + + if [ $DISK_AVAIL -lt 100 ]; then + printf "\tYou must have at least 100GB of available storage to install EOSIO.\n" + printf "\tExiting now.\n" + exit 1 + fi + + process_dep() + { + printf "\tChecking XCode installation\n" + XCODESELECT=$(which xcode-select) + if [ $? -ne 0 ]; then + printf "\n\tXCode must be installed in order to proceed.\n\n" + printf "\texiting now.\n" + exit 1 + fi + + printf "\tXCode installation found.\n\n" + + printf "\tChecking Ruby installation\n" + RUBY=$(which ruby) + if [ $? -ne 0 ]; then + printf "\nRuby must be installed in order to proceed.\n\n" + printf "\texiting now.\n" + exit 1 + fi + + printf "\tRuby installation found.\n\n" + + printf "\tChecking Home Brew installation\n" + BREW=$(which brew) + if [ $? -ne 0 ]; then + printf "\tHomebrew must be installed to compile EOS.IO\n\n" + printf "\tDo you wish to install Home Brew?\n" + select yn in "Yes" "No"; do + case $yn in + [Yy]* ) + $XCODESELECT --install 2>/dev/null; + $RUBY -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + if [ $? -ne 0 ]; then + echo "User aborted homebrew installation. Exiting now." + exit 0; + fi + break;; + [Nn]* ) echo "User aborted homebrew installation. Exiting now."; + exit;; + * ) echo "Please enter 1 for yes or 2 for no.";; + esac + done + fi + + printf "\tHome Brew installation found.\n\n" + # DEPS="git automake libtool openssl cmake wget boost llvm@4 gmp gettext" + DCOUNT=0 + COUNT=1 + PERMISSION_GETTEXT=0 + DISPLAY="" + DEP="" + + printf "\tChecking dependencies.\n" + for line in `cat ${WORK_DIR}/scripts/eosio_build_dep`; do + pkg=$( echo "${line}" | cut -d',' -f1 ) + printf "\tChecking $pkg ... " + BIN=$(which $pkg) + if [ $? -eq 0 ]; then + printf "\t$pkg found\n" + continue + fi + + LIB=$( ls -l /usr/local/lib/lib${pkg}* 2>/dev/null | wc -l) + if [ ${LIB} -ne 0 ]; then + printf "\t$pkg found\n" + continue + else + let DCOUNT++ + + if [ $pkg = "LLVM" ]; then + pkg="llvm@4" + fi + + if [ $pkg = "gettext" ]; then + PERMISSION_GETTEXT=1 + fi + + DEP=$DEP" ${pkg} " + DISPLAY="${DISPLAY}${COUNT}. ${pkg}\n\t" + printf "\tPackage ${pkg} ${bldred}NOT${txtrst} found.\n" + let COUNT++ + fi + done + + if [ $DCOUNT -ne 0 ]; then + printf "\n\tThe following dependencies are required to install EOSIO.\n" + printf "\n\t$DISPLAY\n\n" + echo "Do you wish to install these packages?" + select yn in "Yes" "No"; do + case $yn in + [Yy]* ) + if [ $PERMISSION_GETTEXT -eq 1 ]; then + sudo chown -R $(whoami) /usr/local/share + fi + + $XCODESELECT --install 2>/dev/null; + printf "\tUpdating Home Brew.\n" + brew update + printf "\tInstalling Dependencies.\n" + brew install --force $DEP + brew unlink $DEP && brew link --force $DEP + break;; + [Nn]* ) echo "User aborting installation of required dependencies, Exiting now."; exit;; + * ) echo "Please type 1 for yes or 2 for no.";; + esac + done + else + printf "\n\tNo required Home Brew dependencies to install.\n" + fi + + return 0 + } + + process_dep + + printf "\n\tChecking for secp256k1-zkp\n" + # install secp256k1-zkp (Cryptonomex branch) + if [ ! -e /usr/local/lib/libsecp256k1.a ]; then + cd ${TEMP_DIR} + git clone https://github.com/cryptonomex/secp256k1-zkp.git + cd secp256k1-zkp + ./autogen.sh + if [ $? -ne 0 ]; then + printf "\tError running autogen\n" + printf "\tExiting now.\n\n" + exit; + fi + ./configure + make + if [ $? -ne 0 ]; then + printf "\tError compiling secp256k1-zkp.\n" + printf "\tExiting now.\n\n" + exit; + fi + sudo make install + sudo rm -rf ${TEMP_DIR}/secp256k1-zkp + else + printf "\tsecp256k1 found at /usr/local/lib/\n" + fi + + printf "\n\tChecking for binaryen\n" + if [ ! -e /usr/local/binaryen/bin/binaryen.js ]; then + cd ${TEMP_DIR} + git clone https://github.com/WebAssembly/binaryen + cd binaryen + git checkout tags/1.37.14 + cmake . && make + if [ $? -ne 0 ]; then + printf "\tError compiling binaryen.\n" + printf "\tExiting now.\n\n" + exit; + fi + sudo mkdir /usr/local/binaryen + sudo mv ${TEMP_DIR}/binaryen/bin /usr/local/binaryen + sudo ln -s /usr/local/binaryen/bin/* /usr/local + sudo rm -rf ${TEMP_DIR}/binaryen + else + printf "\tBinaryen found at /usr/local/binaryen/bin/\n" + fi + + printf "\n\tChecking for WASM\n" + if [ ! -d /usr/local/wasm/bin ]; then + # Build LLVM and clang for WASM: + cd ${TEMP_DIR} + mkdir wasm-compiler + cd wasm-compiler + git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git + cd llvm/tools + git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git + cd .. + mkdir build + cd build + sudo cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr/local/wasm \ + -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly \ + -DCMAKE_BUILD_TYPE=Release ../ + if [ $? -ne 0 ]; then + printf "\tError compiling WASM.\n" + printf "\tExiting now.\n\n" + exit; + fi + sudo make -j4 install + sudo rm -rf ${TEMP_DIR}/wasm-compiler + else + printf "\tWASM found at /usr/local/wasm/bin/\n" + fi \ No newline at end of file diff --git a/scripts/eosio_build_dep b/scripts/eosio_build_dep new file mode 100644 index 0000000000000000000000000000000000000000..ba53fe179d89411ff5e7665c731c035c7b5bf0da --- /dev/null +++ b/scripts/eosio_build_dep @@ -0,0 +1,9 @@ +automake,http://ftp.gnu.org/gnu/automake/automake-1.15.tar.gz +libtool,http://gnu.askapache.com/libtool/libtool-2.4.6.tar.gz +openssl,https://www.openssl.org/source/openssl-1.0.2n.tar.gz +LLVM,http://releases.llvm.org/5.0.1/llvm-5.0.1.src.tar.xz +wget,https://ftp.gnu.org/gnu/wget/wget-1.19.2.tar.gz +cmake,https://cmake.org/files/v3.10/cmake-3.10.1-Darwin-x86_64.tar.gz +boost,https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz +gmp,https://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.bz2 +gettext,https://ftp.gnu.org/pub/gnu/gettext/gettext-latest.tar.gz \ No newline at end of file diff --git a/scripts/eosio_build_fedora.sh b/scripts/eosio_build_fedora.sh new file mode 100644 index 0000000000000000000000000000000000000000..32046df17b13afff6851b09faee250cd4b61e638 --- /dev/null +++ b/scripts/eosio_build_fedora.sh @@ -0,0 +1,198 @@ + OS_VER=$( cat /etc/os-release | grep VERSION_ID | cut -d'=' -f2 | sed 's/[^0-9\.]//gI' ) + + MEM_MEG=$( free -m | grep Mem | tr -s ' ' | cut -d\ -f2 ) + + CPU_SPEED=$( lscpu | grep "MHz" | tr -s ' ' | cut -d\ -f3 | cut -d'.' -f1 ) + CPU_CORE=$( lscpu | grep "^CPU(s)" | tr -s ' ' | cut -d\ -f2 ) + + DISK_TOTAL=`df -h / | grep /dev | tr -s ' ' | cut -d\ -f2 | sed 's/[^0-9]//'` + DISK_AVAIL=`df -h / | grep /dev | tr -s ' ' | cut -d\ -f4 | sed 's/[^0-9]//'` + + printf "\n\tOS name: $OS_NAME\n" + printf "\tOS Version: ${OS_VER}\n" + printf "\tCPU speed: ${CPU_SPEED}Mhz\n" + printf "\tCPU cores: $CPU_CORE\n" + printf "\tPhysical Memory: $MEM_MEG Mgb\n" + printf "\tDisk space total: ${DISK_TOTAL}G\n" + printf "\tDisk space available: ${DISK_AVAIL}G\n" + + if [ $MEM_MEG -lt 4000 ]; then + echo "Your system must have 8 or more Gigabytes of physical memory installed." + echo "exiting now." + exit 1 + fi + + if [ $OS_VER -lt 25 ]; then + echo "You must be running Fedora 25 or higher to install EOSIO." + echo "exiting now" + exit 1 + fi + + if [ $DISK_AVAIL -lt 100 ]; then + echo "You must have at least 100GB of available storage to install EOSIO." + echo "exiting now" + exit 1 + fi + + printf "\n\tChecking Yum installation\n" + + YUM=$( which yum 2>/dev/null ) + if [ $? -ne 0 ]; then + printf "\n\tYum must be installed to compile EOS.IO.\n" + printf "\n\tExiting now.\n" + exit 0 + fi + + printf "\tYum installation found at ${YUM}.\n" + printf "\tUpdating YUM.\n" + UPDATE=$( sudo yum update ) + + if [ $? -ne 0 ]; then + printf "\n\tYUM update failed.\n" + printf "\n\tExiting now.\n" + exit 1 + fi + + printf "\t${UPDATE}\n" + DEP_ARRAY=( git gcc.x86_64 gcc-c++.x86_64 autoconf automake libtool make cmake.x86_64 bzip2 bzip2-devel.x86_64 openssl-devel.x86_64 gmp.x86_64 gmp-devel.x86_64 libstdc++-devel.x86_64 python3-devel.x86_64 libedit.x86_64 ncurses-devel.x86_64 swig.x86_64 ) + DCOUNT=0 + COUNT=1 + DISPLAY="" + DEP="" + + printf "\n\tChecking YUM for installed dependencies.\n\n" + + for (( i=0; i<${#DEP_ARRAY[@]}; i++ )); + do + pkg=$( sudo $YUM info ${DEP_ARRAY[$i]} 2>/dev/null | grep Repo | tr -s ' ' | cut -d: -f2 | sed 's/ //g' ) + + if [ "$pkg" != "@System" ]; then + DEP=$DEP" ${DEP_ARRAY[$i]} " + DISPLAY="${DISPLAY}${COUNT}. ${DEP_ARRAY[$i]}\n\t" + printf "\tPackage ${DEP_ARRAY[$i]} ${bldred} NOT ${txtrst} found.\n" + let COUNT++ + let DCOUNT++ + else + printf "\tPackage ${DEP_ARRAY[$i]} found.\n" + continue + fi + done + + if [ ${DCOUNT} -ne 0 ]; then + printf "\n\tThe following dependencies are required to install EOSIO.\n" + printf "\n\t$DISPLAY\n\n" + printf "\tDo you wish to install these dependencies?\n" + select yn in "Yes" "No"; do + case $yn in + [Yy]* ) + printf "\n\n\tInstalling dependencies\n\n" + sudo yum -y install ${DEP} + if [ $? -ne 0 ]; then + printf "\n\tYUM dependency installation failed.\n" + printf "\n\tExiting now.\n" + exit 1 + else + printf "\n\tYUM dependencies installed successfully.\n" + fi + break;; + [Nn]* ) echo "User aborting installation of required dependencies, Exiting now."; exit;; + * ) echo "Please type 1 for yes or 2 for no.";; + esac + done + else + printf "\n\tNo required YUM dependencies to install.\n" + fi + + printf "\n\tChecking for boost libraries\n" + if [ ! -d ${HOME}/opt/boost_1_66_0 ]; then + # install boost + printf "\tInstalling boost libraries\n" + cd ${TEMP_DIR} + curl -L https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.bz2 > boost_1.66.0.tar.bz2 + tar xf boost_1.66.0.tar.bz2 + cd boost_1_66_0/ + ./bootstrap.sh "--prefix=$BOOST_ROOT" + ./b2 install + rm -rf ${TEMP_DIR}/boost_1_66_0/ + rm -f ${TEMP_DIR}/boost_1.66.0.tar.bz2 + else + printf "\tBoost 1.66 found at ${HOME}/opt/boost_1_66_0\n" + fi + + printf "\n\tChecking for secp256k1-zkp\n" + # install secp256k1-zkp (Cryptonomex branch) + if [ ! -e /usr/local/lib/libsecp256k1.a ]; then + printf "\tInstalling secp256k1-zkp (Cryptonomex branch)\n" + cd ${TEMP_DIR} + git clone https://github.com/cryptonomex/secp256k1-zkp.git + cd secp256k1-zkp + ./autogen.sh + if [ $? -ne 0 ]; then + printf "\tError running autogen for secp256k1-zkp.\n" + printf "\tExiting now.\n\n" + exit; + fi + ./configure + make + if [ $? -ne 0 ]; then + printf "\tError compiling secp256k1-zkp.\n" + printf "\tExiting now.\n\n" + exit; + fi + sudo make install + rm -rf cd ${TEMP_DIR}/secp256k1-zkp + else + printf "\tsecp256k1 found\n" + fi + + printf "\n\tChecking for binaryen\n" + if [ ! -d ${HOME}/opt/binaryen ]; then + # Install binaryen v1.37.14: + printf "\tInstalling binaryen v1.37.14:\n" + cd ${TEMP_DIR} + git clone https://github.com/WebAssembly/binaryen + cd binaryen + git checkout tags/1.37.14 + cmake . && make + if [ $? -ne 0 ]; then + printf "\tError compiling binaryen.\n" + printf "\tExiting now.\n\n" + exit; + fi + mkdir -p ${HOME}/opt/binaryen/ 2>/dev/null + mv ${TEMP_DIR}/binaryen/bin ${HOME}/opt/binaryen/ + rm -rf ${TEMP_DIR}/binaryen + else + printf "\tBinaryen found at ${HOME}/opt/binaryen\n" + fi + + printf "\n\tChecking for LLVM with WASM support.\n" + if [ ! -d ${HOME}/opt/wasm/bin ]; then + # Build LLVM and clang with EXPERIMENTAL WASM support: + printf "\tInstalling LLVM & WASM\n" + cd ${TEMP_DIR} + mkdir llvm-compiler 2>/dev/null + cd llvm-compiler + git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git + cd llvm/tools + git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git + cd .. + mkdir build + cd build + cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=${HOME}/opt/wasm -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../ + if [ $? -ne 0 ]; then + printf "\tError compiling LLVM and clang with EXPERIMENTAL WASM support.\n" + printf "\tExiting now.\n\n" + exit; + fi + make -j$(nproc) + if [ $? -ne 0 ]; then + printf "\tError compiling LLVM and clang with EXPERIMENTAL WASM support.\n" + printf "\tExiting now.\n\n" + exit; + fi + make install + rm -rf ${TEMP_DIR}/llvm-compiler 2>/dev/null + else + printf "\tWASM found at ${HOME}/opt/wasm\n" + fi \ No newline at end of file diff --git a/scripts/eosio_build_ubuntu.sh b/scripts/eosio_build_ubuntu.sh new file mode 100644 index 0000000000000000000000000000000000000000..e60bd5bf793bfbeb8fe7d600d92231947195bd1f --- /dev/null +++ b/scripts/eosio_build_ubuntu.sh @@ -0,0 +1,179 @@ + OS_VER=$( cat /etc/os-release | grep VERSION_ID | cut -d'=' -f2 | sed 's/[^0-9\.]//gI' ) + OS_MAJ=`echo "${OS_VER}" | cut -d'.' -f1` + OS_MIN=`echo "${OS_VER}" | cut -d'.' -f2` + + MEM_MEG=$( free -m | grep Mem | tr -s ' ' | cut -d\ -f2 ) + + CPU_SPEED=$( lscpu | grep "MHz" | tr -s ' ' | cut -d\ -f3 | cut -d'.' -f1 ) + CPU_CORE=$( lscpu | grep "^CPU(s)" | tr -s ' ' | cut -d\ -f2 ) + + DISK_TOTAL=`df -h / | grep /dev | tr -s ' ' | cut -d\ -f2 | sed 's/[^0-9]//'` + DISK_AVAIL=`df -h / | grep /dev | tr -s ' ' | cut -d\ -f4 | sed 's/[^0-9]//'` + + printf "\n\tOS name: $OS_NAME\n" + printf "\tOS Version: ${OS_VER}\n" + printf "\tCPU speed: ${CPU_SPEED}Mhz\n" + printf "\tCPU cores: $CPU_CORE\n" + printf "\tPhysical Memory: $MEM_MEG Mgb\n" + printf "\tDisk space total: ${DISK_TOTAL}G\n" + printf "\tDisk space available: ${DISK_AVAIL}G\n" + + if [ $MEM_MEG -lt 4000 ]; then + echo "Your system must have 8 or more Gigabytes of physical memory installed." + echo "exiting now." + exit 1 + fi + + if [ $OS_MIN -lt 4 ]; then + echo "You must be running Ubuntu 16.04.x or higher to install EOSIO." + echo "exiting now" + exit 1 + fi + + if [ $DISK_AVAIL -lt 100 ]; then + echo "You must have at least 100GB of available storage to install EOSIO." + echo "exiting now" + exit 1 + fi + + DEP_ARRAY=(clang-4.0 lldb-4.0 libclang-4.0-dev cmake make libbz2-dev libssl-dev libgmp3-dev autotools-dev build-essential libbz2-dev libicu-dev python-dev autoconf libtool curl) + DCOUNT=0 + COUNT=1 + DISPLAY="" + DEP="" + + printf "\n\tChecking for installed dependencies.\n\n" + + for (( i=0; i<${#DEP_ARRAY[@]}; i++ )); + do + pkg=$( dpkg -s ${DEP_ARRAY[$i]} 2>/dev/null | grep Status | tr -s ' ' | cut -d\ -f4 ) + if [ -z "$pkg" ]; then + DEP=$DEP" ${DEP_ARRAY[$i]} " + DISPLAY="${DISPLAY}${COUNT}. ${DEP_ARRAY[$i]}\n\t" + printf "\tPackage ${DEP_ARRAY[$i]} ${bldred} NOT ${txtrst} found.\n" + let COUNT++ + let DCOUNT++ + else + printf "\tPackage ${DEP_ARRAY[$i]} found.\n" + continue + fi + done + + if [ ${DCOUNT} -ne 0 ]; then + printf "\n\tThe following dependencies are required to install EOSIO.\n" + printf "\n\t$DISPLAY\n\n" + printf "\tDo you wish to install these packages?\n" + select yn in "Yes" "No"; do + case $yn in + [Yy]* ) + printf "\n\n\tInstalling dependencies\n\n" + sudo apt-get update + sudo apt-get -y install ${DEP} + if [ $? -ne 0 ]; then + printf "\n\tDPKG dependency failed.\n" + printf "\n\tExiting now.\n" + exit 1 + else + printf "\n\tDPKG dependencies installed successfully.\n" + fi + break;; + [Nn]* ) echo "User aborting installation of required dependencies, Exiting now."; exit;; + * ) echo "Please type 1 for yes or 2 for no.";; + esac + done + else + printf "\n\tNo required dpkg dependencies to install.\n" + fi + + printf "\n\tChecking for boost libraries\n" + if [ ! -d ${HOME}/opt/boost_1_66_0 ]; then + # install boost + printf "\tInstalling boost libraries\n" + cd ${TEMP_DIR} + curl -L https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.bz2 > boost_1.66.0.tar.bz2 + tar xf boost_1.66.0.tar.bz2 + cd boost_1_66_0/ + ./bootstrap.sh "--prefix=$BOOST_ROOT" + ./b2 install + rm -rf ${TEMP_DIR}/boost_1_66_0/ + rm -f ${TEMP_DIR}/boost_1.66.0.tar.bz2 + else + printf "\tBoost 1.66 found at ${HOME}/opt/boost_1_66_0\n" + fi + + printf "\n\tChecking for secp256k1-zkp\n" + # install secp256k1-zkp (Cryptonomex branch) + if [ ! -e /usr/local/lib/libsecp256k1.a ]; then + printf "\tInstalling secp256k1-zkp (Cryptonomex branch)\n" + cd ${TEMP_DIR} + git clone https://github.com/cryptonomex/secp256k1-zkp.git + cd secp256k1-zkp + ./autogen.sh + if [ $? -ne 0 ]; then + printf "\tError running autogen for secp256k1-zkp.\n" + printf "\tExiting now.\n\n" + exit; + fi + ./configure + make + if [ $? -ne 0 ]; then + printf "\tError compiling secp256k1-zkp.\n" + printf "\tExiting now.\n\n" + exit; + fi + sudo make install + rm -rf cd ${TEMP_DIR}/secp256k1-zkp + else + printf "\tsecp256k1 found\n" + fi + + printf "\n\tChecking for binaryen\n" + if [ ! -d ${HOME}/opt/binaryen ]; then + # Install binaryen v1.37.14: + printf "\tInstalling binaryen v1.37.14:\n" + cd ${TEMP_DIR} + git clone https://github.com/WebAssembly/binaryen + cd binaryen + git checkout tags/1.37.14 + cmake . && make + if [ $? -ne 0 ]; then + printf "\tError compiling binaryen.\n" + printf "\tExiting now.\n\n" + exit; + fi + mkdir -p ${HOME}/opt/binaryen/ 2>/dev/null + mv ${TEMP_DIR}/binaryen/bin ${HOME}/opt/binaryen/ + rm -rf ${TEMP_DIR}/binaryen + else + printf "\tBinaryen found at ${HOME}/opt/binaryen\n" + fi + + printf "\n\tChecking for LLVM with WASM support.\n" + if [ ! -d ${HOME}/opt/wasm/bin ]; then + # Build LLVM and clang for WASM: + printf "\tInstalling LLVM & WASM\n" + cd ${TEMP_DIR} + mkdir llvm-compiler 2>/dev/null + cd llvm-compiler + git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git + cd llvm/tools + git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git + cd .. + mkdir build + cd build + cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=${HOME}/opt/wasm -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../ + if [ $? -ne 0 ]; then + printf "\tError compiling LLVM and clang with EXPERIMENTAL WASM support.\n" + printf "\tExiting now.\n\n" + exit; + fi + make -j$(nproc) + if [ $? -ne 0 ]; then + printf "\tError compiling LLVM and clang with EXPERIMENTAL WASM support.\n" + printf "\tExiting now.\n\n" + exit; + fi + rm -rf ${TEMP_DIR}/llvm-compiler + else + printf "\tWASM found at ${HOME}/opt/wasm/bin\n" + fi \ No newline at end of file diff --git a/scripts/install_dependencies.sh b/scripts/install_dependencies.sh deleted file mode 100644 index bd6c498625e9671c23e582554842662d156dfb81..0000000000000000000000000000000000000000 --- a/scripts/install_dependencies.sh +++ /dev/null @@ -1,106 +0,0 @@ -# Install dependencies script - -if [ $ARCH == "ubuntu" ]; then - # install dev toolkit - sudo apt-get update - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add - - sudo apt-get -y install clang-4.0 lldb-4.0 libclang-4.0-dev cmake make \ - libbz2-dev libssl-dev libgmp3-dev \ - autotools-dev build-essential \ - libbz2-dev libicu-dev python-dev \ - autoconf libtool git curl automake - OPENSSL_ROOT_DIR=/usr/local/opt/openssl - OPENSSL_LIBRARIES=/usr/local/opt/openssl/lib - - # install boost - cd ${TEMP_DIR} - export BOOST_ROOT=${HOME}/opt/boost_1_64_0 - curl -L https://sourceforge.net/projects/boost/files/boost/1.64.0/boost_1_64_0.tar.bz2 > boost_1.64.0.tar.bz2 - tar xvf boost_1.64.0.tar.bz2 - cd boost_1_64_0/ - ./bootstrap.sh "--prefix=$BOOST_ROOT" - ./b2 install - rm -rf ${TEMP_DIR}/boost_1_64_0/ - - # install secp256k1-zkp (Cryptonomex branch) - cd ${TEMP_DIR} - git clone https://github.com/cryptonomex/secp256k1-zkp.git - cd secp256k1-zkp - ./autogen.sh - ./configure - make - sudo make install - rm -rf cd ${TEMP_DIR}/secp256k1-zkp - - # install binaryen - cd ${TEMP_DIR} - git clone https://github.com/WebAssembly/binaryen - cd binaryen - git checkout tags/1.37.14 - cmake . && make - mkdir -p ${HOME}/opt/binaryen/ - mv ${TEMP_DIR}/binaryen/bin ${HOME}/opt/binaryen/ - rm -rf ${TEMP_DIR}/binaryen - BINARYEN_BIN=${HOME}/opt/binaryen/bin - - # build llvm with wasm build target: - cd ${TEMP_DIR} - mkdir wasm-compiler - cd wasm-compiler - git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git - cd llvm/tools - git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git - cd .. - mkdir build - cd build - cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=${HOME}/opt/wasm -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../ - make -j4 install - rm -rf ${TEMP_DIR}/wasm-compiler - WASM_LLVM_CONFIG=${HOME}/opt/wasm/bin/llvm-config -fi - -if [ $ARCH == "darwin" ]; then - DEPS="git automake libtool boost openssl llvm@4 gmp wget cmake gettext" - brew update - brew install --force $DEPS - brew unlink $DEPS && brew link --force $DEPS - # LLVM_DIR=/usr/local/Cellar/llvm/4.0.1/lib/cmake/llvm - - # install secp256k1-zkp (Cryptonomex branch) - cd ${TEMP_DIR} - git clone https://github.com/cryptonomex/secp256k1-zkp.git - cd secp256k1-zkp - ./autogen.sh - ./configure - make - sudo make install - sudo rm -rf ${TEMP_DIR}/secp256k1-zkp - - # Install binaryen v1.37.14: - cd ${TEMP_DIR} - git clone https://github.com/WebAssembly/binaryen - cd binaryen - git checkout tags/1.37.14 - cmake . && make - sudo mkdir /usr/local/binaryen - sudo mv ${TEMP_DIR}/binaryen/bin /usr/local/binaryen - sudo ln -s /usr/local/binaryen/bin/* /usr/local - sudo rm -rf ${TEMP_DIR}/binaryen - BINARYEN_BIN=/usr/local/binaryen/bin/ - - # Build LLVM and clang for WASM: - cd ${TEMP_DIR} - mkdir wasm-compiler - cd wasm-compiler - git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git - cd llvm/tools - git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git - cd .. - mkdir build - cd build - sudo cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr/local/wasm -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../ - sudo make -j4 install - sudo rm -rf ${TEMP_DIR}/wasm-compiler - WASM_LLVM_CONFIG=/usr/local/wasm/bin/llvm-config - -fi diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 980466c229ad21453de5559bb824dd291892398f..d0ccf9175c8ca569204250a1f13a122566bd41ae 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -74,13 +74,14 @@ add_test(chain_test chain_test --report_level=detailed) add_test(NAME eosiod_run_test COMMAND tests/eosiod_run_test.py -v --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_test(NAME eosiod_run_remote_test COMMAND tests/eosiod_run_remote_test.py --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_test(NAME p2p_dawn515_test COMMAND tests/p2p_tests/dawn_515/test.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +if(BUILD_MONGO_DB_PLUGIN) + add_test(NAME eosiod_run_test-mongodb COMMAND tests/eosiod_run_test.py --mongodb --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +endif() + # TODO: Tests removed until working again on master. # TODO: add_test(NAME p2p_sync_test COMMAND tests/p2p_tests/sync/test.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) # TODO: add_test(NAME p2p_sync_test_p2_d10 COMMAND tests/p2p_tests/sync/test.sh -p 2 -d 10 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) # TODO: add_test(NAME message_storm COMMAND tests/p2p_tests/sync/test.sh -m -p 21 -n 21 -d 5 -l WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) -# TODO: if(BUILD_MONGO_DB_PLUGIN) -# TODO: add_test(NAME eosiod_run_test-mongodb COMMAND tests/eosiod_run_test.py --mongodb --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) -# TODO: endif() # TODO: add_test(NAME trans_sync_across_mixed_cluster_test COMMAND tests/trans_sync_across_mixed_cluster_test.sh -p 1 -n 2 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) # TODO: add_test(NAME distributed-transactions-test COMMAND tests/distributed-transactions-test.py -p 1 -n 4 --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) # TODO: add_test(NAME distributed-transactions-remote-test COMMAND tests/distributed-transactions-remote-test.py --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) diff --git a/tests/eosiod_run_test.py b/tests/eosiod_run_test.py index 542d01b5bf7afe3b039093f183109246fdc03453..9b92159876515f9f6359ec01c796441d5b19371c 100755 --- a/tests/eosiod_run_test.py +++ b/tests/eosiod_run_test.py @@ -14,10 +14,8 @@ import re ############################################################### Print=testUtils.Utils.Print +errorExit=testUtils.Utils.errorExit -def errorExit(msg="", raw=False, errorCode=1): - Print("ERROR:" if not raw else "", msg) - exit(errorCode) def cmdError(name, code=0, exitNow=False): msg="FAILURE - %s%s" % (name, ("" if code == 0 else (" returned error code %d" % code))) @@ -374,7 +372,8 @@ try: amountVal=int(decimal.Decimal(amountVal.split()[0])*10000) else: typeVal= transaction["name"] - amountVal=transaction["data"]["amount"] + amountVal=transaction["data"]["quantity"] + amountVal=int(decimal.Decimal(amountVal.split()[0])*10000) else: if not enableMongo: typeVal= transaction["transaction"]["messages"][0]["type"] @@ -582,7 +581,7 @@ try: for blockNum in range(1, currentBlockNum+1): block=node.getBlock(blockNum, retry=False) if block is None: - cmdError("% get block" % (ClientName)) + cmdError("%s get block" % (ClientName)) errorExit("mongo get block by num %d" % blockNum) if enableMongo: diff --git a/tests/testUtils.py b/tests/testUtils.py index f8d7f5e31a5f76928493da83f6fd236029925291..4e0eb7c962f77f2e6cf4293d736db5200fb6a64d 100755 --- a/tests/testUtils.py +++ b/tests/testUtils.py @@ -81,6 +81,11 @@ class Utils: return chainSyncStrategies + @staticmethod + def errorExit(msg="", raw=False, errorCode=1): + Utils.Print("ERROR:" if not raw else "", msg) + exit(errorCode) + ########################################################################################### class Table(object): def __init__(self, name): @@ -405,7 +410,7 @@ class Node(object): Utils.Print("Publish eosio.system contract") trans=self.publishContract(eosio.name, wastFile, abiFile, waitForTransBlock=True) if trans is None: - errorExit("Failed to publish oesio.system.") + Utils.errorExit("Failed to publish oesio.system.") Utils.Print("push issue action to eosio contract") contract=eosio.name @@ -511,7 +516,7 @@ class Node(object): for i in range(2): ret=self.getEosAccountFromDb(account.name) if ret is not None: - account_name=ret["account_name"] + account_name=ret["name"] if account_name is None: Utils.Print("ERROR: Failed to verify account creation.", account.name) return None @@ -1112,7 +1117,7 @@ class Cluster(object): cmdArr.append("--plugin eosio::wallet_api_plugin") if self.enableMongo: if Utils.amINoon: - cmdArr.append("--plugin eosio::mongo_db_plugin --mongodb-uri %s" % self.mongoUri) + cmdArr.append("--plugin eosio::mongo_db_plugin --resync --mongodb-uri %s" % self.mongoUri) else: cmdArr.append("--plugin eosio::db_plugin --mongodb-uri %s" % self.mongoUri) @@ -1294,7 +1299,7 @@ class Cluster(object): for account in accounts: Utils.Print("Importing keys for account %s into wallet %s." % (account.name, wallet.name)) if not self.walletMgr.importKey(account, wallet): - errorExit("Failed to import key for account %s" % (account.name)) + Utils.errorExit("Failed to import key for account %s" % (account.name)) return False self.accounts=accounts diff --git a/tests/tests/abi_tests.cpp b/tests/tests/abi_tests.cpp index 1c58e872c1142b7c4639d2e2724363938a49a207..cb16b7178124b0fa1d24b3886f7d0916e76a20eb 100644 --- a/tests/tests/abi_tests.cpp +++ b/tests/tests/abi_tests.cpp @@ -1536,7 +1536,7 @@ BOOST_AUTO_TEST_CASE(abi_cycle) BOOST_AUTO_TEST_CASE(linkauth) { try { - abi_serializer abis(chain_initializer::eos_contract_abi()); + abi_serializer abis(chain_initializer::eos_contract_abi(abi_def())); BOOST_CHECK(true); const char* test_data = R"=====( @@ -1568,7 +1568,7 @@ BOOST_AUTO_TEST_CASE(linkauth) BOOST_AUTO_TEST_CASE(unlinkauth) { try { - abi_serializer abis(chain_initializer::eos_contract_abi()); + abi_serializer abis(chain_initializer::eos_contract_abi(abi_def())); BOOST_CHECK(true); const char* test_data = R"=====( @@ -1597,7 +1597,7 @@ BOOST_AUTO_TEST_CASE(unlinkauth) BOOST_AUTO_TEST_CASE(updateauth) { try { - abi_serializer abis(chain_initializer::eos_contract_abi()); + abi_serializer abis(chain_initializer::eos_contract_abi(abi_def())); BOOST_CHECK(true); const char* test_data = R"=====( @@ -1664,7 +1664,7 @@ BOOST_AUTO_TEST_CASE(updateauth) BOOST_AUTO_TEST_CASE(deleteauth) { try { - abi_serializer abis(chain_initializer::eos_contract_abi()); + abi_serializer abis(chain_initializer::eos_contract_abi(abi_def())); BOOST_CHECK(true); const char* test_data = R"=====( @@ -1690,7 +1690,7 @@ BOOST_AUTO_TEST_CASE(deleteauth) BOOST_AUTO_TEST_CASE(newaccount) { try { - abi_serializer abis(chain_initializer::eos_contract_abi()); + abi_serializer abis(chain_initializer::eos_contract_abi(abi_def())); BOOST_CHECK(true); const char* test_data = R"=====( @@ -1834,7 +1834,7 @@ BOOST_AUTO_TEST_CASE(newaccount) BOOST_AUTO_TEST_CASE(setcode) { try { - abi_serializer abis(chain_initializer::eos_contract_abi()); + abi_serializer abis(chain_initializer::eos_contract_abi(abi_def())); const char* test_data = R"=====( { @@ -1865,7 +1865,7 @@ BOOST_AUTO_TEST_CASE(setcode) BOOST_AUTO_TEST_CASE(setabi) { try { - abi_serializer abis(chain_initializer::eos_contract_abi()); + abi_serializer abis(chain_initializer::eos_contract_abi(abi_def())); const char* test_data = R"=====( { @@ -2028,7 +2028,7 @@ BOOST_AUTO_TEST_CASE(setabi) BOOST_AUTO_TEST_CASE(postrecovery) { try { - abi_serializer abis(chain_initializer::eos_contract_abi()); + abi_serializer abis(chain_initializer::eos_contract_abi(abi_def())); const char* test_data = R"=====( { @@ -2078,7 +2078,7 @@ BOOST_AUTO_TEST_CASE(postrecovery) BOOST_AUTO_TEST_CASE(passrecovery) { try { - abi_serializer abis(chain_initializer::eos_contract_abi()); + abi_serializer abis(chain_initializer::eos_contract_abi(abi_def())); const char* test_data = R"=====( { @@ -2100,7 +2100,7 @@ BOOST_AUTO_TEST_CASE(passrecovery) BOOST_AUTO_TEST_CASE(vetorecovery) { try { - abi_serializer abis(chain_initializer::eos_contract_abi()); + abi_serializer abis(chain_initializer::eos_contract_abi(abi_def())); const char* test_data = R"=====( { diff --git a/tests/wasm_tests/identity_tests.cpp b/tests/wasm_tests/identity_tests.cpp index 9fe4eea59dbf61674dd5a7962f4ca803185a2298..1f1f33f9aa20da5681e620f4e2379003f3ce379d 100644 --- a/tests/wasm_tests/identity_tests.cpp +++ b/tests/wasm_tests/identity_tests.cpp @@ -38,12 +38,12 @@ public: const auto& accnt = control->get_database().get( N(identity) ); abi_def abi; - BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.name, accnt.abi, abi), true); + BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.abi, abi), true); abi_ser.set_abi(abi); const auto& acnt_test = control->get_database().get( N(identitytest) ); abi_def abi_test; - BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.name, acnt_test.abi, abi_test), true); + BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(acnt_test.abi, abi_test), true); abi_ser_test.set_abi(abi_test); const global_property_object &gpo = control->get_global_properties(); diff --git a/tests/wasm_tests/wasm_tests.cpp b/tests/wasm_tests/wasm_tests.cpp index e817411b099b791a35bbd2ad43528b3a175df64e..e84f1da812c6ab43c911b286fa698dcad95cbff0 100644 --- a/tests/wasm_tests/wasm_tests.cpp +++ b/tests/wasm_tests/wasm_tests.cpp @@ -190,7 +190,7 @@ BOOST_FIXTURE_TEST_CASE( abi_from_variant, tester ) try { try { const auto& accnt = this->control->get_database().get( name ); abi_def abi; - if (abi_serializer::to_abi(accnt.name, accnt.abi, abi)) { + if (abi_serializer::to_abi(accnt.abi, abi)) { return abi_serializer(abi); } return optional(); @@ -364,7 +364,7 @@ BOOST_FIXTURE_TEST_CASE( stl_test, tester ) try { const auto& accnt = control->get_database().get( N(stltest) ); abi_def abi; - BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.name, accnt.abi, abi), true); + BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.abi, abi), true); abi_serializer abi_ser(abi); //send message @@ -582,7 +582,7 @@ BOOST_FIXTURE_TEST_CASE(noop, tester) try { set_abi(N(noop), noop_abi); const auto& accnt = control->get_database().get(N(noop)); abi_def abi; - BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.name, accnt.abi, abi), true); + BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.abi, abi), true); abi_serializer abi_ser(abi); { @@ -647,7 +647,7 @@ BOOST_FIXTURE_TEST_CASE(eosio_abi, tester) try { const auto& accnt = control->get_database().get(config::system_account_name); abi_def abi; - BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.name, accnt.abi, abi), true); + BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.abi, abi), true); abi_serializer abi_ser(abi); abi_ser.validate(); @@ -830,5 +830,96 @@ BOOST_FIXTURE_TEST_CASE( check_table_maximum, tester ) try { } FC_LOG_AND_RETHROW() #endif +BOOST_FIXTURE_TEST_CASE( test_db, tester ) try { + produce_blocks(2); + + create_accounts( {N(tester)} ); + produce_block(); + + set_code(N(tester), test_api_wast); + // set_code(N(tester), test_api_abi); + + produce_blocks(1); + + { + signed_transaction trx; + trx.actions.emplace_back(vector{{N(tester), config::active_name}}, + test_api_action {}); + + set_tapos(trx); + trx.sign(get_private_key(N(tester), "active"), chain_id_type()); + push_transaction(trx); + produce_block(); + + BOOST_REQUIRE_EQUAL(true, chain_has_transaction(trx.id())); + } + + { + signed_transaction trx; + trx.actions.emplace_back(vector{{N(tester), config::active_name}}, + test_api_action {}); + + set_tapos(trx); + trx.sign(get_private_key(N(tester), "active"), chain_id_type()); + push_transaction(trx); + produce_block(); + + BOOST_REQUIRE_EQUAL(true, chain_has_transaction(trx.id())); + } + + { + signed_transaction trx; + trx.actions.emplace_back(vector{{N(tester), config::active_name}}, + test_api_action {}); + + set_tapos(trx); + trx.sign(get_private_key(N(tester), "active"), chain_id_type()); + push_transaction(trx); + produce_block(); + + BOOST_REQUIRE_EQUAL(true, chain_has_transaction(trx.id())); + } + + { + signed_transaction trx; + trx.actions.emplace_back(vector{{N(tester), config::active_name}}, + test_api_action {}); + + set_tapos(trx); + trx.sign(get_private_key(N(tester), "active"), chain_id_type()); + push_transaction(trx); + produce_block(); + + BOOST_REQUIRE_EQUAL(true, chain_has_transaction(trx.id())); + } + + { + signed_transaction trx; + trx.actions.emplace_back(vector{{N(tester), config::active_name}}, + test_api_action {}); + + set_tapos(trx); + trx.sign(get_private_key(N(tester), "active"), chain_id_type()); + push_transaction(trx); + produce_block(); + + BOOST_REQUIRE_EQUAL(true, chain_has_transaction(trx.id())); + } + + { + signed_transaction trx; + trx.actions.emplace_back(vector{{N(tester), config::active_name}}, + test_api_action {}); + + set_tapos(trx); + trx.sign(get_private_key(N(tester), "active"), chain_id_type()); + push_transaction(trx); + produce_block(); + + BOOST_REQUIRE_EQUAL(true, chain_has_transaction(trx.id())); + } + +} FC_LOG_AND_RETHROW() /// test_db + BOOST_AUTO_TEST_SUITE_END()