From fb633dcd8712a3a0b16345a5271d78cc9417aa3c Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Wed, 4 Jul 2018 10:20:50 -0400 Subject: [PATCH 01/28] Add setramrate method for gradual increase - this change allows the elected producers to set the ramrate as bytes per block - this will also resync the bancor parameters to current eosio.ram balance plus reduce the volatility of the market maker - added revision field so that future updates to system contract can reference it if necessary. - updated ABI --- eosio.system/abi/eosio.system.abi | 21 ++++++- .../include/eosio.system/eosio.system.hpp | 26 ++++++++- eosio.system/src/delegate_bandwidth.cpp | 5 ++ eosio.system/src/eosio.system.cpp | 57 +++++++++++++++++-- eosio.system/src/producer_pay.cpp | 1 + 5 files changed, 102 insertions(+), 8 deletions(-) diff --git a/eosio.system/abi/eosio.system.abi b/eosio.system/abi/eosio.system.abi index 87937c787..5877b1f13 100644 --- a/eosio.system/abi/eosio.system.abi +++ b/eosio.system/abi/eosio.system.abi @@ -240,7 +240,14 @@ {"name":"max_inline_action_size", "type":"uint32"}, {"name":"max_inline_action_depth", "type":"uint16"}, {"name":"max_authority_depth", "type":"uint16"} - + ] + },{ + "name": "eosio_global_state2", + "fields": [ + {"name":"new_ram_per_block", "type":"uint16"}, + {"name":"last_ram_increase", "type":"block_timestamp"}, + {"name":"last_block_num", "type":"block_timestamp"}, + {"name":"revision", "type":"uint8_t"} ] },{ "name": "eosio_global_state", @@ -294,6 +301,12 @@ "fields": [ {"name":"max_ram_size", "type":"uint64"} ] + },{ + "name": "setramrate", + "base": "", + "fields": [ + {"name":"bytes_per_block", "type":"uint16"} + ] },{ "name": "regproxy", "base": "", @@ -535,6 +548,12 @@ "index_type": "i64", "key_names" : [], "key_types" : [] + },{ + "name": "global2", + "type": "eosio_global_state2", + "index_type": "i64", + "key_names" : [], + "key_types" : [] },{ "name": "voters", "type": "voter_info", diff --git a/eosio.system/include/eosio.system/eosio.system.hpp b/eosio.system/include/eosio.system/eosio.system.hpp index a33238a1e..97c70345a 100644 --- a/eosio.system/include/eosio.system/eosio.system.hpp +++ b/eosio.system/include/eosio.system/eosio.system.hpp @@ -61,6 +61,21 @@ namespace eosiosystem { (last_producer_schedule_size)(total_producer_vote_weight)(last_name_close) ) }; + /** + * Defines new global state parameters added after version 1.0 + */ + struct eosio_global_state2 { + eosio_global_state2(){} + + uint16_t new_ram_per_block = 0; + block_timestamp last_ram_increase; + block_timestamp last_block_num; + uint8_t revision = 0; ///< used to track version updates in the future. + + + EOSLIB_SERIALIZE( eosio_global_state2, (new_ram_per_block)(last_ram_increase)(last_block_num)(revision) ) + }; + struct producer_info { account_name owner; double total_votes = 0; @@ -120,6 +135,7 @@ namespace eosiosystem { > producers_table; typedef eosio::singleton global_state_singleton; + typedef eosio::singleton global_state2_singleton; // static constexpr uint32_t max_inflation_rate = 5; // 5% annual inflation static constexpr uint32_t seconds_per_day = 24 * 3600; @@ -127,11 +143,13 @@ namespace eosiosystem { class system_contract : public native { private: - voters_table _voters; - producers_table _producers; - global_state_singleton _global; + voters_table _voters; + producers_table _producers; + global_state_singleton _global; + global_state2_singleton _global2; eosio_global_state _gstate; + eosio_global_state2 _gstate2; rammarket _rammarket; public: @@ -200,6 +218,7 @@ namespace eosiosystem { void unregprod( const account_name producer ); void setram( uint64_t max_ram_size ); + void setramrate( uint16_t bytes_per_block ); void voteproducer( const account_name voter, const account_name proxy, const std::vector& producers ); @@ -217,6 +236,7 @@ namespace eosiosystem { void bidname( account_name bidder, account_name newname, asset bid ); private: void update_elected_producers( block_timestamp timestamp ); + void update_ram_supply(); // Implementation details: diff --git a/eosio.system/src/delegate_bandwidth.cpp b/eosio.system/src/delegate_bandwidth.cpp index 9678c28e5..2a9ded4ca 100644 --- a/eosio.system/src/delegate_bandwidth.cpp +++ b/eosio.system/src/delegate_bandwidth.cpp @@ -86,6 +86,7 @@ namespace eosiosystem { * This action will buy an exact amount of ram and bill the payer the current market price. */ void system_contract::buyrambytes( account_name payer, account_name receiver, uint32_t bytes ) { + auto itr = _rammarket.find(S(4,RAMCORE)); auto tmp = *itr; auto eosout = tmp.convert( asset(bytes,S(0,RAM)), CORE_SYMBOL ); @@ -105,6 +106,8 @@ namespace eosiosystem { void system_contract::buyram( account_name payer, account_name receiver, asset quant ) { require_auth( payer ); + update_ram_supply(); + eosio_assert( quant.amount > 0, "must purchase a positive amount" ); auto fee = quant; @@ -161,6 +164,8 @@ namespace eosiosystem { */ void system_contract::sellram( account_name account, int64_t bytes ) { require_auth( account ); + update_ram_supply(); + eosio_assert( bytes > 0, "cannot sell negative byte" ); user_resources_table userres( _self, account ); diff --git a/eosio.system/src/eosio.system.cpp b/eosio.system/src/eosio.system.cpp index a38a4a4f2..4d4749843 100644 --- a/eosio.system/src/eosio.system.cpp +++ b/eosio.system/src/eosio.system.cpp @@ -14,10 +14,12 @@ namespace eosiosystem { _voters(_self,_self), _producers(_self,_self), _global(_self,_self), + _global2(_self,_self), _rammarket(_self,_self) { //print( "construct system\n" ); - _gstate = _global.exists() ? _global.get() : get_default_parameters(); + _gstate = _global.exists() ? _global.get() : get_default_parameters(); + _gstate2 = _global2.exists() ? _global2.get() : eosio_global_state2{}; auto itr = _rammarket.find(S(4,RAMCORE)); @@ -46,9 +48,8 @@ namespace eosiosystem { system_contract::~system_contract() { - //print( "destruct system\n" ); _global.set( _gstate, _self ); - //eosio_exit(0); + _global2.set( _gstate2, _self ); } void system_contract::setram( uint64_t max_ram_size ) { @@ -70,7 +71,55 @@ namespace eosiosystem { }); _gstate.max_ram_size = max_ram_size; - _global.set( _gstate, _self ); + } + + void system_contract::update_ram_supply() { + if( _gstate2.last_block_num <= _gstate2.last_ram_increase ) return; + + auto itr = _rammarket.find(S(4,RAMCORE)); + auto new_ram = (_gstate2.last_block_num.slot - _gstate2.last_ram_increase.slot)*_gstate2.new_ram_per_block; + _gstate.max_ram_size += new_ram; + + /** + * Increase or decrease the amount of ram for sale based upon the change in max + * ram size. + */ + _rammarket.modify( itr, 0, [&]( auto& m ) { + m.base.balance.amount += new_ram; + m.base.weight = 500; + m.quote.weight = 500; + }); + _gstate2.last_ram_increase = _gstate2.last_block_num; + } + + /** + * Sets the rate of increase of RAM in bytes per block. It is capped by the uint16_t to + * a maximum rate of 3 TB per year. + * + * If update_ram_supply hasn't been called for the most recent block, then new ram will + * be allocated at the old rate up to the present block before switching the rate. + * + * This method will also resync the bancor connector balances + * and weights to the actual CORE_SYMBOL held in the eosio.ram account. + */ + void system_contract::setramrate( uint16_t bytes_per_block ) { + _gstate2.new_ram_per_block = bytes_per_block; + if( _gstate2.last_ram_increase == block_timestamp() ) { + _gstate2.last_ram_increase = _gstate2.last_block_num; + } else { + update_ram_supply(); + } + + auto itr = _rammarket.find(S(4,RAMCORE)); + + /** + * Resync the connector state with the eosio.ram CORE token balance. + */ + _rammarket.modify( itr, 0, [&]( auto& m ) { + m.quote.balance = eosio::token(N(eosio.token)).get_balance(N(eosio.ram),eosio::symbol_type(system_token_symbol).name()); + m.base.weight = 500; /// use a connector weight of 50% which minimizes volatility + m.quote.weight = 500;/// use a connector weight of 50% which minimizes volatility + }); } void system_contract::setparams( const eosio::blockchain_parameters& params ) { diff --git a/eosio.system/src/producer_pay.cpp b/eosio.system/src/producer_pay.cpp index 5ff9e450d..39fe64efc 100644 --- a/eosio.system/src/producer_pay.cpp +++ b/eosio.system/src/producer_pay.cpp @@ -21,6 +21,7 @@ namespace eosiosystem { using namespace eosio; require_auth(N(eosio)); + _gstate2.last_block_num = timestamp; /** until activated stake crosses this threshold no new rewards are paid */ if( _gstate.total_activated_stake < min_activated_stake ) From 323e4e53b19d062d705fdb6d3789a6b5cb6bf8fd Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Wed, 4 Jul 2018 10:24:47 -0400 Subject: [PATCH 02/28] require auth for setramrate to owner of contract --- eosio.system/src/eosio.system.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eosio.system/src/eosio.system.cpp b/eosio.system/src/eosio.system.cpp index 4d4749843..1e178e8b5 100644 --- a/eosio.system/src/eosio.system.cpp +++ b/eosio.system/src/eosio.system.cpp @@ -103,6 +103,8 @@ namespace eosiosystem { * and weights to the actual CORE_SYMBOL held in the eosio.ram account. */ void system_contract::setramrate( uint16_t bytes_per_block ) { + require_auth( _self ); + _gstate2.new_ram_per_block = bytes_per_block; if( _gstate2.last_ram_increase == block_timestamp() ) { _gstate2.last_ram_increase = _gstate2.last_block_num; From 615eb28a6c5f0c5c59e1e25648621985094d6cb6 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Wed, 4 Jul 2018 10:30:28 -0400 Subject: [PATCH 03/28] add setramrate to abi --- eosio.system/abi/eosio.system.abi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eosio.system/abi/eosio.system.abi b/eosio.system/abi/eosio.system.abi index 5877b1f13..d2f13573d 100644 --- a/eosio.system/abi/eosio.system.abi +++ b/eosio.system/abi/eosio.system.abi @@ -487,6 +487,10 @@ "name": "setram", "type": "setram", "ricardian_contract": "" + },{ + "name": "setramrate", + "type": "setramrate", + "ricardian_contract": "Sets the number of new bytes of ram to create per block and resyncs bancor connector balances and weights to eosio.ram and 50% CRR" },{ "name": "bidname", "type": "bidname", From f1c689bd5dd36d397318bce73a09bb47805569fa Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Thu, 5 Jul 2018 18:57:20 -0400 Subject: [PATCH 04/28] weight change removed --- eosio.system/abi/eosio.system.abi | 6 +++--- eosio.system/src/eosio.system.cpp | 13 ------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/eosio.system/abi/eosio.system.abi b/eosio.system/abi/eosio.system.abi index d2f13573d..f831ea289 100644 --- a/eosio.system/abi/eosio.system.abi +++ b/eosio.system/abi/eosio.system.abi @@ -245,9 +245,9 @@ "name": "eosio_global_state2", "fields": [ {"name":"new_ram_per_block", "type":"uint16"}, - {"name":"last_ram_increase", "type":"block_timestamp"}, - {"name":"last_block_num", "type":"block_timestamp"}, - {"name":"revision", "type":"uint8_t"} + {"name":"last_ram_increase", "type":"block_timestamp_type"}, + {"name":"last_block_num", "type":"block_timestamp_type"}, + {"name":"revision", "type":"uint8"} ] },{ "name": "eosio_global_state", diff --git a/eosio.system/src/eosio.system.cpp b/eosio.system/src/eosio.system.cpp index 1e178e8b5..f34117b5c 100644 --- a/eosio.system/src/eosio.system.cpp +++ b/eosio.system/src/eosio.system.cpp @@ -86,8 +86,6 @@ namespace eosiosystem { */ _rammarket.modify( itr, 0, [&]( auto& m ) { m.base.balance.amount += new_ram; - m.base.weight = 500; - m.quote.weight = 500; }); _gstate2.last_ram_increase = _gstate2.last_block_num; } @@ -111,17 +109,6 @@ namespace eosiosystem { } else { update_ram_supply(); } - - auto itr = _rammarket.find(S(4,RAMCORE)); - - /** - * Resync the connector state with the eosio.ram CORE token balance. - */ - _rammarket.modify( itr, 0, [&]( auto& m ) { - m.quote.balance = eosio::token(N(eosio.token)).get_balance(N(eosio.ram),eosio::symbol_type(system_token_symbol).name()); - m.base.weight = 500; /// use a connector weight of 50% which minimizes volatility - m.quote.weight = 500;/// use a connector weight of 50% which minimizes volatility - }); } void system_contract::setparams( const eosio::blockchain_parameters& params ) { From 1dfbbe0c29ffa8b6d87a1174fb98514ff8721f6e Mon Sep 17 00:00:00 2001 From: Bucky Kittinger Date: Thu, 5 Jul 2018 21:11:29 -0400 Subject: [PATCH 05/28] New changes --- UnitTestsExternalProject.txt | 15 +++++++ build.sh | 81 ----------------------------------- eosio.msig/CMakeLists.txt | 8 ++++ eosio.sudo/CMakeLists.txt | 8 ++++ eosio.system/CMakeLists.txt | 8 ++++ eosio.token/CMakeLists.txt | 8 ++++ tests/CMakeLists.txt | 2 +- tests/contracts.hpp | 25 +++++++++++ tests/contracts.hpp.in | 24 +++++------ tests/eosio.system_tester.hpp | 2 + 10 files changed, 87 insertions(+), 94 deletions(-) create mode 100644 UnitTestsExternalProject.txt delete mode 100755 build.sh create mode 100644 eosio.msig/CMakeLists.txt create mode 100644 eosio.sudo/CMakeLists.txt create mode 100644 eosio.system/CMakeLists.txt create mode 100644 eosio.token/CMakeLists.txt create mode 100644 tests/contracts.hpp diff --git a/UnitTestsExternalProject.txt b/UnitTestsExternalProject.txt new file mode 100644 index 000000000..5efbdc644 --- /dev/null +++ b/UnitTestsExternalProject.txt @@ -0,0 +1,15 @@ +include(ExternalProject) +find_package(Git REQUIRED) +include(GNUInstallDirs) + +ExternalProject_Add( + contracts_unit_tests + UPDATE_COMMAND "" + PATCH_COMMAND "" + CMAKE_ARGS -DROOT_DIR=${CMAKE_SOURCE_DIR} -DEOSIO_INSTALL_PREFIX=${WASM_ROOT}/eosio -DOPENSSL_INSTALL_PREFIX=${OPENSSL_ROOT} -DSECP256K1_INSTALL_LIB=${SECP256K1_ROOT} -DBOOST_ROOT=${Boost_INCLUDE_DIRS}/../ + + SOURCE_DIR ${CMAKE_SOURCE_DIR}/tests + BINARY_DIR ${CMAKE_SOURCE_DIR} + TEST_COMMAND "" + INSTALL_COMMAND "" +) diff --git a/build.sh b/build.sh deleted file mode 100755 index 7fec92e42..000000000 --- a/build.sh +++ /dev/null @@ -1,81 +0,0 @@ -#! /bin/bash - -contracts=( "eosio.token" - "eosio.system" - "eosio.msig" - "eosio.sudo" ) - -unamestr=`uname` -if [[ "${unamestr}" == 'Darwin' ]]; then - PREFIX=/usr/local - BOOST=/usr/local/include - OPENSSL=/usr/local/opt/openssl -else - PREFIX=~/opt - BOOST=~/opt/boost/include - OPENSSL=/usr/include/openssl - OS_NAME=$( cat /etc/os-release | grep ^NAME | cut -d'=' -f2 | sed 's/\"//gI' ) - - case "$OS_NAME" in - "Amazon Linux AMI") - CXX_COMPILER=g++ - C_COMPILER=gcc - ;; - "CentOS Linux") - CXX_COMPILER=g++ - C_COMPILER=gcc - ;; - "elementary OS") - CXX_COMPILER=clang++-4.0 - C_COMPILER=clang-4.0 - ;; - "Fedora") - CXX_COMPILER=g++ - C_COMPILER=gcc - ;; - "Linux Mint") - CXX_COMPILER=clang++-4.0 - C_COMPILER=clang-4.0 - ;; - "Ubuntu") - CXX_COMPILER=clang++-4.0 - C_COMPILER=clang-4.0 - ;; - *) - printf "\\n\\tUnsupported Linux Distribution. Exiting now.\\n\\n" - exit 1 - esac -fi - -EOSIO_PREFIX=/usr/local/eosio - -export BOOST=${BOOST} -export PREFIX=${PREFIX} -export INSTALL_PREFIX=/usr/local/eosio - -### Build all the contracts - -for contract in "${contracts[@]}"; do - pushd ${contract} &> /dev/null - echo "Building ${contract}..." - CONTRACT_NAME="${contract}" - ./build.sh - popd &> /dev/null -done - - -if [ "$1" == "notests" ]; then - exit 0 -fi - -### Build the unit tests -root_dir=`pwd` -pushd tests &> /dev/null -mkdir -p build -pushd build &> /dev/null -cmake -DCMAKE_CXX_COMPILER="${CXX_COMPILER}" -DROOT_DIR="${root_dir}" -DEOSIO_INSTALL_PREFIX="${EOSIO_PREFIX}" -DOPENSSL_INSTALL_PREFIX="${OPENSSL}" -DSECP256K1_INSTALL_LIB="${EOSIO_PREFIX}" -DBOOST_ROOT="${BOOST}" ../ -make -j8 -cp unit_test ../../ -popd &> /dev/null -rm -r build -popd &> /dev/null diff --git a/eosio.msig/CMakeLists.txt b/eosio.msig/CMakeLists.txt new file mode 100644 index 000000000..9fc45cbc5 --- /dev/null +++ b/eosio.msig/CMakeLists.txt @@ -0,0 +1,8 @@ +add_executable(eosio.msig.wasm ${CMAKE_CURRENT_SOURCE_DIR}/src/eosio.msig.cpp) +target_include_directories(eosio.msig.wasm + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/include) +#install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${WASM_ROOT}/eosio.wasmsdk/include) +install(TARGETS eosio.msig.wasm + RUNTIME DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/abi/eosio.msig.abi DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin) diff --git a/eosio.sudo/CMakeLists.txt b/eosio.sudo/CMakeLists.txt new file mode 100644 index 000000000..b7a9bf158 --- /dev/null +++ b/eosio.sudo/CMakeLists.txt @@ -0,0 +1,8 @@ +add_executable(eosio.sudo.wasm ${CMAKE_CURRENT_SOURCE_DIR}/src/eosio.sudo.cpp) +target_include_directories(eosio.sudo.wasm + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/include) +#install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${WASM_ROOT}/eosio.wasmsdk/include) +install(TARGETS eosio.sudo.wasm + RUNTIME DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/abi/eosio.sudo.abi DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin) diff --git a/eosio.system/CMakeLists.txt b/eosio.system/CMakeLists.txt new file mode 100644 index 000000000..6d84c7670 --- /dev/null +++ b/eosio.system/CMakeLists.txt @@ -0,0 +1,8 @@ +add_executable(eosio.system.wasm ${CMAKE_CURRENT_SOURCE_DIR}/src/eosio.system.cpp) +target_include_directories(eosio.system.wasm + PUBLIC + ${CMAKE_SOURCE_DIR}/include) +#install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${WASM_ROOT}/eosio.wasmsdk/include) +install(TARGETS eosio.system.wasm + RUNTIME DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/abi/eosio.system.abi DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin) diff --git a/eosio.token/CMakeLists.txt b/eosio.token/CMakeLists.txt new file mode 100644 index 000000000..a116f7481 --- /dev/null +++ b/eosio.token/CMakeLists.txt @@ -0,0 +1,8 @@ +add_executable(eosio.token.wasm ${CMAKE_CURRENT_SOURCE_DIR}/src/eosio.token.cpp) +target_include_directories(eosio.token.wasm + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/include) +#install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${WASM_ROOT}/eosio.wasmsdk/include) +install(TARGETS eosio.token.wasm + RUNTIME DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/abi/eosio.token.abi DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a12561023..80e6a4139 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required( VERSION 3.5 ) project( EOSIO_CONTRACTS_TESTS ) set( VERSION_MAJOR 1 ) set( VERSION_MINOR 0 ) -set( VERSION_PATCH 6 ) +set( VERSION_PATCH 0 ) enable_testing() diff --git a/tests/contracts.hpp b/tests/contracts.hpp new file mode 100644 index 000000000..ef9cb14d9 --- /dev/null +++ b/tests/contracts.hpp @@ -0,0 +1,25 @@ +#pragma once +#include + +namespace eosio { namespace testing { + +struct contracts { + static std::vector system_wasm() { return read_wasm("/Users/judgefudge/eosio.contracts/eosio.system/bin/eosio.system.wasm"); } + static std::string system_wast() { return read_wast("/Users/judgefudge/eosio.contracts/eosio.system/bin/eosio.system.wast"); } + static std::vector system_abi() { return read_abi("/Users/judgefudge/eosio.contracts/eosio.system/bin/eosio.system.abi"); } + static std::vector token_wasm() { return read_wasm("/Users/judgefudge/eosio.contracts/eosio.token/bin/eosio.token.wasm"); } + static std::string token_wast() { return read_wast("/Users/judgefudge/eosio.contracts/eosio.token/bin/eosio.token.wast"); } + static std::vector token_abi() { return read_abi("/Users/judgefudge/eosio.contracts/eosio.token/bin/eosio.token.abi"); } + static std::vector msig_wasm() { return read_wasm("/Users/judgefudge/eosio.contracts/eosio.msig/bin/eosio.msig.wasm"); } + static std::string msig_wast() { return read_wast("/Users/judgefudge/eosio.contracts/eosio.msig/bin/eosio.msig.wast"); } + static std::vector msig_abi() { return read_abi("/Users/judgefudge/eosio.contracts/eosio.msig/bin/eosio.msig.abi"); } + static std::vector sudo_wasm() { return read_wasm("/Users/judgefudge/eosio.contracts/eosio.sudo/bin/eosio.sudo.wasm"); } + static std::string sudo_wast() { return read_wast("/Users/judgefudge/eosio.contracts/eosio.sudo/bin/eosio.sudo.wast"); } + static std::vector sudo_abi() { return read_abi("/Users/judgefudge/eosio.contracts/eosio.sudo/bin/eosio.sudo.abi"); } + + struct util { + static std::vector test_api_wasm() { return read_wasm("/Users/judgefudge/eosio.contracts/tests/test_contracts/test_api.wasm"); } + static std::vector exchange_wasm() { return read_wasm("/Users/judgefudge/eosio.contracts/tests/test_contracts/exchange.wasm"); } + }; +}; +}} //ns eosio::testing diff --git a/tests/contracts.hpp.in b/tests/contracts.hpp.in index 1d91f506e..935565234 100644 --- a/tests/contracts.hpp.in +++ b/tests/contracts.hpp.in @@ -4,18 +4,18 @@ namespace eosio { namespace testing { struct contracts { - static std::vector system_wasm() { return read_wasm("${ROOT_DIR}/eosio.system/bin/eosio.system/eosio.system.wasm"); } - static std::string system_wast() { return read_wast("${ROOT_DIR}/eosio.system/bin/eosio.system/eosio.system.wast"); } - static std::vector system_abi() { return read_abi("${ROOT_DIR}/eosio.system/bin/eosio.system/eosio.system.abi"); } - static std::vector token_wasm() { return read_wasm("${ROOT_DIR}/eosio.token/bin/eosio.token/eosio.token.wasm"); } - static std::string token_wast() { return read_wast("${ROOT_DIR}/eosio.token/bin/eosio.token/eosio.token.wast"); } - static std::vector token_abi() { return read_abi("${ROOT_DIR}/eosio.token/bin/eosio.token/eosio.token.abi"); } - static std::vector msig_wasm() { return read_wasm("${ROOT_DIR}/eosio.msig/bin/eosio.msig/eosio.msig.wasm"); } - static std::string msig_wast() { return read_wast("${ROOT_DIR}/eosio.msig/bin/eosio.msig/eosio.msig.wast"); } - static std::vector msig_abi() { return read_abi("${ROOT_DIR}/eosio.msig/bin/eosio.msig/eosio.msig.abi"); } - static std::vector sudo_wasm() { return read_wasm("${ROOT_DIR}/eosio.sudo/bin/eosio.sudo/eosio.sudo.wasm"); } - static std::string sudo_wast() { return read_wast("${ROOT_DIR}/eosio.sudo/bin/eosio.sudo/eosio.sudo.wast"); } - static std::vector sudo_abi() { return read_abi("${ROOT_DIR}/eosio.sudo/bin/eosio.sudo/eosio.sudo.abi"); } + static std::vector system_wasm() { return read_wasm("${ROOT_DIR}/eosio.system/bin/eosio.system.wasm"); } + static std::string system_wast() { return read_wast("${ROOT_DIR}/eosio.system/bin/eosio.system.wast"); } + static std::vector system_abi() { return read_abi("${ROOT_DIR}/eosio.system/bin/eosio.system.abi"); } + static std::vector token_wasm() { return read_wasm("${ROOT_DIR}/eosio.token/bin/eosio.token.wasm"); } + static std::string token_wast() { return read_wast("${ROOT_DIR}/eosio.token/bin/eosio.token.wast"); } + static std::vector token_abi() { return read_abi("${ROOT_DIR}/eosio.token/bin/eosio.token.abi"); } + static std::vector msig_wasm() { return read_wasm("${ROOT_DIR}/eosio.msig/bin/eosio.msig.wasm"); } + static std::string msig_wast() { return read_wast("${ROOT_DIR}/eosio.msig/bin/eosio.msig.wast"); } + static std::vector msig_abi() { return read_abi("${ROOT_DIR}/eosio.msig/bin/eosio.msig.abi"); } + static std::vector sudo_wasm() { return read_wasm("${ROOT_DIR}/eosio.sudo/bin/eosio.sudo.wasm"); } + static std::string sudo_wast() { return read_wast("${ROOT_DIR}/eosio.sudo/bin/eosio.sudo.wast"); } + static std::vector sudo_abi() { return read_abi("${ROOT_DIR}/eosio.sudo/bin/eosio.sudo.abi"); } struct util { static std::vector test_api_wasm() { return read_wasm("${CMAKE_SOURCE_DIR}/test_contracts/test_api.wasm"); } diff --git a/tests/eosio.system_tester.hpp b/tests/eosio.system_tester.hpp index ff90f8d3d..cedf3b398 100644 --- a/tests/eosio.system_tester.hpp +++ b/tests/eosio.system_tester.hpp @@ -4,6 +4,8 @@ */ #pragma once +#define CORE_SYMBOL_NAME "EOS" + #include #include #include "contracts.hpp" From bf5e7795dfe6ddf7d47cb2c0372be9fec1c0a975 Mon Sep 17 00:00:00 2001 From: Bucky Kittinger Date: Thu, 5 Jul 2018 21:24:06 -0400 Subject: [PATCH 06/28] Using eosio.wasmsdk --- CMakeLists.txt | 24 ++++++++++++++++++++++++ UnitTestsExternalProject.txt | 2 +- tests/eosio.system_tester.hpp | 2 -- 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..62558d474 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.5) +project(eosio_contracts VERSION 1.0.0) + +# if no wasm root is given use default path +if(WASM_ROOT STREQUAL "" OR NOT WASM_ROOT) + set(WASM_ROOT ${CMAKE_INSTALL_PREFIX}) +endif() + +list(APPEND CMAKE_MODULE_PATH ${WASM_ROOT}/lib/cmake) +include(EosioWasmToolchain) + +add_subdirectory(eosio.msig) +add_subdirectory(eosio.sudo) +add_subdirectory(eosio.system) +add_subdirectory(eosio.token) + +if (APPLE) + set(OPENSSL_ROOT "/usr/local/opt/openssl") +elseif (UNIX) + set(OPENSSL_ROOT "/usr/include/openssl") +endif() +set(SECP256K1_ROOT "/usr/local") + +include(UnitTestsExternalProject.txt) diff --git a/UnitTestsExternalProject.txt b/UnitTestsExternalProject.txt index 5efbdc644..197411453 100644 --- a/UnitTestsExternalProject.txt +++ b/UnitTestsExternalProject.txt @@ -9,7 +9,7 @@ ExternalProject_Add( CMAKE_ARGS -DROOT_DIR=${CMAKE_SOURCE_DIR} -DEOSIO_INSTALL_PREFIX=${WASM_ROOT}/eosio -DOPENSSL_INSTALL_PREFIX=${OPENSSL_ROOT} -DSECP256K1_INSTALL_LIB=${SECP256K1_ROOT} -DBOOST_ROOT=${Boost_INCLUDE_DIRS}/../ SOURCE_DIR ${CMAKE_SOURCE_DIR}/tests - BINARY_DIR ${CMAKE_SOURCE_DIR} + BINARY_DIR ${CMAKE_SOURCE_DIR}/build/tests TEST_COMMAND "" INSTALL_COMMAND "" ) diff --git a/tests/eosio.system_tester.hpp b/tests/eosio.system_tester.hpp index cedf3b398..ff90f8d3d 100644 --- a/tests/eosio.system_tester.hpp +++ b/tests/eosio.system_tester.hpp @@ -4,8 +4,6 @@ */ #pragma once -#define CORE_SYMBOL_NAME "EOS" - #include #include #include "contracts.hpp" From a8d404b138e041995149e01a149b2aee372583a4 Mon Sep 17 00:00:00 2001 From: Khaled Al-Hassanieh Date: Fri, 6 Jul 2018 11:02:24 -0400 Subject: [PATCH 07/28] Added reserved field to eosio_global_state2 to be used later --- eosio.system/abi/eosio.system.abi | 1 + eosio.system/include/eosio.system/eosio.system.hpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/eosio.system/abi/eosio.system.abi b/eosio.system/abi/eosio.system.abi index f831ea289..ccbd1c3e3 100644 --- a/eosio.system/abi/eosio.system.abi +++ b/eosio.system/abi/eosio.system.abi @@ -247,6 +247,7 @@ {"name":"new_ram_per_block", "type":"uint16"}, {"name":"last_ram_increase", "type":"block_timestamp_type"}, {"name":"last_block_num", "type":"block_timestamp_type"}, + {"name":"reserved", "type":"float64"}, {"name":"revision", "type":"uint8"} ] },{ diff --git a/eosio.system/include/eosio.system/eosio.system.hpp b/eosio.system/include/eosio.system/eosio.system.hpp index 97c70345a..276a61e71 100644 --- a/eosio.system/include/eosio.system/eosio.system.hpp +++ b/eosio.system/include/eosio.system/eosio.system.hpp @@ -70,10 +70,11 @@ namespace eosiosystem { uint16_t new_ram_per_block = 0; block_timestamp last_ram_increase; block_timestamp last_block_num; + double reserved = 0; uint8_t revision = 0; ///< used to track version updates in the future. - EOSLIB_SERIALIZE( eosio_global_state2, (new_ram_per_block)(last_ram_increase)(last_block_num)(revision) ) + EOSLIB_SERIALIZE( eosio_global_state2, (new_ram_per_block)(last_ram_increase)(last_block_num)(reserved)(revision) ) }; struct producer_info { From 6db6e867a7a6722bdec69de132a7c6fd0c3d4fd0 Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Fri, 6 Jul 2018 15:47:54 -0400 Subject: [PATCH 08/28] eosio.ram payment problem --- eosio.token/abi/eosio.token.abi | 7 ++++ .../include/eosio.token/eosio.token.hpp | 5 ++- eosio.token/src/eosio.token.cpp | 22 ++++++----- tests/eosio.token_tests.cpp | 38 +++++++++++++++++++ 4 files changed, 61 insertions(+), 11 deletions(-) diff --git a/eosio.token/abi/eosio.token.abi b/eosio.token/abi/eosio.token.abi index d769deb33..35926470c 100644 --- a/eosio.token/abi/eosio.token.abi +++ b/eosio.token/abi/eosio.token.abi @@ -28,6 +28,13 @@ {"name":"quantity", "type":"asset"}, {"name":"memo", "type":"string"} ] + },{ + "name": "close", + "base": "", + "fields": [ + {"name":"owner", "type":"account_name"}, + {"name":"symbol", "type":"symbol"}, + ] },{ "name": "account", "base": "", diff --git a/eosio.token/include/eosio.token/eosio.token.hpp b/eosio.token/include/eosio.token/eosio.token.hpp index 158751347..1ab0ffa19 100644 --- a/eosio.token/include/eosio.token/eosio.token.hpp +++ b/eosio.token/include/eosio.token/eosio.token.hpp @@ -30,8 +30,9 @@ namespace eosio { account_name to, asset quantity, string memo ); - - + + void close( account_name owner, symbol_name symbol ); + inline asset get_supply( symbol_name sym )const; inline asset get_balance( account_name owner, symbol_name sym )const; diff --git a/eosio.token/src/eosio.token.cpp b/eosio.token/src/eosio.token.cpp index d85c23620..8abb8c85f 100644 --- a/eosio.token/src/eosio.token.cpp +++ b/eosio.token/src/eosio.token.cpp @@ -79,9 +79,10 @@ void token::transfer( account_name from, eosio_assert( quantity.symbol == st.supply.symbol, "symbol precision mismatch" ); eosio_assert( memo.size() <= 256, "memo has more than 256 bytes" ); + auto payer = has_auth( to ) ? to : from; sub_balance( from, quantity ); - add_balance( to, quantity, from ); + add_balance( to, quantity, payer ); } void token::sub_balance( account_name owner, asset value ) { @@ -90,14 +91,9 @@ void token::sub_balance( account_name owner, asset value ) { const auto& from = from_acnts.get( value.symbol.name(), "no balance object found" ); eosio_assert( from.balance.amount >= value.amount, "overdrawn balance" ); - - if( from.balance.amount == value.amount ) { - from_acnts.erase( from ); - } else { - from_acnts.modify( from, owner, [&]( auto& a ) { - a.balance -= value; + from_acnts.modify( from, owner, [&]( auto& a ) { + a.balance -= value; }); - } } void token::add_balance( account_name owner, asset value, account_name ram_payer ) @@ -115,6 +111,14 @@ void token::add_balance( account_name owner, asset value, account_name ram_payer } } +void token::close( account_name owner, symbol_name symbol ) { + accounts acnts( _self, owner ); + auto it = acnts.find( symbol ); + eosio_assert( it != acnts.end(), "Balance row already deleted or never existed. Action won't have any effect." ); + eosio_assert( it->balance.amount == 0, "Cannot close because the balance is not zero." ); + acnts.erase( it ); +} + } /// namespace eosio -EOSIO_ABI( eosio::token, (create)(issue)(transfer) ) +EOSIO_ABI( eosio::token, (create)(issue)(transfer)(close) ) diff --git a/tests/eosio.token_tests.cpp b/tests/eosio.token_tests.cpp index 0fcc7b62d..a73e47eba 100644 --- a/tests/eosio.token_tests.cpp +++ b/tests/eosio.token_tests.cpp @@ -92,6 +92,16 @@ class eosio_token_tester : public tester { ); } + action_result close( account_name owner, + const string& symbolname ) { + auto symb = eosio::chain::symbol::from_string(symbolname); + auto symbol_code = symb.to_symbol_code().value; + return push_action( owner, N(close), mvo() + ( "owner", owner ) + ( "symbol", symbol_code.to_string() ) + ); + } + abi_serializer abi_ser; }; @@ -263,4 +273,32 @@ BOOST_FIXTURE_TEST_CASE( transfer_tests, eosio_token_tester ) try { } FC_LOG_AND_RETHROW() + +BOOST_FIXTURE_TEST_CASE( close_tests, eosio_token_tester ) try { + + auto token = create( N(alice), asset::from_string("1000 CERO")); + + auto alice_balance = get_account(N(alice), "0,CERO"); + BOOST_REQUIRE_EQUAL(true, alice_balance.is_null() ); + + BOOST_REQUIRE_EQUAL( success(), issue( N(alice), N(alice), asset::from_string("1000 CERO"), "hola" ) ); + + alice_balance = get_account(N(alice), "0,CERO"); + REQUIRE_MATCHING_OBJECT( alice_balance, mvo() + ("balance", "1000 CERO") + ); + + BOOST_REQUIRE_EQUAL( success(), transfer( N(alice), N(bob), asset::from_string("1000 CERO"), "hola" ) ); + + alice_balance = get_account(N(alice), "0,CERO"); + REQUIRE_MATCHING_OBJECT( alice_balance, mvo() + ("balance", "0 CERO") + ); + + BOOST_REQUIRE_EQUAL( success(), close( N(alice), "0,CERO" ) ); + alice_balance = get_account(N(alice), "0,CERO"); + BOOST_REQUIRE_EQUAL(true, alice_balance.is_null() ); + +} FC_LOG_AND_RETHROW() + BOOST_AUTO_TEST_SUITE_END() From cdd0827ac0b4f82cba06a4c9b7ec0c960c4beb9b Mon Sep 17 00:00:00 2001 From: Bucky Kittinger Date: Fri, 6 Jul 2018 15:49:37 -0400 Subject: [PATCH 09/28] Fixed some build location problems --- UnitTestsExternalProject.txt | 3 +- eosio.msig/CMakeLists.txt | 10 +- eosio.msig/bin/eosio.msig/eosio.msig.abi | 152 +++++ eosio.sudo/CMakeLists.txt | 9 +- eosio.sudo/bin/eosio.sudo/eosio.sudo.abi | 73 +++ eosio.system/CMakeLists.txt | 10 +- .../bin/eosio.system/eosio.system.abi | 578 ++++++++++++++++++ eosio.token/CMakeLists.txt | 9 +- eosio.token/bin/eosio.token/eosio.token.abi | 78 +++ tests/contracts.hpp | 25 - tests/contracts.hpp.in | 24 +- tests/eosio.system_tests.cpp | 4 +- 12 files changed, 922 insertions(+), 53 deletions(-) create mode 100644 eosio.msig/bin/eosio.msig/eosio.msig.abi create mode 100644 eosio.sudo/bin/eosio.sudo/eosio.sudo.abi create mode 100644 eosio.system/bin/eosio.system/eosio.system.abi create mode 100644 eosio.token/bin/eosio.token/eosio.token.abi delete mode 100644 tests/contracts.hpp diff --git a/UnitTestsExternalProject.txt b/UnitTestsExternalProject.txt index 197411453..f05d9ec28 100644 --- a/UnitTestsExternalProject.txt +++ b/UnitTestsExternalProject.txt @@ -4,12 +4,11 @@ include(GNUInstallDirs) ExternalProject_Add( contracts_unit_tests - UPDATE_COMMAND "" - PATCH_COMMAND "" CMAKE_ARGS -DROOT_DIR=${CMAKE_SOURCE_DIR} -DEOSIO_INSTALL_PREFIX=${WASM_ROOT}/eosio -DOPENSSL_INSTALL_PREFIX=${OPENSSL_ROOT} -DSECP256K1_INSTALL_LIB=${SECP256K1_ROOT} -DBOOST_ROOT=${Boost_INCLUDE_DIRS}/../ SOURCE_DIR ${CMAKE_SOURCE_DIR}/tests BINARY_DIR ${CMAKE_SOURCE_DIR}/build/tests + BUILD_ALWAYS 1 TEST_COMMAND "" INSTALL_COMMAND "" ) diff --git a/eosio.msig/CMakeLists.txt b/eosio.msig/CMakeLists.txt index 9fc45cbc5..c5dd83e7e 100644 --- a/eosio.msig/CMakeLists.txt +++ b/eosio.msig/CMakeLists.txt @@ -1,8 +1,12 @@ +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/abi/eosio.msig.abi" "${CMAKE_CURRENT_SOURCE_DIR}/bin/eosio.msig" COPYONLY) + add_executable(eosio.msig.wasm ${CMAKE_CURRENT_SOURCE_DIR}/src/eosio.msig.cpp) target_include_directories(eosio.msig.wasm PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) + +set_target_properties(eosio.msig.wasm + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin/eosio.msig") + #install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${WASM_ROOT}/eosio.wasmsdk/include) -install(TARGETS eosio.msig.wasm - RUNTIME DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/abi/eosio.msig.abi DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin) diff --git a/eosio.msig/bin/eosio.msig/eosio.msig.abi b/eosio.msig/bin/eosio.msig/eosio.msig.abi new file mode 100644 index 000000000..9fcf8a957 --- /dev/null +++ b/eosio.msig/bin/eosio.msig/eosio.msig.abi @@ -0,0 +1,152 @@ +{ + "version": "eosio::abi/1.0", + "types": [{ + "new_type_name": "account_name", + "type": "name" + },{ + "new_type_name": "permission_name", + "type": "name" + },{ + "new_type_name": "action_name", + "type": "name" + }], + "structs": [{ + "name": "permission_level", + "base": "", + "fields": [ + {"name": "actor", "type": "account_name"}, + {"name": "permission", "type": "permission_name"} + ] + },{ + "name": "action", + "base": "", + "fields": [ + {"name": "account", "type": "account_name"}, + {"name": "name", "type": "action_name"}, + {"name": "authorization", "type": "permission_level[]"}, + {"name": "data", "type": "bytes"} + ] + },{ + "name": "transaction_header", + "base": "", + "fields": [ + {"name": "expiration", "type": "time_point_sec"}, + {"name": "ref_block_num", "type": "uint16"}, + {"name": "ref_block_prefix", "type": "uint32"}, + {"name": "max_net_usage_words", "type": "varuint32"}, + {"name": "max_cpu_usage_ms", "type": "uint8"}, + {"name": "delay_sec", "type": "varuint32"} + ] + },{ + "name": "extension", + "base": "", + "fields": [ + {"name": "type", "type" : "uint16" }, + {"name": "data", "type": "bytes"} + ] + },{ + "name": "transaction", + "base": "transaction_header", + "fields": [ + {"name": "context_free_actions", "type": "action[]"}, + {"name": "actions", "type": "action[]"}, + {"name": "transaction_extensions", "type": "extension[]"} + ] + },{ + "name": "propose", + "base": "", + "fields": [ + {"name":"proposer", "type":"account_name"}, + {"name":"proposal_name", "type":"name"}, + {"name":"requested", "type":"permission_level[]"}, + {"name":"trx", "type":"transaction"} + ] + },{ + "name": "approve", + "base": "", + "fields": [ + {"name":"proposer", "type":"account_name"}, + {"name":"proposal_name", "type":"name"}, + {"name":"level", "type":"permission_level"} + ] + },{ + "name": "unapprove", + "base": "", + "fields": [ + {"name":"proposer", "type":"account_name"}, + {"name":"proposal_name", "type":"name"}, + {"name":"level", "type":"permission_level"} + ] + },{ + "name": "cancel", + "base": "", + "fields": [ + {"name":"proposer", "type":"account_name"}, + {"name":"proposal_name", "type":"name"}, + {"name":"canceler", "type":"account_name"} + ] + },{ + "name": "exec", + "base": "", + "fields": [ + {"name":"proposer", "type":"account_name"}, + {"name":"proposal_name", "type":"name"}, + {"name":"executer", "type":"account_name"} + ] + },{ + "name": "proposal", + "base": "", + "fields": [ + {"name": "proposal_name", "type": "name"}, + {"name": "packed_transaction", "type": "bytes"} + ] + },{ + "name": "approvals_info", + "base": "", + "fields": [ + {"name": "proposal_name", "type": "name"}, + {"name": "requested_approvals", "type": "permission_level[]"}, + {"name": "provided_approvals", "type": "permission_level[]"} + ] + } + ], + "actions": [{ + "name": "propose", + "type": "propose", + "ricardian_contract": "" + },{ + "name": "approve", + "type": "approve", + "ricardian_contract": "" + },{ + "name": "unapprove", + "type": "unapprove", + "ricardian_contract": "" + }, { + "name": "cancel", + "type": "cancel", + "ricardian_contract": "" + }, { + "name": "exec", + "type": "exec", + "ricardian_contract": "" + } + + ], + "tables": [{ + "name": "proposal", + "type": "proposal", + "index_type": "i64", + "key_names" : ["proposal_name"], + "key_types" : ["name"] + },{ + "name": "approvals", + "type": "approvals_info", + "index_type": "i64", + "key_names" : ["proposal_name"], + "key_types" : ["name"] + } + ], + "ricardian_clauses": [], + "abi_extensions": [] +} diff --git a/eosio.sudo/CMakeLists.txt b/eosio.sudo/CMakeLists.txt index b7a9bf158..f38dae570 100644 --- a/eosio.sudo/CMakeLists.txt +++ b/eosio.sudo/CMakeLists.txt @@ -2,7 +2,10 @@ add_executable(eosio.sudo.wasm ${CMAKE_CURRENT_SOURCE_DIR}/src/eosio.sudo.cpp) target_include_directories(eosio.sudo.wasm PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) + +set_target_properties(eosio.sudo.wasm + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin/eosio.sudo") + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/abi/eosio.sudo.abi" "${CMAKE_CURRENT_SOURCE_DIR}/bin/eosio.sudo" COPYONLY) #install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${WASM_ROOT}/eosio.wasmsdk/include) -install(TARGETS eosio.sudo.wasm - RUNTIME DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/abi/eosio.sudo.abi DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin) diff --git a/eosio.sudo/bin/eosio.sudo/eosio.sudo.abi b/eosio.sudo/bin/eosio.sudo/eosio.sudo.abi new file mode 100644 index 000000000..6f74921bc --- /dev/null +++ b/eosio.sudo/bin/eosio.sudo/eosio.sudo.abi @@ -0,0 +1,73 @@ +{ + "version": "eosio::abi/1.0", + "types": [{ + "new_type_name": "account_name", + "type": "name" + },{ + "new_type_name": "permission_name", + "type": "name" + },{ + "new_type_name": "action_name", + "type": "name" + }], + "structs": [{ + "name": "permission_level", + "base": "", + "fields": [ + {"name": "actor", "type": "account_name"}, + {"name": "permission", "type": "permission_name"} + ] + },{ + "name": "action", + "base": "", + "fields": [ + {"name": "account", "type": "account_name"}, + {"name": "name", "type": "action_name"}, + {"name": "authorization", "type": "permission_level[]"}, + {"name": "data", "type": "bytes"} + ] + },{ + "name": "transaction_header", + "base": "", + "fields": [ + {"name": "expiration", "type": "time_point_sec"}, + {"name": "ref_block_num", "type": "uint16"}, + {"name": "ref_block_prefix", "type": "uint32"}, + {"name": "max_net_usage_words", "type": "varuint32"}, + {"name": "max_cpu_usage_ms", "type": "uint8"}, + {"name": "delay_sec", "type": "varuint32"} + ] + },{ + "name": "extension", + "base": "", + "fields": [ + {"name": "type", "type" : "uint16" }, + {"name": "data", "type": "bytes"} + ] + },{ + "name": "transaction", + "base": "transaction_header", + "fields": [ + {"name": "context_free_actions", "type": "action[]"}, + {"name": "actions", "type": "action[]"}, + {"name": "transaction_extensions", "type": "extension[]"} + ] + },{ + "name": "exec", + "base": "", + "fields": [ + {"name":"executer", "type":"account_name"}, + {"name":"trx", "type":"transaction"} + ] + } + ], + "actions": [{ + "name": "exec", + "type": "exec", + "ricardian_contract": "" + } + ], + "tables": [], + "ricardian_clauses": [], + "abi_extensions": [] +} diff --git a/eosio.system/CMakeLists.txt b/eosio.system/CMakeLists.txt index 6d84c7670..936d74e1e 100644 --- a/eosio.system/CMakeLists.txt +++ b/eosio.system/CMakeLists.txt @@ -2,7 +2,11 @@ add_executable(eosio.system.wasm ${CMAKE_CURRENT_SOURCE_DIR}/src/eosio.system.cp target_include_directories(eosio.system.wasm PUBLIC ${CMAKE_SOURCE_DIR}/include) + +set_target_properties(eosio.system.wasm + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin/eosio.system") + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/abi/eosio.system.abi" "${CMAKE_CURRENT_SOURCE_DIR}/bin/eosio.system" COPYONLY) + #install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${WASM_ROOT}/eosio.wasmsdk/include) -install(TARGETS eosio.system.wasm - RUNTIME DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/abi/eosio.system.abi DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin) diff --git a/eosio.system/bin/eosio.system/eosio.system.abi b/eosio.system/bin/eosio.system/eosio.system.abi new file mode 100644 index 000000000..87937c787 --- /dev/null +++ b/eosio.system/bin/eosio.system/eosio.system.abi @@ -0,0 +1,578 @@ +{ + "version": "eosio::abi/1.0", + "types": [{ + "new_type_name": "account_name", + "type": "name" + },{ + "new_type_name": "permission_name", + "type": "name" + },{ + "new_type_name": "action_name", + "type": "name" + },{ + "new_type_name": "transaction_id_type", + "type": "checksum256" + },{ + "new_type_name": "weight_type", + "type": "uint16" + }], + "____comment": "eosio.bios structs: set_account_limits, setpriv, set_global_limits, producer_key, set_producers, require_auth are provided so abi available for deserialization in future.", + "structs": [{ + "name": "permission_level", + "base": "", + "fields": [ + {"name":"actor", "type":"account_name"}, + {"name":"permission", "type":"permission_name"} + ] + },{ + "name": "key_weight", + "base": "", + "fields": [ + {"name":"key", "type":"public_key"}, + {"name":"weight", "type":"weight_type"} + ] + },{ + "name": "bidname", + "base": "", + "fields": [ + {"name":"bidder", "type":"account_name"}, + {"name":"newname", "type":"account_name"}, + {"name":"bid", "type":"asset"} + ] + },{ + "name": "permission_level_weight", + "base": "", + "fields": [ + {"name":"permission", "type":"permission_level"}, + {"name":"weight", "type":"weight_type"} + ] + },{ + "name": "wait_weight", + "base": "", + "fields": [ + {"name":"wait_sec", "type":"uint32"}, + {"name":"weight", "type":"weight_type"} + ] + },{ + "name": "authority", + "base": "", + "fields": [ + {"name":"threshold", "type":"uint32"}, + {"name":"keys", "type":"key_weight[]"}, + {"name":"accounts", "type":"permission_level_weight[]"}, + {"name":"waits", "type":"wait_weight[]"} + ] + },{ + "name": "newaccount", + "base": "", + "fields": [ + {"name":"creator", "type":"account_name"}, + {"name":"name", "type":"account_name"}, + {"name":"owner", "type":"authority"}, + {"name":"active", "type":"authority"} + ] + },{ + "name": "setcode", + "base": "", + "fields": [ + {"name":"account", "type":"account_name"}, + {"name":"vmtype", "type":"uint8"}, + {"name":"vmversion", "type":"uint8"}, + {"name":"code", "type":"bytes"} + ] + },{ + "name": "setabi", + "base": "", + "fields": [ + {"name":"account", "type":"account_name"}, + {"name":"abi", "type":"bytes"} + ] + },{ + "name": "updateauth", + "base": "", + "fields": [ + {"name":"account", "type":"account_name"}, + {"name":"permission", "type":"permission_name"}, + {"name":"parent", "type":"permission_name"}, + {"name":"auth", "type":"authority"} + ] + },{ + "name": "deleteauth", + "base": "", + "fields": [ + {"name":"account", "type":"account_name"}, + {"name":"permission", "type":"permission_name"} + ] + },{ + "name": "linkauth", + "base": "", + "fields": [ + {"name":"account", "type":"account_name"}, + {"name":"code", "type":"account_name"}, + {"name":"type", "type":"action_name"}, + {"name":"requirement", "type":"permission_name"} + ] + },{ + "name": "unlinkauth", + "base": "", + "fields": [ + {"name":"account", "type":"account_name"}, + {"name":"code", "type":"account_name"}, + {"name":"type", "type":"action_name"} + ] + },{ + "name": "canceldelay", + "base": "", + "fields": [ + {"name":"canceling_auth", "type":"permission_level"}, + {"name":"trx_id", "type":"transaction_id_type"} + ] + },{ + "name": "onerror", + "base": "", + "fields": [ + {"name":"sender_id", "type":"uint128"}, + {"name":"sent_trx", "type":"bytes"} + ] + },{ + "name": "buyrambytes", + "base": "", + "fields": [ + {"name":"payer", "type":"account_name"}, + {"name":"receiver", "type":"account_name"}, + {"name":"bytes", "type":"uint32"} + ] + },{ + "name": "sellram", + "base": "", + "fields": [ + {"name":"account", "type":"account_name"}, + {"name":"bytes", "type":"uint64"} + ] + },{ + "name": "buyram", + "base": "", + "fields": [ + {"name":"payer", "type":"account_name"}, + {"name":"receiver", "type":"account_name"}, + {"name":"quant", "type":"asset"} + ] + },{ + "name": "delegatebw", + "base": "", + "fields": [ + {"name":"from", "type":"account_name"}, + {"name":"receiver", "type":"account_name"}, + {"name":"stake_net_quantity", "type":"asset"}, + {"name":"stake_cpu_quantity", "type":"asset"}, + {"name":"transfer", "type":"bool"} + ] + },{ + "name": "undelegatebw", + "base": "", + "fields": [ + {"name":"from", "type":"account_name"}, + {"name":"receiver", "type":"account_name"}, + {"name":"unstake_net_quantity", "type":"asset"}, + {"name":"unstake_cpu_quantity", "type":"asset"} + ] + },{ + "name": "refund", + "base": "", + "fields": [ + {"name":"owner", "type":"account_name"} + ] + },{ + "name": "delegated_bandwidth", + "base": "", + "fields": [ + {"name":"from", "type":"account_name"}, + {"name":"to", "type":"account_name"}, + {"name":"net_weight", "type":"asset"}, + {"name":"cpu_weight", "type":"asset"} + ] + },{ + "name": "user_resources", + "base": "", + "fields": [ + {"name":"owner", "type":"account_name"}, + {"name":"net_weight", "type":"asset"}, + {"name":"cpu_weight", "type":"asset"}, + {"name":"ram_bytes", "type":"uint64"} + ] + },{ + "name": "total_resources", + "base": "", + "fields": [ + {"name":"owner", "type":"account_name"}, + {"name":"net_weight", "type":"asset"}, + {"name":"cpu_weight", "type":"asset"}, + {"name":"ram_bytes", "type":"uint64"} + ] + },{ + "name": "refund_request", + "base": "", + "fields": [ + {"name":"owner", "type":"account_name"}, + {"name":"request_time", "type":"time_point_sec"}, + {"name":"net_amount", "type":"asset"}, + {"name":"cpu_amount", "type":"asset"} + ] + },{ + "name": "blockchain_parameters", + "base": "", + "fields": [ + + {"name":"max_block_net_usage", "type":"uint64"}, + {"name":"target_block_net_usage_pct", "type":"uint32"}, + {"name":"max_transaction_net_usage", "type":"uint32"}, + {"name":"base_per_transaction_net_usage", "type":"uint32"}, + {"name":"net_usage_leeway", "type":"uint32"}, + {"name":"context_free_discount_net_usage_num", "type":"uint32"}, + {"name":"context_free_discount_net_usage_den", "type":"uint32"}, + {"name":"max_block_cpu_usage", "type":"uint32"}, + {"name":"target_block_cpu_usage_pct", "type":"uint32"}, + {"name":"max_transaction_cpu_usage", "type":"uint32"}, + {"name":"min_transaction_cpu_usage", "type":"uint32"}, + {"name":"max_transaction_lifetime", "type":"uint32"}, + {"name":"deferred_trx_expiration_window", "type":"uint32"}, + {"name":"max_transaction_delay", "type":"uint32"}, + {"name":"max_inline_action_size", "type":"uint32"}, + {"name":"max_inline_action_depth", "type":"uint16"}, + {"name":"max_authority_depth", "type":"uint16"} + + ] + },{ + "name": "eosio_global_state", + "base": "blockchain_parameters", + "fields": [ + {"name":"max_ram_size", "type":"uint64"}, + {"name":"total_ram_bytes_reserved", "type":"uint64"}, + {"name":"total_ram_stake", "type":"int64"}, + {"name":"last_producer_schedule_update", "type":"block_timestamp_type"}, + {"name":"last_pervote_bucket_fill", "type":"uint64"}, + {"name":"pervote_bucket", "type":"int64"}, + {"name":"perblock_bucket", "type":"int64"}, + {"name":"total_unpaid_blocks", "type":"uint32"}, + {"name":"total_activated_stake", "type":"int64"}, + {"name":"thresh_activated_stake_time", "type":"uint64"}, + {"name":"last_producer_schedule_size", "type":"uint16"}, + {"name":"total_producer_vote_weight", "type":"float64"}, + {"name":"last_name_close", "type":"block_timestamp_type"} + ] + },{ + "name": "producer_info", + "base": "", + "fields": [ + {"name":"owner", "type":"account_name"}, + {"name":"total_votes", "type":"float64"}, + {"name":"producer_key", "type":"public_key"}, + {"name":"is_active", "type":"bool"}, + {"name":"url", "type":"string"}, + {"name":"unpaid_blocks", "type":"uint32"}, + {"name":"last_claim_time", "type":"uint64"}, + {"name":"location", "type":"uint16"} + ] + },{ + "name": "regproducer", + "base": "", + "fields": [ + {"name":"producer", "type":"account_name"}, + {"name":"producer_key", "type":"public_key"}, + {"name":"url", "type":"string"}, + {"name":"location", "type":"uint16"} + ] + },{ + "name": "unregprod", + "base": "", + "fields": [ + {"name":"producer", "type":"account_name"} + ] + },{ + "name": "setram", + "base": "", + "fields": [ + {"name":"max_ram_size", "type":"uint64"} + ] + },{ + "name": "regproxy", + "base": "", + "fields": [ + {"name":"proxy", "type":"account_name"}, + {"name":"isproxy", "type":"bool"} + ] + },{ + "name": "voteproducer", + "base": "", + "fields": [ + {"name":"voter", "type":"account_name"}, + {"name":"proxy", "type":"account_name"}, + {"name":"producers", "type":"account_name[]"} + ] + },{ + "name": "voter_info", + "base": "", + "fields": [ + {"name":"owner", "type":"account_name"}, + {"name":"proxy", "type":"account_name"}, + {"name":"producers", "type":"account_name[]"}, + {"name":"staked", "type":"int64"}, + {"name":"last_vote_weight", "type":"float64"}, + {"name":"proxied_vote_weight", "type":"float64"}, + {"name":"is_proxy", "type":"bool"} + ] + },{ + "name": "claimrewards", + "base": "", + "fields": [ + {"name":"owner", "type":"account_name"} + ] + },{ + "name": "setpriv", + "base": "", + "fields": [ + {"name":"account", "type":"account_name"}, + {"name":"is_priv", "type":"int8"} + ] + },{ + "name": "rmvproducer", + "base": "", + "fields": [ + {"name":"producer", "type":"account_name"} + ] + },{ + "name": "set_account_limits", + "base": "", + "fields": [ + {"name":"account", "type":"account_name"}, + {"name":"ram_bytes", "type":"int64"}, + {"name":"net_weight", "type":"int64"}, + {"name":"cpu_weight", "type":"int64"} + ] + },{ + "name": "set_global_limits", + "base": "", + "fields": [ + {"name":"cpu_usec_per_period", "type":"int64"} + ] + },{ + "name": "producer_key", + "base": "", + "fields": [ + {"name":"producer_name", "type":"account_name"}, + {"name":"block_signing_key", "type":"public_key"} + ] + },{ + "name": "set_producers", + "base": "", + "fields": [ + {"name":"schedule", "type":"producer_key[]"} + ] + },{ + "name": "require_auth", + "base": "", + "fields": [ + {"name":"from", "type":"account_name"} + ] + },{ + "name": "setparams", + "base": "", + "fields": [ + {"name":"params", "type":"blockchain_parameters"} + ] + },{ + "name": "connector", + "base": "", + "fields": [ + {"name":"balance", "type":"asset"}, + {"name":"weight", "type":"float64"} + ] + },{ + "name": "exchange_state", + "base": "", + "fields": [ + {"name":"supply", "type":"asset"}, + {"name":"base", "type":"connector"}, + {"name":"quote", "type":"connector"} + ] + }, { + "name": "namebid_info", + "base": "", + "fields": [ + {"name":"newname", "type":"account_name"}, + {"name":"high_bidder", "type":"account_name"}, + {"name":"high_bid", "type":"int64"}, + {"name":"last_bid_time", "type":"uint64"} + ] + } + ], + "actions": [{ + "name": "newaccount", + "type": "newaccount", + "ricardian_contract": "" + },{ + "name": "setcode", + "type": "setcode", + "ricardian_contract": "" + },{ + "name": "setabi", + "type": "setabi", + "ricardian_contract": "" + },{ + "name": "updateauth", + "type": "updateauth", + "ricardian_contract": "" + },{ + "name": "deleteauth", + "type": "deleteauth", + "ricardian_contract": "" + },{ + "name": "linkauth", + "type": "linkauth", + "ricardian_contract": "" + },{ + "name": "unlinkauth", + "type": "unlinkauth", + "ricardian_contract": "" + },{ + "name": "canceldelay", + "type": "canceldelay", + "ricardian_contract": "" + },{ + "name": "onerror", + "type": "onerror", + "ricardian_contract": "" + },{ + "name": "buyrambytes", + "type": "buyrambytes", + "ricardian_contract": "" + },{ + "name": "buyram", + "type": "buyram", + "ricardian_contract": "" + },{ + "name": "sellram", + "type": "sellram", + "ricardian_contract": "" + },{ + "name": "delegatebw", + "type": "delegatebw", + "ricardian_contract": "" + },{ + "name": "undelegatebw", + "type": "undelegatebw", + "ricardian_contract": "" + },{ + "name": "refund", + "type": "refund", + "ricardian_contract": "" + },{ + "name": "regproducer", + "type": "regproducer", + "ricardian_contract": "" + },{ + "name": "setram", + "type": "setram", + "ricardian_contract": "" + },{ + "name": "bidname", + "type": "bidname", + "ricardian_contract": "" + },{ + "name": "unregprod", + "type": "unregprod", + "ricardian_contract": "" + },{ + "name": "regproxy", + "type": "regproxy", + "ricardian_contract": "" + },{ + "name": "voteproducer", + "type": "voteproducer", + "ricardian_contract": "" + },{ + "name": "claimrewards", + "type": "claimrewards", + "ricardian_contract": "" + },{ + "name": "setpriv", + "type": "setpriv", + "ricardian_contract": "" + },{ + "name": "rmvproducer", + "type": "rmvproducer", + "ricardian_contract": "" + },{ + "name": "setalimits", + "type": "set_account_limits", + "ricardian_contract": "" + },{ + "name": "setglimits", + "type": "set_global_limits", + "ricardian_contract": "" + },{ + "name": "setprods", + "type": "set_producers", + "ricardian_contract": "" + },{ + "name": "reqauth", + "type": "require_auth", + "ricardian_contract": "" + },{ + "name": "setparams", + "type": "setparams", + "ricardian_contract": "" + }], + "tables": [{ + "name": "producers", + "type": "producer_info", + "index_type": "i64", + "key_names" : ["owner"], + "key_types" : ["uint64"] + },{ + "name": "global", + "type": "eosio_global_state", + "index_type": "i64", + "key_names" : [], + "key_types" : [] + },{ + "name": "voters", + "type": "voter_info", + "index_type": "i64", + "key_names" : ["owner"], + "key_types" : ["account_name"] + },{ + "name": "userres", + "type": "user_resources", + "index_type": "i64", + "key_names" : ["owner"], + "key_types" : ["uint64"] + },{ + "name": "delband", + "type": "delegated_bandwidth", + "index_type": "i64", + "key_names" : ["to"], + "key_types" : ["uint64"] + },{ + "name": "rammarket", + "type": "exchange_state", + "index_type": "i64", + "key_names" : ["supply"], + "key_types" : ["uint64"] + },{ + "name": "refunds", + "type": "refund_request", + "index_type": "i64", + "key_names" : ["owner"], + "key_types" : ["uint64"] + },{ + "name": "namebids", + "type": "namebid_info", + "index_type": "i64", + "key_names" : ["newname"], + "key_types" : ["account_name"] + } + ], + "ricardian_clauses": [], + "abi_extensions": [] +} diff --git a/eosio.token/CMakeLists.txt b/eosio.token/CMakeLists.txt index a116f7481..39993201b 100644 --- a/eosio.token/CMakeLists.txt +++ b/eosio.token/CMakeLists.txt @@ -2,7 +2,10 @@ add_executable(eosio.token.wasm ${CMAKE_CURRENT_SOURCE_DIR}/src/eosio.token.cpp) target_include_directories(eosio.token.wasm PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) + +set_target_properties(eosio.token.wasm + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin/eosio.token") + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/abi/eosio.token.abi" "${CMAKE_CURRENT_SOURCE_DIR}/bin/eosio.token" COPYONLY) #install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${WASM_ROOT}/eosio.wasmsdk/include) -install(TARGETS eosio.token.wasm - RUNTIME DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/abi/eosio.token.abi DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin) diff --git a/eosio.token/bin/eosio.token/eosio.token.abi b/eosio.token/bin/eosio.token/eosio.token.abi new file mode 100644 index 000000000..d769deb33 --- /dev/null +++ b/eosio.token/bin/eosio.token/eosio.token.abi @@ -0,0 +1,78 @@ +{ + "version": "eosio::abi/1.0", + "types": [{ + "new_type_name": "account_name", + "type": "name" + }], + "structs": [{ + "name": "transfer", + "base": "", + "fields": [ + {"name":"from", "type":"account_name"}, + {"name":"to", "type":"account_name"}, + {"name":"quantity", "type":"asset"}, + {"name":"memo", "type":"string"} + ] + },{ + "name": "create", + "base": "", + "fields": [ + {"name":"issuer", "type":"account_name"}, + {"name":"maximum_supply", "type":"asset"} + ] + },{ + "name": "issue", + "base": "", + "fields": [ + {"name":"to", "type":"account_name"}, + {"name":"quantity", "type":"asset"}, + {"name":"memo", "type":"string"} + ] + },{ + "name": "account", + "base": "", + "fields": [ + {"name":"balance", "type":"asset"} + ] + },{ + "name": "currency_stats", + "base": "", + "fields": [ + {"name":"supply", "type":"asset"}, + {"name":"max_supply", "type":"asset"}, + {"name":"issuer", "type":"account_name"} + ] + } + ], + "actions": [{ + "name": "transfer", + "type": "transfer", + "ricardian_contract": "" + },{ + "name": "issue", + "type": "issue", + "ricardian_contract": "" + }, { + "name": "create", + "type": "create", + "ricardian_contract": "" + } + + ], + "tables": [{ + "name": "accounts", + "type": "account", + "index_type": "i64", + "key_names" : ["currency"], + "key_types" : ["uint64"] + },{ + "name": "stat", + "type": "currency_stats", + "index_type": "i64", + "key_names" : ["currency"], + "key_types" : ["uint64"] + } + ], + "ricardian_clauses": [], + "abi_extensions": [] +} diff --git a/tests/contracts.hpp b/tests/contracts.hpp deleted file mode 100644 index ef9cb14d9..000000000 --- a/tests/contracts.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -#include - -namespace eosio { namespace testing { - -struct contracts { - static std::vector system_wasm() { return read_wasm("/Users/judgefudge/eosio.contracts/eosio.system/bin/eosio.system.wasm"); } - static std::string system_wast() { return read_wast("/Users/judgefudge/eosio.contracts/eosio.system/bin/eosio.system.wast"); } - static std::vector system_abi() { return read_abi("/Users/judgefudge/eosio.contracts/eosio.system/bin/eosio.system.abi"); } - static std::vector token_wasm() { return read_wasm("/Users/judgefudge/eosio.contracts/eosio.token/bin/eosio.token.wasm"); } - static std::string token_wast() { return read_wast("/Users/judgefudge/eosio.contracts/eosio.token/bin/eosio.token.wast"); } - static std::vector token_abi() { return read_abi("/Users/judgefudge/eosio.contracts/eosio.token/bin/eosio.token.abi"); } - static std::vector msig_wasm() { return read_wasm("/Users/judgefudge/eosio.contracts/eosio.msig/bin/eosio.msig.wasm"); } - static std::string msig_wast() { return read_wast("/Users/judgefudge/eosio.contracts/eosio.msig/bin/eosio.msig.wast"); } - static std::vector msig_abi() { return read_abi("/Users/judgefudge/eosio.contracts/eosio.msig/bin/eosio.msig.abi"); } - static std::vector sudo_wasm() { return read_wasm("/Users/judgefudge/eosio.contracts/eosio.sudo/bin/eosio.sudo.wasm"); } - static std::string sudo_wast() { return read_wast("/Users/judgefudge/eosio.contracts/eosio.sudo/bin/eosio.sudo.wast"); } - static std::vector sudo_abi() { return read_abi("/Users/judgefudge/eosio.contracts/eosio.sudo/bin/eosio.sudo.abi"); } - - struct util { - static std::vector test_api_wasm() { return read_wasm("/Users/judgefudge/eosio.contracts/tests/test_contracts/test_api.wasm"); } - static std::vector exchange_wasm() { return read_wasm("/Users/judgefudge/eosio.contracts/tests/test_contracts/exchange.wasm"); } - }; -}; -}} //ns eosio::testing diff --git a/tests/contracts.hpp.in b/tests/contracts.hpp.in index 935565234..1d91f506e 100644 --- a/tests/contracts.hpp.in +++ b/tests/contracts.hpp.in @@ -4,18 +4,18 @@ namespace eosio { namespace testing { struct contracts { - static std::vector system_wasm() { return read_wasm("${ROOT_DIR}/eosio.system/bin/eosio.system.wasm"); } - static std::string system_wast() { return read_wast("${ROOT_DIR}/eosio.system/bin/eosio.system.wast"); } - static std::vector system_abi() { return read_abi("${ROOT_DIR}/eosio.system/bin/eosio.system.abi"); } - static std::vector token_wasm() { return read_wasm("${ROOT_DIR}/eosio.token/bin/eosio.token.wasm"); } - static std::string token_wast() { return read_wast("${ROOT_DIR}/eosio.token/bin/eosio.token.wast"); } - static std::vector token_abi() { return read_abi("${ROOT_DIR}/eosio.token/bin/eosio.token.abi"); } - static std::vector msig_wasm() { return read_wasm("${ROOT_DIR}/eosio.msig/bin/eosio.msig.wasm"); } - static std::string msig_wast() { return read_wast("${ROOT_DIR}/eosio.msig/bin/eosio.msig.wast"); } - static std::vector msig_abi() { return read_abi("${ROOT_DIR}/eosio.msig/bin/eosio.msig.abi"); } - static std::vector sudo_wasm() { return read_wasm("${ROOT_DIR}/eosio.sudo/bin/eosio.sudo.wasm"); } - static std::string sudo_wast() { return read_wast("${ROOT_DIR}/eosio.sudo/bin/eosio.sudo.wast"); } - static std::vector sudo_abi() { return read_abi("${ROOT_DIR}/eosio.sudo/bin/eosio.sudo.abi"); } + static std::vector system_wasm() { return read_wasm("${ROOT_DIR}/eosio.system/bin/eosio.system/eosio.system.wasm"); } + static std::string system_wast() { return read_wast("${ROOT_DIR}/eosio.system/bin/eosio.system/eosio.system.wast"); } + static std::vector system_abi() { return read_abi("${ROOT_DIR}/eosio.system/bin/eosio.system/eosio.system.abi"); } + static std::vector token_wasm() { return read_wasm("${ROOT_DIR}/eosio.token/bin/eosio.token/eosio.token.wasm"); } + static std::string token_wast() { return read_wast("${ROOT_DIR}/eosio.token/bin/eosio.token/eosio.token.wast"); } + static std::vector token_abi() { return read_abi("${ROOT_DIR}/eosio.token/bin/eosio.token/eosio.token.abi"); } + static std::vector msig_wasm() { return read_wasm("${ROOT_DIR}/eosio.msig/bin/eosio.msig/eosio.msig.wasm"); } + static std::string msig_wast() { return read_wast("${ROOT_DIR}/eosio.msig/bin/eosio.msig/eosio.msig.wast"); } + static std::vector msig_abi() { return read_abi("${ROOT_DIR}/eosio.msig/bin/eosio.msig/eosio.msig.abi"); } + static std::vector sudo_wasm() { return read_wasm("${ROOT_DIR}/eosio.sudo/bin/eosio.sudo/eosio.sudo.wasm"); } + static std::string sudo_wast() { return read_wast("${ROOT_DIR}/eosio.sudo/bin/eosio.sudo/eosio.sudo.wast"); } + static std::vector sudo_abi() { return read_abi("${ROOT_DIR}/eosio.sudo/bin/eosio.sudo/eosio.sudo.abi"); } struct util { static std::vector test_api_wasm() { return read_wasm("${CMAKE_SOURCE_DIR}/test_contracts/test_api.wasm"); } diff --git a/tests/eosio.system_tests.cpp b/tests/eosio.system_tests.cpp index 03351a5e3..6ff7a9649 100644 --- a/tests/eosio.system_tests.cpp +++ b/tests/eosio.system_tests.cpp @@ -1708,7 +1708,7 @@ BOOST_FIXTURE_TEST_CASE(producers_upgrade_system_contract, eosio_system_tester) prod_perms.push_back( { name(x), config::active_name } ); } //prepare system contract with different hash (contract differs in one byte) - string eosio_system_wast2 = contracts::system_wast(); + string eosio_system_wast2 = wasm_to_wast(contracts::system_wasm(), true); string msg = "producer votes must be unique and sorted"; auto pos = eosio_system_wast2.find(msg); BOOST_REQUIRE( pos != std::string::npos ); @@ -1717,7 +1717,7 @@ BOOST_FIXTURE_TEST_CASE(producers_upgrade_system_contract, eosio_system_tester) transaction trx; { - auto code = wast_to_wasm( eosio_system_wast2 ); + auto code = contracts::system_wasm(); //wast_to_wasm( eosio_system_wast2 ); variant pretty_trx = fc::mutable_variant_object() ("expiration", "2020-01-01T00:30") ("ref_block_num", 2) From c973039199086bd983679d8ad76d04f9937d0622 Mon Sep 17 00:00:00 2001 From: Bucky Kittinger Date: Fri, 6 Jul 2018 18:17:16 -0400 Subject: [PATCH 10/28] Fixed missing debug symbols in fc for debug build --- eosio.system/CMakeLists.txt | 3 ++- tests/CMakeLists.txt | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/eosio.system/CMakeLists.txt b/eosio.system/CMakeLists.txt index 936d74e1e..b0bc44312 100644 --- a/eosio.system/CMakeLists.txt +++ b/eosio.system/CMakeLists.txt @@ -1,7 +1,8 @@ add_executable(eosio.system.wasm ${CMAKE_CURRENT_SOURCE_DIR}/src/eosio.system.cpp) target_include_directories(eosio.system.wasm PUBLIC - ${CMAKE_SOURCE_DIR}/include) + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/../eosio.token/include) set_target_properties(eosio.system.wasm PROPERTIES diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 80e6a4139..5c3e0d4b2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -40,9 +40,13 @@ find_package(Boost 1.67 REQUIRED COMPONENTS file(GLOB UNIT_TESTS "*.cpp") -find_library(libtester eosio_testing ) +find_library(libtester eosio_testing ${EOSIO_INSTALL_PREFIX}/lib) find_library(libchain eosio_chain ${EOSIO_INSTALL_PREFIX}/lib) -find_library(libfc fc ${EOSIO_INSTALL_PREFIX}/lib) +if ( "${CMAKE_BUILD_TYPE}" EQUAL "Debug" ) + find_library(libfc fc_debug ${EOSIO_INSTALL_PREFIX}/lib) +else() + find_library(libfc fc ${EOSIO_INSTALL_PREFIX}/lib) +endif() find_library(libbinaryen binaryen ${EOSIO_INSTALL_PREFIX}/lib) find_library(libwasm WASM ${EOSIO_INSTALL_PREFIX}/lib) find_library(libwast WAST ${EOSIO_INSTALL_PREFIX}/lib) From 47cee42e85cd96f2391e15b2b8a537c11f2380fc Mon Sep 17 00:00:00 2001 From: Bucky Kittinger Date: Fri, 6 Jul 2018 18:35:56 -0400 Subject: [PATCH 11/28] added gitignores --- eosio.msig/bin/eosio.msig/.gitignore | 2 + eosio.msig/bin/eosio.msig/eosio.msig.abi | 152 ----- eosio.sudo/bin/eosio.sudo/.gitignore | 2 + eosio.sudo/bin/eosio.sudo/eosio.sudo.abi | 73 --- eosio.system/bin/eosio.system/.gitignore | 2 + .../bin/eosio.system/eosio.system.abi | 578 ------------------ eosio.token/bin/eosio.token/.gitignore | 2 + eosio.token/bin/eosio.token/eosio.token.abi | 78 --- 8 files changed, 8 insertions(+), 881 deletions(-) create mode 100644 eosio.msig/bin/eosio.msig/.gitignore delete mode 100644 eosio.msig/bin/eosio.msig/eosio.msig.abi create mode 100644 eosio.sudo/bin/eosio.sudo/.gitignore delete mode 100644 eosio.sudo/bin/eosio.sudo/eosio.sudo.abi create mode 100644 eosio.system/bin/eosio.system/.gitignore delete mode 100644 eosio.system/bin/eosio.system/eosio.system.abi create mode 100644 eosio.token/bin/eosio.token/.gitignore delete mode 100644 eosio.token/bin/eosio.token/eosio.token.abi diff --git a/eosio.msig/bin/eosio.msig/.gitignore b/eosio.msig/bin/eosio.msig/.gitignore new file mode 100644 index 000000000..db5b01ccb --- /dev/null +++ b/eosio.msig/bin/eosio.msig/.gitignore @@ -0,0 +1,2 @@ +eosio.msig.abi +eosio.msig.wasm diff --git a/eosio.msig/bin/eosio.msig/eosio.msig.abi b/eosio.msig/bin/eosio.msig/eosio.msig.abi deleted file mode 100644 index 9fcf8a957..000000000 --- a/eosio.msig/bin/eosio.msig/eosio.msig.abi +++ /dev/null @@ -1,152 +0,0 @@ -{ - "version": "eosio::abi/1.0", - "types": [{ - "new_type_name": "account_name", - "type": "name" - },{ - "new_type_name": "permission_name", - "type": "name" - },{ - "new_type_name": "action_name", - "type": "name" - }], - "structs": [{ - "name": "permission_level", - "base": "", - "fields": [ - {"name": "actor", "type": "account_name"}, - {"name": "permission", "type": "permission_name"} - ] - },{ - "name": "action", - "base": "", - "fields": [ - {"name": "account", "type": "account_name"}, - {"name": "name", "type": "action_name"}, - {"name": "authorization", "type": "permission_level[]"}, - {"name": "data", "type": "bytes"} - ] - },{ - "name": "transaction_header", - "base": "", - "fields": [ - {"name": "expiration", "type": "time_point_sec"}, - {"name": "ref_block_num", "type": "uint16"}, - {"name": "ref_block_prefix", "type": "uint32"}, - {"name": "max_net_usage_words", "type": "varuint32"}, - {"name": "max_cpu_usage_ms", "type": "uint8"}, - {"name": "delay_sec", "type": "varuint32"} - ] - },{ - "name": "extension", - "base": "", - "fields": [ - {"name": "type", "type" : "uint16" }, - {"name": "data", "type": "bytes"} - ] - },{ - "name": "transaction", - "base": "transaction_header", - "fields": [ - {"name": "context_free_actions", "type": "action[]"}, - {"name": "actions", "type": "action[]"}, - {"name": "transaction_extensions", "type": "extension[]"} - ] - },{ - "name": "propose", - "base": "", - "fields": [ - {"name":"proposer", "type":"account_name"}, - {"name":"proposal_name", "type":"name"}, - {"name":"requested", "type":"permission_level[]"}, - {"name":"trx", "type":"transaction"} - ] - },{ - "name": "approve", - "base": "", - "fields": [ - {"name":"proposer", "type":"account_name"}, - {"name":"proposal_name", "type":"name"}, - {"name":"level", "type":"permission_level"} - ] - },{ - "name": "unapprove", - "base": "", - "fields": [ - {"name":"proposer", "type":"account_name"}, - {"name":"proposal_name", "type":"name"}, - {"name":"level", "type":"permission_level"} - ] - },{ - "name": "cancel", - "base": "", - "fields": [ - {"name":"proposer", "type":"account_name"}, - {"name":"proposal_name", "type":"name"}, - {"name":"canceler", "type":"account_name"} - ] - },{ - "name": "exec", - "base": "", - "fields": [ - {"name":"proposer", "type":"account_name"}, - {"name":"proposal_name", "type":"name"}, - {"name":"executer", "type":"account_name"} - ] - },{ - "name": "proposal", - "base": "", - "fields": [ - {"name": "proposal_name", "type": "name"}, - {"name": "packed_transaction", "type": "bytes"} - ] - },{ - "name": "approvals_info", - "base": "", - "fields": [ - {"name": "proposal_name", "type": "name"}, - {"name": "requested_approvals", "type": "permission_level[]"}, - {"name": "provided_approvals", "type": "permission_level[]"} - ] - } - ], - "actions": [{ - "name": "propose", - "type": "propose", - "ricardian_contract": "" - },{ - "name": "approve", - "type": "approve", - "ricardian_contract": "" - },{ - "name": "unapprove", - "type": "unapprove", - "ricardian_contract": "" - }, { - "name": "cancel", - "type": "cancel", - "ricardian_contract": "" - }, { - "name": "exec", - "type": "exec", - "ricardian_contract": "" - } - - ], - "tables": [{ - "name": "proposal", - "type": "proposal", - "index_type": "i64", - "key_names" : ["proposal_name"], - "key_types" : ["name"] - },{ - "name": "approvals", - "type": "approvals_info", - "index_type": "i64", - "key_names" : ["proposal_name"], - "key_types" : ["name"] - } - ], - "ricardian_clauses": [], - "abi_extensions": [] -} diff --git a/eosio.sudo/bin/eosio.sudo/.gitignore b/eosio.sudo/bin/eosio.sudo/.gitignore new file mode 100644 index 000000000..35898c3b5 --- /dev/null +++ b/eosio.sudo/bin/eosio.sudo/.gitignore @@ -0,0 +1,2 @@ +eosio.sudo.abi +eosio.sudo.wasm diff --git a/eosio.sudo/bin/eosio.sudo/eosio.sudo.abi b/eosio.sudo/bin/eosio.sudo/eosio.sudo.abi deleted file mode 100644 index 6f74921bc..000000000 --- a/eosio.sudo/bin/eosio.sudo/eosio.sudo.abi +++ /dev/null @@ -1,73 +0,0 @@ -{ - "version": "eosio::abi/1.0", - "types": [{ - "new_type_name": "account_name", - "type": "name" - },{ - "new_type_name": "permission_name", - "type": "name" - },{ - "new_type_name": "action_name", - "type": "name" - }], - "structs": [{ - "name": "permission_level", - "base": "", - "fields": [ - {"name": "actor", "type": "account_name"}, - {"name": "permission", "type": "permission_name"} - ] - },{ - "name": "action", - "base": "", - "fields": [ - {"name": "account", "type": "account_name"}, - {"name": "name", "type": "action_name"}, - {"name": "authorization", "type": "permission_level[]"}, - {"name": "data", "type": "bytes"} - ] - },{ - "name": "transaction_header", - "base": "", - "fields": [ - {"name": "expiration", "type": "time_point_sec"}, - {"name": "ref_block_num", "type": "uint16"}, - {"name": "ref_block_prefix", "type": "uint32"}, - {"name": "max_net_usage_words", "type": "varuint32"}, - {"name": "max_cpu_usage_ms", "type": "uint8"}, - {"name": "delay_sec", "type": "varuint32"} - ] - },{ - "name": "extension", - "base": "", - "fields": [ - {"name": "type", "type" : "uint16" }, - {"name": "data", "type": "bytes"} - ] - },{ - "name": "transaction", - "base": "transaction_header", - "fields": [ - {"name": "context_free_actions", "type": "action[]"}, - {"name": "actions", "type": "action[]"}, - {"name": "transaction_extensions", "type": "extension[]"} - ] - },{ - "name": "exec", - "base": "", - "fields": [ - {"name":"executer", "type":"account_name"}, - {"name":"trx", "type":"transaction"} - ] - } - ], - "actions": [{ - "name": "exec", - "type": "exec", - "ricardian_contract": "" - } - ], - "tables": [], - "ricardian_clauses": [], - "abi_extensions": [] -} diff --git a/eosio.system/bin/eosio.system/.gitignore b/eosio.system/bin/eosio.system/.gitignore new file mode 100644 index 000000000..105891a48 --- /dev/null +++ b/eosio.system/bin/eosio.system/.gitignore @@ -0,0 +1,2 @@ +eosio.system.abi +eosio.system.wasm diff --git a/eosio.system/bin/eosio.system/eosio.system.abi b/eosio.system/bin/eosio.system/eosio.system.abi deleted file mode 100644 index 87937c787..000000000 --- a/eosio.system/bin/eosio.system/eosio.system.abi +++ /dev/null @@ -1,578 +0,0 @@ -{ - "version": "eosio::abi/1.0", - "types": [{ - "new_type_name": "account_name", - "type": "name" - },{ - "new_type_name": "permission_name", - "type": "name" - },{ - "new_type_name": "action_name", - "type": "name" - },{ - "new_type_name": "transaction_id_type", - "type": "checksum256" - },{ - "new_type_name": "weight_type", - "type": "uint16" - }], - "____comment": "eosio.bios structs: set_account_limits, setpriv, set_global_limits, producer_key, set_producers, require_auth are provided so abi available for deserialization in future.", - "structs": [{ - "name": "permission_level", - "base": "", - "fields": [ - {"name":"actor", "type":"account_name"}, - {"name":"permission", "type":"permission_name"} - ] - },{ - "name": "key_weight", - "base": "", - "fields": [ - {"name":"key", "type":"public_key"}, - {"name":"weight", "type":"weight_type"} - ] - },{ - "name": "bidname", - "base": "", - "fields": [ - {"name":"bidder", "type":"account_name"}, - {"name":"newname", "type":"account_name"}, - {"name":"bid", "type":"asset"} - ] - },{ - "name": "permission_level_weight", - "base": "", - "fields": [ - {"name":"permission", "type":"permission_level"}, - {"name":"weight", "type":"weight_type"} - ] - },{ - "name": "wait_weight", - "base": "", - "fields": [ - {"name":"wait_sec", "type":"uint32"}, - {"name":"weight", "type":"weight_type"} - ] - },{ - "name": "authority", - "base": "", - "fields": [ - {"name":"threshold", "type":"uint32"}, - {"name":"keys", "type":"key_weight[]"}, - {"name":"accounts", "type":"permission_level_weight[]"}, - {"name":"waits", "type":"wait_weight[]"} - ] - },{ - "name": "newaccount", - "base": "", - "fields": [ - {"name":"creator", "type":"account_name"}, - {"name":"name", "type":"account_name"}, - {"name":"owner", "type":"authority"}, - {"name":"active", "type":"authority"} - ] - },{ - "name": "setcode", - "base": "", - "fields": [ - {"name":"account", "type":"account_name"}, - {"name":"vmtype", "type":"uint8"}, - {"name":"vmversion", "type":"uint8"}, - {"name":"code", "type":"bytes"} - ] - },{ - "name": "setabi", - "base": "", - "fields": [ - {"name":"account", "type":"account_name"}, - {"name":"abi", "type":"bytes"} - ] - },{ - "name": "updateauth", - "base": "", - "fields": [ - {"name":"account", "type":"account_name"}, - {"name":"permission", "type":"permission_name"}, - {"name":"parent", "type":"permission_name"}, - {"name":"auth", "type":"authority"} - ] - },{ - "name": "deleteauth", - "base": "", - "fields": [ - {"name":"account", "type":"account_name"}, - {"name":"permission", "type":"permission_name"} - ] - },{ - "name": "linkauth", - "base": "", - "fields": [ - {"name":"account", "type":"account_name"}, - {"name":"code", "type":"account_name"}, - {"name":"type", "type":"action_name"}, - {"name":"requirement", "type":"permission_name"} - ] - },{ - "name": "unlinkauth", - "base": "", - "fields": [ - {"name":"account", "type":"account_name"}, - {"name":"code", "type":"account_name"}, - {"name":"type", "type":"action_name"} - ] - },{ - "name": "canceldelay", - "base": "", - "fields": [ - {"name":"canceling_auth", "type":"permission_level"}, - {"name":"trx_id", "type":"transaction_id_type"} - ] - },{ - "name": "onerror", - "base": "", - "fields": [ - {"name":"sender_id", "type":"uint128"}, - {"name":"sent_trx", "type":"bytes"} - ] - },{ - "name": "buyrambytes", - "base": "", - "fields": [ - {"name":"payer", "type":"account_name"}, - {"name":"receiver", "type":"account_name"}, - {"name":"bytes", "type":"uint32"} - ] - },{ - "name": "sellram", - "base": "", - "fields": [ - {"name":"account", "type":"account_name"}, - {"name":"bytes", "type":"uint64"} - ] - },{ - "name": "buyram", - "base": "", - "fields": [ - {"name":"payer", "type":"account_name"}, - {"name":"receiver", "type":"account_name"}, - {"name":"quant", "type":"asset"} - ] - },{ - "name": "delegatebw", - "base": "", - "fields": [ - {"name":"from", "type":"account_name"}, - {"name":"receiver", "type":"account_name"}, - {"name":"stake_net_quantity", "type":"asset"}, - {"name":"stake_cpu_quantity", "type":"asset"}, - {"name":"transfer", "type":"bool"} - ] - },{ - "name": "undelegatebw", - "base": "", - "fields": [ - {"name":"from", "type":"account_name"}, - {"name":"receiver", "type":"account_name"}, - {"name":"unstake_net_quantity", "type":"asset"}, - {"name":"unstake_cpu_quantity", "type":"asset"} - ] - },{ - "name": "refund", - "base": "", - "fields": [ - {"name":"owner", "type":"account_name"} - ] - },{ - "name": "delegated_bandwidth", - "base": "", - "fields": [ - {"name":"from", "type":"account_name"}, - {"name":"to", "type":"account_name"}, - {"name":"net_weight", "type":"asset"}, - {"name":"cpu_weight", "type":"asset"} - ] - },{ - "name": "user_resources", - "base": "", - "fields": [ - {"name":"owner", "type":"account_name"}, - {"name":"net_weight", "type":"asset"}, - {"name":"cpu_weight", "type":"asset"}, - {"name":"ram_bytes", "type":"uint64"} - ] - },{ - "name": "total_resources", - "base": "", - "fields": [ - {"name":"owner", "type":"account_name"}, - {"name":"net_weight", "type":"asset"}, - {"name":"cpu_weight", "type":"asset"}, - {"name":"ram_bytes", "type":"uint64"} - ] - },{ - "name": "refund_request", - "base": "", - "fields": [ - {"name":"owner", "type":"account_name"}, - {"name":"request_time", "type":"time_point_sec"}, - {"name":"net_amount", "type":"asset"}, - {"name":"cpu_amount", "type":"asset"} - ] - },{ - "name": "blockchain_parameters", - "base": "", - "fields": [ - - {"name":"max_block_net_usage", "type":"uint64"}, - {"name":"target_block_net_usage_pct", "type":"uint32"}, - {"name":"max_transaction_net_usage", "type":"uint32"}, - {"name":"base_per_transaction_net_usage", "type":"uint32"}, - {"name":"net_usage_leeway", "type":"uint32"}, - {"name":"context_free_discount_net_usage_num", "type":"uint32"}, - {"name":"context_free_discount_net_usage_den", "type":"uint32"}, - {"name":"max_block_cpu_usage", "type":"uint32"}, - {"name":"target_block_cpu_usage_pct", "type":"uint32"}, - {"name":"max_transaction_cpu_usage", "type":"uint32"}, - {"name":"min_transaction_cpu_usage", "type":"uint32"}, - {"name":"max_transaction_lifetime", "type":"uint32"}, - {"name":"deferred_trx_expiration_window", "type":"uint32"}, - {"name":"max_transaction_delay", "type":"uint32"}, - {"name":"max_inline_action_size", "type":"uint32"}, - {"name":"max_inline_action_depth", "type":"uint16"}, - {"name":"max_authority_depth", "type":"uint16"} - - ] - },{ - "name": "eosio_global_state", - "base": "blockchain_parameters", - "fields": [ - {"name":"max_ram_size", "type":"uint64"}, - {"name":"total_ram_bytes_reserved", "type":"uint64"}, - {"name":"total_ram_stake", "type":"int64"}, - {"name":"last_producer_schedule_update", "type":"block_timestamp_type"}, - {"name":"last_pervote_bucket_fill", "type":"uint64"}, - {"name":"pervote_bucket", "type":"int64"}, - {"name":"perblock_bucket", "type":"int64"}, - {"name":"total_unpaid_blocks", "type":"uint32"}, - {"name":"total_activated_stake", "type":"int64"}, - {"name":"thresh_activated_stake_time", "type":"uint64"}, - {"name":"last_producer_schedule_size", "type":"uint16"}, - {"name":"total_producer_vote_weight", "type":"float64"}, - {"name":"last_name_close", "type":"block_timestamp_type"} - ] - },{ - "name": "producer_info", - "base": "", - "fields": [ - {"name":"owner", "type":"account_name"}, - {"name":"total_votes", "type":"float64"}, - {"name":"producer_key", "type":"public_key"}, - {"name":"is_active", "type":"bool"}, - {"name":"url", "type":"string"}, - {"name":"unpaid_blocks", "type":"uint32"}, - {"name":"last_claim_time", "type":"uint64"}, - {"name":"location", "type":"uint16"} - ] - },{ - "name": "regproducer", - "base": "", - "fields": [ - {"name":"producer", "type":"account_name"}, - {"name":"producer_key", "type":"public_key"}, - {"name":"url", "type":"string"}, - {"name":"location", "type":"uint16"} - ] - },{ - "name": "unregprod", - "base": "", - "fields": [ - {"name":"producer", "type":"account_name"} - ] - },{ - "name": "setram", - "base": "", - "fields": [ - {"name":"max_ram_size", "type":"uint64"} - ] - },{ - "name": "regproxy", - "base": "", - "fields": [ - {"name":"proxy", "type":"account_name"}, - {"name":"isproxy", "type":"bool"} - ] - },{ - "name": "voteproducer", - "base": "", - "fields": [ - {"name":"voter", "type":"account_name"}, - {"name":"proxy", "type":"account_name"}, - {"name":"producers", "type":"account_name[]"} - ] - },{ - "name": "voter_info", - "base": "", - "fields": [ - {"name":"owner", "type":"account_name"}, - {"name":"proxy", "type":"account_name"}, - {"name":"producers", "type":"account_name[]"}, - {"name":"staked", "type":"int64"}, - {"name":"last_vote_weight", "type":"float64"}, - {"name":"proxied_vote_weight", "type":"float64"}, - {"name":"is_proxy", "type":"bool"} - ] - },{ - "name": "claimrewards", - "base": "", - "fields": [ - {"name":"owner", "type":"account_name"} - ] - },{ - "name": "setpriv", - "base": "", - "fields": [ - {"name":"account", "type":"account_name"}, - {"name":"is_priv", "type":"int8"} - ] - },{ - "name": "rmvproducer", - "base": "", - "fields": [ - {"name":"producer", "type":"account_name"} - ] - },{ - "name": "set_account_limits", - "base": "", - "fields": [ - {"name":"account", "type":"account_name"}, - {"name":"ram_bytes", "type":"int64"}, - {"name":"net_weight", "type":"int64"}, - {"name":"cpu_weight", "type":"int64"} - ] - },{ - "name": "set_global_limits", - "base": "", - "fields": [ - {"name":"cpu_usec_per_period", "type":"int64"} - ] - },{ - "name": "producer_key", - "base": "", - "fields": [ - {"name":"producer_name", "type":"account_name"}, - {"name":"block_signing_key", "type":"public_key"} - ] - },{ - "name": "set_producers", - "base": "", - "fields": [ - {"name":"schedule", "type":"producer_key[]"} - ] - },{ - "name": "require_auth", - "base": "", - "fields": [ - {"name":"from", "type":"account_name"} - ] - },{ - "name": "setparams", - "base": "", - "fields": [ - {"name":"params", "type":"blockchain_parameters"} - ] - },{ - "name": "connector", - "base": "", - "fields": [ - {"name":"balance", "type":"asset"}, - {"name":"weight", "type":"float64"} - ] - },{ - "name": "exchange_state", - "base": "", - "fields": [ - {"name":"supply", "type":"asset"}, - {"name":"base", "type":"connector"}, - {"name":"quote", "type":"connector"} - ] - }, { - "name": "namebid_info", - "base": "", - "fields": [ - {"name":"newname", "type":"account_name"}, - {"name":"high_bidder", "type":"account_name"}, - {"name":"high_bid", "type":"int64"}, - {"name":"last_bid_time", "type":"uint64"} - ] - } - ], - "actions": [{ - "name": "newaccount", - "type": "newaccount", - "ricardian_contract": "" - },{ - "name": "setcode", - "type": "setcode", - "ricardian_contract": "" - },{ - "name": "setabi", - "type": "setabi", - "ricardian_contract": "" - },{ - "name": "updateauth", - "type": "updateauth", - "ricardian_contract": "" - },{ - "name": "deleteauth", - "type": "deleteauth", - "ricardian_contract": "" - },{ - "name": "linkauth", - "type": "linkauth", - "ricardian_contract": "" - },{ - "name": "unlinkauth", - "type": "unlinkauth", - "ricardian_contract": "" - },{ - "name": "canceldelay", - "type": "canceldelay", - "ricardian_contract": "" - },{ - "name": "onerror", - "type": "onerror", - "ricardian_contract": "" - },{ - "name": "buyrambytes", - "type": "buyrambytes", - "ricardian_contract": "" - },{ - "name": "buyram", - "type": "buyram", - "ricardian_contract": "" - },{ - "name": "sellram", - "type": "sellram", - "ricardian_contract": "" - },{ - "name": "delegatebw", - "type": "delegatebw", - "ricardian_contract": "" - },{ - "name": "undelegatebw", - "type": "undelegatebw", - "ricardian_contract": "" - },{ - "name": "refund", - "type": "refund", - "ricardian_contract": "" - },{ - "name": "regproducer", - "type": "regproducer", - "ricardian_contract": "" - },{ - "name": "setram", - "type": "setram", - "ricardian_contract": "" - },{ - "name": "bidname", - "type": "bidname", - "ricardian_contract": "" - },{ - "name": "unregprod", - "type": "unregprod", - "ricardian_contract": "" - },{ - "name": "regproxy", - "type": "regproxy", - "ricardian_contract": "" - },{ - "name": "voteproducer", - "type": "voteproducer", - "ricardian_contract": "" - },{ - "name": "claimrewards", - "type": "claimrewards", - "ricardian_contract": "" - },{ - "name": "setpriv", - "type": "setpriv", - "ricardian_contract": "" - },{ - "name": "rmvproducer", - "type": "rmvproducer", - "ricardian_contract": "" - },{ - "name": "setalimits", - "type": "set_account_limits", - "ricardian_contract": "" - },{ - "name": "setglimits", - "type": "set_global_limits", - "ricardian_contract": "" - },{ - "name": "setprods", - "type": "set_producers", - "ricardian_contract": "" - },{ - "name": "reqauth", - "type": "require_auth", - "ricardian_contract": "" - },{ - "name": "setparams", - "type": "setparams", - "ricardian_contract": "" - }], - "tables": [{ - "name": "producers", - "type": "producer_info", - "index_type": "i64", - "key_names" : ["owner"], - "key_types" : ["uint64"] - },{ - "name": "global", - "type": "eosio_global_state", - "index_type": "i64", - "key_names" : [], - "key_types" : [] - },{ - "name": "voters", - "type": "voter_info", - "index_type": "i64", - "key_names" : ["owner"], - "key_types" : ["account_name"] - },{ - "name": "userres", - "type": "user_resources", - "index_type": "i64", - "key_names" : ["owner"], - "key_types" : ["uint64"] - },{ - "name": "delband", - "type": "delegated_bandwidth", - "index_type": "i64", - "key_names" : ["to"], - "key_types" : ["uint64"] - },{ - "name": "rammarket", - "type": "exchange_state", - "index_type": "i64", - "key_names" : ["supply"], - "key_types" : ["uint64"] - },{ - "name": "refunds", - "type": "refund_request", - "index_type": "i64", - "key_names" : ["owner"], - "key_types" : ["uint64"] - },{ - "name": "namebids", - "type": "namebid_info", - "index_type": "i64", - "key_names" : ["newname"], - "key_types" : ["account_name"] - } - ], - "ricardian_clauses": [], - "abi_extensions": [] -} diff --git a/eosio.token/bin/eosio.token/.gitignore b/eosio.token/bin/eosio.token/.gitignore new file mode 100644 index 000000000..e55130074 --- /dev/null +++ b/eosio.token/bin/eosio.token/.gitignore @@ -0,0 +1,2 @@ +eosio.token.abi +eosio.token.wasm diff --git a/eosio.token/bin/eosio.token/eosio.token.abi b/eosio.token/bin/eosio.token/eosio.token.abi deleted file mode 100644 index d769deb33..000000000 --- a/eosio.token/bin/eosio.token/eosio.token.abi +++ /dev/null @@ -1,78 +0,0 @@ -{ - "version": "eosio::abi/1.0", - "types": [{ - "new_type_name": "account_name", - "type": "name" - }], - "structs": [{ - "name": "transfer", - "base": "", - "fields": [ - {"name":"from", "type":"account_name"}, - {"name":"to", "type":"account_name"}, - {"name":"quantity", "type":"asset"}, - {"name":"memo", "type":"string"} - ] - },{ - "name": "create", - "base": "", - "fields": [ - {"name":"issuer", "type":"account_name"}, - {"name":"maximum_supply", "type":"asset"} - ] - },{ - "name": "issue", - "base": "", - "fields": [ - {"name":"to", "type":"account_name"}, - {"name":"quantity", "type":"asset"}, - {"name":"memo", "type":"string"} - ] - },{ - "name": "account", - "base": "", - "fields": [ - {"name":"balance", "type":"asset"} - ] - },{ - "name": "currency_stats", - "base": "", - "fields": [ - {"name":"supply", "type":"asset"}, - {"name":"max_supply", "type":"asset"}, - {"name":"issuer", "type":"account_name"} - ] - } - ], - "actions": [{ - "name": "transfer", - "type": "transfer", - "ricardian_contract": "" - },{ - "name": "issue", - "type": "issue", - "ricardian_contract": "" - }, { - "name": "create", - "type": "create", - "ricardian_contract": "" - } - - ], - "tables": [{ - "name": "accounts", - "type": "account", - "index_type": "i64", - "key_names" : ["currency"], - "key_types" : ["uint64"] - },{ - "name": "stat", - "type": "currency_stats", - "index_type": "i64", - "key_names" : ["currency"], - "key_types" : ["uint64"] - } - ], - "ricardian_clauses": [], - "abi_extensions": [] -} From 559c243626e2cae702712f77a2e9da5cebc155f7 Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Fri, 6 Jul 2018 18:32:32 -0400 Subject: [PATCH 12/28] eosio.ram payment problem #4 --- eosio.token/abi/eosio.token.abi | 4 ++++ eosio.token/include/eosio.token/eosio.token.hpp | 2 +- eosio.token/src/eosio.token.cpp | 4 ++-- tests/eosio.token_tests.cpp | 4 +--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/eosio.token/abi/eosio.token.abi b/eosio.token/abi/eosio.token.abi index 35926470c..9d600f14b 100644 --- a/eosio.token/abi/eosio.token.abi +++ b/eosio.token/abi/eosio.token.abi @@ -63,6 +63,10 @@ "name": "create", "type": "create", "ricardian_contract": "" + }, { + "name": "close", + "type": "close", + "ricardian_contract": "" } ], diff --git a/eosio.token/include/eosio.token/eosio.token.hpp b/eosio.token/include/eosio.token/eosio.token.hpp index 1ab0ffa19..e5b5fd288 100644 --- a/eosio.token/include/eosio.token/eosio.token.hpp +++ b/eosio.token/include/eosio.token/eosio.token.hpp @@ -31,7 +31,7 @@ namespace eosio { asset quantity, string memo ); - void close( account_name owner, symbol_name symbol ); + void close( account_name owner, symbol_type symbol ); inline asset get_supply( symbol_name sym )const; diff --git a/eosio.token/src/eosio.token.cpp b/eosio.token/src/eosio.token.cpp index 8abb8c85f..e39b1181e 100644 --- a/eosio.token/src/eosio.token.cpp +++ b/eosio.token/src/eosio.token.cpp @@ -111,9 +111,9 @@ void token::add_balance( account_name owner, asset value, account_name ram_payer } } -void token::close( account_name owner, symbol_name symbol ) { +void token::close( account_name owner, symbol_type symbol ) { accounts acnts( _self, owner ); - auto it = acnts.find( symbol ); + auto it = acnts.find( symbol.name() ); eosio_assert( it != acnts.end(), "Balance row already deleted or never existed. Action won't have any effect." ); eosio_assert( it->balance.amount == 0, "Cannot close because the balance is not zero." ); acnts.erase( it ); diff --git a/tests/eosio.token_tests.cpp b/tests/eosio.token_tests.cpp index a73e47eba..cd5f1f97e 100644 --- a/tests/eosio.token_tests.cpp +++ b/tests/eosio.token_tests.cpp @@ -94,11 +94,9 @@ class eosio_token_tester : public tester { action_result close( account_name owner, const string& symbolname ) { - auto symb = eosio::chain::symbol::from_string(symbolname); - auto symbol_code = symb.to_symbol_code().value; return push_action( owner, N(close), mvo() ( "owner", owner ) - ( "symbol", symbol_code.to_string() ) + ( "symbol", "0,CERO" ) ); } From 329313623ac39a412c8d1a075e22b84fac958f04 Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Mon, 9 Jul 2018 14:42:54 -0400 Subject: [PATCH 13/28] sellram bills eosio.ram balance storage to eosio.ram, unit-test for eosio.ram memory usage #4 --- eosio.system/src/delegate_bandwidth.cpp | 5 ++-- eosio.token/bin/eosio.token/eosio.token.abi | 11 ++++++++ tests/eosio.system_tests.cpp | 31 +++++++++++++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/eosio.system/src/delegate_bandwidth.cpp b/eosio.system/src/delegate_bandwidth.cpp index 9678c28e5..567d3a9dc 100644 --- a/eosio.system/src/delegate_bandwidth.cpp +++ b/eosio.system/src/delegate_bandwidth.cpp @@ -117,7 +117,7 @@ namespace eosiosystem { // quant_after_fee.amount should be > 0 if quant.amount > 1. // If quant.amount == 1, then quant_after_fee.amount == 0 and the next inline transfer will fail causing the buyram action to fail. - INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {payer,N(active)}, + INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {{payer,N(active)},{N(eosio.ram),N(active)}}, { payer, N(eosio.ram), quant_after_fee, std::string("buy ram") } ); if( fee.amount > 0 ) { @@ -188,12 +188,11 @@ namespace eosiosystem { }); set_resource_limits( res_itr->owner, res_itr->ram_bytes, res_itr->net_weight.amount, res_itr->cpu_weight.amount ); - INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(eosio.ram),N(active)}, + INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {{N(eosio.ram),N(active)},{account,N(active)}}, { N(eosio.ram), account, asset(tokens_out), std::string("sell ram") } ); auto fee = ( tokens_out.amount + 199 ) / 200; /// .5% fee (round up) // since tokens_out.amount was asserted to be at least 2 earlier, fee.amount < tokens_out.amount - if( fee > 0 ) { INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {account,N(active)}, { account, N(eosio.ramfee), asset(fee), std::string("sell ram fee") } ); diff --git a/eosio.token/bin/eosio.token/eosio.token.abi b/eosio.token/bin/eosio.token/eosio.token.abi index d769deb33..9d600f14b 100644 --- a/eosio.token/bin/eosio.token/eosio.token.abi +++ b/eosio.token/bin/eosio.token/eosio.token.abi @@ -28,6 +28,13 @@ {"name":"quantity", "type":"asset"}, {"name":"memo", "type":"string"} ] + },{ + "name": "close", + "base": "", + "fields": [ + {"name":"owner", "type":"account_name"}, + {"name":"symbol", "type":"symbol"}, + ] },{ "name": "account", "base": "", @@ -56,6 +63,10 @@ "name": "create", "type": "create", "ricardian_contract": "" + }, { + "name": "close", + "type": "close", + "ricardian_contract": "" } ], diff --git a/tests/eosio.system_tests.cpp b/tests/eosio.system_tests.cpp index 6ff7a9649..8a40140de 100644 --- a/tests/eosio.system_tests.cpp +++ b/tests/eosio.system_tests.cpp @@ -2584,6 +2584,37 @@ BOOST_FIXTURE_TEST_CASE( setram_effect, eosio_system_tester ) try { } } FC_LOG_AND_RETHROW() + +BOOST_FIXTURE_TEST_CASE( eosioram_ramusage, eosio_system_tester ) try { + BOOST_REQUIRE_EQUAL( core_from_string("0.0000"), get_balance( "alice1111111" ) ); + transfer( "eosio", "alice1111111", core_from_string("1000.0000"), "eosio" ); + BOOST_REQUIRE_EQUAL( success(), stake( "eosio", "alice1111111", core_from_string("200.0000"), core_from_string("100.0000") ) ); + + const asset initial_ram_balance = get_balance(N(eosio.ram)); + const asset initial_ramfee_balance = get_balance(N(eosio.ramfee)); + BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", core_from_string("1000.0000") ) ); + + BOOST_REQUIRE_EQUAL( false, get_row_by_account( N(eosio.token), N(alice1111111), N(accounts), symbol().to_symbol_code() ).empty() ); + + //remove row + base_tester::push_action( N(eosio.token), N(close), N(alice1111111), mvo() + ( "owner", "alice1111111" ) + ( "symbol", symbol() ) + ); + BOOST_REQUIRE_EQUAL( true, get_row_by_account( N(eosio.token), N(alice1111111), N(accounts), symbol().to_symbol_code() ).empty() ); + + auto rlm = control->get_resource_limits_manager(); + auto eosioram_ram_usage = rlm.get_account_ram_usage(N(eosio.ram)); + auto alice_ram_usage = rlm.get_account_ram_usage(N(alice1111111)); + //std::cout << "Sellram" << std::endl; + BOOST_REQUIRE_EQUAL( success(), sellram( "alice1111111", 2048 ) ); + + //make sure that ram was billed to alice, not to eosio.ram + BOOST_REQUIRE_EQUAL( true, alice_ram_usage < rlm.get_account_ram_usage(N(alice1111111)) ); + BOOST_REQUIRE_EQUAL( eosioram_ram_usage, rlm.get_account_ram_usage(N(eosio.ram)) ); + +} FC_LOG_AND_RETHROW() + BOOST_AUTO_TEST_SUITE_END() void translate_fc_exception(const fc::exception &e) { From a8ac8306f59a9c9e9557b85cb05aa66f85c7cb8e Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Mon, 9 Jul 2018 17:30:34 -0400 Subject: [PATCH 14/28] retire tokens #6 --- eosio.token/abi/eosio.token.abi | 11 ++++ .../include/eosio.token/eosio.token.hpp | 2 + eosio.token/src/eosio.token.cpp | 27 +++++++- tests/eosio.token_tests.cpp | 65 +++++++++++++++++++ 4 files changed, 104 insertions(+), 1 deletion(-) diff --git a/eosio.token/abi/eosio.token.abi b/eosio.token/abi/eosio.token.abi index 9d600f14b..b7352d365 100644 --- a/eosio.token/abi/eosio.token.abi +++ b/eosio.token/abi/eosio.token.abi @@ -28,6 +28,13 @@ {"name":"quantity", "type":"asset"}, {"name":"memo", "type":"string"} ] + },{ + "name": "retire", + "base": "", + "fields": [ + {"name":"quantity", "type":"asset"}, + {"name":"memo", "type":"string"} + ] },{ "name": "close", "base": "", @@ -59,6 +66,10 @@ "name": "issue", "type": "issue", "ricardian_contract": "" + },{ + "name": "retire", + "type": "retire", + "ricardian_contract": "" }, { "name": "create", "type": "create", diff --git a/eosio.token/include/eosio.token/eosio.token.hpp b/eosio.token/include/eosio.token/eosio.token.hpp index e5b5fd288..629524ad0 100644 --- a/eosio.token/include/eosio.token/eosio.token.hpp +++ b/eosio.token/include/eosio.token/eosio.token.hpp @@ -26,6 +26,8 @@ namespace eosio { void issue( account_name to, asset quantity, string memo ); + void retire( asset quantity, string memo ); + void transfer( account_name from, account_name to, asset quantity, diff --git a/eosio.token/src/eosio.token.cpp b/eosio.token/src/eosio.token.cpp index e39b1181e..ff25071d6 100644 --- a/eosio.token/src/eosio.token.cpp +++ b/eosio.token/src/eosio.token.cpp @@ -59,6 +59,31 @@ void token::issue( account_name to, asset quantity, string memo ) } } +void token::retire( asset quantity, string memo ) +{ + auto sym = quantity.symbol; + eosio_assert( sym.is_valid(), "invalid symbol name" ); + eosio_assert( memo.size() <= 256, "memo has more than 256 bytes" ); + + auto sym_name = sym.name(); + stats statstable( _self, sym_name ); + auto existing = statstable.find( sym_name ); + eosio_assert( existing != statstable.end(), "token with symbol does not exist" ); + const auto& st = *existing; + + require_auth( st.issuer ); + eosio_assert( quantity.is_valid(), "invalid quantity" ); + eosio_assert( quantity.amount > 0, "must retire positive quantity" ); + + eosio_assert( quantity.symbol == st.supply.symbol, "symbol precision mismatch" ); + + statstable.modify( st, 0, [&]( auto& s ) { + s.supply -= quantity; + }); + + sub_balance( st.issuer, quantity ); +} + void token::transfer( account_name from, account_name to, asset quantity, @@ -121,4 +146,4 @@ void token::close( account_name owner, symbol_type symbol ) { } /// namespace eosio -EOSIO_ABI( eosio::token, (create)(issue)(transfer)(close) ) +EOSIO_ABI( eosio::token, (create)(issue)(transfer)(close)(retire) ) diff --git a/tests/eosio.token_tests.cpp b/tests/eosio.token_tests.cpp index cd5f1f97e..093d8d0f1 100644 --- a/tests/eosio.token_tests.cpp +++ b/tests/eosio.token_tests.cpp @@ -80,6 +80,14 @@ class eosio_token_tester : public tester { ); } + action_result retire( account_name issuer, asset quantity, string memo ) { + return push_action( issuer, N(retire), mvo() + ( "quantity", quantity) + ( "memo", memo) + ); + + } + action_result transfer( account_name from, account_name to, asset quantity, @@ -225,6 +233,63 @@ BOOST_FIXTURE_TEST_CASE( issue_tests, eosio_token_tester ) try { } FC_LOG_AND_RETHROW() +BOOST_FIXTURE_TEST_CASE( retire_tests, eosio_token_tester ) try { + + auto token = create( N(alice), asset::from_string("1000.000 TKN")); + produce_blocks(1); + + BOOST_REQUIRE_EQUAL( success(), issue( N(alice), N(alice), asset::from_string("500.000 TKN"), "hola" ) ); + + auto stats = get_stats("3,TKN"); + REQUIRE_MATCHING_OBJECT( stats, mvo() + ("supply", "500.000 TKN") + ("max_supply", "1000.000 TKN") + ("issuer", "alice") + ); + + auto alice_balance = get_account(N(alice), "3,TKN"); + REQUIRE_MATCHING_OBJECT( alice_balance, mvo() + ("balance", "500.000 TKN") + ); + + BOOST_REQUIRE_EQUAL( success(), retire( N(alice), asset::from_string("200.000 TKN"), "hola" ) ); + stats = get_stats("3,TKN"); + REQUIRE_MATCHING_OBJECT( stats, mvo() + ("supply", "300.000 TKN") + ("max_supply", "1000.000 TKN") + ("issuer", "alice") + ); + alice_balance = get_account(N(alice), "3,TKN"); + REQUIRE_MATCHING_OBJECT( alice_balance, mvo() + ("balance", "300.000 TKN") + ); + + //should fail to retire more than current supply + BOOST_REQUIRE_EQUAL( wasm_assert_msg("overdrawn balance"), retire( N(alice), asset::from_string("500.000 TKN"), "hola" ) ); + + BOOST_REQUIRE_EQUAL( success(), transfer( N(alice), N(bob), asset::from_string("200.000 TKN"), "hola" ) ); + //should fail to retire since tokens are not on the issuer's balance + BOOST_REQUIRE_EQUAL( wasm_assert_msg("overdrawn balance"), retire( N(alice), asset::from_string("300.000 TKN"), "hola" ) ); + //transfer tokens back + BOOST_REQUIRE_EQUAL( success(), transfer( N(bob), N(alice), asset::from_string("200.000 TKN"), "hola" ) ); + + BOOST_REQUIRE_EQUAL( success(), retire( N(alice), asset::from_string("300.000 TKN"), "hola" ) ); + stats = get_stats("3,TKN"); + REQUIRE_MATCHING_OBJECT( stats, mvo() + ("supply", "0.000 TKN") + ("max_supply", "1000.000 TKN") + ("issuer", "alice") + ); + alice_balance = get_account(N(alice), "3,TKN"); + REQUIRE_MATCHING_OBJECT( alice_balance, mvo() + ("balance", "0.000 TKN") + ); + + //trying to retire tokens with zero supply + BOOST_REQUIRE_EQUAL( wasm_assert_msg("overdrawn balance"), retire( N(alice), asset::from_string("1.000 TKN"), "hola" ) ); + +} FC_LOG_AND_RETHROW() + BOOST_FIXTURE_TEST_CASE( transfer_tests, eosio_token_tester ) try { auto token = create( N(alice), asset::from_string("1000 CERO")); From ec31a4300dbbfa595ee56a4433423efb7512f22f Mon Sep 17 00:00:00 2001 From: Khaled Al-Hassanieh Date: Mon, 9 Jul 2018 18:17:43 -0400 Subject: [PATCH 15/28] setramrate testing --- eosio.system/src/eosio.system.cpp | 2 ++ tests/eosio.system_tester.hpp | 4 ++++ tests/eosio.system_tests.cpp | 25 ++++++++++++++++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/eosio.system/src/eosio.system.cpp b/eosio.system/src/eosio.system.cpp index f34117b5c..b26f4a249 100644 --- a/eosio.system/src/eosio.system.cpp +++ b/eosio.system/src/eosio.system.cpp @@ -109,6 +109,8 @@ namespace eosiosystem { } else { update_ram_supply(); } + + _global2.set( _gstate2, _self ); } void system_contract::setparams( const eosio::blockchain_parameters& params ) { diff --git a/tests/eosio.system_tester.hpp b/tests/eosio.system_tester.hpp index ff90f8d3d..7ce52211c 100644 --- a/tests/eosio.system_tester.hpp +++ b/tests/eosio.system_tester.hpp @@ -386,7 +386,11 @@ class eosio_system_tester : public TESTER { vector data = get_row_by_account( config::system_account_name, config::system_account_name, N(global), N(global) ); if (data.empty()) std::cout << "\nData is empty\n" << std::endl; return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "eosio_global_state", data ); + } + fc::variant get_global_state2() { + vector data = get_row_by_account( config::system_account_name, config::system_account_name, N(global2), N(global2) ); + return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "eosio_global_state2", data ); } fc::variant get_refund_request( name account ) { diff --git a/tests/eosio.system_tests.cpp b/tests/eosio.system_tests.cpp index 6ff7a9649..cf3cc7f17 100644 --- a/tests/eosio.system_tests.cpp +++ b/tests/eosio.system_tests.cpp @@ -1380,7 +1380,6 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t } FC_LOG_AND_RETHROW() - BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::unit_test::tolerance(1e-10)) try { auto within_one = [](int64_t a, int64_t b) -> bool { return std::abs( a - b ) <= 1; }; @@ -2584,6 +2583,30 @@ BOOST_FIXTURE_TEST_CASE( setram_effect, eosio_system_tester ) try { } } FC_LOG_AND_RETHROW() + +BOOST_FIXTURE_TEST_CASE( ram_inflation, eosio_system_tester ) try { + + const uint64_t init_max_ram_size = 64ll*1024 * 1024 * 1024; + + BOOST_REQUIRE_EQUAL( init_max_ram_size, get_global_state()["max_ram_size"].as_uint64() ); + produce_blocks(20); + BOOST_REQUIRE_EQUAL( init_max_ram_size, get_global_state()["max_ram_size"].as_uint64() ); + transfer( config::system_account_name, "alice1111111", core_from_string("1000.0000"), config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", core_from_string("100.0000") ) ); + produce_block(); + BOOST_REQUIRE_EQUAL( init_max_ram_size, get_global_state()["max_ram_size"].as_uint64() ); + + BOOST_REQUIRE_EQUAL( success(), push_action(config::system_account_name, N(setramrate), mvo()("bytes_per_block", 1000)) ); + BOOST_REQUIRE_EQUAL( 1000, get_global_state2()["new_ram_per_block"].as() ); + produce_blocks(100); + BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", core_from_string("100.0000") ) ); + BOOST_REQUIRE_EQUAL( init_max_ram_size, get_global_state()["max_ram_size"].as_uint64() ); + produce_blocks(100); + BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", core_from_string("100.0000") ) ); + BOOST_REQUIRE_EQUAL( init_max_ram_size, get_global_state()["max_ram_size"].as_uint64() ); + +} FC_LOG_AND_RETHROW() + BOOST_AUTO_TEST_SUITE_END() void translate_fc_exception(const fc::exception &e) { From 846b8901de2ce058d9e0f812f206f6b8e85c30b6 Mon Sep 17 00:00:00 2001 From: Bucky Kittinger Date: Tue, 10 Jul 2018 11:17:21 -0400 Subject: [PATCH 16/28] Small changes for Linux and build script --- UnitTestsExternalProject.txt | 2 +- build.sh | 57 ++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100755 build.sh diff --git a/UnitTestsExternalProject.txt b/UnitTestsExternalProject.txt index f05d9ec28..2091f8d7c 100644 --- a/UnitTestsExternalProject.txt +++ b/UnitTestsExternalProject.txt @@ -4,7 +4,7 @@ include(GNUInstallDirs) ExternalProject_Add( contracts_unit_tests - CMAKE_ARGS -DROOT_DIR=${CMAKE_SOURCE_DIR} -DEOSIO_INSTALL_PREFIX=${WASM_ROOT}/eosio -DOPENSSL_INSTALL_PREFIX=${OPENSSL_ROOT} -DSECP256K1_INSTALL_LIB=${SECP256K1_ROOT} -DBOOST_ROOT=${Boost_INCLUDE_DIRS}/../ + CMAKE_ARGS -DROOT_DIR=${CMAKE_SOURCE_DIR} -DEOSIO_INSTALL_PREFIX=${WASM_ROOT}/eosio -DOPENSSL_INSTALL_PREFIX=${OPENSSL_ROOT} -DSECP256K1_INSTALL_LIB=${SECP256K1_ROOT} -DBOOST_ROOT=${BOOST_ROOT}/include -DCMAKE_CXX_COMPILER=${CXX_COMPILER} SOURCE_DIR ${CMAKE_SOURCE_DIR}/tests BINARY_DIR ${CMAKE_SOURCE_DIR}/build/tests diff --git a/build.sh b/build.sh new file mode 100755 index 000000000..1175fdef3 --- /dev/null +++ b/build.sh @@ -0,0 +1,57 @@ +#! /bin/bash + +printf "\t=========== Building eosio.contracts ===========\n\n" + +RED='\033[0;31m' +NC='\033[0m' + +if [ ! -d "/usr/local/eosio.wasmsdk" ]; then + printf "${RED}Error, please ensure that eosio.wasmsdk is installed correctly!\n\n${NC}" + exit -1 +fi + +unamestr=`uname` +if [[ "${unamestr}" == 'Darwin' ]]; then + BOOST=/usr/local + CXX_COMPILER=g++ +else + BOOST=~/opt/boost + OS_NAME=$( cat /etc/os-release | grep ^NAME | cut -d'=' -f2 | sed 's/\"//gI' ) + + case "$OS_NAME" in + "Amazon Linux AMI") + CXX_COMPILER=g++ + C_COMPILER=gcc + ;; + "CentOS Linux") + CXX_COMPILER=g++ + C_COMPILER=gcc + ;; + "elementary OS") + CXX_COMPILER=clang++-4.0 + C_COMPILER=clang-4.0 + ;; + "Fedora") + CXX_COMPILER=g++ + C_COMPILER=gcc + ;; + "Linux Mint") + CXX_COMPILER=clang++-4.0 + C_COMPILER=clang-4.0 + ;; + "Ubuntu") + CXX_COMPILER=clang++-4.0 + C_COMPILER=clang-4.0 + ;; + *) + printf "\\n\\tUnsupported Linux Distribution. Exiting now.\\n\\n" + exit 1 + esac +fi + +CORES=`getconf _NPROCESSORS_ONLN` +mkdir -p build +pushd build &> /dev/null +cmake -DCXX_COMPILER="${CXX_COMPILER}" -DBOOST_ROOT="${BOOST}" ../ +make -j${CORES} +popd &> /dev/null From 7c925aa0d286474fcb688e1f5e8c067d62aeedcd Mon Sep 17 00:00:00 2001 From: Khaled Al-Hassanieh Date: Tue, 10 Jul 2018 11:53:28 -0400 Subject: [PATCH 17/28] setramrate testing, fixes --- eosio.system/src/eosio.system.cpp | 4 +--- tests/eosio.system_tests.cpp | 30 +++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/eosio.system/src/eosio.system.cpp b/eosio.system/src/eosio.system.cpp index b26f4a249..223f4ef9b 100644 --- a/eosio.system/src/eosio.system.cpp +++ b/eosio.system/src/eosio.system.cpp @@ -109,8 +109,6 @@ namespace eosiosystem { } else { update_ram_supply(); } - - _global2.set( _gstate2, _self ); } void system_contract::setparams( const eosio::blockchain_parameters& params ) { @@ -229,7 +227,7 @@ EOSIO_ABI( eosiosystem::system_contract, // native.hpp (newaccount definition is actually in eosio.system.cpp) (newaccount)(updateauth)(deleteauth)(linkauth)(unlinkauth)(canceldelay)(onerror) // eosio.system.cpp - (setram)(setparams)(setpriv)(rmvproducer)(bidname) + (setram)(setramrate)(setparams)(setpriv)(rmvproducer)(bidname) // delegate_bandwidth.cpp (buyrambytes)(buyram)(sellram)(delegatebw)(undelegatebw)(refund) // voting.cpp diff --git a/tests/eosio.system_tests.cpp b/tests/eosio.system_tests.cpp index cf3cc7f17..3a8a456ab 100644 --- a/tests/eosio.system_tests.cpp +++ b/tests/eosio.system_tests.cpp @@ -2593,17 +2593,29 @@ BOOST_FIXTURE_TEST_CASE( ram_inflation, eosio_system_tester ) try { BOOST_REQUIRE_EQUAL( init_max_ram_size, get_global_state()["max_ram_size"].as_uint64() ); transfer( config::system_account_name, "alice1111111", core_from_string("1000.0000"), config::system_account_name ); BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", core_from_string("100.0000") ) ); - produce_block(); - BOOST_REQUIRE_EQUAL( init_max_ram_size, get_global_state()["max_ram_size"].as_uint64() ); - - BOOST_REQUIRE_EQUAL( success(), push_action(config::system_account_name, N(setramrate), mvo()("bytes_per_block", 1000)) ); - BOOST_REQUIRE_EQUAL( 1000, get_global_state2()["new_ram_per_block"].as() ); - produce_blocks(100); - BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", core_from_string("100.0000") ) ); + produce_blocks(3); BOOST_REQUIRE_EQUAL( init_max_ram_size, get_global_state()["max_ram_size"].as_uint64() ); - produce_blocks(100); + const uint16_t rate = 1000; + BOOST_REQUIRE_EQUAL( success(), push_action( config::system_account_name, N(setramrate), mvo()("bytes_per_block", rate) ) ); + BOOST_REQUIRE_EQUAL( rate, get_global_state2()["new_ram_per_block"].as() ); + // last time update_ram_supply called is in buyram, num of blocks since then is 1 + 3 = 4 + uint64_t cur_ram_size = get_global_state()["max_ram_size"].as_uint64(); + BOOST_REQUIRE_EQUAL( init_max_ram_size + 4 * rate, get_global_state()["max_ram_size"].as_uint64() ); + produce_blocks(10); BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", core_from_string("100.0000") ) ); - BOOST_REQUIRE_EQUAL( init_max_ram_size, get_global_state()["max_ram_size"].as_uint64() ); + BOOST_REQUIRE_EQUAL( cur_ram_size + 11 * rate, get_global_state()["max_ram_size"].as_uint64() ); + cur_ram_size = get_global_state()["max_ram_size"].as_uint64(); + produce_blocks(5); + BOOST_REQUIRE_EQUAL( cur_ram_size, get_global_state()["max_ram_size"].as_uint64() ); + BOOST_REQUIRE_EQUAL( success(), sellram( "alice1111111", 100 ) ); + BOOST_REQUIRE_EQUAL( cur_ram_size + 6 * rate, get_global_state()["max_ram_size"].as_uint64() ); + cur_ram_size = get_global_state()["max_ram_size"].as_uint64(); + produce_blocks(); + BOOST_REQUIRE_EQUAL( success(), buyrambytes( "alice1111111", "alice1111111", 100 ) ); + BOOST_REQUIRE_EQUAL( cur_ram_size + 2 * rate, get_global_state()["max_ram_size"].as_uint64() ); + + BOOST_REQUIRE_EQUAL( error("missing authority of eosio"), + push_action( "alice1111111", N(setramrate), mvo()("bytes_per_block", rate) ) ); } FC_LOG_AND_RETHROW() From 9a2ae4f853e10d077f089aeabf4f5af3cf8b3db0 Mon Sep 17 00:00:00 2001 From: Khaled Al-Hassanieh Date: Tue, 10 Jul 2018 16:44:45 -0400 Subject: [PATCH 18/28] Fix unit test build issues --- tests/eosio.msig_tests.cpp | 10 +++++----- tests/eosio.sudo_tests.cpp | 6 +++--- tests/eosio.system_tester.hpp | 26 +++++++++++++------------- tests/eosio.system_tests.cpp | 8 ++++---- tests/eosio.token_tests.cpp | 8 ++++---- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/tests/eosio.msig_tests.cpp b/tests/eosio.msig_tests.cpp index ce01cc85d..d6439d696 100644 --- a/tests/eosio.msig_tests.cpp +++ b/tests/eosio.msig_tests.cpp @@ -36,7 +36,7 @@ class eosio_msig_tester : public tester { const auto& accnt = control->db().get( N(eosio.msig) ); abi_def abi; BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.abi, abi), true); - abi_ser.set_abi(abi); + abi_ser.set_abi(abi, abi_serializer_max_time); } transaction_trace_ptr create_account_with_resources( account_name a, account_name creator, asset ramfunds, bool multisig, @@ -174,7 +174,7 @@ transaction eosio_msig_tester::reqauth( account_name from, const vectordb().get( N(eosio.sudo) ); abi_def abi; BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.abi, abi), true); - abi_ser.set_abi(abi); + abi_ser.set_abi(abi, abi_serializer_max_time); while( control->pending_block_state()->header.producer.to_string() == "eosio" ) { produce_block(); @@ -134,7 +134,7 @@ transaction eosio_sudo_tester::sudo_exec( account_name executer, const transacti transaction trx2; set_transaction_headers(trx2, expiration); action act; - abi_serializer::from_variant( act_obj, act, get_resolver() ); + abi_serializer::from_variant( act_obj, act, get_resolver(), abi_serializer_max_time ); trx2.actions.push_back( std::move(act) ); return trx2; } @@ -155,7 +155,7 @@ transaction eosio_sudo_tester::reqauth( account_name from, const vectordb().get( N(eosio.token) ); abi_def abi; BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.abi, abi), true); - token_abi_ser.set_abi(abi); + token_abi_ser.set_abi(abi, abi_serializer_max_time); } create_currency( N(eosio.token), config::system_account_name, core_from_string("10000000000.0000") ); @@ -63,7 +63,7 @@ class eosio_system_tester : public TESTER { const auto& accnt = control->db().get( config::system_account_name ); abi_def abi; BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.abi, abi), true); - abi_ser.set_abi(abi); + abi_ser.set_abi(abi, abi_serializer_max_time); } produce_blocks(); @@ -219,7 +219,7 @@ class eosio_system_tester : public TESTER { action act; act.account = config::system_account_name; act.name = name; - act.data = abi_ser.variant_to_binary( action_type_name, data ); + act.data = abi_ser.variant_to_binary( action_type_name, data, abi_serializer_max_time ); return base_tester::push_action( std::move(act), auth ? uint64_t(signer) : signer == N(bob111111111) ? N(alice1111111) : N(bob111111111) ); } @@ -320,22 +320,22 @@ class eosio_system_tester : public TESTER { asset get_balance( const account_name& act ) { vector data = get_row_by_account( N(eosio.token), act, N(accounts), symbol(CORE_SYMBOL).to_symbol_code().value ); - return data.empty() ? asset(0, symbol(CORE_SYMBOL)) : token_abi_ser.binary_to_variant("account", data)["balance"].as(); + return data.empty() ? asset(0, symbol(CORE_SYMBOL)) : token_abi_ser.binary_to_variant("account", data, abi_serializer_max_time)["balance"].as(); } fc::variant get_total_stake( const account_name& act ) { vector data = get_row_by_account( config::system_account_name, act, N(userres), act ); - return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "user_resources", data ); + return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "user_resources", data, abi_serializer_max_time ); } fc::variant get_voter_info( const account_name& act ) { vector data = get_row_by_account( config::system_account_name, config::system_account_name, N(voters), act ); - return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "voter_info", data ); + return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "voter_info", data, abi_serializer_max_time ); } fc::variant get_producer_info( const account_name& act ) { vector data = get_row_by_account( config::system_account_name, config::system_account_name, N(producers), act ); - return abi_ser.binary_to_variant( "producer_info", data ); + return abi_ser.binary_to_variant( "producer_info", data, abi_serializer_max_time ); } void create_currency( name contract, name manager, asset maxsupply ) { @@ -375,7 +375,7 @@ class eosio_system_tester : public TESTER { auto symb = eosio::chain::symbol::from_string(symbolname); auto symbol_code = symb.to_symbol_code().value; vector data = get_row_by_account( N(eosio.token), symbol_code, N(stat), symbol_code ); - return data.empty() ? fc::variant() : token_abi_ser.binary_to_variant( "currency_stats", data ); + return data.empty() ? fc::variant() : token_abi_ser.binary_to_variant( "currency_stats", data, abi_serializer_max_time ); } asset get_token_supply() { @@ -385,17 +385,17 @@ class eosio_system_tester : public TESTER { fc::variant get_global_state() { vector data = get_row_by_account( config::system_account_name, config::system_account_name, N(global), N(global) ); if (data.empty()) std::cout << "\nData is empty\n" << std::endl; - return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "eosio_global_state", data ); + return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "eosio_global_state", data, abi_serializer_max_time ); } fc::variant get_global_state2() { vector data = get_row_by_account( config::system_account_name, config::system_account_name, N(global2), N(global2) ); - return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "eosio_global_state2", data ); + return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "eosio_global_state2", data, abi_serializer_max_time ); } fc::variant get_refund_request( name account ) { vector data = get_row_by_account( config::system_account_name, account, N(refunds), account ); - return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "refund_request", data ); + return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "refund_request", data, abi_serializer_max_time ); } abi_serializer initialize_multisig() { @@ -418,7 +418,7 @@ class eosio_system_tester : public TESTER { const auto& accnt = control->db().get( N(eosio.msig) ); abi_def msig_abi; BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.abi, msig_abi), true); - msig_abi_ser.set_abi(msig_abi); + msig_abi_ser.set_abi(msig_abi, abi_serializer_max_time); } return msig_abi_ser; } diff --git a/tests/eosio.system_tests.cpp b/tests/eosio.system_tests.cpp index 3a8a456ab..325c219d1 100644 --- a/tests/eosio.system_tests.cpp +++ b/tests/eosio.system_tests.cpp @@ -1697,7 +1697,7 @@ BOOST_FIXTURE_TEST_CASE(producers_upgrade_system_contract, eosio_system_tester) action act; act.account = N(eosio.msig); act.name = name; - act.data = msig_abi_ser.variant_to_binary( action_type_name, data ); + act.data = msig_abi_ser.variant_to_binary( action_type_name, data, abi_serializer_max_time ); return base_tester::push_action( std::move(act), auth ? uint64_t(signer) : signer == N(bob111111111) ? N(alice1111111) : N(bob111111111) ); }; @@ -1736,7 +1736,7 @@ BOOST_FIXTURE_TEST_CASE(producers_upgrade_system_contract, eosio_system_tester) ) }) ); - abi_serializer::from_variant(pretty_trx, trx, get_resolver()); + abi_serializer::from_variant(pretty_trx, trx, get_resolver(), abi_serializer_max_time); } BOOST_REQUIRE_EQUAL(success(), push_action_msig( N(alice1111111), N(propose), mvo() @@ -2457,7 +2457,7 @@ BOOST_FIXTURE_TEST_CASE( setparams, eosio_system_tester ) try { action act; act.account = N(eosio.msig); act.name = name; - act.data = msig_abi_ser.variant_to_binary( action_type_name, data ); + act.data = msig_abi_ser.variant_to_binary( action_type_name, data, abi_serializer_max_time ); return base_tester::push_action( std::move(act), auth ? uint64_t(signer) : signer == N(bob111111111) ? N(alice1111111) : N(bob111111111) ); }; @@ -2493,7 +2493,7 @@ BOOST_FIXTURE_TEST_CASE( setparams, eosio_system_tester ) try { ) }) ); - abi_serializer::from_variant(pretty_trx, trx, get_resolver()); + abi_serializer::from_variant(pretty_trx, trx, get_resolver(), abi_serializer_max_time); } BOOST_REQUIRE_EQUAL(success(), push_action_msig( N(alice1111111), N(propose), mvo() diff --git a/tests/eosio.token_tests.cpp b/tests/eosio.token_tests.cpp index 0fcc7b62d..28a6b596b 100644 --- a/tests/eosio.token_tests.cpp +++ b/tests/eosio.token_tests.cpp @@ -33,7 +33,7 @@ class eosio_token_tester : public tester { const auto& accnt = control->db().get( N(eosio.token) ); abi_def abi; BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.abi, abi), true); - abi_ser.set_abi(abi); + abi_ser.set_abi(abi, abi_serializer_max_time); } action_result push_action( const account_name& signer, const action_name &name, const variant_object &data ) { @@ -42,7 +42,7 @@ class eosio_token_tester : public tester { action act; act.account = N(eosio.token); act.name = name; - act.data = abi_ser.variant_to_binary( action_type_name, data ); + act.data = abi_ser.variant_to_binary( action_type_name, data, abi_serializer_max_time ); return base_tester::push_action( std::move(act), uint64_t(signer)); } @@ -52,7 +52,7 @@ class eosio_token_tester : public tester { auto symb = eosio::chain::symbol::from_string(symbolname); auto symbol_code = symb.to_symbol_code().value; vector data = get_row_by_account( N(eosio.token), symbol_code, N(stat), symbol_code ); - return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "currency_stats", data ); + return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "currency_stats", data, abi_serializer_max_time ); } fc::variant get_account( account_name acc, const string& symbolname) @@ -60,7 +60,7 @@ class eosio_token_tester : public tester { auto symb = eosio::chain::symbol::from_string(symbolname); auto symbol_code = symb.to_symbol_code().value; vector data = get_row_by_account( N(eosio.token), acc, N(accounts), symbol_code ); - return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "account", data ); + return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "account", data, abi_serializer_max_time ); } action_result create( account_name issuer, From 2efcc4ac20a9ffe12a8b41027a97de4cdb7df61b Mon Sep 17 00:00:00 2001 From: Khaled Al-Hassanieh Date: Tue, 10 Jul 2018 17:59:03 -0400 Subject: [PATCH 19/28] Fix rammarket connector weights --- eosio.system/src/exchange_state.cpp | 6 ++---- tests/eosio.system_tests.cpp | 11 +++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/eosio.system/src/exchange_state.cpp b/eosio.system/src/exchange_state.cpp index 621d3e714..b01169038 100644 --- a/eosio.system/src/exchange_state.cpp +++ b/eosio.system/src/exchange_state.cpp @@ -5,12 +5,11 @@ namespace eosiosystem { real_type R(supply.amount); real_type C(c.balance.amount+in.amount); - real_type F(c.weight/1000.0); + real_type F(c.weight); real_type T(in.amount); real_type ONE(1.0); real_type E = -R * (ONE - std::pow( ONE + T / C, F) ); - //print( "E: ", E, "\n"); int64_t issued = int64_t(E); supply.amount += issued; @@ -24,7 +23,7 @@ namespace eosiosystem { real_type R(supply.amount - in.amount); real_type C(c.balance.amount); - real_type F(1000.0/c.weight); + real_type F(1.0/c.weight); real_type E(in.amount); real_type ONE(1.0); @@ -36,7 +35,6 @@ namespace eosiosystem { // real_type T = C * std::expm1( F * std::log1p(E/R) ); real_type T = C * (std::pow( ONE + E/R, F) - ONE); - //print( "T: ", T, "\n"); int64_t out = int64_t(T); supply.amount -= in.amount; diff --git a/tests/eosio.system_tests.cpp b/tests/eosio.system_tests.cpp index 325c219d1..b161126dd 100644 --- a/tests/eosio.system_tests.cpp +++ b/tests/eosio.system_tests.cpp @@ -68,7 +68,7 @@ BOOST_FIXTURE_TEST_CASE( buysell, eosio_system_tester ) try { wdump((init_bytes)(bought_bytes)(bytes) ); BOOST_REQUIRE_EQUAL( true, total["ram_bytes"].as_uint64() == init_bytes ); - BOOST_REQUIRE_EQUAL( core_from_string("99901248.0041"), get_balance( "alice1111111" ) ); + BOOST_REQUIRE_EQUAL( core_from_string("99901248.0048"), get_balance( "alice1111111" ) ); BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", core_from_string("100.0000") ) ); BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", core_from_string("100.0000") ) ); @@ -79,7 +79,7 @@ BOOST_FIXTURE_TEST_CASE( buysell, eosio_system_tester ) try { BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", core_from_string("10.0000") ) ); BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", core_from_string("10.0000") ) ); BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", core_from_string("30.0000") ) ); - BOOST_REQUIRE_EQUAL( core_from_string("99900688.0041"), get_balance( "alice1111111" ) ); + BOOST_REQUIRE_EQUAL( core_from_string("99900688.0048"), get_balance( "alice1111111" ) ); auto newtotal = get_total_stake( "alice1111111" ); @@ -88,8 +88,7 @@ BOOST_FIXTURE_TEST_CASE( buysell, eosio_system_tester ) try { wdump((newbytes)(bytes)(bought_bytes) ); BOOST_REQUIRE_EQUAL( success(), sellram( "alice1111111", bought_bytes ) ); - BOOST_REQUIRE_EQUAL( core_from_string("99901242.4179"), get_balance( "alice1111111" ) ); - + BOOST_REQUIRE_EQUAL( core_from_string("99901242.4187"), get_balance( "alice1111111" ) ); newtotal = get_total_stake( "alice1111111" ); auto startbytes = newtotal["ram_bytes"].as_uint64(); @@ -103,7 +102,7 @@ BOOST_FIXTURE_TEST_CASE( buysell, eosio_system_tester ) try { BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", core_from_string("100000.0000") ) ); BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", core_from_string("100000.0000") ) ); BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", core_from_string("300000.0000") ) ); - BOOST_REQUIRE_EQUAL( core_from_string("49301242.4179"), get_balance( "alice1111111" ) ); + BOOST_REQUIRE_EQUAL( core_from_string("49301242.4187"), get_balance( "alice1111111" ) ); auto finaltotal = get_total_stake( "alice1111111" ); auto endbytes = finaltotal["ram_bytes"].as_uint64(); @@ -113,7 +112,7 @@ BOOST_FIXTURE_TEST_CASE( buysell, eosio_system_tester ) try { BOOST_REQUIRE_EQUAL( success(), sellram( "alice1111111", bought_bytes ) ); - BOOST_REQUIRE_EQUAL( core_from_string("99396507.4142"), get_balance( "alice1111111" ) ); + BOOST_REQUIRE_EQUAL( core_from_string("99396507.4158"), get_balance( "alice1111111" ) ); } FC_LOG_AND_RETHROW() From 6f4618fe657ccfd698918f50f56fd8f76ea90514 Mon Sep 17 00:00:00 2001 From: Khaled Al-Hassanieh Date: Tue, 10 Jul 2018 18:07:38 -0400 Subject: [PATCH 20/28] Fix setramrate documentation --- eosio.system/src/eosio.system.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/eosio.system/src/eosio.system.cpp b/eosio.system/src/eosio.system.cpp index 223f4ef9b..3fde58e43 100644 --- a/eosio.system/src/eosio.system.cpp +++ b/eosio.system/src/eosio.system.cpp @@ -96,9 +96,6 @@ namespace eosiosystem { * * If update_ram_supply hasn't been called for the most recent block, then new ram will * be allocated at the old rate up to the present block before switching the rate. - * - * This method will also resync the bancor connector balances - * and weights to the actual CORE_SYMBOL held in the eosio.ram account. */ void system_contract::setramrate( uint16_t bytes_per_block ) { require_auth( _self ); From ec9286322e786b92cfd19160afc50126d82b7c35 Mon Sep 17 00:00:00 2001 From: Bucky Kittinger Date: Tue, 10 Jul 2018 18:29:49 -0400 Subject: [PATCH 21/28] Fixed to use eosio v1.0.8 install path --- UnitTestsExternalProject.txt | 2 +- build.sh | 7 ++++++- tests/CMakeLists.txt | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/UnitTestsExternalProject.txt b/UnitTestsExternalProject.txt index 2091f8d7c..e66cc6b1a 100644 --- a/UnitTestsExternalProject.txt +++ b/UnitTestsExternalProject.txt @@ -4,7 +4,7 @@ include(GNUInstallDirs) ExternalProject_Add( contracts_unit_tests - CMAKE_ARGS -DROOT_DIR=${CMAKE_SOURCE_DIR} -DEOSIO_INSTALL_PREFIX=${WASM_ROOT}/eosio -DOPENSSL_INSTALL_PREFIX=${OPENSSL_ROOT} -DSECP256K1_INSTALL_LIB=${SECP256K1_ROOT} -DBOOST_ROOT=${BOOST_ROOT}/include -DCMAKE_CXX_COMPILER=${CXX_COMPILER} + CMAKE_ARGS -DROOT_DIR=${CMAKE_SOURCE_DIR} -DEOSIO_INSTALL_PREFIX=${EOSIO_INSTALL_PREFIX} -DOPENSSL_INSTALL_PREFIX=${OPENSSL_ROOT} -DSECP256K1_INSTALL_LIB=${SECP256K1_ROOT} -DBOOST_ROOT=${BOOST_ROOT}/include -DCMAKE_CXX_COMPILER=${CXX_COMPILER} SOURCE_DIR ${CMAKE_SOURCE_DIR}/tests BINARY_DIR ${CMAKE_SOURCE_DIR}/build/tests diff --git a/build.sh b/build.sh index 1175fdef3..b79505597 100755 --- a/build.sh +++ b/build.sh @@ -5,6 +5,11 @@ printf "\t=========== Building eosio.contracts ===========\n\n" RED='\033[0;31m' NC='\033[0m' +if [ ! -d "/usr/local/eosio" ]; then + printf "${RED}Error, please ensure that eosio is installed correctly!\n\n${NC}" + exit -1 +fi + if [ ! -d "/usr/local/eosio.wasmsdk" ]; then printf "${RED}Error, please ensure that eosio.wasmsdk is installed correctly!\n\n${NC}" exit -1 @@ -52,6 +57,6 @@ fi CORES=`getconf _NPROCESSORS_ONLN` mkdir -p build pushd build &> /dev/null -cmake -DCXX_COMPILER="${CXX_COMPILER}" -DBOOST_ROOT="${BOOST}" ../ +cmake -DCXX_COMPILER="${CXX_COMPILER}" -DBOOST_ROOT="${BOOST}" -DEOSIO_INSTALL_PREFIX=/usr/local ../ make -j${CORES} popd &> /dev/null diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5c3e0d4b2..bc85714ee 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -117,6 +117,7 @@ target_link_libraries( unit_test target_include_directories( unit_test PUBLIC ${Boost_INCLUDE_DIRS} ${OPENSSL_INSTALL_PREFIX}/include + ${EOSIO_INSTALL_PREFIX} ${EOSIO_INSTALL_PREFIX}/include ${EOSIO_INSTALL_PREFIX}/include/eosio/wasm-jit/Include ${EOSIO_INSTALL_PREFIX}/include/eosio/softfloat/include From daa907efb187fc28b027c5b82623a1dd23dc0b22 Mon Sep 17 00:00:00 2001 From: Khaled Al-Hassanieh Date: Tue, 10 Jul 2018 18:33:21 -0400 Subject: [PATCH 22/28] Revert "Fix unit test build issues" This reverts commit 9a2ae4f853e10d077f089aeabf4f5af3cf8b3db0. --- tests/eosio.msig_tests.cpp | 10 +++++----- tests/eosio.sudo_tests.cpp | 6 +++--- tests/eosio.system_tester.hpp | 26 +++++++++++++------------- tests/eosio.system_tests.cpp | 8 ++++---- tests/eosio.token_tests.cpp | 8 ++++---- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/tests/eosio.msig_tests.cpp b/tests/eosio.msig_tests.cpp index d6439d696..ce01cc85d 100644 --- a/tests/eosio.msig_tests.cpp +++ b/tests/eosio.msig_tests.cpp @@ -36,7 +36,7 @@ class eosio_msig_tester : public tester { const auto& accnt = control->db().get( N(eosio.msig) ); abi_def abi; BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.abi, abi), true); - abi_ser.set_abi(abi, abi_serializer_max_time); + abi_ser.set_abi(abi); } transaction_trace_ptr create_account_with_resources( account_name a, account_name creator, asset ramfunds, bool multisig, @@ -174,7 +174,7 @@ transaction eosio_msig_tester::reqauth( account_name from, const vectordb().get( N(eosio.sudo) ); abi_def abi; BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.abi, abi), true); - abi_ser.set_abi(abi, abi_serializer_max_time); + abi_ser.set_abi(abi); while( control->pending_block_state()->header.producer.to_string() == "eosio" ) { produce_block(); @@ -134,7 +134,7 @@ transaction eosio_sudo_tester::sudo_exec( account_name executer, const transacti transaction trx2; set_transaction_headers(trx2, expiration); action act; - abi_serializer::from_variant( act_obj, act, get_resolver(), abi_serializer_max_time ); + abi_serializer::from_variant( act_obj, act, get_resolver() ); trx2.actions.push_back( std::move(act) ); return trx2; } @@ -155,7 +155,7 @@ transaction eosio_sudo_tester::reqauth( account_name from, const vectordb().get( N(eosio.token) ); abi_def abi; BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.abi, abi), true); - token_abi_ser.set_abi(abi, abi_serializer_max_time); + token_abi_ser.set_abi(abi); } create_currency( N(eosio.token), config::system_account_name, core_from_string("10000000000.0000") ); @@ -63,7 +63,7 @@ class eosio_system_tester : public TESTER { const auto& accnt = control->db().get( config::system_account_name ); abi_def abi; BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.abi, abi), true); - abi_ser.set_abi(abi, abi_serializer_max_time); + abi_ser.set_abi(abi); } produce_blocks(); @@ -219,7 +219,7 @@ class eosio_system_tester : public TESTER { action act; act.account = config::system_account_name; act.name = name; - act.data = abi_ser.variant_to_binary( action_type_name, data, abi_serializer_max_time ); + act.data = abi_ser.variant_to_binary( action_type_name, data ); return base_tester::push_action( std::move(act), auth ? uint64_t(signer) : signer == N(bob111111111) ? N(alice1111111) : N(bob111111111) ); } @@ -320,22 +320,22 @@ class eosio_system_tester : public TESTER { asset get_balance( const account_name& act ) { vector data = get_row_by_account( N(eosio.token), act, N(accounts), symbol(CORE_SYMBOL).to_symbol_code().value ); - return data.empty() ? asset(0, symbol(CORE_SYMBOL)) : token_abi_ser.binary_to_variant("account", data, abi_serializer_max_time)["balance"].as(); + return data.empty() ? asset(0, symbol(CORE_SYMBOL)) : token_abi_ser.binary_to_variant("account", data)["balance"].as(); } fc::variant get_total_stake( const account_name& act ) { vector data = get_row_by_account( config::system_account_name, act, N(userres), act ); - return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "user_resources", data, abi_serializer_max_time ); + return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "user_resources", data ); } fc::variant get_voter_info( const account_name& act ) { vector data = get_row_by_account( config::system_account_name, config::system_account_name, N(voters), act ); - return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "voter_info", data, abi_serializer_max_time ); + return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "voter_info", data ); } fc::variant get_producer_info( const account_name& act ) { vector data = get_row_by_account( config::system_account_name, config::system_account_name, N(producers), act ); - return abi_ser.binary_to_variant( "producer_info", data, abi_serializer_max_time ); + return abi_ser.binary_to_variant( "producer_info", data ); } void create_currency( name contract, name manager, asset maxsupply ) { @@ -375,7 +375,7 @@ class eosio_system_tester : public TESTER { auto symb = eosio::chain::symbol::from_string(symbolname); auto symbol_code = symb.to_symbol_code().value; vector data = get_row_by_account( N(eosio.token), symbol_code, N(stat), symbol_code ); - return data.empty() ? fc::variant() : token_abi_ser.binary_to_variant( "currency_stats", data, abi_serializer_max_time ); + return data.empty() ? fc::variant() : token_abi_ser.binary_to_variant( "currency_stats", data ); } asset get_token_supply() { @@ -385,17 +385,17 @@ class eosio_system_tester : public TESTER { fc::variant get_global_state() { vector data = get_row_by_account( config::system_account_name, config::system_account_name, N(global), N(global) ); if (data.empty()) std::cout << "\nData is empty\n" << std::endl; - return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "eosio_global_state", data, abi_serializer_max_time ); + return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "eosio_global_state", data ); } fc::variant get_global_state2() { vector data = get_row_by_account( config::system_account_name, config::system_account_name, N(global2), N(global2) ); - return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "eosio_global_state2", data, abi_serializer_max_time ); + return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "eosio_global_state2", data ); } fc::variant get_refund_request( name account ) { vector data = get_row_by_account( config::system_account_name, account, N(refunds), account ); - return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "refund_request", data, abi_serializer_max_time ); + return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "refund_request", data ); } abi_serializer initialize_multisig() { @@ -418,7 +418,7 @@ class eosio_system_tester : public TESTER { const auto& accnt = control->db().get( N(eosio.msig) ); abi_def msig_abi; BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.abi, msig_abi), true); - msig_abi_ser.set_abi(msig_abi, abi_serializer_max_time); + msig_abi_ser.set_abi(msig_abi); } return msig_abi_ser; } diff --git a/tests/eosio.system_tests.cpp b/tests/eosio.system_tests.cpp index b161126dd..5bcb7e882 100644 --- a/tests/eosio.system_tests.cpp +++ b/tests/eosio.system_tests.cpp @@ -1696,7 +1696,7 @@ BOOST_FIXTURE_TEST_CASE(producers_upgrade_system_contract, eosio_system_tester) action act; act.account = N(eosio.msig); act.name = name; - act.data = msig_abi_ser.variant_to_binary( action_type_name, data, abi_serializer_max_time ); + act.data = msig_abi_ser.variant_to_binary( action_type_name, data ); return base_tester::push_action( std::move(act), auth ? uint64_t(signer) : signer == N(bob111111111) ? N(alice1111111) : N(bob111111111) ); }; @@ -1735,7 +1735,7 @@ BOOST_FIXTURE_TEST_CASE(producers_upgrade_system_contract, eosio_system_tester) ) }) ); - abi_serializer::from_variant(pretty_trx, trx, get_resolver(), abi_serializer_max_time); + abi_serializer::from_variant(pretty_trx, trx, get_resolver()); } BOOST_REQUIRE_EQUAL(success(), push_action_msig( N(alice1111111), N(propose), mvo() @@ -2456,7 +2456,7 @@ BOOST_FIXTURE_TEST_CASE( setparams, eosio_system_tester ) try { action act; act.account = N(eosio.msig); act.name = name; - act.data = msig_abi_ser.variant_to_binary( action_type_name, data, abi_serializer_max_time ); + act.data = msig_abi_ser.variant_to_binary( action_type_name, data ); return base_tester::push_action( std::move(act), auth ? uint64_t(signer) : signer == N(bob111111111) ? N(alice1111111) : N(bob111111111) ); }; @@ -2492,7 +2492,7 @@ BOOST_FIXTURE_TEST_CASE( setparams, eosio_system_tester ) try { ) }) ); - abi_serializer::from_variant(pretty_trx, trx, get_resolver(), abi_serializer_max_time); + abi_serializer::from_variant(pretty_trx, trx, get_resolver()); } BOOST_REQUIRE_EQUAL(success(), push_action_msig( N(alice1111111), N(propose), mvo() diff --git a/tests/eosio.token_tests.cpp b/tests/eosio.token_tests.cpp index 28a6b596b..0fcc7b62d 100644 --- a/tests/eosio.token_tests.cpp +++ b/tests/eosio.token_tests.cpp @@ -33,7 +33,7 @@ class eosio_token_tester : public tester { const auto& accnt = control->db().get( N(eosio.token) ); abi_def abi; BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.abi, abi), true); - abi_ser.set_abi(abi, abi_serializer_max_time); + abi_ser.set_abi(abi); } action_result push_action( const account_name& signer, const action_name &name, const variant_object &data ) { @@ -42,7 +42,7 @@ class eosio_token_tester : public tester { action act; act.account = N(eosio.token); act.name = name; - act.data = abi_ser.variant_to_binary( action_type_name, data, abi_serializer_max_time ); + act.data = abi_ser.variant_to_binary( action_type_name, data ); return base_tester::push_action( std::move(act), uint64_t(signer)); } @@ -52,7 +52,7 @@ class eosio_token_tester : public tester { auto symb = eosio::chain::symbol::from_string(symbolname); auto symbol_code = symb.to_symbol_code().value; vector data = get_row_by_account( N(eosio.token), symbol_code, N(stat), symbol_code ); - return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "currency_stats", data, abi_serializer_max_time ); + return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "currency_stats", data ); } fc::variant get_account( account_name acc, const string& symbolname) @@ -60,7 +60,7 @@ class eosio_token_tester : public tester { auto symb = eosio::chain::symbol::from_string(symbolname); auto symbol_code = symb.to_symbol_code().value; vector data = get_row_by_account( N(eosio.token), acc, N(accounts), symbol_code ); - return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "account", data, abi_serializer_max_time ); + return data.empty() ? fc::variant() : abi_ser.binary_to_variant( "account", data ); } action_result create( account_name issuer, From 869424d498f933bf032479ed181dc4caaf22b7c4 Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Wed, 11 Jul 2018 11:16:22 -0400 Subject: [PATCH 23/28] fixing producers_upgrade_system_contract test #10 --- tests/eosio.system_tests.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/eosio.system_tests.cpp b/tests/eosio.system_tests.cpp index 8a40140de..89686bcda 100644 --- a/tests/eosio.system_tests.cpp +++ b/tests/eosio.system_tests.cpp @@ -1707,17 +1707,17 @@ BOOST_FIXTURE_TEST_CASE(producers_upgrade_system_contract, eosio_system_tester) for ( auto& x : producer_names ) { prod_perms.push_back( { name(x), config::active_name } ); } - //prepare system contract with different hash (contract differs in one byte) - string eosio_system_wast2 = wasm_to_wast(contracts::system_wasm(), true); - string msg = "producer votes must be unique and sorted"; - auto pos = eosio_system_wast2.find(msg); - BOOST_REQUIRE( pos != std::string::npos ); - msg[0] = 'P'; - eosio_system_wast2.replace( pos, msg.size(), msg ); transaction trx; { - auto code = contracts::system_wasm(); //wast_to_wasm( eosio_system_wast2 ); + //prepare system contract with different hash (contract differs in one byte) + auto code = contracts::system_wasm(); + string msg = "producer votes must be unique and sorted"; + auto it = std::search( code.begin(), code.end(), msg.begin(), msg.end() ); + BOOST_REQUIRE( it != code.end() ); + msg[0] = 'P'; + std::copy( msg.begin(), msg.end(), it ); + variant pretty_trx = fc::mutable_variant_object() ("expiration", "2020-01-01T00:30") ("ref_block_num", 2) From 4d1d7b57b7b48f8cd24a8cb2ae7f448b68e90430 Mon Sep 17 00:00:00 2001 From: Bucky Kittinger Date: Wed, 11 Jul 2018 11:22:00 -0400 Subject: [PATCH 24/28] Added defaults to cmake variables --- CMakeLists.txt | 8 ++++++++ build.sh | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 62558d474..834e6c1eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,14 @@ cmake_minimum_required(VERSION 3.5) project(eosio_contracts VERSION 1.0.0) +if(CXX_COMPILER STREQUAL "" OR NOT CXX_COMPILER) + set(CXX_COMPILER ${CMAKE_CXX_COMPILER}) +endif() + +if(EOSIO_INSTALL_PREFIX STREQUAL "" OR NOT EOSIO_INSTALL_PREFIX) + set(EOSIO_INSTALL_PREFIX "/usr/local") +endif() + # if no wasm root is given use default path if(WASM_ROOT STREQUAL "" OR NOT WASM_ROOT) set(WASM_ROOT ${CMAKE_INSTALL_PREFIX}) diff --git a/build.sh b/build.sh index b79505597..815e9f277 100755 --- a/build.sh +++ b/build.sh @@ -5,10 +5,10 @@ printf "\t=========== Building eosio.contracts ===========\n\n" RED='\033[0;31m' NC='\033[0m' -if [ ! -d "/usr/local/eosio" ]; then - printf "${RED}Error, please ensure that eosio is installed correctly!\n\n${NC}" - exit -1 -fi +#if [ ! -d "/usr/local/eosio" ]; then +# printf "${RED}Error, please ensure that eosio is installed correctly!\n\n${NC}" +# exit -1 +#fi if [ ! -d "/usr/local/eosio.wasmsdk" ]; then printf "${RED}Error, please ensure that eosio.wasmsdk is installed correctly!\n\n${NC}" From 97d9d5884ee52f4fd3947f8c4770cf18c9726ba9 Mon Sep 17 00:00:00 2001 From: Bucky Kittinger Date: Wed, 11 Jul 2018 11:27:52 -0400 Subject: [PATCH 25/28] Added support for debug test builds --- CMakeLists.txt | 6 ++++++ UnitTestsExternalProject.txt | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 834e6c1eb..9aff36572 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,12 @@ cmake_minimum_required(VERSION 3.5) project(eosio_contracts VERSION 1.0.0) +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(TEST_BUILD_TYPE "Debug") + set(CMAKE_BUILD_TYPE "Release") +else() + set(TEST_BUILD_TYPE ${CMAKE_BUILD_TYPE}) +endif() if(CXX_COMPILER STREQUAL "" OR NOT CXX_COMPILER) set(CXX_COMPILER ${CMAKE_CXX_COMPILER}) endif() diff --git a/UnitTestsExternalProject.txt b/UnitTestsExternalProject.txt index e66cc6b1a..73ccd2d91 100644 --- a/UnitTestsExternalProject.txt +++ b/UnitTestsExternalProject.txt @@ -4,7 +4,7 @@ include(GNUInstallDirs) ExternalProject_Add( contracts_unit_tests - CMAKE_ARGS -DROOT_DIR=${CMAKE_SOURCE_DIR} -DEOSIO_INSTALL_PREFIX=${EOSIO_INSTALL_PREFIX} -DOPENSSL_INSTALL_PREFIX=${OPENSSL_ROOT} -DSECP256K1_INSTALL_LIB=${SECP256K1_ROOT} -DBOOST_ROOT=${BOOST_ROOT}/include -DCMAKE_CXX_COMPILER=${CXX_COMPILER} + CMAKE_ARGS -DCMAKE_BUILD_TYPE=${TEST_BUILD_TYPE} -DROOT_DIR=${CMAKE_SOURCE_DIR} -DEOSIO_INSTALL_PREFIX=${EOSIO_INSTALL_PREFIX} -DOPENSSL_INSTALL_PREFIX=${OPENSSL_ROOT} -DSECP256K1_INSTALL_LIB=${SECP256K1_ROOT} -DBOOST_ROOT=${BOOST_ROOT}/include -DCMAKE_CXX_COMPILER=${CXX_COMPILER} SOURCE_DIR ${CMAKE_SOURCE_DIR}/tests BINARY_DIR ${CMAKE_SOURCE_DIR}/build/tests From 4aa06db4cad7b7cbed810a4e79774f0800c24ec6 Mon Sep 17 00:00:00 2001 From: Bucky Kittinger Date: Wed, 11 Jul 2018 15:03:26 -0400 Subject: [PATCH 26/28] Changed link ordering Fix for unresolved references --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bc85714ee..2a22a3ea4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -64,6 +64,7 @@ find_library(libsecp256k1 secp256k1 ${SECP256K1_INSTALL_LIB}) add_executable( unit_test ${UNIT_TESTS} ) target_link_libraries( unit_test ${LLVM} + ${libtester} ${libchain} ${libfc} ${libbinaryen} @@ -79,7 +80,6 @@ target_link_libraries( unit_test ${libchainbase} ${libbuiltins} ${libsecp256k1} - ${libtester} LLVMX86Disassembler LLVMX86AsmParser From 595e99ba9ecd9c0e723378b0cd06476d4aad6364 Mon Sep 17 00:00:00 2001 From: Khaled Al-Hassanieh Date: Wed, 11 Jul 2018 17:25:18 -0400 Subject: [PATCH 27/28] Fixed comments and ricardian contract --- eosio.system/abi/eosio.system.abi | 2 +- eosio.system/src/eosio.system.cpp | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/eosio.system/abi/eosio.system.abi b/eosio.system/abi/eosio.system.abi index ccbd1c3e3..4e30369a7 100644 --- a/eosio.system/abi/eosio.system.abi +++ b/eosio.system/abi/eosio.system.abi @@ -491,7 +491,7 @@ },{ "name": "setramrate", "type": "setramrate", - "ricardian_contract": "Sets the number of new bytes of ram to create per block and resyncs bancor connector balances and weights to eosio.ram and 50% CRR" + "ricardian_contract": "Sets the number of new bytes of ram to create per block and resyncs bancor base connector balance" },{ "name": "bidname", "type": "bidname", diff --git a/eosio.system/src/eosio.system.cpp b/eosio.system/src/eosio.system.cpp index 3fde58e43..1f0b6a11f 100644 --- a/eosio.system/src/eosio.system.cpp +++ b/eosio.system/src/eosio.system.cpp @@ -63,8 +63,7 @@ namespace eosiosystem { auto itr = _rammarket.find(S(4,RAMCORE)); /** - * Increase or decrease the amount of ram for sale based upon the change in max - * ram size. + * Increase the amount of ram for sale based upon the change in max ram size. */ _rammarket.modify( itr, 0, [&]( auto& m ) { m.base.balance.amount += delta; @@ -81,8 +80,7 @@ namespace eosiosystem { _gstate.max_ram_size += new_ram; /** - * Increase or decrease the amount of ram for sale based upon the change in max - * ram size. + * Increase the amount of ram for sale based upon the change in max ram size. */ _rammarket.modify( itr, 0, [&]( auto& m ) { m.base.balance.amount += new_ram; From a5ef132e0c661be4168a5eb993581ac486ceef9e Mon Sep 17 00:00:00 2001 From: Bucky Kittinger Date: Wed, 11 Jul 2018 18:28:43 -0400 Subject: [PATCH 28/28] change to v1.1.0 --- CMakeLists.txt | 2 +- README.md | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9aff36572..11c809ca9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.5) -project(eosio_contracts VERSION 1.0.0) +project(eosio_contracts VERSION 1.1.0) if(CMAKE_BUILD_TYPE STREQUAL "Debug") set(TEST_BUILD_TYPE "Debug") diff --git a/README.md b/README.md index 83a6cb1ab..37c721125 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # eosio.contracts -## Version : 1.0.0 +## Version : 1.1.0 The design of the EOSIO blockchain calls for a number of smart contracts that are run at a privileged permission level in order to support functions such as block producer registration and voting, token staking for CPU and network bandwidth, RAM purchasing, multi-sig, etc. These smart contracts are referred to as the system, token, msig and sudo contracts. @@ -16,14 +16,14 @@ The following unpriviledged contract(s) are also part of the system. Dependencies: * [eosio v1.0.8](https://github.com/eosio/eos/tree/v1.0.8) +* [eosio.wasmsdk v1.0](https://github.com/eosio/eosio.wasmsdk/tree/v1.0) To build the contracts and the unit tests: * First, ensure that your __eosio__ is compiled to the core symbol for the EOSIO blockchain that intend to deploy to. * Second, make sure that you have ```sudo make install```ed __eosio__. -* Then just run the ```build.sh``` in the top directory to build all the contracts and the unit tests for these contracts. If you want to skip building the unit tests, the option ```notests``` can be given to ```build.sh```. -* Or, you can run the ```build.sh``` in a given contract folder to only build that contract. +* Then just run the ```build.sh``` in the top directory to build all the contracts and the unit tests for these contracts. After build: -* The unit tests executable is placed in the top directory and is named __unit_test__. +* The unit tests executable is placed in the _build/tests_ and is named __unit_test__. * The contracts are built into a _bin/\_ folder in their respective directories. * Finally, simply use __cleos__ to _set contract_ by pointing to the previously mentioned directory.