From 441a6cc9dbdd300772d515d8a44eda5dc10ac87b Mon Sep 17 00:00:00 2001 From: Harry Wong Date: Mon, 14 May 2018 12:54:00 +0800 Subject: [PATCH 01/27] Fix reflect issue in block_state.hpp --- libraries/chain/include/eosio/chain/block_state.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chain/include/eosio/chain/block_state.hpp b/libraries/chain/include/eosio/chain/block_state.hpp index 9b5bdd1f660..d8d00435f79 100644 --- a/libraries/chain/include/eosio/chain/block_state.hpp +++ b/libraries/chain/include/eosio/chain/block_state.hpp @@ -31,4 +31,4 @@ namespace eosio { namespace chain { } } /// namespace eosio::chain -FC_REFLECT_DERIVED( eosio::chain::block_state, (eosio::chain::block_header_state), (block)(validated) ) +FC_REFLECT_DERIVED( eosio::chain::block_state, (eosio::chain::block_header_state), (block)(validated)(in_current_chain) ) From 3ea6cdbfa4a0dd786d2682727035c2f0571cd9a0 Mon Sep 17 00:00:00 2001 From: Kayan Date: Mon, 14 May 2018 17:54:59 +0800 Subject: [PATCH 02/27] fix expired delay txn handling, add test case for 2071 --- libraries/chain/controller.cpp | 1 + unittests/delay_tests.cpp | 40 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index 6eb89b52c78..aa091b2db42 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -463,6 +463,7 @@ struct controller_impl { trace->id = gto.trx_id; trace->scheduled = false; trace->receipt = push_receipt( gto.trx_id, transaction_receipt::expired, billed_cpu_time_us, 0 ); // expire the transaction + undo_session.squash(); return trace; } diff --git a/unittests/delay_tests.cpp b/unittests/delay_tests.cpp index ca08f7aaa3c..6eac79b6141 100644 --- a/unittests/delay_tests.cpp +++ b/unittests/delay_tests.cpp @@ -2392,4 +2392,44 @@ BOOST_AUTO_TEST_CASE( max_transaction_delay_execute ) { try { } FC_LOG_AND_RETHROW() } +BOOST_FIXTURE_TEST_CASE( delay_expired, validating_tester) { try { + + produce_blocks(2); + signed_transaction trx; + + account_name a = N(newco); + account_name creator = config::system_account_name; + + auto owner_auth = authority( get_public_key( a, "owner" ) ); + trx.actions.emplace_back( vector{{creator,config::active_name}}, + newaccount{ + .creator = creator, + .name = a, + .owner = owner_auth, + .active = authority( get_public_key( a, "active" ) ) + }); + set_transaction_headers(trx); + trx.delay_sec = 3; + trx.expiration = control->head_block_time() + fc::microseconds(1000000); + trx.sign( get_private_key( creator, "active" ), chain_id_type() ); + + auto trace = push_transaction( trx ); + + BOOST_REQUIRE_EQUAL(transaction_receipt_header::delayed, trace->receipt->status); + + signed_block_ptr sb = produce_block(); + + sb = produce_block(); + + BOOST_REQUIRE_EQUAL(transaction_receipt_header::delayed, trace->receipt->status); + produce_empty_block(fc::milliseconds(610 * 1000)); + sb = produce_block(); + BOOST_REQUIRE_EQUAL(1, sb->transactions.size()); + BOOST_REQUIRE_EQUAL(transaction_receipt_header::expired, sb->transactions[0].status); + + create_account(a); // account can still be created + +} FC_LOG_AND_RETHROW() } + + BOOST_AUTO_TEST_SUITE_END() From 440eaa783eb7a472172219cc76b80f9e3096147d Mon Sep 17 00:00:00 2001 From: Eric Iles Date: Mon, 14 May 2018 10:25:15 -0400 Subject: [PATCH 03/27] Create debug pipeline --- .buildkite/debug.yml | 230 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 .buildkite/debug.yml diff --git a/.buildkite/debug.yml b/.buildkite/debug.yml new file mode 100644 index 00000000000..9c322aa96f7 --- /dev/null +++ b/.buildkite/debug.yml @@ -0,0 +1,230 @@ +steps: + - command: | + echo "--- Creating symbolic link to job directory :file_folder:" && \ + sleep 5 && ln -s "$(pwd)" /data/job && cd /data/job && \ + echo "+++ Building :hammer:" && \ + echo 1 | ./eosio_build.sh -o Debug && \ + echo "--- Compressing build directory :compression:" && \ + tar -pczf build.tar.gz build/ + label: ":darwin: Build" + agents: + - "role=macos-builder" + artifact_paths: "build.tar.gz" + timeout: 30 + + - command: | + echo "+++ :hammer: Building" && \ + echo 1 | ./eosio_build.sh -o Debug && \ + echo "--- :compression: Compressing build directory" && \ + tar -pczf build.tar.gz build/ + label: ":ubuntu: Build" + agents: + - "role=linux-builder" + artifact_paths: "build.tar.gz" + plugins: + docker#v1.1.1: + image: "eosio/ci:ubuntu" + workdir: /data/job + timeout: 30 + + - command: | + echo "+++ :hammer: Building" && \ + echo 1 | ./eosio_build.sh -o Debug && \ + echo "--- :compression: Compressing build directory" && \ + tar -pczf build.tar.gz build/ + label: ":ubuntu: 18.04 Build" + agents: + - "role=linux-builder" + artifact_paths: "build.tar.gz" + plugins: + docker#v1.1.1: + image: "eosio/ci:ubuntu18" + workdir: /data/job + timeout: 30 + + - command: | + echo "+++ :hammer: Building" && \ + echo 1 | ./eosio_build.sh -o Debug && \ + echo "--- :compression: Compressing build directory" && \ + tar -pczf build.tar.gz build/ + label: ":fedora: Build" + agents: + - "role=linux-builder" + artifact_paths: "build.tar.gz" + plugins: + docker#v1.1.1: + image: "eosio/ci:fedora" + workdir: /data/job + timeout: 30 + + - command: | + echo "+++ :hammer: Building" && \ + echo 1 | ./eosio_build.sh -o Debug && \ + echo "--- :compression: Compressing build directory" && \ + tar -pczf build.tar.gz build/ + label: ":centos: Build" + agents: + - "role=linux-builder" + artifact_paths: "build.tar.gz" + plugins: + docker#v1.1.1: + image: "eosio/ci:centos" + workdir: /data/job + timeout: 30 + + - command: | + echo "+++ :hammer: Building" && \ + echo 1 | ./eosio_build.sh -o Debug && \ + echo "--- :compression: Compressing build directory" && \ + tar -pczf build.tar.gz build/ + label: ":aws: Build" + agents: + - "role=linux-builder" + artifact_paths: "build.tar.gz" + plugins: + docker#v1.1.1: + image: "eosio/ci:amazonlinux" + workdir: /data/job + timeout: 30 + + - wait + + - command: | + echo "--- :arrow_down: Downloading build directory" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":darwin: Build" && + tar -zxf build.tar.gz && \ + echo "--- :m: Starting MongoDB" && \ + $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + echo "+++ :microscope: Running tests" && \ + ln -s "$(pwd)" /data/job && cd /data/job/build && ctest --output-on-failure + retry: + automatic: + limit: 1 + label: ":darwin: Tests" + agents: + - "role=macos-tester" + artifact_paths: + - "mongod.log" + - "build/genesis.json" + - "build/config.ini" + timeout: 30 + + - command: | + echo "--- :arrow_down: Downloading build directory" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":ubuntu: Build" && + tar -zxf build.tar.gz && \ + echo "--- :m: Starting MongoDB" && \ + $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + echo "+++ :microscope: Running tests" && \ + cd /data/job/build && ctest --output-on-failure + retry: + automatic: + limit: 1 + label: ":ubuntu: Tests" + agents: + - "role=linux-tester" + artifact_paths: + - "mongod.log" + - "build/genesis.json" + - "build/config.ini" + plugins: + docker#v1.1.1: + image: "eosio/ci:ubuntu" + workdir: /data/job + timeout: 30 + + - command: | + echo "--- :arrow_down: Downloading build directory" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":ubuntu: 18.04 Build" && + tar -zxf build.tar.gz && \ + echo "--- :m: Starting MongoDB" && \ + $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + echo "+++ :microscope: Running tests" && \ + cd /data/job/build && ctest --output-on-failure + retry: + automatic: + limit: 1 + label: ":ubuntu: 18.04 Tests" + agents: + - "role=linux-tester" + artifact_paths: + - "mongod.log" + - "build/genesis.json" + - "build/config.ini" + plugins: + docker#v1.1.1: + image: "eosio/ci:ubuntu18" + workdir: /data/job + timeout: 30 + + - command: | + echo "--- :arrow_down: Downloading build directory" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":fedora: Build" && + tar -zxf build.tar.gz && \ + echo "--- :m: Starting MongoDB" && \ + $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + echo "+++ :microscope: Running tests" && \ + cd /data/job/build && ctest --output-on-failure + retry: + automatic: + limit: 1 + label: ":fedora: Tests" + agents: + - "role=linux-tester" + artifact_paths: + - "mongod.log" + - "build/genesis.json" + - "build/config.ini" + plugins: + docker#v1.1.1: + image: "eosio/ci:fedora" + workdir: /data/job + timeout: 30 + + - command: | + echo "--- :arrow_down: Downloading build directory" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":centos: Build" && + tar -zxf build.tar.gz && \ + echo "--- :m: Starting MongoDB" && \ + $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + echo "+++ :microscope: Running tests" && \ + cd /data/job/build && ctest --output-on-failure + retry: + automatic: + limit: 1 + label: ":centos: Tests" + agents: + - "role=linux-tester" + artifact_paths: + - "mongod.log" + - "build/genesis.json" + - "build/config.ini" + plugins: + docker#v1.1.1: + image: "eosio/ci:centos" + workdir: /data/job + timeout: 30 + + - command: | + echo "--- :arrow_down: Downloading build directory" && \ + buildkite-agent artifact download "build.tar.gz" . --step ":aws: Build" && + tar -zxf build.tar.gz && \ + echo "--- :m: Starting MongoDB" && \ + $(which mongod) --fork --logpath "$(pwd)"/mongod.log && \ + echo "+++ :microscope: Running tests" && \ + cd /data/job/build && ctest --output-on-failure + retry: + automatic: + limit: 1 + label: ":aws: Tests" + agents: + - "role=linux-tester" + artifact_paths: + - "mongod.log" + - "build/genesis.json" + - "build/config.ini" + plugins: + docker#v1.1.1: + image: "eosio/ci:amazonlinux" + workdir: /data/job + timeout: 30 From d11efdb6dcb3636bd86996f1d74c905131a2f622 Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Mon, 14 May 2018 10:28:45 -0400 Subject: [PATCH 04/27] prevent destruction of mutex before appbase (and maybe other classes) may use it #3035 --- libraries/fc/src/log/console_appender.cpp | 6 +++++- libraries/fc/src/log/gelf_appender.cpp | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libraries/fc/src/log/console_appender.cpp b/libraries/fc/src/log/console_appender.cpp index b7499297b24..fa3c45a047a 100644 --- a/libraries/fc/src/log/console_appender.cpp +++ b/libraries/fc/src/log/console_appender.cpp @@ -83,7 +83,11 @@ namespace fc { } boost::mutex& log_mutex() { - static boost::mutex m; return m; + //this mutex should live longer than any other static variables + //which may want to write logs from destructor (for example, nodeos`appbase::application) + //so, make it live forever (it's a memory leak, but memory usage doesn't grow over time) + static boost::mutex* m_ptr = new boost::mutex; + return *m_ptr; } void console_appender::log( const log_message& m ) { diff --git a/libraries/fc/src/log/gelf_appender.cpp b/libraries/fc/src/log/gelf_appender.cpp index 6d4bce4f701..d5274f80da4 100644 --- a/libraries/fc/src/log/gelf_appender.cpp +++ b/libraries/fc/src/log/gelf_appender.cpp @@ -101,7 +101,11 @@ namespace fc {} boost::mutex& gelf_log_mutex() { - static boost::mutex m; return m; + //this mutex should live longer than any other static variables + //which may want to write logs from destructor (for example, nodeos`appbase::application) + //so, make it live forever (it's a memory leak, but memory usage doesn't grow over time) + static boost::mutex* m_ptr = new boost::mutex; + return *m_ptr; } void gelf_appender::log(const log_message& message) From bdbc3f81216187a87736c8c1db4c547fd25e1469 Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Fri, 11 May 2018 07:19:07 -0500 Subject: [PATCH 05/27] Force account names to be exactly 12 chars and contain no dots. GH #2660 --- contracts/eosio.system/delegate_bandwidth.cpp | 13 ++++++---- contracts/eosio.system/native.hpp | 7 +++-- contracts/eosiolib/types.hpp | 26 +++++++++++++++++++ libraries/chain/name.cpp | 1 + 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/contracts/eosio.system/delegate_bandwidth.cpp b/contracts/eosio.system/delegate_bandwidth.cpp index 8ddfa22c7c5..d9c1580a478 100644 --- a/contracts/eosio.system/delegate_bandwidth.cpp +++ b/contracts/eosio.system/delegate_bandwidth.cpp @@ -93,13 +93,16 @@ namespace eosiosystem { * an amount equal to the current new account creation fee. */ void native::newaccount( account_name creator, - account_name newact - /* no need to parse authorites - const authority& owner, - const authority& active, - const authority& recovery*/ ) { + account_name newact + /* no need to parse authorites + const authority& owner, + const authority& active*/ ) { + auto name_str = eosio::name{newact}.to_string(); eosio::print( eosio::name{creator}, " created ", eosio::name{newact}, "\n"); + eosio_assert( name_str.size() == 12, "account names must be 12 chars long" ); + eosio_assert( name_str.find_first_of('.') == std::string::npos, "account names cannot contain '.' character"); + user_resources_table userres( _self, newact); userres.emplace( newact, [&]( auto& res ) { diff --git a/contracts/eosio.system/native.hpp b/contracts/eosio.system/native.hpp index 18c89cdc4a2..3a9bed79bdf 100644 --- a/contracts/eosio.system/native.hpp +++ b/contracts/eosio.system/native.hpp @@ -83,10 +83,9 @@ namespace eosiosystem { */ void newaccount( account_name creator, account_name newact - /* no need to parse authorites - const authority& owner, - const authority& active, - const authority& recovery*/ ); + /* no need to parse authorites + const authority& owner, + const authority& active*/ ); void updateauth( /*account_name account, diff --git a/contracts/eosiolib/types.hpp b/contracts/eosiolib/types.hpp index cc65059548e..d395c3d09bd 100644 --- a/contracts/eosiolib/types.hpp +++ b/contracts/eosiolib/types.hpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace eosio { @@ -77,8 +78,33 @@ namespace eosio { struct name { operator uint64_t()const { return value; } + // keep in sync with name::operator string() in eosio source code definition for name + std::string to_string() const { + static const char* charmap = ".12345abcdefghijklmnopqrstuvwxyz"; + + std::string str(13,'.'); + + uint64_t tmp = value; + for( uint32_t i = 0; i <= 12; ++i ) { + char c = charmap[tmp & (i == 0 ? 0x0f : 0x1f)]; + str[12-i] = c; + tmp >>= (i == 0 ? 4 : 5); + } + + trim_right_if( str, []( char c ){ return c == '.'; } ); + return str; + } + friend bool operator==( const name& a, const name& b ) { return a.value == b.value; } account_name value = 0; + + private: + template + static void trim_right_if(std::string& str, Lambda&& l ) { + const auto last = str.find_last_not_of('.'); + if (last != std::string::npos) + str = str.substr(0, last + 1); + } }; /// @} diff --git a/libraries/chain/name.cpp b/libraries/chain/name.cpp index 6cb09b34906..7e0a7e4a621 100644 --- a/libraries/chain/name.cpp +++ b/libraries/chain/name.cpp @@ -15,6 +15,7 @@ namespace eosio { namespace chain { ("name", string(str))("normalized", to_string())); } + // keep in sync with name::to_string() in contract definition for name name::operator string()const { static const char* charmap = ".12345abcdefghijklmnopqrstuvwxyz"; From fc60303d4c8916f6158829a85b561cdb037930b2 Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Fri, 11 May 2018 07:20:12 -0500 Subject: [PATCH 06/27] Code cleanup. GH #2660 --- libraries/chain/eosio_contract_abi.cpp | 1 - .../faucet_testnet_plugin.cpp | 2 +- tests/chain_tests/block_tests.cpp | 31 ++++++------------- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/libraries/chain/eosio_contract_abi.cpp b/libraries/chain/eosio_contract_abi.cpp index 185395dd17e..30806ac933e 100644 --- a/libraries/chain/eosio_contract_abi.cpp +++ b/libraries/chain/eosio_contract_abi.cpp @@ -88,7 +88,6 @@ abi_def eosio_contract_abi(const abi_def& eosio_system_abi) {"name", "account_name"}, {"owner", "authority"}, {"active", "authority"}, - {"recovery", "authority"}, } }); diff --git a/plugins/faucet_testnet_plugin/faucet_testnet_plugin.cpp b/plugins/faucet_testnet_plugin/faucet_testnet_plugin.cpp index f21aebc36d8..76e6f9d8241 100644 --- a/plugins/faucet_testnet_plugin/faucet_testnet_plugin.cpp +++ b/plugins/faucet_testnet_plugin/faucet_testnet_plugin.cpp @@ -232,7 +232,7 @@ struct faucet_testnet_plugin_impl { auto recovery_auth = chain::authority{1, {}, {{{_create_account_name, "active"}, 1}}}; trx.actions.emplace_back(vector{{_create_account_name,"active"}}, - newaccount{_create_account_name, new_account_name, owner_auth, active_auth, recovery_auth}); + newaccount{_create_account_name, new_account_name, owner_auth, active_auth}); trx.expiration = cc.head_block_time() + fc::seconds(30); trx.set_reference_block(cc.head_block_id()); diff --git a/tests/chain_tests/block_tests.cpp b/tests/chain_tests/block_tests.cpp index 655d7059d24..7170922c2b2 100644 --- a/tests/chain_tests/block_tests.cpp +++ b/tests/chain_tests/block_tests.cpp @@ -288,7 +288,6 @@ BOOST_AUTO_TEST_CASE(trx_variant ) { .name = new_account_name, .owner = owner_auth, .active = authority( chain.get_public_key( new_account_name, "active" ) ), - .recovery = authority( chain.get_public_key( new_account_name, "recovery" ) ), }); trx.expiration = time_point_sec(chain.control->head_block_time()) + 100; trx.ref_block_num = (uint16_t)chain.control->head_block_num(); @@ -322,8 +321,7 @@ BOOST_AUTO_TEST_CASE(trx_uniqueness) { .creator = config::system_account_name, .name = new_account_name, .owner = owner_auth, - .active = authority(chain.get_public_key(new_account_name, "active")), - .recovery = authority(chain.get_public_key(new_account_name, "recovery)),")) + .active = authority(chain.get_public_key(new_account_name, "active")) }); chain.set_transaction_headers(trx, 90); trx.sign(chain.get_private_key(config::system_account_name, "active"), chain_id_type()); @@ -344,8 +342,7 @@ BOOST_AUTO_TEST_CASE(invalid_expiration) { .creator = config::system_account_name, .name = new_account_name, .owner = owner_auth, - .active = authority(chain.get_public_key(new_account_name, "active")), - .recovery = authority(chain.get_public_key(new_account_name, "recovery)),")) + .active = authority(chain.get_public_key(new_account_name, "active")) }); trx.ref_block_num = static_cast(chain.control->head_block_num()); trx.ref_block_prefix = static_cast(chain.control->head_block_id()._hash[1]); @@ -372,8 +369,7 @@ BOOST_AUTO_TEST_CASE(transaction_expiration) { .creator = config::system_account_name, .name = new_account_name, .owner = owner_auth, - .active = authority(chain.get_public_key(new_account_name, "active")), - .recovery = authority(chain.get_public_key(new_account_name, "recovery)),")) + .active = authority(chain.get_public_key(new_account_name, "active")) }); trx.ref_block_num = static_cast(chain.control->head_block_num()); trx.ref_block_prefix = static_cast(chain.control->head_block_id()._hash[1]); @@ -400,8 +396,7 @@ BOOST_AUTO_TEST_CASE(invalid_tapos) { .creator = config::system_account_name, .name = new_account_name, .owner = owner_auth, - .active = authority(chain.get_public_key(new_account_name, "active")), - .recovery = authority(chain.get_public_key(new_account_name, "recovery)),")) + .active = authority(chain.get_public_key(new_account_name, "active")) }); trx.ref_block_num = static_cast(chain.control->head_block_num() + 1); trx.ref_block_prefix = static_cast(chain.control->head_block_id()._hash[1]); @@ -429,8 +424,7 @@ BOOST_AUTO_TEST_CASE(irrelevant_auth) { .creator = config::system_account_name, .name = new_account_name, .owner = owner_auth, - .active = authority( chain.get_public_key( new_account_name, "active" ) ), - .recovery = authority( chain.get_public_key( new_account_name, "recovery" ) ), + .active = authority( chain.get_public_key( new_account_name, "active" ) ) }); chain.set_transaction_headers(trx); trx.sign( chain.get_private_key( config::system_account_name, "active" ), chain_id_type() ); @@ -463,8 +457,7 @@ BOOST_AUTO_TEST_CASE(no_auth) { .creator = config::system_account_name, .name = new_account_name, .owner = owner_auth, - .active = authority(), - .recovery = authority(), + .active = authority() }); chain.set_transaction_headers(trx); trx.sign( chain.get_private_key( config::system_account_name, "active" ), chain_id_type() ); @@ -958,8 +951,7 @@ BOOST_AUTO_TEST_CASE(irrelevant_sig_soft_check) { .creator = config::system_account_name, .name = new_account_name, .owner = owner_auth, - .active = authority( chain.get_public_key( new_account_name, "active" ) ), - .recovery = authority( chain.get_public_key( new_account_name, "recovery" ) ), + .active = authority( chain.get_public_key( new_account_name, "active" ) ) }); chain.set_transaction_headers(trx); trx.sign( chain.get_private_key( config::system_account_name, "active" ), chain_id_type() ); @@ -1008,8 +1000,7 @@ BOOST_AUTO_TEST_CASE(irrelevant_sig_hard_check) { .creator = config::system_account_name, .name = new_account_name, .owner = owner_auth, - .active = authority( chain.get_public_key( new_account_name, "active" ) ), - .recovery = authority( chain.get_public_key( new_account_name, "recovery" ) ), + .active = authority( chain.get_public_key( new_account_name, "active" ) ) }); chain.set_transaction_headers(trx); trx.sign( chain.get_private_key( config::system_account_name, "active" ), chain_id_type() ); @@ -1041,8 +1032,7 @@ BOOST_AUTO_TEST_CASE(irrelevant_sig_hard_check) { .creator = config::system_account_name, .name = new_account_name, .owner = owner_auth, - .active = authority( chain.get_public_key( new_account_name, "active" ) ), - .recovery = authority( chain.get_public_key( new_account_name, "recovery" ) ), + .active = authority( chain.get_public_key( new_account_name, "active" ) ) }); chain.set_transaction_headers(trx); trx.sign( chain.get_private_key( config::system_account_name, "active" ), chain_id_type() ); @@ -1123,8 +1113,7 @@ BOOST_AUTO_TEST_CASE(get_required_keys) .creator = creator, .name = a, .owner = owner_auth, - .active = authority( chain.get_public_key( a, "active" ) ), - .recovery = authority( chain.get_public_key( a, "recovery" ) ), + .active = authority( chain.get_public_key( a, "active" ) ) }); chain.set_transaction_headers(trx); From 8d17303056d8bec14c8347baa7aa79a7464f3b4c Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Fri, 11 May 2018 07:21:21 -0500 Subject: [PATCH 07/27] Fixed launcher to create producer names that are 12 chars long. GH #2660 --- programs/eosio-launcher/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/eosio-launcher/main.cpp b/programs/eosio-launcher/main.cpp index 56631940199..2e63770d31d 100644 --- a/programs/eosio-launcher/main.cpp +++ b/programs/eosio-launcher/main.cpp @@ -769,7 +769,7 @@ launcher_def::bind_nodes () { --extra; } char ext = 'a' + i; - string pname = "init"; + string pname = "defproducer"; while (count--) { string prodname = pname+ext; node.producers.push_back(prodname); From 35bfff5f5627ebc8d7c1f5f12271cc109584788a Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Fri, 11 May 2018 07:24:48 -0500 Subject: [PATCH 08/27] Fixed scripts to create producer names that are 12 chars long. GH #2660 --- ...onsensus-validation-malicious-producers.py | 64 +++---- tests/distributed-transactions-remote-test.py | 10 +- tests/distributed-transactions-test.py | 4 +- tests/nodeos_run_remote_test.py | 6 +- tests/nodeos_run_test.py | 172 +++++++++--------- tests/p2p_network_test.py | 44 ++--- tests/p2p_stress.py | 6 +- tests/restart-scenarios-test.py | 16 +- tests/testUtils.py | 100 +++++----- 9 files changed, 211 insertions(+), 211 deletions(-) diff --git a/tests/consensus-validation-malicious-producers.py b/tests/consensus-validation-malicious-producers.py index 2024c39fb29..e59af720da7 100755 --- a/tests/consensus-validation-malicious-producers.py +++ b/tests/consensus-validation-malicious-producers.py @@ -119,32 +119,32 @@ p2p-peer-address = localhost:9876 required-participation = true private-key = ["EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"] -producer-name = initb +producer-name = defproducerb plugin = eosio::producer_plugin plugin = eosio::chain_api_plugin plugin = eosio::account_history_plugin plugin = eosio::account_history_api_plugin""" -producers="""producer-name = initd -producer-name = initf -producer-name = inith -producer-name = initj -producer-name = initl -producer-name = initn -producer-name = initp -producer-name = initr -producer-name = initt -producer-name = inita -producer-name = initc -producer-name = inite -producer-name = initg -producer-name = initi -producer-name = initk -producer-name = initm -producer-name = inito -producer-name = initq -producer-name = inits""" +producers="""producer-name = defproducerd +producer-name = defproducerf +producer-name = defproducerh +producer-name = defproducerj +producer-name = defproducerl +producer-name = defproducern +producer-name = defproducerp +producer-name = defproducerr +producer-name = defproducert +producer-name = defproducera +producer-name = defproducerc +producer-name = defproducere +producer-name = defproducerg +producer-name = defproduceri +producer-name = defproducerk +producer-name = defproducerm +producer-name = defproducero +producer-name = defproducerq +producer-name = defproducers""" zeroExecTime="trans-execution-time = 0" @@ -259,7 +259,7 @@ def myTest(transWillEnterBlock): error("FAILURE - create keys") return False currencyAccount=accounts[0] - currencyAccount.name="currency" + currencyAccount.name="currency0000" Print("Stand up walletd") if walletMgr.launch() is False: @@ -285,15 +285,15 @@ def myTest(transWillEnterBlock): error("Cluster in bad state, received None node") return False - initaAccount=testUtils.Cluster.initaAccount + defproduceraAccount=testUtils.Cluster.defproduceraAccount - Print("Importing keys for account %s into wallet %s." % (initaAccount.name, testWallet.name)) - if not walletMgr.importKey(initaAccount, testWallet): - error("Failed to import key for account %s" % (initaAccount.name)) + Print("Importing keys for account %s into wallet %s." % (defproduceraAccount.name, testWallet.name)) + if not walletMgr.importKey(defproduceraAccount, testWallet): + error("Failed to import key for account %s" % (defproduceraAccount.name)) return False - Print("Create new account %s via %s" % (currencyAccount.name, initaAccount.name)) - transId=node.createAccount(currencyAccount, initaAccount, stakedDeposit=5000, waitForTransBlock=True) + Print("Create new account %s via %s" % (currencyAccount.name, defproduceraAccount.name)) + transId=node.createAccount(currencyAccount, defproduceraAccount, stakedDeposit=5000, waitForTransBlock=True) if transId is None: error("Failed to create account %s" % (currencyAccount.name)) return False @@ -306,17 +306,17 @@ def myTest(transWillEnterBlock): error("Failed to publish contract.") return False - Print("push transfer action to currency contract") - contract="currency" + Print("push transfer action to currency0000 contract") + contract="currency0000" action="transfer" - data="{\"from\":\"currency\",\"to\":\"inita\",\"quantity\":" + data="{\"from\":\"currency0000\",\"to\":\"defproducera\",\"quantity\":" if amINoon: data +="\"00.0050 CUR\",\"memo\":\"test\"}" else: data +="50}" - opts="--permission currency@active" + opts="--permission currency0000@active" if not amINoon: - opts += " --scope currency,inita" + opts += " --scope currency0000,defproducera" trans=node.pushMessage(contract, action, data, opts, silentErrors=True) transInBlock=False diff --git a/tests/distributed-transactions-remote-test.py b/tests/distributed-transactions-remote-test.py index 42a9001e4d8..8ac7bb0001c 100755 --- a/tests/distributed-transactions-remote-test.py +++ b/tests/distributed-transactions-remote-test.py @@ -42,8 +42,8 @@ def errorExit(msg="", errorCode=1): clusterMapJsonTemplate="""{ "keys": { - "initaPrivateKey": "%s", - "initbPrivateKey": "%s" + "defproduceraPrivateKey": "%s", + "defproducerbPrivateKey": "%s" }, "nodes": [ {"port": 8888, "host": "localhost"}, @@ -73,10 +73,10 @@ def errorExit(msg="", errorCode=1): errorExit("Cluster never stabilized") producerKeys=testUtils.Cluster.parseClusterKeys(total_nodes) - initaPrvtKey=producerKeys["inita"]["private"] - initbPrvtKey=producerKeys["initb"]["private"] + defproduceraPrvtKey=producerKeys["defproducera"]["private"] + defproducerbPrvtKey=producerKeys["defproducerb"]["private"] - clusterMapJson = clusterMapJsonTemplate % (initaPrvtKey, initbPrvtKey) + clusterMapJson = clusterMapJsonTemplate % (defproduceraPrvtKey, defproducerbPrvtKey) tfile = os.fdopen(fd, "w") tfile.write(clusterMapJson) diff --git a/tests/distributed-transactions-test.py b/tests/distributed-transactions-test.py index 7f75ea0bef9..81c3bdd1b49 100755 --- a/tests/distributed-transactions-test.py +++ b/tests/distributed-transactions-test.py @@ -95,8 +95,8 @@ def errorExit(msg="", errorCode=1): if not cluster.populateWallet(accountsCount, wallet): errorExit("Wallet initialization failed.") - initaAccount=cluster.initaAccount - initbAccount=cluster.initbAccount + defproduceraAccount=cluster.defproduceraAccount + defproducerbAccount=cluster.defproducerbAccount eosioAccount=cluster.eosioAccount # TBD: get account is currently failing. Enable when ready diff --git a/tests/nodeos_run_remote_test.py b/tests/nodeos_run_remote_test.py index 62deb7172b5..ef5d3b7ac07 100755 --- a/tests/nodeos_run_remote_test.py +++ b/tests/nodeos_run_remote_test.py @@ -54,10 +54,10 @@ def errorExit(msg="", errorCode=1): errorExit("Cluster never stabilized") producerKeys=testUtils.Cluster.parseClusterKeys(1) - initaPrvtKey=producerKeys["inita"]["private"] - initbPrvtKey=producerKeys["initb"]["private"] + defproduceraPrvtKey=producerKeys["defproducera"]["private"] + defproducerbPrvtKey=producerKeys["defproducerb"]["private"] - cmd="%s --dont-launch --inita_prvt_key %s --initb_prvt_key %s %s %s %s" % (actualTest, initaPrvtKey, initbPrvtKey, "-v" if debug else "", "--dont-kill" if dontKill else "", "--only-bios" if onlyBios else "") + cmd="%s --dont-launch --defproducera_prvt_key %s --defproducerb_prvt_key %s %s %s %s" % (actualTest, defproduceraPrvtKey, defproducerbPrvtKey, "-v" if debug else "", "--dont-kill" if dontKill else "", "--only-bios" if onlyBios else "") Print("Starting up %s test: %s" % ("nodeos", actualTest)) Print("cmd: %s\n" % (cmd)) if 0 != subprocess.call(cmd, shell=True): diff --git a/tests/nodeos_run_test.py b/tests/nodeos_run_test.py index 94b3d50b71d..b2ed6f110f5 100755 --- a/tests/nodeos_run_test.py +++ b/tests/nodeos_run_test.py @@ -37,8 +37,8 @@ def cmdError(name, cmdCode=0, exitNow=False): parser.add_argument("-p", "--port", type=int, help="%s host port" % testUtils.Utils.EosServerName, default=DEFAULT_PORT) parser.add_argument("-c", "--prod-count", type=int, help="Per node producer count", default=1) -parser.add_argument("--inita_prvt_key", type=str, help="Inita private key.") -parser.add_argument("--initb_prvt_key", type=str, help="Initb private key.") +parser.add_argument("--defproducera_prvt_key", type=str, help="defproducera private key.") +parser.add_argument("--defproducerb_prvt_key", type=str, help="defproducerb private key.") parser.add_argument("--mongodb", help="Configure a MongoDb instance", action='store_true') parser.add_argument("--dump-error-details", help="Upon error print etc/eosio/node_*/config.ini and var/lib/node_*/stderr.log to stdout", @@ -57,8 +57,8 @@ def cmdError(name, cmdCode=0, exitNow=False): port=args.port debug=args.v enableMongo=args.mongodb -initaPrvtKey=args.inita_prvt_key -initbPrvtKey=args.initb_prvt_key +defproduceraPrvtKey=args.defproducera_prvt_key +defproducerbPrvtKey=args.defproducerb_prvt_key dumpErrorDetails=args.dump_error_details keepLogs=args.keep_logs dontLaunch=args.dont_launch @@ -68,7 +68,7 @@ def cmdError(name, cmdCode=0, exitNow=False): testUtils.Utils.Debug=debug localTest=True if server == LOCAL_HOST else False -cluster=testUtils.Cluster(walletd=True, enableMongo=enableMongo, initaPrvtKey=initaPrvtKey, initbPrvtKey=initbPrvtKey) +cluster=testUtils.Cluster(walletd=True, enableMongo=enableMongo, defproduceraPrvtKey=defproduceraPrvtKey, defproducerbPrvtKey=defproducerbPrvtKey) walletMgr=testUtils.WalletMgr(True) testSuccessful=False killEosInstances=not dontKill @@ -98,18 +98,18 @@ def cmdError(name, cmdCode=0, exitNow=False): cmdError("launcher") errorExit("Failed to stand up eos cluster.") else: - cluster.initializeNodes(initaPrvtKey=initaPrvtKey, initbPrvtKey=initbPrvtKey) + cluster.initializeNodes(defproduceraPrvtKey=defproduceraPrvtKey, defproducerbPrvtKey=defproducerbPrvtKey) killEosInstances=False accounts=testUtils.Cluster.createAccountKeys(3) if accounts is None: errorExit("FAILURE - create keys") testeraAccount=accounts[0] - testeraAccount.name="testera" + testeraAccount.name="testera11111" currencyAccount=accounts[1] - currencyAccount.name="currency" + currencyAccount.name="currency1111" exchangeAccount=accounts[2] - exchangeAccount.name="exchange" + exchangeAccount.name="exchange1111" PRV_KEY1=testeraAccount.ownerPrivateKey PUB_KEY1=testeraAccount.ownerPublicKey @@ -144,20 +144,20 @@ def cmdError(name, cmdCode=0, exitNow=False): cmdError("%s wallet import" % (ClientName)) errorExit("Failed to import key for account %s" % (account.name)) - initaWalletName="inita" - Print("Creating wallet \"%s\"." % (initaWalletName)) - initaWallet=walletMgr.create(initaWalletName) - if initaWallet is None: + defproduceraWalletName="defproducera" + Print("Creating wallet \"%s\"." % (defproduceraWalletName)) + defproduceraWallet=walletMgr.create(defproduceraWalletName) + if defproduceraWallet is None: cmdError("eos wallet create") - errorExit("Failed to create wallet %s." % (initaWalletName)) + errorExit("Failed to create wallet %s." % (defproduceraWalletName)) - initaAccount=cluster.initaAccount - initbAccount=cluster.initbAccount + defproduceraAccount=cluster.defproduceraAccount + defproducerbAccount=cluster.defproducerbAccount - Print("Importing keys for account %s into wallet %s." % (initaAccount.name, initaWallet.name)) - if not walletMgr.importKey(initaAccount, initaWallet): + Print("Importing keys for account %s into wallet %s." % (defproduceraAccount.name, defproduceraWallet.name)) + if not walletMgr.importKey(defproduceraAccount, defproduceraWallet): cmdError("%s wallet import" % (ClientName)) - errorExit("Failed to import key for account %s" % (initaAccount.name)) + errorExit("Failed to import key for account %s" % (defproduceraAccount.name)) Print("Locking wallet \"%s\"." % (testWallet.name)) if not walletMgr.lockWallet(testWallet): @@ -200,10 +200,10 @@ def cmdError(name, cmdCode=0, exitNow=False): cmdError("%s wallet lock_all" % (ClientName)) errorExit("Failed to lock all wallets") - Print("Unlocking wallet \"%s\"." % (initaWallet.name)) - if not walletMgr.unlockWallet(initaWallet): + Print("Unlocking wallet \"%s\"." % (defproduceraWallet.name)) + if not walletMgr.unlockWallet(defproduceraWallet): cmdError("%s wallet unlock" % (ClientName)) - errorExit("Failed to unlock wallet %s" % (initaWallet.name)) + errorExit("Failed to unlock wallet %s" % (defproduceraWallet.name)) Print("Unlocking wallet \"%s\"." % (testWallet.name)) if not walletMgr.unlockWallet(testWallet): @@ -212,7 +212,7 @@ def cmdError(name, cmdCode=0, exitNow=False): Print("Getting wallet keys.") actualKeys=walletMgr.getKeys() - expectedkeys=[initaAccount.ownerPrivateKey] + expectedkeys=[defproduceraAccount.ownerPrivateKey] noMatch=list(set(expectedkeys) - set(actualKeys)) if len(noMatch) > 0: errorExit("FAILURE - wallet keys did not include %s" % (noMatch), raw=True) @@ -221,8 +221,8 @@ def cmdError(name, cmdCode=0, exitNow=False): if node is None: errorExit("Cluster in bad state, received None node") - Print("Create new account %s via %s" % (testeraAccount.name, initaAccount.name)) - transId=node.createInitializeAccount(testeraAccount, initaAccount, stakedDeposit=0, waitForTransBlock=False) + Print("Create new account %s via %s" % (testeraAccount.name, defproduceraAccount.name)) + transId=node.createInitializeAccount(testeraAccount, defproduceraAccount, stakedDeposit=0, waitForTransBlock=False) if transId is None: cmdError("%s create account" % (ClientName)) errorExit("Failed to create account %s" % (testeraAccount.name)) @@ -232,11 +232,11 @@ def cmdError(name, cmdCode=0, exitNow=False): errorExit("FAILURE - account creation failed.", raw=True) transferAmount="97.5321 EOS" - Print("Transfer funds %s from account %s to %s" % (transferAmount, initaAccount.name, testeraAccount.name)) - if node.transferFunds(initaAccount, testeraAccount, transferAmount, "test transfer") is None: + Print("Transfer funds %s from account %s to %s" % (transferAmount, defproduceraAccount.name, testeraAccount.name)) + if node.transferFunds(defproduceraAccount, testeraAccount, transferAmount, "test transfer") is None: cmdError("%s transfer" % (ClientName)) errorExit("Failed to transfer funds %d from account %s to %s" % ( - transferAmount, initaAccount.name, testeraAccount.name)) + transferAmount, defproduceraAccount.name, testeraAccount.name)) expectedAmount=transferAmount Print("Verify transfer, Expected: %s" % (expectedAmount)) @@ -247,11 +247,11 @@ def cmdError(name, cmdCode=0, exitNow=False): transferAmount="0.0100 EOS" Print("Force transfer funds %s from account %s to %s" % ( - transferAmount, initaAccount.name, testeraAccount.name)) - if node.transferFunds(initaAccount, testeraAccount, transferAmount, "test transfer", force=True) is None: + transferAmount, defproduceraAccount.name, testeraAccount.name)) + if node.transferFunds(defproduceraAccount, testeraAccount, transferAmount, "test transfer", force=True) is None: cmdError("%s transfer" % (ClientName)) errorExit("Failed to force transfer funds %d from account %s to %s" % ( - transferAmount, initaAccount.name, testeraAccount.name)) + transferAmount, defproduceraAccount.name, testeraAccount.name)) expectedAmount="97.5421 EOS" Print("Verify transfer, Expected: %s" % (expectedAmount)) @@ -260,14 +260,14 @@ def cmdError(name, cmdCode=0, exitNow=False): cmdError("FAILURE - transfer failed") errorExit("Transfer verification failed. Excepted %s, actual: %s" % (expectedAmount, actualAmount)) - Print("Create new account %s via %s" % (currencyAccount.name, initbAccount.name)) - transId=node.createInitializeAccount(currencyAccount, initbAccount, stakedDeposit=5000) + Print("Create new account %s via %s" % (currencyAccount.name, defproducerbAccount.name)) + transId=node.createInitializeAccount(currencyAccount, defproducerbAccount, stakedDeposit=5000) if transId is None: cmdError("%s create account" % (ClientName)) errorExit("Failed to create account %s" % (currencyAccount.name)) - Print("Create new account %s via %s" % (exchangeAccount.name, initaAccount.name)) - transId=node.createInitializeAccount(exchangeAccount, initaAccount, waitForTransBlock=True) + Print("Create new account %s via %s" % (exchangeAccount.name, defproduceraAccount.name)) + transId=node.createInitializeAccount(exchangeAccount, defproduceraAccount, waitForTransBlock=True) if transId is None: cmdError("%s create account" % (ClientName)) errorExit("Failed to create account %s" % (exchangeAccount.name)) @@ -337,20 +337,20 @@ def cmdError(name, cmdCode=0, exitNow=False): # # This API (get servants) is no longer supported. # expectedServants=[testeraAccount.name, currencyAccount.name] - # Print("Get %s servants, Expected: %s" % (initaAccount.name, expectedServants)) - # actualServants=node.getServantsArr(initaAccount.name) + # Print("Get %s servants, Expected: %s" % (defproduceraAccount.name, expectedServants)) + # actualServants=node.getServantsArr(defproduceraAccount.name) # if actualServants is None: - # cmdError("%s get servants testera" % (ClientName)) - # errorExit("Failed to retrieve %s servants" % (initaAccount.name)) + # cmdError("%s get servants testera11111" % (ClientName)) + # errorExit("Failed to retrieve %s servants" % (defproduceraAccount.name)) # noMatch=list(set(expectedAccounts) - set(actualAccounts)) # if len(noMatch) > 0: # errorExit("FAILURE - %s servants. Expected: %s, Actual: %s" % ( - # initaAccount.name, expectedServants, actualServants), raw=True) + # defproduceraAccount.name, expectedServants, actualServants), raw=True) # # Print("Get %s servants, Expected: []" % (testeraAccount.name)) # actualServants=node.getServantsArr(testeraAccount.name) # if actualServants is None: - # cmdError("%s get servants testera" % (ClientName)) + # cmdError("%s get servants testera11111" % (ClientName)) # errorExit("Failed to retrieve %s servants" % (testeraAccount.name)) # if len(actualServants) > 0: # errorExit("FAILURE - %s servants. Expected: [], Actual: %s" % ( @@ -390,21 +390,21 @@ def cmdError(name, cmdCode=0, exitNow=False): # Print("Get transactions for account %s" % (testeraAccount.name)) # actualTransactions=node.getTransactionsArrByAccount(testeraAccount.name) # if actualTransactions is None: - # cmdError("%s get transactions testera" % (ClientName)) + # cmdError("%s get transactions testera11111" % (ClientName)) # errorExit("Failed to get transactions by account %s" % (testeraAccount.name)) # if transId not in actualTransactions: - # errorExit("FAILURE - get transactions testera failed", raw=True) + # errorExit("FAILURE - get transactions testera11111 failed", raw=True) Print("Currency Contract Tests") Print("verify no contract in place") Print("Get code hash for account %s" % (currencyAccount.name)) codeHash=node.getAccountCodeHash(currencyAccount.name) if codeHash is None: - cmdError("%s get code currency" % (ClientName)) + cmdError("%s get code currency1111" % (ClientName)) errorExit("Failed to get code hash for account %s" % (currencyAccount.name)) hashNum=int(codeHash, 16) if hashNum != 0: - errorExit("FAILURE - get code currency failed", raw=True) + errorExit("FAILURE - get code currency1111 failed", raw=True) contractDir="contracts/eosio.token" wastFile="contracts/eosio.token/eosio.token.wast" @@ -412,18 +412,18 @@ def cmdError(name, cmdCode=0, exitNow=False): Print("Publish contract") trans=node.publishContract(currencyAccount.name, contractDir, wastFile, abiFile, waitForTransBlock=True) if trans is None: - cmdError("%s set contract currency" % (ClientName)) + cmdError("%s set contract currency1111" % (ClientName)) errorExit("Failed to publish contract.") if not enableMongo: Print("Get code hash for account %s" % (currencyAccount.name)) codeHash=node.getAccountCodeHash(currencyAccount.name) if codeHash is None: - cmdError("%s get code currency" % (ClientName)) + cmdError("%s get code currency1111" % (ClientName)) errorExit("Failed to get code hash for account %s" % (currencyAccount.name)) hashNum=int(codeHash, 16) if hashNum == 0: - errorExit("FAILURE - get code currency failed", raw=True) + errorExit("FAILURE - get code currency1111 failed", raw=True) else: Print("verify abi is set") account=node.getEosAccountFromDb(currencyAccount.name) @@ -433,64 +433,64 @@ def cmdError(name, cmdCode=0, exitNow=False): if abiName != "transfer" or abiActionName != "transfer" or abiType != "transfer": errorExit("FAILURE - get EOS account failed", raw=True) - Print("push create action to currency contract") - contract="currency" + Print("push create action to currency1111 contract") + contract="currency1111" action="create" - data="{\"issuer\":\"currency\",\"maximum_supply\":\"100000.0000 CUR\",\"can_freeze\":\"0\",\"can_recall\":\"0\",\"can_whitelist\":\"0\"}" - opts="--permission currency@active" + data="{\"issuer\":\"currency1111\",\"maximum_supply\":\"100000.0000 CUR\",\"can_freeze\":\"0\",\"can_recall\":\"0\",\"can_whitelist\":\"0\"}" + opts="--permission currency1111@active" trans=node.pushMessage(contract, action, data, opts) if trans is None or not trans[0]: - errorExit("FAILURE - create action to currency contract failed", raw=True) + errorExit("FAILURE - create action to currency1111 contract failed", raw=True) - Print("push issue action to currency contract") + Print("push issue action to currency1111 contract") action="issue" - data="{\"to\":\"currency\",\"quantity\":\"100000.0000 CUR\",\"memo\":\"issue\"}" - opts="--permission currency@active" + data="{\"to\":\"currency1111\",\"quantity\":\"100000.0000 CUR\",\"memo\":\"issue\"}" + opts="--permission currency1111@active" trans=node.pushMessage(contract, action, data, opts) if trans is None or not trans[0]: - errorExit("FAILURE - issue action to currency contract failed", raw=True) + errorExit("FAILURE - issue action to currency1111 contract failed", raw=True) - Print("Verify currency contract has proper initial balance (via get table)") - contract="currency" + Print("Verify currency1111 contract has proper initial balance (via get table)") + contract="currency1111" table="accounts" row0=node.getTableRow(contract, currencyAccount.name, table, 0) if row0 is None: - cmdError("%s get currency table currency account" % (ClientName)) + cmdError("%s get currency1111 table currency1111 account" % (ClientName)) errorExit("Failed to retrieve contract %s table %s" % (contract, table)) balanceKey="balance" keyKey="key" if row0[balanceKey] != "100000.0000 CUR": - errorExit("FAILURE - Wrong currency balance", raw=True) + errorExit("FAILURE - Wrong currency1111 balance", raw=True) - Print("Verify currency contract has proper initial balance (via get currency balance)") - amountStr=node.getNodeAccountBalance("currency", currencyAccount.name) + Print("Verify currency1111 contract has proper initial balance (via get currency1111 balance)") + amountStr=node.getNodeAccountBalance("currency1111", currencyAccount.name) expected="100000.0000 CUR" actual=amountStr if actual != expected: - errorExit("FAILURE - get currency balance failed. Recieved response: <%s>" % (res), raw=True) + errorExit("FAILURE - get currency1111 balance failed. Recieved response: <%s>" % (res), raw=True) - # TBD: "get currency stats is still not working. Enable when ready. - # Print("Verify currency contract has proper total supply of CUR (via get currency stats)") + # TBD: "get currency1111 stats is still not working. Enable when ready. + # Print("Verify currency1111 contract has proper total supply of CUR (via get currency1111 stats)") # res=node.getCurrencyStats(contract, "CUR") # if res is None or not ("supply" in res): - # cmdError("%s get currency stats" % (ClientName)) + # cmdError("%s get currency1111 stats" % (ClientName)) # errorExit("Failed to retrieve CUR stats from contract %s" % (contract)) # if res["supply"] != "100000.0000 CUR": - # errorExit("FAILURE - get currency stats failed", raw=True) + # errorExit("FAILURE - get currency1111 stats failed", raw=True) - Print("push transfer action to currency contract") - contract="currency" + Print("push transfer action to currency1111 contract") + contract="currency1111" action="transfer" - data="{\"from\":\"currency\",\"to\":\"inita\",\"quantity\":" + data="{\"from\":\"currency1111\",\"to\":\"defproducera\",\"quantity\":" data +="\"00.0050 CUR\",\"memo\":\"test\"}" - opts="--permission currency@active" + opts="--permission currency1111@active" trans=node.pushMessage(contract, action, data, opts) if trans is None or not trans[0]: - cmdError("%s push message currency transfer" % (ClientName)) - errorExit("Failed to push message to currency contract") + cmdError("%s push message currency1111 transfer" % (ClientName)) + errorExit("Failed to push message to currency1111 contract") transId=testUtils.Node.getTransId(trans[1]) Print("verify transaction exists") @@ -499,19 +499,19 @@ def cmdError(name, cmdCode=0, exitNow=False): errorExit("Failed to verify push message transaction id.") Print("read current contract balance") - amountStr=node.getNodeAccountBalance("currency", initaAccount.name) + amountStr=node.getNodeAccountBalance("currency1111", defproduceraAccount.name) expected="0.0050 CUR" actual=amountStr if actual != expected: - errorExit("FAILURE - Wrong currency balance (expected=%s, actual=%s)" % (str(expected), str(actual)), raw=True) + errorExit("FAILURE - Wrong currency1111 balance (expected=%s, actual=%s)" % (str(expected), str(actual)), raw=True) - amountStr=node.getNodeAccountBalance("currency", currencyAccount.name) + amountStr=node.getNodeAccountBalance("currency1111", currencyAccount.name) expected="99999.9950 CUR" actual=amountStr if actual != expected: - errorExit("FAILURE - Wrong currency balance (expected=%s, actual=%s)" % (str(expected), str(actual)), raw=True) + errorExit("FAILURE - Wrong currency1111 balance (expected=%s, actual=%s)" % (str(expected), str(actual)), raw=True) Print("Exchange Contract Tests") Print("upload exchange contract") @@ -539,7 +539,7 @@ def cmdError(name, cmdCode=0, exitNow=False): Print("Test successful, %s returned error code: %d" % (ClientName, retMap["returncode"])) Print("set permission") - code="currency" + code="currency1111" pType="transfer" requirement="active" trans=node.setPermission(testeraAccount.name, code, pType, requirement, waitForTransBlock=True) @@ -559,16 +559,16 @@ def cmdError(name, cmdCode=0, exitNow=False): cmdError("%s wallet lock_all" % (ClientName)) errorExit("Failed to lock all wallets") - Print("Unlocking wallet \"%s\"." % (initaWallet.name)) - if not walletMgr.unlockWallet(initaWallet): - cmdError("%s wallet unlock inita" % (ClientName)) - errorExit("Failed to unlock wallet %s" % (initaWallet.name)) + Print("Unlocking wallet \"%s\"." % (defproduceraWallet.name)) + if not walletMgr.unlockWallet(defproduceraWallet): + cmdError("%s wallet unlock defproducera" % (ClientName)) + errorExit("Failed to unlock wallet %s" % (defproduceraWallet.name)) - Print("Get account inita") - account=node.getEosAccount(initaAccount.name) + Print("Get account defproducera") + account=node.getEosAccount(defproduceraAccount.name) if account is None: cmdError("%s get account" % (ClientName)) - errorExit("Failed to get account %s" % (initaAccount.name)) + errorExit("Failed to get account %s" % (defproduceraAccount.name)) # # Proxy diff --git a/tests/p2p_network_test.py b/tests/p2p_network_test.py index c8d72e931dd..a8a6fb2711c 100755 --- a/tests/p2p_network_test.py +++ b/tests/p2p_network_test.py @@ -30,10 +30,10 @@ parser.add_argument('-?', action='help', default=argparse.SUPPRESS, help=argparse._('show this help message and exit')) parser.add_argument("-o", "--output", type=str, help="output file", default=TEST_OUTPUT_DEFAULT) -parser.add_argument("--inita_prvt_key", type=str, help="Inita private key.", - default=testUtils.Cluster.initaAccount.ownerPrivateKey) -parser.add_argument("--initb_prvt_key", type=str, help="Initb private key.", - default=testUtils.Cluster.initbAccount.ownerPrivateKey) +parser.add_argument("--defproducera_prvt_key", type=str, help="defproducera private key.", + default=testUtils.Cluster.defproduceraAccount.ownerPrivateKey) +parser.add_argument("--defproducerb_prvt_key", type=str, help="defproducerb private key.", + default=testUtils.Cluster.defproducerbAccount.ownerPrivateKey) parser.add_argument("--wallet_host", type=str, help="wallet host", default="localhost") parser.add_argument("--wallet_port", type=int, help="wallet port", default=8899) parser.add_argument("--impaired_network", help="test impaired network", action='store_true') @@ -44,8 +44,8 @@ args = parser.parse_args() testOutputFile=args.output enableMongo=False -initaPrvtKey=args.inita_prvt_key -initbPrvtKey=args.initb_prvt_key +defproduceraPrvtKey=args.defproducera_prvt_key +defproducerbPrvtKey=args.defproducerb_prvt_key walletMgr=testUtils.WalletMgr(True, port=args.wallet_port, host=args.wallet_host) @@ -58,7 +58,7 @@ else: errorExit("one of impaired_network, lossy_network or stress_network must be set. Please also check peer configs in p2p_test_peers.py.") -cluster=testUtils.Cluster(walletd=True, enableMongo=enableMongo, initaPrvtKey=initaPrvtKey, initbPrvtKey=initbPrvtKey, walletHost=args.wallet_host, walletPort=args.wallet_port) +cluster=testUtils.Cluster(walletd=True, enableMongo=enableMongo, defproduceraPrvtKey=defproduceraPrvtKey, defproducerbPrvtKey=defproducerbPrvtKey, walletHost=args.wallet_host, walletPort=args.wallet_port) print("BEGIN") print("TEST_OUTPUT: %s" % (testOutputFile)) @@ -88,11 +88,11 @@ if accounts is None: errorExit("FAILURE - create keys") testeraAccount=accounts[0] -testeraAccount.name="testera" +testeraAccount.name="testera11111" currencyAccount=accounts[1] -currencyAccount.name="currency" +currencyAccount.name="currency1111" exchangeAccount=accounts[2] -exchangeAccount.name="exchange" +exchangeAccount.name="exchange1111" PRV_KEY1=testeraAccount.ownerPrivateKey PUB_KEY1=testeraAccount.ownerPublicKey @@ -125,27 +125,27 @@ cmdError("%s wallet import" % (ClientName)) errorExit("Failed to import key for account %s" % (account.name)) -initaWalletName="inita" -Print("Creating wallet \"%s\"." % (initaWalletName)) -initaWallet=walletMgr.create(initaWalletName) -if initaWallet is None: +defproduceraWalletName="defproducera" +Print("Creating wallet \"%s\"." % (defproduceraWalletName)) +defproduceraWallet=walletMgr.create(defproduceraWalletName) +if defproduceraWallet is None: cmdError("eos wallet create") - errorExit("Failed to create wallet %s." % (initaWalletName)) + errorExit("Failed to create wallet %s." % (defproduceraWalletName)) -initaAccount=testUtils.Cluster.initaAccount -# initbAccount=testUtils.Cluster.initbAccount +defproduceraAccount=testUtils.Cluster.defproduceraAccount +# defproducerbAccount=testUtils.Cluster.defproducerbAccount -Print("Importing keys for account %s into wallet %s." % (initaAccount.name, initaWallet.name)) -if not walletMgr.importKey(initaAccount, initaWallet): +Print("Importing keys for account %s into wallet %s." % (defproduceraAccount.name, defproduceraWallet.name)) +if not walletMgr.importKey(defproduceraAccount, defproduceraWallet): cmdError("%s wallet import" % (ClientName)) - errorExit("Failed to import key for account %s" % (initaAccount.name)) + errorExit("Failed to import key for account %s" % (defproduceraAccount.name)) node0=cluster.getNode(0) if node0 is None: errorExit("cluster in bad state, received None node") -# eosio should have the same key as inita -eosio = copy.copy(initaAccount) +# eosio should have the same key as defproducera +eosio = copy.copy(defproduceraAccount) eosio.name = "eosio" Print("Info of each node:") diff --git a/tests/p2p_stress.py b/tests/p2p_stress.py index 5e2d688b50b..dcd2867469d 100644 --- a/tests/p2p_stress.py +++ b/tests/p2p_stress.py @@ -47,7 +47,7 @@ def execute(self, cmdInd, node, ta, eosio): return ([], "", 0.0, "failed to create account") print("transaction id %s" % (trid)) - print("issue currency into %s" % (acc1.name)) + print("issue currency0000 into %s" % (acc1.name)) contract="eosio" action="issue" data="{\"to\":\"" + acc1.name + "\",\"quantity\":\"1000000.0000 EOS\"}" @@ -55,7 +55,7 @@ def execute(self, cmdInd, node, ta, eosio): tr=node.pushMessage(contract, action, data, opts) trid = node.getTransId(tr[1]) if trid is None: - return ([], "", 0.0, "failed to issue currency") + return ([], "", 0.0, "failed to issue currency0000") print("transaction id %s" % (trid)) node.waitForTransIdOnNode(trid) @@ -68,7 +68,7 @@ def execute(self, cmdInd, node, ta, eosio): total = cycle * nthreads # rounding delay = 1.0 / self.speeds[cmdInd] * nthreads - print("start currency trasfer from %s to %s for %d times with %d threads" % (acc1.name, acc2.name, total, nthreads)) + print("start currency0000 trasfer from %s to %s for %d times with %d threads" % (acc1.name, acc2.name, total, nthreads)) t00 = time.time() for k in range(cycle): diff --git a/tests/restart-scenarios-test.py b/tests/restart-scenarios-test.py index 23b532139c3..5eb6ad892a0 100755 --- a/tests/restart-scenarios-test.py +++ b/tests/restart-scenarios-test.py @@ -98,22 +98,22 @@ def errorExit(msg="", errorCode=1): if not cluster.populateWallet(accountsCount, wallet): errorExit("Wallet initialization failed.") - initaAccount=cluster.initaAccount + defproduceraAccount=cluster.defproduceraAccount - Print("Importing keys for account %s into wallet %s." % (initaAccount.name, wallet.name)) - if not walletMgr.importKey(initaAccount, wallet): - errorExit("Failed to import key for account %s" % (initaAccount.name)) + Print("Importing keys for account %s into wallet %s." % (defproduceraAccount.name, wallet.name)) + if not walletMgr.importKey(defproduceraAccount, wallet): + errorExit("Failed to import key for account %s" % (defproduceraAccount.name)) Print("Create accounts.") #if not cluster.createAccounts(wallet): - if not cluster.createAccounts(initaAccount): + if not cluster.createAccounts(defproduceraAccount): errorExit("Accounts creation failed.") Print("Wait on cluster sync.") if not cluster.waitOnClusterSync(): errorExit("Cluster sync wait failed.") - # TBD: Known issue (Issue 2043) that 'get currency balance' doesn't return balance. + # TBD: Known issue (Issue 2043) that 'get currency0000 balance' doesn't return balance. # Uncomment when functional # Print("Spread funds and validate") # if not cluster.spreadFundsAndValidate(10): @@ -128,7 +128,7 @@ def errorExit(msg="", errorCode=1): errorExit("Failed to kill Eos instances") Print("nodeos instances killed.") - # TBD: Known issue (Issue 2043) that 'get currency balance' doesn't return balance. + # TBD: Known issue (Issue 2043) that 'get currency0000 balance' doesn't return balance. # Uncomment when functional # Print("Spread funds and validate") # if not cluster.spreadFundsAndValidate(10): @@ -148,7 +148,7 @@ def errorExit(msg="", errorCode=1): errorExit("Cluster never synchronized") Print ("Cluster synched") - # TBD: Known issue (Issue 2043) that 'get currency balance' doesn't return balance. + # TBD: Known issue (Issue 2043) that 'get currency0000 balance' doesn't return balance. # Uncomment when functional # Print("Spread funds and validate") # if not cluster.spreadFundsAndValidate(10): diff --git a/tests/testUtils.py b/tests/testUtils.py index 6281c0cd067..47bc7d4625f 100755 --- a/tests/testUtils.py +++ b/tests/testUtils.py @@ -568,14 +568,14 @@ def getNodeAccountBalance(self, contract, scope): raise def getCurrencyStats(self, contract, symbol=""): - cmd="%s %s get currency stats %s %s" % (Utils.EosClientPath, self.endpointArgs, contract, symbol) + cmd="%s %s get currency0000 stats %s %s" % (Utils.EosClientPath, self.endpointArgs, contract, symbol) if Utils.Debug: Utils.Print("cmd: %s" % (cmd)) try: trans=Node.runCmdReturnJson(cmd) return trans except subprocess.CalledProcessError as ex: msg=ex.output.decode("utf-8") - Utils.Print("ERROR: Exception during get currency stats. %s" % (msg)) + Utils.Print("ERROR: Exception during get currency0000 stats. %s" % (msg)) return None # Verifies account. Returns "get account" json return object @@ -716,7 +716,7 @@ def getServantsArr(self, name): return servants def getAccountEosBalanceStr(self, scope): - """Returns EOS currency account balance from cleos get table command. Returned balance is string following syntax "98.0311 EOS". """ + """Returns EOS currency0000 account balance from cleos get table command. Returned balance is string following syntax "98.0311 EOS". """ assert isinstance(scope, str) if not self.enableMongo: amount=self.getNodeAccountBalance("eosio.token", scope) @@ -736,7 +736,7 @@ def getAccountEosBalanceStr(self, scope): return None def getAccountEosBalance(self, scope): - """Returns EOS currency account balance from cleos get table command. Returned balance is an integer e.g. 980311. """ + """Returns EOS currency0000 account balance from cleos get table command. Returned balance is an integer e.g. 980311. """ balanceStr=self.getAccountEosBalanceStr(scope) balanceStr=balanceStr.split()[0] balance=int(decimal.Decimal(balanceStr[1:])*10000) @@ -1174,7 +1174,7 @@ class Cluster(object): # pylint: disable=too-many-arguments # walletd [True|False] Is keosd running. If not load the wallet plugin - def __init__(self, walletd=False, localCluster=True, host="localhost", port=8888, walletHost="localhost", walletPort=8899, enableMongo=False, mongoHost="localhost", mongoPort=27017, mongoDb="EOStest", initaPrvtKey=None, initbPrvtKey=None, staging=False): + def __init__(self, walletd=False, localCluster=True, host="localhost", port=8888, walletHost="localhost", walletPort=8899, enableMongo=False, mongoHost="localhost", mongoPort=27017, mongoDb="EOStest", defproduceraPrvtKey=None, defproducerbPrvtKey=None, staging=False): """Cluster container. walletd [True|False] Is wallet keosd running. If not load the wallet plugin localCluster [True|False] Is cluster local to host. @@ -1185,8 +1185,8 @@ def __init__(self, walletd=False, localCluster=True, host="localhost", port=8888 enableMongo: Include mongoDb support, configures eos mongo plugin mongoHost: MongoDB host mongoPort: MongoDB port - initaPrvtKey: Inita account private key - initbPrvtKey: Initb account private key + defproduceraPrvtKey: Defproducera account private key + defproducerbPrvtKey: Defproducerb account private key """ self.accounts={} self.nodes={} @@ -1212,13 +1212,13 @@ def __init__(self, walletd=False, localCluster=True, host="localhost", port=8888 self.mongoEndpointArgs += "--host %s --port %d %s" % (mongoHost, mongoPort, mongoDb) self.staging=staging # init accounts - self.initaAccount=Account("inita") - self.initbAccount=Account("initb") + self.defproduceraAccount=Account("defproducera") + self.defproducerbAccount=Account("defproducerb") self.eosioAccount=Account("eosio") - self.initaAccount.ownerPrivateKey=initaPrvtKey - self.initaAccount.activePrivateKey=initaPrvtKey - self.initbAccount.ownerPrivateKey=initbPrvtKey - self.initbAccount.activePrivateKey=initbPrvtKey + self.defproduceraAccount.ownerPrivateKey=defproduceraPrvtKey + self.defproduceraAccount.activePrivateKey=defproduceraPrvtKey + self.defproducerbAccount.ownerPrivateKey=defproducerbPrvtKey + self.defproducerbAccount.activePrivateKey=defproducerbPrvtKey def setChainStrategy(self, chainSyncStrategy=Utils.SyncReplayTag): @@ -1309,24 +1309,24 @@ def launch(self, pnodes=1, totalNodes=1, prodCount=1, topo="mesh", delay=1, only Utils.Print("ERROR: Unable to parse cluster info") return False - init1Keys=producerKeys["inita"] - init2Keys=producerKeys["initb"] + init1Keys=producerKeys["defproducera"] + init2Keys=producerKeys["defproducerb"] if init1Keys is None or init2Keys is None: - Utils.Print("ERROR: Failed to parse inita or intb private keys from cluster config files.") - self.initaAccount.ownerPrivateKey=init1Keys["private"] - self.initaAccount.ownerPublicKey=init1Keys["public"] - self.initaAccount.activePrivateKey=init1Keys["private"] - self.initaAccount.activePublicKey=init1Keys["public"] - self.initbAccount.ownerPrivateKey=init2Keys["private"] - self.initbAccount.ownerPublicKey=init2Keys["public"] - self.initbAccount.activePrivateKey=init2Keys["private"] - self.initbAccount.activePublicKey=init2Keys["public"] + Utils.Print("ERROR: Failed to parse defproducera or intb private keys from cluster config files.") + self.defproduceraAccount.ownerPrivateKey=init1Keys["private"] + self.defproduceraAccount.ownerPublicKey=init1Keys["public"] + self.defproduceraAccount.activePrivateKey=init1Keys["private"] + self.defproduceraAccount.activePublicKey=init1Keys["public"] + self.defproducerbAccount.ownerPrivateKey=init2Keys["private"] + self.defproducerbAccount.ownerPublicKey=init2Keys["public"] + self.defproducerbAccount.activePrivateKey=init2Keys["private"] + self.defproducerbAccount.activePublicKey=init2Keys["public"] producerKeys.pop("eosio") return True # Initialize the default nodes (at present just the root node) - def initializeNodes(self, initaPrvtKey=None, initbPrvtKey=None, onlyBios=False): + def initializeNodes(self, defproduceraPrvtKey=None, defproducerbPrvtKey=None, onlyBios=False): port=Cluster.__BiosPort if onlyBios else self.port host=Cluster.__BiosHost if onlyBios else self.host node=Node(self.host, self.port, enableMongo=self.enableMongo, mongoHost=self.mongoHost, mongoPort=self.mongoPort, mongoDb=self.mongoDb) @@ -1336,13 +1336,13 @@ def initializeNodes(self, initaPrvtKey=None, initbPrvtKey=None, onlyBios=False): node.checkPulse() self.nodes=[node] - if initaPrvtKey is not None: - self.initaAccount.ownerPrivateKey=initaPrvtKey - self.initaAccount.activePrivateKey=initaPrvtKey + if defproduceraPrvtKey is not None: + self.defproduceraAccount.ownerPrivateKey=defproduceraPrvtKey + self.defproduceraAccount.activePrivateKey=defproduceraPrvtKey - if initbPrvtKey is not None: - self.initbAccount.ownerPrivateKey=initbPrvtKey - self.initbAccount.activePrivateKey=initbPrvtKey + if defproducerbPrvtKey is not None: + self.defproducerbAccount.ownerPrivateKey=defproducerbPrvtKey + self.defproducerbAccount.activePrivateKey=defproducerbPrvtKey return True @@ -1356,13 +1356,13 @@ def initializeNodesFromJson(self, nodesJsonStr): if "keys" in nodesObj: keysMap=nodesObj["keys"] - if "initaPrivateKey" in keysMap: - initaPrivateKey=keysMap["initaPrivateKey"] - self.initaAccount.ownerPrivateKey=initaPrivateKey + if "defproduceraPrivateKey" in keysMap: + defproduceraPrivateKey=keysMap["defproduceraPrivateKey"] + self.defproduceraAccount.ownerPrivateKey=defproduceraPrivateKey - if "initbPrivateKey" in keysMap: - initbPrivateKey=keysMap["initbPrivateKey"] - self.initbAccount.ownerPrivateKey=initbPrivateKey + if "defproducerbPrivateKey" in keysMap: + defproducerbPrivateKey=keysMap["defproducerbPrivateKey"] + self.defproducerbAccount.ownerPrivateKey=defproducerbPrivateKey nArr=nodesObj["nodes"] nodes=[] @@ -1434,7 +1434,7 @@ def createAccountKeys(count): activePrivate=m.group(1) activePublic=m.group(2) - name=''.join(random.choice(string.ascii_lowercase) for _ in range(5)) + name=''.join(random.choice(string.ascii_lowercase) for _ in range(12)) account=Account(name) account.ownerPrivateKey=ownerPrivate account.ownerPublicKey=ownerPublic @@ -1455,7 +1455,7 @@ def createAccountKeys(count): return accounts # create account keys and import into wallet. Wallet initialization will be user responsibility - # also imports inita and initb accounts + # also imports defproducera and defproducerb accounts def populateWallet(self, accountsCount, wallet): if self.walletMgr is None: Utils.Print("ERROR: WalletMgr hasn't been initialized.") @@ -1469,14 +1469,14 @@ def populateWallet(self, accountsCount, wallet): Utils.Print("Account keys creation failed.") return False - Utils.Print("Importing keys for account %s into wallet %s." % (self.initaAccount.name, wallet.name)) - if not self.walletMgr.importKey(self.initaAccount, wallet): - Utils.Print("ERROR: Failed to import key for account %s" % (self.initaAccount.name)) + Utils.Print("Importing keys for account %s into wallet %s." % (self.defproduceraAccount.name, wallet.name)) + if not self.walletMgr.importKey(self.defproduceraAccount, wallet): + Utils.Print("ERROR: Failed to import key for account %s" % (self.defproduceraAccount.name)) return False - Utils.Print("Importing keys for account %s into wallet %s." % (self.initbAccount.name, wallet.name)) - if not self.walletMgr.importKey(self.initbAccount, wallet): - Utils.Print("ERROR: Failed to import key for account %s" % (self.initbAccount.name)) + Utils.Print("Importing keys for account %s into wallet %s." % (self.defproducerbAccount.name, wallet.name)) + if not self.walletMgr.importKey(self.defproducerbAccount, wallet): + Utils.Print("ERROR: Failed to import key for account %s" % (self.defproducerbAccount.name)) return False for account in accounts: @@ -1504,7 +1504,7 @@ def spreadFunds(self, amount=1): count=len(self.accounts) transferAmount=(count*amount)+amount node=self.nodes[0] - fromm=self.initaAccount + fromm=self.defproduceraAccount to=self.accounts[0] Utils.Print("Transfer %d units from account %s to %s on eos server port %d" % ( transferAmount, fromm.name, to.name, node.port)) @@ -1541,7 +1541,7 @@ def spreadFunds(self, amount=1): transferAmount -= amount fromm=account - to=self.accounts[i+1] if i < (count-1) else self.initaAccount + to=self.accounts[i+1] if i < (count-1) else self.defproduceraAccount Utils.Print("Transfer %d units from account %s to %s on eos server port %d." % (transferAmount, fromm.name, to.name, node.port)) @@ -1570,7 +1570,7 @@ def validateSpreadFunds(self, expectedTotal): if not node.killed: if Utils.Debug: Utils.Print("Validate funds on %s server port %d." % (Utils.EosServerName, node.port)) - if node.validateSpreadFundsOnNode(self.initaAccount, self.accounts, expectedTotal) is False: + if node.validateSpreadFundsOnNode(self.defproduceraAccount, self.accounts, expectedTotal) is False: Utils.Print("ERROR: Failed to validate funds on eos node port: %d" % (node.port)) return False @@ -1578,7 +1578,7 @@ def validateSpreadFunds(self, expectedTotal): def spreadFundsAndValidate(self, amount=1): if Utils.Debug: Utils.Print("Get system balance.") - initialFunds=self.nodes[0].getSystemBalance(self.initaAccount, self.accounts) + initialFunds=self.nodes[0].getSystemBalance(self.defproduceraAccount, self.accounts) if Utils.Debug: Utils.Print("Initial system balance: %d" % (initialFunds)) if False == self.spreadFunds(amount): @@ -1829,7 +1829,7 @@ def bootstrap(totalNodes, prodCount, biosHost, biosPort, dontKill=False, onlyBio Utils.Print("ERROR: Failed to publish contract %s." % (contract)) return False - # Create currency, followed by issue currency + # Create currency0000, followed by issue currency0000 contract=eosioTokenAccount.name Utils.Print("push create action to %s contract" % (contract)) action="create" From 28095a5ee1d55e04028c53ba920deb760a429695 Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Mon, 14 May 2018 10:23:51 -0500 Subject: [PATCH 09/27] Fixed test account names for eosio.system contract loaded. GH #2660 --- unittests/eosio.system_tests.cpp | 1222 +++++++++++++++--------------- 1 file changed, 611 insertions(+), 611 deletions(-) diff --git a/unittests/eosio.system_tests.cpp b/unittests/eosio.system_tests.cpp index 9d8635e2237..a600c56a180 100644 --- a/unittests/eosio.system_tests.cpp +++ b/unittests/eosio.system_tests.cpp @@ -51,9 +51,9 @@ class eosio_system_tester : public TESTER { produce_blocks(); - create_account_with_resources( N(alice), N(eosio), asset::from_string("1.0000 EOS"), false ); - create_account_with_resources( N(bob), N(eosio), asset::from_string("0.4500 EOS"), false ); - create_account_with_resources( N(carol), N(eosio), asset::from_string("1.0000 EOS"), false ); + create_account_with_resources( N(alice1111111), N(eosio), asset::from_string("1.0000 EOS"), false ); + create_account_with_resources( N(bob111111111), N(eosio), asset::from_string("0.4500 EOS"), false ); + create_account_with_resources( N(carol1111111), N(eosio), asset::from_string("1.0000 EOS"), false ); BOOST_REQUIRE_EQUAL( asset::from_string("1000000000.0000 EOS"), get_balance( "eosio" ) ); @@ -221,7 +221,7 @@ class eosio_system_tester : public TESTER { act.name = name; 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(bob) ? N(alice) : N(bob) ); + return base_tester::push_action( std::move(act), auth ? uint64_t(signer) : signer == N(bob111111111) ? N(alice1111111) : N(bob111111111) ); } action_result stake( const account_name& from, const account_name& to, const string& net, const string& cpu ) { @@ -425,40 +425,40 @@ BOOST_AUTO_TEST_SUITE(eosio_system_tests) BOOST_FIXTURE_TEST_CASE( buysell, eosio_system_tester ) try { BOOST_REQUIRE_EQUAL( asset::from_string("1000000000.0000 EOS"), get_balance( "eosio" ) ); - BOOST_REQUIRE_EQUAL( asset::from_string("0.0000 EOS"), get_balance( "alice" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("0.0000 EOS"), get_balance( "alice1111111" ) ); - transfer( "eosio", "alice", "1000.0000 EOS", "eosio" ); - BOOST_REQUIRE_EQUAL( success(), stake( "eosio", "alice", "200.0000 EOS", "100.0000 EOS" ) ); + transfer( "eosio", "alice1111111", "1000.0000 EOS", "eosio" ); + BOOST_REQUIRE_EQUAL( success(), stake( "eosio", "alice1111111", "200.0000 EOS", "100.0000 EOS" ) ); - auto total = get_total_stake( "alice" ); + auto total = get_total_stake( "alice1111111" ); auto init_bytes = total["ram_bytes"].as_uint64(); - BOOST_REQUIRE_EQUAL( success(), buyram( "alice", "alice", "200.0000 EOS" ) ); - BOOST_REQUIRE_EQUAL( asset::from_string("800.0000 EOS"), get_balance( "alice" ) ); + BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "200.0000 EOS" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("800.0000 EOS"), get_balance( "alice1111111" ) ); - total = get_total_stake( "alice" ); + total = get_total_stake( "alice1111111" ); auto bytes = total["ram_bytes"].as_uint64(); auto bought_bytes = bytes - init_bytes; wdump((init_bytes)(bought_bytes)(bytes) ); BOOST_REQUIRE_EQUAL( true, 0 < bought_bytes ); - BOOST_REQUIRE_EQUAL( success(), sellram( "alice", bought_bytes ) ); - BOOST_REQUIRE_EQUAL( asset::from_string("999.9999 EOS"), get_balance( "alice" ) ); - total = get_total_stake( "alice" ); + BOOST_REQUIRE_EQUAL( success(), sellram( "alice1111111", bought_bytes ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("999.9999 EOS"), get_balance( "alice1111111" ) ); + total = get_total_stake( "alice1111111" ); BOOST_REQUIRE_EQUAL( true, total["ram_bytes"].as_uint64() == init_bytes ); - transfer( "eosio", "alice", "100000000.0000 EOS", "eosio" ); - BOOST_REQUIRE_EQUAL( asset::from_string("100000999.9999 EOS"), get_balance( "alice" ) ); - BOOST_REQUIRE_EQUAL( success(), buyram( "alice", "alice", "10000000.0000 EOS" ) ); + transfer( "eosio", "alice1111111", "100000000.0000 EOS", "eosio" ); + BOOST_REQUIRE_EQUAL( asset::from_string("100000999.9999 EOS"), get_balance( "alice1111111" ) ); + BOOST_REQUIRE_EQUAL( success(), buyram( "alice1111111", "alice1111111", "10000000.0000 EOS" ) ); - total = get_total_stake( "alice" ); + total = get_total_stake( "alice1111111" ); bytes = total["ram_bytes"].as_uint64(); bought_bytes = bytes - init_bytes; wdump((init_bytes)(bought_bytes)(bytes) ); - BOOST_REQUIRE_EQUAL( success(), sellram( "alice", bought_bytes ) ); - total = get_total_stake( "alice" ); + BOOST_REQUIRE_EQUAL( success(), sellram( "alice1111111", bought_bytes ) ); + total = get_total_stake( "alice1111111" ); bytes = total["ram_bytes"].as_uint64(); bought_bytes = bytes - init_bytes; @@ -466,7 +466,7 @@ BOOST_FIXTURE_TEST_CASE( buysell, eosio_system_tester ) try { BOOST_REQUIRE_EQUAL( true, total["ram_bytes"].as_uint64() == init_bytes ); - BOOST_REQUIRE_EQUAL( asset::from_string("100000999.9993 EOS"), get_balance( "alice" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("100000999.9993 EOS"), get_balance( "alice1111111" ) ); } FC_LOG_AND_RETHROW() @@ -474,71 +474,71 @@ BOOST_FIXTURE_TEST_CASE( stake_unstake, eosio_system_tester ) try { //issue( "eosio", "1000.0000 EOS", config::system_account_name ); BOOST_REQUIRE_EQUAL( asset::from_string("1000000000.0000 EOS"), get_balance( "eosio" ) ); - BOOST_REQUIRE_EQUAL( asset::from_string("0.0000 EOS"), get_balance( "alice" ) ); - transfer( "eosio", "alice", "1000.0000 EOS", "eosio" ); + BOOST_REQUIRE_EQUAL( asset::from_string("0.0000 EOS"), get_balance( "alice1111111" ) ); + transfer( "eosio", "alice1111111", "1000.0000 EOS", "eosio" ); BOOST_REQUIRE_EQUAL( asset::from_string("999999000.0000 EOS"), get_balance( "eosio" ) ); - BOOST_REQUIRE_EQUAL( asset::from_string("1000.0000 EOS"), get_balance( "alice" ) ); - BOOST_REQUIRE_EQUAL( success(), stake( "eosio", "alice", "200.0000 EOS", "100.0000 EOS" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("1000.0000 EOS"), get_balance( "alice1111111" ) ); + BOOST_REQUIRE_EQUAL( success(), stake( "eosio", "alice1111111", "200.0000 EOS", "100.0000 EOS" ) ); - auto total = get_total_stake("alice"); + auto total = get_total_stake("alice1111111"); BOOST_REQUIRE_EQUAL( asset::from_string("210.0000 EOS"), total["net_weight"].as()); BOOST_REQUIRE_EQUAL( asset::from_string("110.0000 EOS"), total["cpu_weight"].as()); - BOOST_REQUIRE_EQUAL( success(), stake( "alice", "alice", "200.0000 EOS", "100.0000 EOS" ) ); - BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice" ) ); - BOOST_REQUIRE_EQUAL( success(), unstake( "alice", "alice", "200.0000 EOS", "100.0000 EOS" ) ); - BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice" ) ); + BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "alice1111111", "200.0000 EOS", "100.0000 EOS" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice1111111" ) ); + BOOST_REQUIRE_EQUAL( success(), unstake( "alice1111111", "alice1111111", "200.0000 EOS", "100.0000 EOS" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice1111111" ) ); produce_block( fc::hours(3*24-1) ); produce_blocks(1); - BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice1111111" ) ); //after 3 days funds should be released produce_block( fc::hours(1) ); produce_blocks(1); - BOOST_REQUIRE_EQUAL( asset::from_string("1000.0000 EOS"), get_balance( "alice" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("1000.0000 EOS"), get_balance( "alice1111111" ) ); - BOOST_REQUIRE_EQUAL( success(), stake( "alice", "bob", "200.0000 EOS", "100.0000 EOS" ) ); - BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice" ) ); - total = get_total_stake("bob"); + BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "bob111111111", "200.0000 EOS", "100.0000 EOS" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice1111111" ) ); + total = get_total_stake("bob111111111"); BOOST_REQUIRE_EQUAL( asset::from_string("210.0000 EOS"), total["net_weight"].as()); BOOST_REQUIRE_EQUAL( asset::from_string("110.0000 EOS"), total["cpu_weight"].as()); - total = get_total_stake( "alice" ); + total = get_total_stake( "alice1111111" ); BOOST_REQUIRE_EQUAL( asset::from_string("210.0000 EOS").amount, total["net_weight"].as().amount ); BOOST_REQUIRE_EQUAL( asset::from_string("110.0000 EOS").amount, total["cpu_weight"].as().amount ); - REQUIRE_MATCHING_OBJECT( voter( "alice", "300.0000 EOS"), get_voter_info( "alice" ) ); + REQUIRE_MATCHING_OBJECT( voter( "alice1111111", "300.0000 EOS"), get_voter_info( "alice1111111" ) ); auto bytes = total["ram_bytes"].as_uint64(); BOOST_REQUIRE_EQUAL( true, 0 < bytes ); - //unstake from bob - BOOST_REQUIRE_EQUAL( success(), unstake( "alice", "bob", "200.0000 EOS", "100.0000 EOS" ) ); - total = get_total_stake("bob"); + //unstake from bob111111111 + BOOST_REQUIRE_EQUAL( success(), unstake( "alice1111111", "bob111111111", "200.0000 EOS", "100.0000 EOS" ) ); + total = get_total_stake("bob111111111"); BOOST_REQUIRE_EQUAL( asset::from_string("10.0000 EOS"), total["net_weight"].as()); BOOST_REQUIRE_EQUAL( asset::from_string("10.0000 EOS"), total["cpu_weight"].as()); produce_block( fc::hours(3*24-1) ); produce_blocks(1); - BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice1111111" ) ); //after 3 days funds should be released produce_block( fc::hours(1) ); produce_blocks(1); - REQUIRE_MATCHING_OBJECT( voter( "alice", "0.0000 EOS" ), get_voter_info( "alice" ) ); + REQUIRE_MATCHING_OBJECT( voter( "alice1111111", "0.0000 EOS" ), get_voter_info( "alice1111111" ) ); produce_blocks(1); - BOOST_REQUIRE_EQUAL( asset::from_string("1000.0000 EOS"), get_balance( "alice" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("1000.0000 EOS"), get_balance( "alice1111111" ) ); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( fail_without_auth, eosio_system_tester ) try { - issue( "alice", "1000.0000 EOS", config::system_account_name ); + issue( "alice1111111", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "eosio", "alice", "2000.0000 EOS", "1000.0000 EOS" ) ); - BOOST_REQUIRE_EQUAL( success(), stake( "alice", "bob", "10.0000 EOS", "10.0000 EOS" ) ); + BOOST_REQUIRE_EQUAL( success(), stake( "eosio", "alice1111111", "2000.0000 EOS", "1000.0000 EOS" ) ); + BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "bob111111111", "10.0000 EOS", "10.0000 EOS" ) ); - BOOST_REQUIRE_EQUAL( error("missing authority of alice"), - push_action( N(alice), N(delegatebw), mvo() - ("from", "alice") - ("receiver", "bob") + BOOST_REQUIRE_EQUAL( error("missing authority of alice1111111"), + push_action( N(alice1111111), N(delegatebw), mvo() + ("from", "alice1111111") + ("receiver", "bob111111111") ("stake_net_quantity", "10.0000 EOS") ("stake_cpu_quantity", "10.0000 EOS") ("transfer", 0 ) @@ -546,266 +546,266 @@ BOOST_FIXTURE_TEST_CASE( fail_without_auth, eosio_system_tester ) try { ) ); - BOOST_REQUIRE_EQUAL( error("missing authority of alice"), - push_action(N(alice), N(undelegatebw), mvo() - ("from", "alice") - ("receiver", "bob") + BOOST_REQUIRE_EQUAL( error("missing authority of alice1111111"), + push_action(N(alice1111111), N(undelegatebw), mvo() + ("from", "alice1111111") + ("receiver", "bob111111111") ("unstake_net_quantity", "200.0000 EOS") ("unstake_cpu_quantity", "100.0000 EOS") ("transfer", 0 ) ,false ) ); - //REQUIRE_MATCHING_OBJECT( , get_voter_info( "alice" ) ); + //REQUIRE_MATCHING_OBJECT( , get_voter_info( "alice1111111" ) ); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( stake_negative, eosio_system_tester ) try { - issue( "alice", "1000.0000 EOS", config::system_account_name ); + issue( "alice1111111", "1000.0000 EOS", config::system_account_name ); BOOST_REQUIRE_EQUAL( error("condition: assertion failed: must stake a positive amount"), - stake( "alice", "-0.0001 EOS", "0.0000 EOS" ) + stake( "alice1111111", "-0.0001 EOS", "0.0000 EOS" ) ); BOOST_REQUIRE_EQUAL( error("condition: assertion failed: must stake a positive amount"), - stake( "alice", "0.0000 EOS", "-0.0001 EOS" ) + stake( "alice1111111", "0.0000 EOS", "-0.0001 EOS" ) ); BOOST_REQUIRE_EQUAL( error("condition: assertion failed: must stake a positive amount"), - stake( "alice", "00.0000 EOS", "00.0000 EOS" ) + stake( "alice1111111", "00.0000 EOS", "00.0000 EOS" ) ); BOOST_REQUIRE_EQUAL( error("condition: assertion failed: must stake a positive amount"), - stake( "alice", "0.0000 EOS", "00.0000 EOS" ) + stake( "alice1111111", "0.0000 EOS", "00.0000 EOS" ) ); - BOOST_REQUIRE_EQUAL( true, get_voter_info( "alice" ).is_null() ); + BOOST_REQUIRE_EQUAL( true, get_voter_info( "alice1111111" ).is_null() ); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( unstake_negative, eosio_system_tester ) try { - issue( "alice", "1000.0000 EOS", config::system_account_name ); + issue( "alice1111111", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "alice", "bob", "200.0001 EOS", "100.0001 EOS" ) ); + BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "bob111111111", "200.0001 EOS", "100.0001 EOS" ) ); - auto total = get_total_stake( "bob" ); + auto total = get_total_stake( "bob111111111" ); BOOST_REQUIRE_EQUAL( asset::from_string("210.0001 EOS"), total["net_weight"].as()); - auto vinfo = get_voter_info("alice" ); + auto vinfo = get_voter_info("alice1111111" ); wdump((vinfo)); - REQUIRE_MATCHING_OBJECT( voter( "alice", "300.0002 EOS" ), get_voter_info( "alice" ) ); + REQUIRE_MATCHING_OBJECT( voter( "alice1111111", "300.0002 EOS" ), get_voter_info( "alice1111111" ) ); BOOST_REQUIRE_EQUAL( error("condition: assertion failed: must unstake a positive amount"), - unstake( "alice", "bob", "-1.0000 EOS", "0.0000 EOS" ) + unstake( "alice1111111", "bob111111111", "-1.0000 EOS", "0.0000 EOS" ) ); BOOST_REQUIRE_EQUAL( error("condition: assertion failed: must unstake a positive amount"), - unstake( "alice", "bob", "0.0000 EOS", "-1.0000 EOS" ) + unstake( "alice1111111", "bob111111111", "0.0000 EOS", "-1.0000 EOS" ) ); //unstake all zeros BOOST_REQUIRE_EQUAL( error("condition: assertion failed: must unstake a positive amount"), - unstake( "alice", "bob", "0.0000 EOS", "0.0000 EOS" ) + unstake( "alice1111111", "bob111111111", "0.0000 EOS", "0.0000 EOS" ) ); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( unstake_more_than_at_stake, eosio_system_tester ) try { - issue( "alice", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "alice", "200.0000 EOS", "100.0000 EOS" ) ); + issue( "alice1111111", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "200.0000 EOS", "100.0000 EOS" ) ); - auto total = get_total_stake( "alice" ); + auto total = get_total_stake( "alice1111111" ); BOOST_REQUIRE_EQUAL( asset::from_string("210.0000 EOS"), total["net_weight"].as()); BOOST_REQUIRE_EQUAL( asset::from_string("110.0000 EOS"), total["cpu_weight"].as()); - BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice1111111" ) ); //trying to unstake more net bandwith than at stake BOOST_REQUIRE_EQUAL( error("condition: assertion failed: insufficient staked net bandwidth"), - unstake( "alice", "200.0001 EOS", "0.0000 EOS" ) + unstake( "alice1111111", "200.0001 EOS", "0.0000 EOS" ) ); //trying to unstake more cpu bandwith than at stake BOOST_REQUIRE_EQUAL( error("condition: assertion failed: insufficient staked cpu bandwidth"), - unstake( "alice", "0.0000 EOS", "100.0001 EOS" ) + unstake( "alice1111111", "0.0000 EOS", "100.0001 EOS" ) ); //check that nothing has changed - total = get_total_stake( "alice" ); + total = get_total_stake( "alice1111111" ); BOOST_REQUIRE_EQUAL( asset::from_string("210.0000 EOS"), total["net_weight"].as()); BOOST_REQUIRE_EQUAL( asset::from_string("110.0000 EOS"), total["cpu_weight"].as()); - BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice1111111" ) ); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( delegate_to_another_user, eosio_system_tester ) try { - issue( "alice", "1000.0000 EOS", config::system_account_name ); + issue( "alice1111111", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake ( "alice", "bob", "200.0000 EOS", "100.0000 EOS" ) ); + BOOST_REQUIRE_EQUAL( success(), stake ( "alice1111111", "bob111111111", "200.0000 EOS", "100.0000 EOS" ) ); - auto total = get_total_stake( "bob" ); + auto total = get_total_stake( "bob111111111" ); BOOST_REQUIRE_EQUAL( asset::from_string("210.0000 EOS"), total["net_weight"].as()); BOOST_REQUIRE_EQUAL( asset::from_string("110.0000 EOS"), total["cpu_weight"].as()); - BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice" ) ); - //all voting power goes to alice - REQUIRE_MATCHING_OBJECT( voter( "alice", "300.0000 EOS" ), get_voter_info( "alice" ) ); - //but not to bob - BOOST_REQUIRE_EQUAL( true, get_voter_info( "bob" ).is_null() ); + BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice1111111" ) ); + //all voting power goes to alice1111111 + REQUIRE_MATCHING_OBJECT( voter( "alice1111111", "300.0000 EOS" ), get_voter_info( "alice1111111" ) ); + //but not to bob111111111 + BOOST_REQUIRE_EQUAL( true, get_voter_info( "bob111111111" ).is_null() ); - //bob should not be able to unstake what was staked by alice + //bob111111111 should not be able to unstake what was staked by alice1111111 BOOST_REQUIRE_EQUAL( error("condition: assertion failed: unable to find key"), - unstake( "bob", "0.0000 EOS", "10.0000 EOS" ) + unstake( "bob111111111", "0.0000 EOS", "10.0000 EOS" ) ); - issue( "carol", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "carol", "bob", "20.0000 EOS", "10.0000 EOS" ) ); - total = get_total_stake( "bob" ); + issue( "carol1111111", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "carol1111111", "bob111111111", "20.0000 EOS", "10.0000 EOS" ) ); + total = get_total_stake( "bob111111111" ); BOOST_REQUIRE_EQUAL( asset::from_string("230.0000 EOS"), total["net_weight"].as()); BOOST_REQUIRE_EQUAL( asset::from_string("120.0000 EOS"), total["cpu_weight"].as()); - BOOST_REQUIRE_EQUAL( asset::from_string("970.0000 EOS"), get_balance( "carol" ) ); - REQUIRE_MATCHING_OBJECT( voter( "carol", "30.0000 EOS" ), get_voter_info( "carol" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("970.0000 EOS"), get_balance( "carol1111111" ) ); + REQUIRE_MATCHING_OBJECT( voter( "carol1111111", "30.0000 EOS" ), get_voter_info( "carol1111111" ) ); - //alice should not be able to unstake money staked by carol + //alice1111111 should not be able to unstake money staked by carol1111111 BOOST_REQUIRE_EQUAL( error("condition: assertion failed: insufficient staked net bandwidth"), - unstake( "alice", "bob", "2001.0000 EOS", "1.0000 EOS" ) + unstake( "alice1111111", "bob111111111", "2001.0000 EOS", "1.0000 EOS" ) ); BOOST_REQUIRE_EQUAL( error("condition: assertion failed: insufficient staked cpu bandwidth"), - unstake( "alice", "bob", "1.0000 EOS", "101.0000 EOS" ) + unstake( "alice1111111", "bob111111111", "1.0000 EOS", "101.0000 EOS" ) ); - total = get_total_stake( "bob" ); + total = get_total_stake( "bob111111111" ); BOOST_REQUIRE_EQUAL( asset::from_string("230.0000 EOS"), total["net_weight"].as()); BOOST_REQUIRE_EQUAL( asset::from_string("120.0000 EOS"), total["cpu_weight"].as()); //balance should not change after unsuccessfull attempts to unstake - BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice1111111" ) ); //voting power too - REQUIRE_MATCHING_OBJECT( voter( "alice", "300.0000 EOS" ), get_voter_info( "alice" ) ); - REQUIRE_MATCHING_OBJECT( voter( "carol", "30.0000 EOS" ), get_voter_info( "carol" ) ); - BOOST_REQUIRE_EQUAL( true, get_voter_info( "bob" ).is_null() ); + REQUIRE_MATCHING_OBJECT( voter( "alice1111111", "300.0000 EOS" ), get_voter_info( "alice1111111" ) ); + REQUIRE_MATCHING_OBJECT( voter( "carol1111111", "30.0000 EOS" ), get_voter_info( "carol1111111" ) ); + BOOST_REQUIRE_EQUAL( true, get_voter_info( "bob111111111" ).is_null() ); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( stake_unstake_separate, eosio_system_tester ) try { - issue( "alice", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( asset::from_string("1000.0000 EOS"), get_balance( "alice" ) ); + issue( "alice1111111", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( asset::from_string("1000.0000 EOS"), get_balance( "alice1111111" ) ); //everything at once - BOOST_REQUIRE_EQUAL( success(), stake( "alice", "10.0000 EOS", "20.0000 EOS" ) ); - auto total = get_total_stake( "alice" ); + BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "10.0000 EOS", "20.0000 EOS" ) ); + auto total = get_total_stake( "alice1111111" ); BOOST_REQUIRE_EQUAL( asset::from_string("20.0000 EOS"), total["net_weight"].as()); BOOST_REQUIRE_EQUAL( asset::from_string("30.0000 EOS"), total["cpu_weight"].as()); //cpu - BOOST_REQUIRE_EQUAL( success(), stake( "alice", "100.0000 EOS", "0.0000 EOS" ) ); - total = get_total_stake( "alice" ); + BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "100.0000 EOS", "0.0000 EOS" ) ); + total = get_total_stake( "alice1111111" ); BOOST_REQUIRE_EQUAL( asset::from_string("120.0000 EOS"), total["net_weight"].as()); BOOST_REQUIRE_EQUAL( asset::from_string("30.0000 EOS"), total["cpu_weight"].as()); //net - BOOST_REQUIRE_EQUAL( success(), stake( "alice", "0.0000 EOS", "200.0000 EOS" ) ); - total = get_total_stake( "alice" ); + BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "0.0000 EOS", "200.0000 EOS" ) ); + total = get_total_stake( "alice1111111" ); BOOST_REQUIRE_EQUAL( asset::from_string("120.0000 EOS"), total["net_weight"].as()); BOOST_REQUIRE_EQUAL( asset::from_string("230.0000 EOS"), total["cpu_weight"].as()); //unstake cpu - BOOST_REQUIRE_EQUAL( success(), unstake( "alice", "100.0000 EOS", "0.0000 EOS" ) ); - total = get_total_stake( "alice" ); + BOOST_REQUIRE_EQUAL( success(), unstake( "alice1111111", "100.0000 EOS", "0.0000 EOS" ) ); + total = get_total_stake( "alice1111111" ); BOOST_REQUIRE_EQUAL( asset::from_string("20.0000 EOS"), total["net_weight"].as()); BOOST_REQUIRE_EQUAL( asset::from_string("230.0000 EOS"), total["cpu_weight"].as()); //unstake net - BOOST_REQUIRE_EQUAL( success(), unstake( "alice", "0.0000 EOS", "200.0000 EOS" ) ); - total = get_total_stake( "alice" ); + BOOST_REQUIRE_EQUAL( success(), unstake( "alice1111111", "0.0000 EOS", "200.0000 EOS" ) ); + total = get_total_stake( "alice1111111" ); BOOST_REQUIRE_EQUAL( asset::from_string("20.0000 EOS"), total["net_weight"].as()); BOOST_REQUIRE_EQUAL( asset::from_string("30.0000 EOS"), total["cpu_weight"].as()); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( adding_stake_partial_unstake, eosio_system_tester ) try { - issue( "alice", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "alice", "bob", "200.0000 EOS", "100.0000 EOS" ) ); + issue( "alice1111111", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "bob111111111", "200.0000 EOS", "100.0000 EOS" ) ); - REQUIRE_MATCHING_OBJECT( voter( "alice", "300.0000 EOS" ), get_voter_info( "alice" ) ); + REQUIRE_MATCHING_OBJECT( voter( "alice1111111", "300.0000 EOS" ), get_voter_info( "alice1111111" ) ); - BOOST_REQUIRE_EQUAL( success(), stake( "alice", "bob", "100.0000 EOS", "50.0000 EOS" ) ); + BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "bob111111111", "100.0000 EOS", "50.0000 EOS" ) ); - auto total = get_total_stake( "bob" ); + auto total = get_total_stake( "bob111111111" ); BOOST_REQUIRE_EQUAL( asset::from_string("310.0000 EOS"), total["net_weight"].as()); BOOST_REQUIRE_EQUAL( asset::from_string("160.0000 EOS"), total["cpu_weight"].as()); - REQUIRE_MATCHING_OBJECT( voter( "alice", "450.0000 EOS" ), get_voter_info( "alice" ) ); - BOOST_REQUIRE_EQUAL( asset::from_string("550.0000 EOS"), get_balance( "alice" ) ); + REQUIRE_MATCHING_OBJECT( voter( "alice1111111", "450.0000 EOS" ), get_voter_info( "alice1111111" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("550.0000 EOS"), get_balance( "alice1111111" ) ); //unstake a share - BOOST_REQUIRE_EQUAL( success(), unstake( "alice", "bob", "150.0000 EOS", "75.0000 EOS" ) ); + BOOST_REQUIRE_EQUAL( success(), unstake( "alice1111111", "bob111111111", "150.0000 EOS", "75.0000 EOS" ) ); - total = get_total_stake( "bob" ); + total = get_total_stake( "bob111111111" ); BOOST_REQUIRE_EQUAL( asset::from_string("160.0000 EOS"), total["net_weight"].as()); BOOST_REQUIRE_EQUAL( asset::from_string("85.0000 EOS"), total["cpu_weight"].as()); - REQUIRE_MATCHING_OBJECT( voter( "alice", "225.0000 EOS" ), get_voter_info( "alice" ) ); + REQUIRE_MATCHING_OBJECT( voter( "alice1111111", "225.0000 EOS" ), get_voter_info( "alice1111111" ) ); //unstake more - BOOST_REQUIRE_EQUAL( success(), unstake( "alice", "bob", "50.0000 EOS", "25.0000 EOS" ) ); - total = get_total_stake( "bob" ); + BOOST_REQUIRE_EQUAL( success(), unstake( "alice1111111", "bob111111111", "50.0000 EOS", "25.0000 EOS" ) ); + total = get_total_stake( "bob111111111" ); BOOST_REQUIRE_EQUAL( asset::from_string("110.0000 EOS"), total["net_weight"].as()); BOOST_REQUIRE_EQUAL( asset::from_string("60.0000 EOS"), total["cpu_weight"].as()); - REQUIRE_MATCHING_OBJECT( voter( "alice", "150.0000 EOS" ), get_voter_info( "alice" ) ); + REQUIRE_MATCHING_OBJECT( voter( "alice1111111", "150.0000 EOS" ), get_voter_info( "alice1111111" ) ); //combined amount should be available only in 3 days produce_block( fc::days(2) ); produce_blocks(1); - BOOST_REQUIRE_EQUAL( asset::from_string("550.0000 EOS"), get_balance( "alice" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("550.0000 EOS"), get_balance( "alice1111111" ) ); produce_block( fc::days(1) ); produce_blocks(1); - BOOST_REQUIRE_EQUAL( asset::from_string("850.0000 EOS"), get_balance( "alice" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("850.0000 EOS"), get_balance( "alice1111111" ) ); } FC_LOG_AND_RETHROW() // Tests for voting BOOST_FIXTURE_TEST_CASE( producer_register_unregister, eosio_system_tester ) try { - issue( "alice", "1000.0000 EOS", config::system_account_name ); + issue( "alice1111111", "1000.0000 EOS", config::system_account_name ); fc::variant params = producer_parameters_example(1); auto key = fc::crypto::public_key( std::string("EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV") ); - BOOST_REQUIRE_EQUAL( success(), push_action(N(alice), N(regproducer), mvo() - ("producer", "alice") + BOOST_REQUIRE_EQUAL( success(), push_action(N(alice1111111), N(regproducer), mvo() + ("producer", "alice1111111") ("producer_key", key ) ("url", "http://block.one") ) ); - auto info = get_producer_info( "alice" ); - BOOST_REQUIRE_EQUAL( "alice", info["owner"].as_string() ); + auto info = get_producer_info( "alice1111111" ); + BOOST_REQUIRE_EQUAL( "alice1111111", info["owner"].as_string() ); BOOST_REQUIRE_EQUAL( 0, info["total_votes"].as_double() ); BOOST_REQUIRE_EQUAL( "http://block.one", info["url"].as_string() ); //call regproducer again to change parameters fc::variant params2 = producer_parameters_example(2); - info = get_producer_info( "alice" ); - BOOST_REQUIRE_EQUAL( "alice", info["owner"].as_string() ); + info = get_producer_info( "alice1111111" ); + BOOST_REQUIRE_EQUAL( "alice1111111", info["owner"].as_string() ); BOOST_REQUIRE_EQUAL( 0, info["total_votes"].as_double() ); BOOST_REQUIRE_EQUAL( "http://block.one", info["url"].as_string() ); //unregister producer - BOOST_REQUIRE_EQUAL( success(), push_action(N(alice), N(unregprod), mvo() - ("producer", "alice") + BOOST_REQUIRE_EQUAL( success(), push_action(N(alice1111111), N(unregprod), mvo() + ("producer", "alice1111111") ) ); - info = get_producer_info( "alice" ); + info = get_producer_info( "alice1111111" ); //key should be empty wdump((info)); BOOST_REQUIRE_EQUAL( fc::crypto::public_key(), fc::crypto::public_key(info["producer_key"].as_string()) ); //everything else should stay the same - BOOST_REQUIRE_EQUAL( "alice", info["owner"].as_string() ); + BOOST_REQUIRE_EQUAL( "alice1111111", info["owner"].as_string() ); BOOST_REQUIRE_EQUAL( 0, info["total_votes"].as_double() ); BOOST_REQUIRE_EQUAL( "http://block.one", info["url"].as_string() ); - //unregister bob who is not a producer + //unregister bob111111111 who is not a producer BOOST_REQUIRE_EQUAL( error( "condition: assertion failed: producer not found" ), - push_action( N(bob), N(unregprod), mvo() - ("producer", "bob") + push_action( N(bob111111111), N(unregprod), mvo() + ("producer", "bob111111111") ) ); @@ -813,134 +813,134 @@ BOOST_FIXTURE_TEST_CASE( producer_register_unregister, eosio_system_tester ) try BOOST_FIXTURE_TEST_CASE( vote_for_producer, eosio_system_tester, * boost::unit_test::tolerance(1e+5) ) try { - issue( "alice", "1000.0000 EOS", config::system_account_name ); + issue( "alice1111111", "1000.0000 EOS", config::system_account_name ); fc::variant params = producer_parameters_example(1); - BOOST_REQUIRE_EQUAL( success(), push_action( N(alice), N(regproducer), mvo() - ("producer", "alice") - ("producer_key", get_public_key( N(alice), "active") ) + BOOST_REQUIRE_EQUAL( success(), push_action( N(alice1111111), N(regproducer), mvo() + ("producer", "alice1111111") + ("producer_key", get_public_key( N(alice1111111), "active") ) ("url", "http://block.one") ) ); - auto prod = get_producer_info( "alice" ); - BOOST_REQUIRE_EQUAL( "alice", prod["owner"].as_string() ); + auto prod = get_producer_info( "alice1111111" ); + BOOST_REQUIRE_EQUAL( "alice1111111", prod["owner"].as_string() ); BOOST_REQUIRE_EQUAL( 0, prod["total_votes"].as_double() ); BOOST_REQUIRE_EQUAL( "http://block.one", prod["url"].as_string() ); - issue( "bob", "2000.0000 EOS", config::system_account_name ); - issue( "carol", "3000.0000 EOS", config::system_account_name ); + issue( "bob111111111", "2000.0000 EOS", config::system_account_name ); + issue( "carol1111111", "3000.0000 EOS", config::system_account_name ); - //bob makes stake - BOOST_REQUIRE_EQUAL( success(), stake( "bob", "11.0000 EOS", "0.1111 EOS" ) ); - BOOST_REQUIRE_EQUAL( asset::from_string("1988.8889 EOS"), get_balance( "bob" ) ); - REQUIRE_MATCHING_OBJECT( voter( "bob", "11.1111 EOS" ), get_voter_info( "bob" ) ); + //bob111111111 makes stake + BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", "11.0000 EOS", "0.1111 EOS" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("1988.8889 EOS"), get_balance( "bob111111111" ) ); + REQUIRE_MATCHING_OBJECT( voter( "bob111111111", "11.1111 EOS" ), get_voter_info( "bob111111111" ) ); - //bob votes for alice - BOOST_REQUIRE_EQUAL( success(), push_action(N(bob), N(voteproducer), mvo() - ("voter", "bob") + //bob111111111 votes for alice1111111 + BOOST_REQUIRE_EQUAL( success(), push_action(N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") ("proxy", name(0).to_string() ) - ("producers", vector{ N(alice) } ) + ("producers", vector{ N(alice1111111) } ) ) ); //check that producer parameters stay the same after voting - prod = get_producer_info( "alice" ); + prod = get_producer_info( "alice1111111" ); BOOST_TEST_REQUIRE( stake2votes("11.1111 EOS") == prod["total_votes"].as_double() ); - BOOST_REQUIRE_EQUAL( "alice", prod["owner"].as_string() ); + BOOST_REQUIRE_EQUAL( "alice1111111", prod["owner"].as_string() ); BOOST_REQUIRE_EQUAL( "http://block.one", prod["url"].as_string() ); - //carol makes stake - BOOST_REQUIRE_EQUAL( success(), stake( "carol", "22.0000 EOS", "0.2222 EOS" ) ); - REQUIRE_MATCHING_OBJECT( voter( "carol", "22.2222 EOS" ), get_voter_info( "carol" ) ); - BOOST_REQUIRE_EQUAL( asset::from_string("2977.7778 EOS"), get_balance( "carol" ) ); - //carol votes for alice - BOOST_REQUIRE_EQUAL( success(), push_action(N(carol), N(voteproducer), mvo() - ("voter", "carol") + //carol1111111 makes stake + BOOST_REQUIRE_EQUAL( success(), stake( "carol1111111", "22.0000 EOS", "0.2222 EOS" ) ); + REQUIRE_MATCHING_OBJECT( voter( "carol1111111", "22.2222 EOS" ), get_voter_info( "carol1111111" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("2977.7778 EOS"), get_balance( "carol1111111" ) ); + //carol1111111 votes for alice1111111 + BOOST_REQUIRE_EQUAL( success(), push_action(N(carol1111111), N(voteproducer), mvo() + ("voter", "carol1111111") ("proxy", name(0).to_string() ) - ("producers", vector{ N(alice) } ) + ("producers", vector{ N(alice1111111) } ) ) ); - //new stake votes be added to alice's total_votes - prod = get_producer_info( "alice" ); + //new stake votes be added to alice1111111's total_votes + prod = get_producer_info( "alice1111111" ); BOOST_TEST_REQUIRE( stake2votes("33.3333 EOS") == prod["total_votes"].as_double() ); - //bob increases his stake - BOOST_REQUIRE_EQUAL( success(), stake( "bob", "55.0000 EOS", "0.5555 EOS" ) ); - //should increase alice's total_votes - prod = get_producer_info( "alice" ); + //bob111111111 increases his stake + BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", "55.0000 EOS", "0.5555 EOS" ) ); + //should increase alice1111111's total_votes + prod = get_producer_info( "alice1111111" ); BOOST_TEST_REQUIRE( stake2votes("88.8888 EOS") == prod["total_votes"].as_double() ); - //carol unstakes part of the stake - BOOST_REQUIRE_EQUAL( success(), unstake( "carol", "2.0000 EOS", "0.0002 EOS"/*"2.0000 EOS", "0.0002 EOS"*/ ) ); - //should decrease alice's total_votes - prod = get_producer_info( "alice" ); + //carol1111111 unstakes part of the stake + BOOST_REQUIRE_EQUAL( success(), unstake( "carol1111111", "2.0000 EOS", "0.0002 EOS"/*"2.0000 EOS", "0.0002 EOS"*/ ) ); + //should decrease alice1111111's total_votes + prod = get_producer_info( "alice1111111" ); wdump((prod)); BOOST_TEST_REQUIRE( stake2votes("86.8886 EOS") == prod["total_votes"].as_double() ); - //bob revokes his vote - BOOST_REQUIRE_EQUAL( success(), push_action( N(bob), N(voteproducer), mvo() - ("voter", "bob") + //bob111111111 revokes his vote + BOOST_REQUIRE_EQUAL( success(), push_action( N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") ("proxy", name(0).to_string() ) ("producers", vector() ) ) ); - //should decrease alice's total_votes - prod = get_producer_info( "alice" ); + //should decrease alice1111111's total_votes + prod = get_producer_info( "alice1111111" ); BOOST_TEST_REQUIRE( stake2votes("20.2220 EOS") == prod["total_votes"].as_double() ); //but eos should still be at stake - BOOST_REQUIRE_EQUAL( asset::from_string("1933.3334 EOS"), get_balance( "bob" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("1933.3334 EOS"), get_balance( "bob111111111" ) ); - //carol unstakes rest of eos - BOOST_REQUIRE_EQUAL( success(), unstake( "carol", "20.0000 EOS", "0.2220 EOS" ) ); - //should decrease alice's total_votes to zero - prod = get_producer_info( "alice" ); + //carol1111111 unstakes rest of eos + BOOST_REQUIRE_EQUAL( success(), unstake( "carol1111111", "20.0000 EOS", "0.2220 EOS" ) ); + //should decrease alice1111111's total_votes to zero + prod = get_producer_info( "alice1111111" ); BOOST_TEST_REQUIRE( 0.0 == prod["total_votes"].as_double() ); - //carol should receive funds in 3 days + //carol1111111 should receive funds in 3 days produce_block( fc::days(3) ); produce_block(); - BOOST_REQUIRE_EQUAL( asset::from_string("3000.0000 EOS"), get_balance( "carol" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("3000.0000 EOS"), get_balance( "carol1111111" ) ); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( unregistered_producer_voting, eosio_system_tester, * boost::unit_test::tolerance(1e+5) ) try { - issue( "bob", "2000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "bob", "13.0000 EOS", "0.5791 EOS" ) ); - REQUIRE_MATCHING_OBJECT( voter( "bob", "13.5791 EOS" ), get_voter_info( "bob" ) ); + issue( "bob111111111", "2000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", "13.0000 EOS", "0.5791 EOS" ) ); + REQUIRE_MATCHING_OBJECT( voter( "bob111111111", "13.5791 EOS" ), get_voter_info( "bob111111111" ) ); - //bob should not be able to vote for alice who is not a producer + //bob111111111 should not be able to vote for alice1111111 who is not a producer BOOST_REQUIRE_EQUAL( error( "condition: assertion failed: producer is not registered" ), - push_action( N(bob), N(voteproducer), mvo() - ("voter", "bob") + push_action( N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") ("proxy", name(0).to_string() ) - ("producers", vector{ N(alice) } ) + ("producers", vector{ N(alice1111111) } ) ) ); - //alice registers as a producer - issue( "alice", "1000.0000 EOS", config::system_account_name ); + //alice1111111 registers as a producer + issue( "alice1111111", "1000.0000 EOS", config::system_account_name ); fc::variant params = producer_parameters_example(1); - BOOST_REQUIRE_EQUAL( success(), push_action( N(alice), N(regproducer), mvo() - ("producer", "alice") - ("producer_key", get_public_key( N(alice), "active") ) + BOOST_REQUIRE_EQUAL( success(), push_action( N(alice1111111), N(regproducer), mvo() + ("producer", "alice1111111") + ("producer_key", get_public_key( N(alice1111111), "active") ) ("url", "") ) ); //and then unregisters - BOOST_REQUIRE_EQUAL( success(), push_action( N(alice), N(unregprod), mvo() - ("producer", "alice") + BOOST_REQUIRE_EQUAL( success(), push_action( N(alice1111111), N(unregprod), mvo() + ("producer", "alice1111111") ) ); //key should be empty - auto prod = get_producer_info( "alice" ); + auto prod = get_producer_info( "alice1111111" ); BOOST_REQUIRE_EQUAL( fc::crypto::public_key(), fc::crypto::public_key(prod["producer_key"].as_string()) ); - //bob should not be able to vote for alice who is an unregistered producer + //bob111111111 should not be able to vote for alice1111111 who is an unregistered producer BOOST_REQUIRE_EQUAL( error( "condition: assertion failed: producer is not currently registered" ), - push_action( N(bob), N(voteproducer), mvo() - ("voter", "bob") + push_action( N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") ("proxy", name(0).to_string() ) - ("producers", vector{ N(alice) } ) + ("producers", vector{ N(alice1111111) } ) ) ); @@ -948,16 +948,16 @@ BOOST_FIXTURE_TEST_CASE( unregistered_producer_voting, eosio_system_tester, * bo BOOST_FIXTURE_TEST_CASE( more_than_30_producer_voting, eosio_system_tester ) try { - issue( "bob", "2000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "bob", "13.0000 EOS", "0.5791 EOS" ) ); - REQUIRE_MATCHING_OBJECT( voter( "bob", "13.5791 EOS" ), get_voter_info( "bob" ) ); + issue( "bob111111111", "2000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", "13.0000 EOS", "0.5791 EOS" ) ); + REQUIRE_MATCHING_OBJECT( voter( "bob111111111", "13.5791 EOS" ), get_voter_info( "bob111111111" ) ); - //bob should not be able to vote for alice who is not a producer + //bob111111111 should not be able to vote for alice1111111 who is not a producer BOOST_REQUIRE_EQUAL( error( "condition: assertion failed: attempt to vote for too many producers" ), - push_action( N(bob), N(voteproducer), mvo() - ("voter", "bob") + push_action( N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") ("proxy", name(0).to_string() ) - ("producers", vector(31, N(alice)) ) + ("producers", vector(31, N(alice1111111)) ) ) ); @@ -965,68 +965,68 @@ BOOST_FIXTURE_TEST_CASE( more_than_30_producer_voting, eosio_system_tester ) try BOOST_FIXTURE_TEST_CASE( vote_same_producer_30_times, eosio_system_tester ) try { - issue( "bob", "2000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "bob", "50.0000 EOS", "50.0000 EOS" ) ); - REQUIRE_MATCHING_OBJECT( voter( "bob", "100.0000 EOS" ), get_voter_info( "bob" ) ); + issue( "bob111111111", "2000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", "50.0000 EOS", "50.0000 EOS" ) ); + REQUIRE_MATCHING_OBJECT( voter( "bob111111111", "100.0000 EOS" ), get_voter_info( "bob111111111" ) ); - //alice becomes a producer - issue( "alice", "1000.0000 EOS", config::system_account_name ); + //alice1111111 becomes a producer + issue( "alice1111111", "1000.0000 EOS", config::system_account_name ); fc::variant params = producer_parameters_example(1); - BOOST_REQUIRE_EQUAL( success(), push_action( N(alice), N(regproducer), mvo() - ("producer", "alice") - ("producer_key", get_public_key(N(alice), "active") ) + BOOST_REQUIRE_EQUAL( success(), push_action( N(alice1111111), N(regproducer), mvo() + ("producer", "alice1111111") + ("producer_key", get_public_key(N(alice1111111), "active") ) ("url", "") ) ); - //bob should not be able to vote for alice who is not a producer + //bob111111111 should not be able to vote for alice1111111 who is not a producer BOOST_REQUIRE_EQUAL( error( "condition: assertion failed: producer votes must be unique and sorted" ), - push_action( N(bob), N(voteproducer), mvo() - ("voter", "bob") + push_action( N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") ("proxy", name(0).to_string() ) - ("producers", vector(30, N(alice)) ) + ("producers", vector(30, N(alice1111111)) ) ) ); - auto prod = get_producer_info( "alice" ); + auto prod = get_producer_info( "alice1111111" ); BOOST_TEST_REQUIRE( 0 == prod["total_votes"].as_double() ); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( producer_keep_votes, eosio_system_tester, * boost::unit_test::tolerance(1e+5) ) try { - issue( "alice", "1000.0000 EOS", config::system_account_name ); + issue( "alice1111111", "1000.0000 EOS", config::system_account_name ); fc::variant params = producer_parameters_example(1); - vector key = fc::raw::pack( get_public_key( N(alice), "active" ) ); - BOOST_REQUIRE_EQUAL( success(), push_action( N(alice), N(regproducer), mvo() - ("producer", "alice") - ("producer_key", get_public_key( N(alice), "active") ) + vector key = fc::raw::pack( get_public_key( N(alice1111111), "active" ) ); + BOOST_REQUIRE_EQUAL( success(), push_action( N(alice1111111), N(regproducer), mvo() + ("producer", "alice1111111") + ("producer_key", get_public_key( N(alice1111111), "active") ) ("url", "") ) ); - //bob makes stake - issue( "bob", "2000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "bob", "13.0000 EOS", "0.5791 EOS" ) ); - REQUIRE_MATCHING_OBJECT( voter( "bob", "13.5791 EOS" ), get_voter_info( "bob" ) ); + //bob111111111 makes stake + issue( "bob111111111", "2000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", "13.0000 EOS", "0.5791 EOS" ) ); + REQUIRE_MATCHING_OBJECT( voter( "bob111111111", "13.5791 EOS" ), get_voter_info( "bob111111111" ) ); - //bob votes for alice - BOOST_REQUIRE_EQUAL( success(), push_action(N(bob), N(voteproducer), mvo() - ("voter", "bob") + //bob111111111 votes for alice1111111 + BOOST_REQUIRE_EQUAL( success(), push_action(N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") ("proxy", name(0).to_string() ) - ("producers", vector{ N(alice) } ) + ("producers", vector{ N(alice1111111) } ) ) ); - auto prod = get_producer_info( "alice" ); + auto prod = get_producer_info( "alice1111111" ); BOOST_TEST_REQUIRE( stake2votes("13.5791 EOS") == prod["total_votes"].as_double() ); //unregister producer - BOOST_REQUIRE_EQUAL( success(), push_action(N(alice), N(unregprod), mvo() - ("producer", "alice") + BOOST_REQUIRE_EQUAL( success(), push_action(N(alice1111111), N(unregprod), mvo() + ("producer", "alice1111111") ) ); - prod = get_producer_info( "alice" ); + prod = get_producer_info( "alice1111111" ); //key should be empty BOOST_REQUIRE_EQUAL( fc::crypto::public_key(), fc::crypto::public_key(prod["producer_key"].as_string()) ); //check parameters just in case @@ -1036,25 +1036,25 @@ BOOST_FIXTURE_TEST_CASE( producer_keep_votes, eosio_system_tester, * boost::unit //regtister the same producer again params = producer_parameters_example(2); - BOOST_REQUIRE_EQUAL( success(), push_action( N(alice), N(regproducer), mvo() - ("producer", "alice") - ("producer_key", get_public_key( N(alice), "active") ) + BOOST_REQUIRE_EQUAL( success(), push_action( N(alice1111111), N(regproducer), mvo() + ("producer", "alice1111111") + ("producer_key", get_public_key( N(alice1111111), "active") ) ("url", "") ) ); - prod = get_producer_info( "alice" ); + prod = get_producer_info( "alice1111111" ); //votes should stay the same BOOST_TEST_REQUIRE( stake2votes("13.5791 EOS"), prod["total_votes"].as_double() ); //change parameters params = producer_parameters_example(3); - BOOST_REQUIRE_EQUAL( success(), push_action( N(alice), N(regproducer), mvo() - ("producer", "alice") - ("producer_key", get_public_key( N(alice), "active") ) + BOOST_REQUIRE_EQUAL( success(), push_action( N(alice1111111), N(regproducer), mvo() + ("producer", "alice1111111") + ("producer_key", get_public_key( N(alice1111111), "active") ) ("url","") ) ); - prod = get_producer_info( "alice" ); + prod = get_producer_info( "alice1111111" ); //votes should stay the same BOOST_TEST_REQUIRE( stake2votes("13.5791 EOS"), prod["total_votes"].as_double() ); //check parameters just in case @@ -1064,67 +1064,67 @@ BOOST_FIXTURE_TEST_CASE( producer_keep_votes, eosio_system_tester, * boost::unit BOOST_FIXTURE_TEST_CASE( vote_for_two_producers, eosio_system_tester, * boost::unit_test::tolerance(1e+5) ) try { - //alice becomes a producer + //alice1111111 becomes a producer fc::variant params = producer_parameters_example(1); - auto key = get_public_key( N(alice), "active" ); - BOOST_REQUIRE_EQUAL( success(), push_action( N(alice), N(regproducer), mvo() - ("producer", "alice") - ("producer_key", get_public_key( N(alice), "active") ) + auto key = get_public_key( N(alice1111111), "active" ); + BOOST_REQUIRE_EQUAL( success(), push_action( N(alice1111111), N(regproducer), mvo() + ("producer", "alice1111111") + ("producer_key", get_public_key( N(alice1111111), "active") ) ("url","") ) ); - //bob becomes a producer + //bob111111111 becomes a producer params = producer_parameters_example(2); - key = get_public_key( N(bob), "active" ); - BOOST_REQUIRE_EQUAL( success(), push_action( N(bob), N(regproducer), mvo() - ("producer", "bob") - ("producer_key", get_public_key( N(alice), "active") ) + key = get_public_key( N(bob111111111), "active" ); + BOOST_REQUIRE_EQUAL( success(), push_action( N(bob111111111), N(regproducer), mvo() + ("producer", "bob111111111") + ("producer_key", get_public_key( N(alice1111111), "active") ) ("url","") ) ); - //carol votes for alice and bob - issue( "carol", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "carol", "15.0005 EOS", "5.0000 EOS" ) ); - BOOST_REQUIRE_EQUAL( success(), push_action(N(carol), N(voteproducer), mvo() - ("voter", "carol") + //carol1111111 votes for alice1111111 and bob111111111 + issue( "carol1111111", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "carol1111111", "15.0005 EOS", "5.0000 EOS" ) ); + BOOST_REQUIRE_EQUAL( success(), push_action(N(carol1111111), N(voteproducer), mvo() + ("voter", "carol1111111") ("proxy", name(0).to_string() ) - ("producers", vector{ N(alice), N(bob) } ) + ("producers", vector{ N(alice1111111), N(bob111111111) } ) ) ); - auto alice_info = get_producer_info( "alice" ); + auto alice_info = get_producer_info( "alice1111111" ); BOOST_TEST_REQUIRE( stake2votes("20.0005 EOS") == alice_info["total_votes"].as_double() ); - auto bob_info = get_producer_info( "bob" ); + auto bob_info = get_producer_info( "bob111111111" ); BOOST_TEST_REQUIRE( stake2votes("20.0005 EOS") == bob_info["total_votes"].as_double() ); - //carol votes for alice (but revokes vote for bob) - BOOST_REQUIRE_EQUAL( success(), push_action(N(carol), N(voteproducer), mvo() - ("voter", "carol") + //carol1111111 votes for alice1111111 (but revokes vote for bob111111111) + BOOST_REQUIRE_EQUAL( success(), push_action(N(carol1111111), N(voteproducer), mvo() + ("voter", "carol1111111") ("proxy", name(0).to_string() ) - ("producers", vector{ N(alice) } ) + ("producers", vector{ N(alice1111111) } ) ) ); - alice_info = get_producer_info( "alice" ); + alice_info = get_producer_info( "alice1111111" ); BOOST_TEST_REQUIRE( stake2votes("20.0005 EOS") == alice_info["total_votes"].as_double() ); - bob_info = get_producer_info( "bob" ); + bob_info = get_producer_info( "bob111111111" ); BOOST_TEST_REQUIRE( 0 == bob_info["total_votes"].as_double() ); - //alice votes for herself and bob - issue( "alice", "2.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "alice", "1.0000 EOS", "1.0000 EOS" ) ); - BOOST_REQUIRE_EQUAL( success(), push_action(N(alice), N(voteproducer), mvo() - ("voter", "alice") + //alice1111111 votes for herself and bob111111111 + issue( "alice1111111", "2.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "1.0000 EOS", "1.0000 EOS" ) ); + BOOST_REQUIRE_EQUAL( success(), push_action(N(alice1111111), N(voteproducer), mvo() + ("voter", "alice1111111") ("proxy", name(0).to_string() ) - ("producers", vector{ N(alice), N(bob) } ) + ("producers", vector{ N(alice1111111), N(bob111111111) } ) ) ); - alice_info = get_producer_info( "alice" ); + alice_info = get_producer_info( "alice1111111" ); BOOST_TEST_REQUIRE( stake2votes("22.0005 EOS") == alice_info["total_votes"].as_double() ); - bob_info = get_producer_info( "bob" ); + bob_info = get_producer_info( "bob111111111" ); BOOST_TEST_REQUIRE( stake2votes("2.0000 EOS") == bob_info["total_votes"].as_double() ); } FC_LOG_AND_RETHROW() @@ -1132,197 +1132,197 @@ BOOST_FIXTURE_TEST_CASE( vote_for_two_producers, eosio_system_tester, * boost::u BOOST_FIXTURE_TEST_CASE( proxy_register_unregister_keeps_stake, eosio_system_tester ) try { //register proxy by first action for this user ever - BOOST_REQUIRE_EQUAL( success(), push_action(N(alice), N(regproxy), mvo() - ("proxy", "alice") + BOOST_REQUIRE_EQUAL( success(), push_action(N(alice1111111), N(regproxy), mvo() + ("proxy", "alice1111111") ("isproxy", true ) ) ); - REQUIRE_MATCHING_OBJECT( proxy( "alice" ), get_voter_info( "alice" ) ); + REQUIRE_MATCHING_OBJECT( proxy( "alice1111111" ), get_voter_info( "alice1111111" ) ); //unregister proxy - BOOST_REQUIRE_EQUAL( success(), push_action(N(alice), N(regproxy), mvo() - ("proxy", "alice") + BOOST_REQUIRE_EQUAL( success(), push_action(N(alice1111111), N(regproxy), mvo() + ("proxy", "alice1111111") ("isproxy", false) ) ); - REQUIRE_MATCHING_OBJECT( voter( "alice" ), get_voter_info( "alice" ) ); + REQUIRE_MATCHING_OBJECT( voter( "alice1111111" ), get_voter_info( "alice1111111" ) ); //stake and then register as a proxy - issue( "bob", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "bob", "200.0002 EOS", "100.0001 EOS" ) ); - BOOST_REQUIRE_EQUAL( success(), push_action( N(bob), N(regproxy), mvo() - ("proxy", "bob") + issue( "bob111111111", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", "200.0002 EOS", "100.0001 EOS" ) ); + BOOST_REQUIRE_EQUAL( success(), push_action( N(bob111111111), N(regproxy), mvo() + ("proxy", "bob111111111") ("isproxy", true) ) ); - REQUIRE_MATCHING_OBJECT( proxy( "bob" )( "staked", 3000003 ), get_voter_info( "bob" ) ); + REQUIRE_MATCHING_OBJECT( proxy( "bob111111111" )( "staked", 3000003 ), get_voter_info( "bob111111111" ) ); //unrgister and check that stake is still in place - BOOST_REQUIRE_EQUAL( success(), push_action( N(bob), N(regproxy), mvo() - ("proxy", "bob") + BOOST_REQUIRE_EQUAL( success(), push_action( N(bob111111111), N(regproxy), mvo() + ("proxy", "bob111111111") ("isproxy", false) ) ); - REQUIRE_MATCHING_OBJECT( voter( "bob", "300.0003 EOS" ), get_voter_info( "bob" ) ); + REQUIRE_MATCHING_OBJECT( voter( "bob111111111", "300.0003 EOS" ), get_voter_info( "bob111111111" ) ); //register as a proxy and then stake - BOOST_REQUIRE_EQUAL( success(), push_action( N(carol), N(regproxy), mvo() - ("proxy", "carol") + BOOST_REQUIRE_EQUAL( success(), push_action( N(carol1111111), N(regproxy), mvo() + ("proxy", "carol1111111") ("isproxy", true) ) ); - issue( "carol", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "carol", "246.0002 EOS", "531.0001 EOS" ) ); + issue( "carol1111111", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "carol1111111", "246.0002 EOS", "531.0001 EOS" ) ); //check that both proxy flag and stake a correct - REQUIRE_MATCHING_OBJECT( proxy( "carol" )( "staked", 7770003 ), get_voter_info( "carol" ) ); + REQUIRE_MATCHING_OBJECT( proxy( "carol1111111" )( "staked", 7770003 ), get_voter_info( "carol1111111" ) ); //unregister - BOOST_REQUIRE_EQUAL( success(), push_action( N(carol), N(regproxy), mvo() - ("proxy", "carol") + BOOST_REQUIRE_EQUAL( success(), push_action( N(carol1111111), N(regproxy), mvo() + ("proxy", "carol1111111") ("isproxy", false) ) ); - REQUIRE_MATCHING_OBJECT( voter( "carol", "777.0003 EOS" ), get_voter_info( "carol" ) ); + REQUIRE_MATCHING_OBJECT( voter( "carol1111111", "777.0003 EOS" ), get_voter_info( "carol1111111" ) ); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( proxy_stake_unstake_keeps_proxy_flag, eosio_system_tester ) try { - BOOST_REQUIRE_EQUAL( success(), push_action( N(alice), N(regproxy), mvo() - ("proxy", "alice") + BOOST_REQUIRE_EQUAL( success(), push_action( N(alice1111111), N(regproxy), mvo() + ("proxy", "alice1111111") ("isproxy", true) ) ); - issue( "alice", "1000.0000 EOS", config::system_account_name ); - REQUIRE_MATCHING_OBJECT( proxy( "alice" ), get_voter_info( "alice" ) ); + issue( "alice1111111", "1000.0000 EOS", config::system_account_name ); + REQUIRE_MATCHING_OBJECT( proxy( "alice1111111" ), get_voter_info( "alice1111111" ) ); //stake - BOOST_REQUIRE_EQUAL( success(), stake( "alice", "100.0000 EOS", "50.0000 EOS" ) ); + BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "100.0000 EOS", "50.0000 EOS" ) ); //check that account is still a proxy - REQUIRE_MATCHING_OBJECT( proxy( "alice" )( "staked", 1500000 ), get_voter_info( "alice" ) ); + REQUIRE_MATCHING_OBJECT( proxy( "alice1111111" )( "staked", 1500000 ), get_voter_info( "alice1111111" ) ); //stake more - BOOST_REQUIRE_EQUAL( success(), stake( "alice", "30.0000 EOS", "20.0000 EOS" ) ); + BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "30.0000 EOS", "20.0000 EOS" ) ); //check that account is still a proxy - REQUIRE_MATCHING_OBJECT( proxy( "alice" )("staked", 2000000 ), get_voter_info( "alice" ) ); + REQUIRE_MATCHING_OBJECT( proxy( "alice1111111" )("staked", 2000000 ), get_voter_info( "alice1111111" ) ); //unstake more - BOOST_REQUIRE_EQUAL( success(), unstake( "alice", "65.0000 EOS", "35.0000 EOS" ) ); - REQUIRE_MATCHING_OBJECT( proxy( "alice" )("staked", 1000000 ), get_voter_info( "alice" ) ); + BOOST_REQUIRE_EQUAL( success(), unstake( "alice1111111", "65.0000 EOS", "35.0000 EOS" ) ); + REQUIRE_MATCHING_OBJECT( proxy( "alice1111111" )("staked", 1000000 ), get_voter_info( "alice1111111" ) ); //unstake the rest - BOOST_REQUIRE_EQUAL( success(), unstake( "alice", "65.0000 EOS", "35.0000 EOS" ) ); - REQUIRE_MATCHING_OBJECT( proxy( "alice" )( "staked", 0 ), get_voter_info( "alice" ) ); + BOOST_REQUIRE_EQUAL( success(), unstake( "alice1111111", "65.0000 EOS", "35.0000 EOS" ) ); + REQUIRE_MATCHING_OBJECT( proxy( "alice1111111" )( "staked", 0 ), get_voter_info( "alice1111111" ) ); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( proxy_actions_affect_producers, eosio_system_tester, * boost::unit_test::tolerance(1e+5) ) try { - create_accounts_with_resources( { N(producer1), N(producer2), N(producer3) } ); - BOOST_REQUIRE_EQUAL( success(), regproducer( "producer1", 1) ); - BOOST_REQUIRE_EQUAL( success(), regproducer( "producer2", 2) ); - BOOST_REQUIRE_EQUAL( success(), regproducer( "producer3", 3) ); + create_accounts_with_resources( { N(defproducer1), N(defproducer2), N(defproducer3) } ); + BOOST_REQUIRE_EQUAL( success(), regproducer( "defproducer1", 1) ); + BOOST_REQUIRE_EQUAL( success(), regproducer( "defproducer2", 2) ); + BOOST_REQUIRE_EQUAL( success(), regproducer( "defproducer3", 3) ); //register as a proxy - BOOST_REQUIRE_EQUAL( success(), push_action( N(alice), N(regproxy), mvo() - ("proxy", "alice") + BOOST_REQUIRE_EQUAL( success(), push_action( N(alice1111111), N(regproxy), mvo() + ("proxy", "alice1111111") ("isproxy", true) ) ); //accumulate proxied votes - issue( "bob", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "bob", "100.0002 EOS", "50.0001 EOS" ) ); - BOOST_REQUIRE_EQUAL( success(), push_action(N(bob), N(voteproducer), mvo() - ("voter", "bob") - ("proxy", "alice" ) + issue( "bob111111111", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", "100.0002 EOS", "50.0001 EOS" ) ); + BOOST_REQUIRE_EQUAL( success(), push_action(N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") + ("proxy", "alice1111111" ) ("producers", vector() ) ) ); - REQUIRE_MATCHING_OBJECT( proxy( "alice" )( "proxied_vote_weight", stake2votes("150.0003 EOS") ), get_voter_info( "alice" ) ); + REQUIRE_MATCHING_OBJECT( proxy( "alice1111111" )( "proxied_vote_weight", stake2votes("150.0003 EOS") ), get_voter_info( "alice1111111" ) ); //vote for producers - BOOST_REQUIRE_EQUAL( success(), push_action(N(alice), N(voteproducer), mvo() - ("voter", "alice") + BOOST_REQUIRE_EQUAL( success(), push_action(N(alice1111111), N(voteproducer), mvo() + ("voter", "alice1111111") ("proxy", name(0).to_string() ) - ("producers", vector{ N(producer1), N(producer2) } ) + ("producers", vector{ N(defproducer1), N(defproducer2) } ) ) ); - BOOST_TEST_REQUIRE( stake2votes("150.0003 EOS") == get_producer_info( "producer1" )["total_votes"].as_double() ); - BOOST_TEST_REQUIRE( stake2votes("150.0003 EOS") == get_producer_info( "producer2" )["total_votes"].as_double() ); - BOOST_TEST_REQUIRE( 0 == get_producer_info( "producer3" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("150.0003 EOS") == get_producer_info( "defproducer1" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("150.0003 EOS") == get_producer_info( "defproducer2" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( 0 == get_producer_info( "defproducer3" )["total_votes"].as_double() ); //vote for another producers - BOOST_REQUIRE_EQUAL( success(), push_action(N(alice), N(voteproducer), mvo() - ("voter", "alice") + BOOST_REQUIRE_EQUAL( success(), push_action(N(alice1111111), N(voteproducer), mvo() + ("voter", "alice1111111") ("proxy", name(0).to_string() ) - ("producers", vector{ N(producer1), N(producer3) } ) + ("producers", vector{ N(defproducer1), N(defproducer3) } ) ) ); - BOOST_TEST_REQUIRE( stake2votes("150.0003 EOS") == get_producer_info( "producer1" )["total_votes"].as_double() ); - BOOST_REQUIRE_EQUAL( 0, get_producer_info( "producer2" )["total_votes"].as_double() ); - BOOST_TEST_REQUIRE( stake2votes("150.0003 EOS") == get_producer_info( "producer3" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("150.0003 EOS") == get_producer_info( "defproducer1" )["total_votes"].as_double() ); + BOOST_REQUIRE_EQUAL( 0, get_producer_info( "defproducer2" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("150.0003 EOS") == get_producer_info( "defproducer3" )["total_votes"].as_double() ); //unregister proxy - BOOST_REQUIRE_EQUAL( success(), push_action( N(alice), N(regproxy), mvo() - ("proxy", "alice") + BOOST_REQUIRE_EQUAL( success(), push_action( N(alice1111111), N(regproxy), mvo() + ("proxy", "alice1111111") ("isproxy", false) ) ); - //REQUIRE_MATCHING_OBJECT( voter( "alice" )( "proxied_vote_weight", stake2votes("150.0003 EOS") ), get_voter_info( "alice" ) ); - BOOST_REQUIRE_EQUAL( 0, get_producer_info( "producer1" )["total_votes"].as_double() ); - BOOST_REQUIRE_EQUAL( 0, get_producer_info( "producer2" )["total_votes"].as_double() ); - BOOST_REQUIRE_EQUAL( 0, get_producer_info( "producer3" )["total_votes"].as_double() ); + //REQUIRE_MATCHING_OBJECT( voter( "alice1111111" )( "proxied_vote_weight", stake2votes("150.0003 EOS") ), get_voter_info( "alice1111111" ) ); + BOOST_REQUIRE_EQUAL( 0, get_producer_info( "defproducer1" )["total_votes"].as_double() ); + BOOST_REQUIRE_EQUAL( 0, get_producer_info( "defproducer2" )["total_votes"].as_double() ); + BOOST_REQUIRE_EQUAL( 0, get_producer_info( "defproducer3" )["total_votes"].as_double() ); //register proxy again - BOOST_REQUIRE_EQUAL( success(), push_action( N(alice), N(regproxy), mvo() - ("proxy", "alice") + BOOST_REQUIRE_EQUAL( success(), push_action( N(alice1111111), N(regproxy), mvo() + ("proxy", "alice1111111") ("isproxy", true) ) ); - BOOST_TEST_REQUIRE( stake2votes("150.0003 EOS") == get_producer_info( "producer1" )["total_votes"].as_double() ); - BOOST_REQUIRE_EQUAL( 0, get_producer_info( "producer2" )["total_votes"].as_double() ); - BOOST_TEST_REQUIRE( stake2votes("150.0003 EOS") == get_producer_info( "producer3" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("150.0003 EOS") == get_producer_info( "defproducer1" )["total_votes"].as_double() ); + BOOST_REQUIRE_EQUAL( 0, get_producer_info( "defproducer2" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("150.0003 EOS") == get_producer_info( "defproducer3" )["total_votes"].as_double() ); //stake increase by proxy itself affects producers - issue( "alice", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "alice", "30.0001 EOS", "20.0001 EOS" ) ); - BOOST_REQUIRE_EQUAL( stake2votes("200.0005 EOS"), get_producer_info( "producer1" )["total_votes"].as_double() ); - BOOST_REQUIRE_EQUAL( 0, get_producer_info( "producer2" )["total_votes"].as_double() ); - BOOST_REQUIRE_EQUAL( stake2votes("200.0005 EOS"), get_producer_info( "producer3" )["total_votes"].as_double() ); + issue( "alice1111111", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "30.0001 EOS", "20.0001 EOS" ) ); + BOOST_REQUIRE_EQUAL( stake2votes("200.0005 EOS"), get_producer_info( "defproducer1" )["total_votes"].as_double() ); + BOOST_REQUIRE_EQUAL( 0, get_producer_info( "defproducer2" )["total_votes"].as_double() ); + BOOST_REQUIRE_EQUAL( stake2votes("200.0005 EOS"), get_producer_info( "defproducer3" )["total_votes"].as_double() ); //stake decrease by proxy itself affects producers - BOOST_REQUIRE_EQUAL( success(), unstake( "alice", "10.0001 EOS", "10.0001 EOS" ) ); - BOOST_TEST_REQUIRE( stake2votes("180.0003 EOS") == get_producer_info( "producer1" )["total_votes"].as_double() ); - BOOST_REQUIRE_EQUAL( 0, get_producer_info( "producer2" )["total_votes"].as_double() ); - BOOST_TEST_REQUIRE( stake2votes("180.0003 EOS") == get_producer_info( "producer3" )["total_votes"].as_double() ); + BOOST_REQUIRE_EQUAL( success(), unstake( "alice1111111", "10.0001 EOS", "10.0001 EOS" ) ); + BOOST_TEST_REQUIRE( stake2votes("180.0003 EOS") == get_producer_info( "defproducer1" )["total_votes"].as_double() ); + BOOST_REQUIRE_EQUAL( 0, get_producer_info( "defproducer2" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("180.0003 EOS") == get_producer_info( "defproducer3" )["total_votes"].as_double() ); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::tolerance(1e-10)) try { const asset large_asset = asset::from_string("80.0000 EOS"); - create_account_with_resources( N(inita), N(eosio), asset::from_string("1.0000 EOS"), false, large_asset, large_asset ); - create_account_with_resources( N(initb), N(eosio), asset::from_string("1.0000 EOS"), false, large_asset, large_asset ); + create_account_with_resources( N(defproducera), N(eosio), asset::from_string("1.0000 EOS"), false, large_asset, large_asset ); + create_account_with_resources( N(defproducerb), N(eosio), asset::from_string("1.0000 EOS"), false, large_asset, large_asset ); - create_account_with_resources( N(vota), N(eosio), asset::from_string("1.0000 EOS"), false, large_asset, large_asset ); - create_account_with_resources( N(votb), N(eosio), asset::from_string("1.0000 EOS"), false, large_asset, large_asset ); + create_account_with_resources( N(producvotera), N(eosio), asset::from_string("1.0000 EOS"), false, large_asset, large_asset ); + create_account_with_resources( N(producvoterb), N(eosio), asset::from_string("1.0000 EOS"), false, large_asset, large_asset ); - BOOST_REQUIRE_EQUAL(success(), regproducer(N(inita))); - auto prod = get_producer_info( N(inita) ); - BOOST_REQUIRE_EQUAL("inita", prod["owner"].as_string()); + BOOST_REQUIRE_EQUAL(success(), regproducer(N(defproducera))); + auto prod = get_producer_info( N(defproducera) ); + BOOST_REQUIRE_EQUAL("defproducera", prod["owner"].as_string()); BOOST_REQUIRE_EQUAL(0, prod["total_votes"].as_double()); - issue( "vota", "400000000.0000 EOS", config::system_account_name); - BOOST_REQUIRE_EQUAL(success(), stake("vota", "100000000.0000 EOS", "100000000.0000 EOS")); + issue( "producvotera", "400000000.0000 EOS", config::system_account_name); + BOOST_REQUIRE_EQUAL(success(), stake("producvotera", "100000000.0000 EOS", "100000000.0000 EOS")); - BOOST_REQUIRE_EQUAL(success(), push_action(N(vota), N(voteproducer), mvo() - ("voter", "vota") + BOOST_REQUIRE_EQUAL(success(), push_action(N(producvotera), N(voteproducer), mvo() + ("voter", "producvotera") ("proxy", name(0).to_string()) - ("producers", vector{ N(inita) }) + ("producers", vector{ N(defproducera) }) ) ); - // inita is the only active producer - // produce enough blocks so new schedule kicks in and inita produces some blocks + // defproducera is the only active producer + // produce enough blocks so new schedule kicks in and defproducera produces some blocks { produce_blocks(50); @@ -1331,23 +1331,23 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t const asset initial_pervote_bucket = initial_global_state["pervote_bucket"].as(); const asset initial_savings = initial_global_state["savings"].as(); - prod = get_producer_info("inita"); + prod = get_producer_info("defproducera"); const uint32_t produced_blocks = prod["produced_blocks"].as(); BOOST_REQUIRE(1 < produced_blocks); BOOST_REQUIRE_EQUAL(0, prod["last_claim_time"].as()); const asset initial_supply = get_token_supply(); - const asset initial_balance = get_balance(N(inita)); + const asset initial_balance = get_balance(N(defproducera)); - BOOST_REQUIRE_EQUAL(success(), push_action(N(inita), N(claimrewards), mvo()("owner", "inita"))); + BOOST_REQUIRE_EQUAL(success(), push_action(N(defproducera), N(claimrewards), mvo()("owner", "defproducera"))); const auto global_state = get_global_state(); const uint64_t claim_time = global_state["last_pervote_bucket_fill"].as_uint64(); const asset pervote_bucket = global_state["pervote_bucket"].as(); const asset savings = global_state["savings"].as(); - prod = get_producer_info("inita"); + prod = get_producer_info("defproducera"); BOOST_REQUIRE_EQUAL(1, prod["produced_blocks"].as()); const asset supply = get_token_supply(); - const asset balance = get_balance(N(inita)); + const asset balance = get_balance(N(defproducera)); BOOST_REQUIRE_EQUAL(claim_time, prod["last_claim_time"].as()); const int32_t secs_between_fills = static_cast((claim_time - initial_claim_time) / 1000000); @@ -1374,17 +1374,17 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t { BOOST_REQUIRE_EQUAL(error("condition: assertion failed: already claimed rewards within a day"), - push_action(N(inita), N(claimrewards), mvo()("owner", "inita"))); + push_action(N(defproducera), N(claimrewards), mvo()("owner", "defproducera"))); } - // inita waits for 23 hours and 55 minutes, can't claim rewards yet + // defproducera waits for 23 hours and 55 minutes, can't claim rewards yet { produce_block(fc::seconds(23 * 3600 + 55 * 60)); BOOST_REQUIRE_EQUAL(error("condition: assertion failed: already claimed rewards within a day"), - push_action(N(inita), N(claimrewards), mvo()("owner", "inita"))); + push_action(N(defproducera), N(claimrewards), mvo()("owner", "defproducera"))); } - // wait 5 more minutes, inita can now claim rewards again + // wait 5 more minutes, defproducera can now claim rewards again { produce_block(fc::seconds(5 * 60)); const auto initial_global_state = get_global_state(); @@ -1392,25 +1392,25 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t const asset initial_pervote_bucket = initial_global_state["pervote_bucket"].as(); const asset initial_savings = initial_global_state["savings"].as(); - prod = get_producer_info("inita"); + prod = get_producer_info("defproducera"); const uint32_t produced_blocks = prod["produced_blocks"].as(); BOOST_REQUIRE(1 < produced_blocks); BOOST_REQUIRE(0 < prod["last_claim_time"].as()); const asset initial_supply = get_token_supply(); - const asset initial_balance = get_balance(N(inita)); + const asset initial_balance = get_balance(N(defproducera)); BOOST_REQUIRE_EQUAL(success(), - push_action(N(inita), N(claimrewards), mvo()("owner", "inita"))); + push_action(N(defproducera), N(claimrewards), mvo()("owner", "defproducera"))); const auto global_state = get_global_state(); const uint64_t claim_time = global_state["last_pervote_bucket_fill"].as_uint64(); const asset pervote_bucket = global_state["pervote_bucket"].as(); const asset savings = global_state["savings"].as(); - prod = get_producer_info("inita"); + prod = get_producer_info("defproducera"); BOOST_REQUIRE_EQUAL(1, prod["produced_blocks"].as()); const asset supply = get_token_supply(); - const asset balance = get_balance(N(inita)); + const asset balance = get_balance(N(defproducera)); BOOST_REQUIRE_EQUAL(claim_time, prod["last_claim_time"].as()); const int32_t secs_between_fills = static_cast((claim_time - initial_claim_time) / 1000000); @@ -1433,10 +1433,10 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t BOOST_REQUIRE(max_supply_growth >= supply.amount - initial_supply.amount); } - // initb tries to claim rewards but he's not on the list + // defproducerb tries to claim rewards but he's not on the list { BOOST_REQUIRE_EQUAL(error("condition: assertion failed: account name is not in producer list"), - push_action(N(initb), N(claimrewards), mvo()("owner", "initb"))); + push_action(N(defproducerb), N(claimrewards), mvo()("owner", "defproducerb"))); } } FC_LOG_AND_RETHROW() @@ -1452,15 +1452,15 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni const asset net = asset::from_string("80.0000 EOS"); const asset cpu = asset::from_string("80.0000 EOS"); - create_account_with_resources( N(vota), N(eosio), asset::from_string("1.0000 EOS"), false, net, cpu ); - create_account_with_resources( N(votb), N(eosio), asset::from_string("1.0000 EOS"), false, net, cpu ); - create_account_with_resources( N(votc), N(eosio), asset::from_string("1.0000 EOS"), false, net, cpu ); + create_account_with_resources( N(producvotera), N(eosio), asset::from_string("1.0000 EOS"), false, net, cpu ); + create_account_with_resources( N(producvoterb), N(eosio), asset::from_string("1.0000 EOS"), false, net, cpu ); + create_account_with_resources( N(producvoterc), N(eosio), asset::from_string("1.0000 EOS"), false, net, cpu ); - // create accounts {inita, initb, ..., initz} and register as producers + // create accounts {defproducera, defproducerb, ..., defproducerz} and register as producers std::vector producer_names; { producer_names.reserve('z' - 'a' + 1); - const std::string root("init"); + const std::string root("defproducer"); for ( char c = 'a'; c <= 'z'; ++c ) { producer_names.emplace_back(root + std::string(1, c)); } @@ -1475,48 +1475,48 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni } { - ilog( "------ get initz ----------" ); - auto inita_info = get_producer_info( N(inita) ); - wdump((inita_info)); - BOOST_REQUIRE_EQUAL(0, inita_info["total_votes"].as()); + ilog( "------ get defproducerz ----------" ); + auto defproducera_info = get_producer_info( N(defproducera) ); + wdump((defproducera_info)); + BOOST_REQUIRE_EQUAL(0, defproducera_info["total_votes"].as()); - ilog( "------ get initz ----------" ); - auto initz_info = get_producer_info( N(initz) ); - wdump((initz_info)); - BOOST_REQUIRE_EQUAL(0, initz_info["total_votes"].as()); + ilog( "------ get defproducerz ----------" ); + auto defproducerz_info = get_producer_info( N(defproducerz) ); + wdump((defproducerz_info)); + BOOST_REQUIRE_EQUAL(0, defproducerz_info["total_votes"].as()); } } { - transfer( config::system_account_name, "vota", "100000000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL(success(), stake("vota", "30000000.0000 EOS", "30000000.0000 EOS") ); - transfer( config::system_account_name, "votb", "100000000.0000 EOS", config::system_account_name); - BOOST_REQUIRE_EQUAL(success(), stake("votb", "30000000.0000 EOS", "30000000.0000 EOS") ); - transfer( config::system_account_name, "votc", "100000000.0000 EOS", config::system_account_name); - BOOST_REQUIRE_EQUAL(success(), stake("votc", "30000000.0000 EOS", "30000000.0000 EOS") ); + transfer( config::system_account_name, "producvotera", "100000000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL(success(), stake("producvotera", "30000000.0000 EOS", "30000000.0000 EOS") ); + transfer( config::system_account_name, "producvoterb", "100000000.0000 EOS", config::system_account_name); + BOOST_REQUIRE_EQUAL(success(), stake("producvoterb", "30000000.0000 EOS", "30000000.0000 EOS") ); + transfer( config::system_account_name, "producvoterc", "100000000.0000 EOS", config::system_account_name); + BOOST_REQUIRE_EQUAL(success(), stake("producvoterc", "30000000.0000 EOS", "30000000.0000 EOS") ); } - // vota votes for inita ... initj - // votb votes for inita ... initu - // votc votes for inita ... initz + // producvotera votes for defproducera ... defproducerj + // producvoterb votes for defproducera ... defproduceru + // producvoterc votes for defproducera ... defproducerz { - BOOST_REQUIRE_EQUAL(success(), push_action(N(vota), N(voteproducer), mvo() - ("voter", "vota") + BOOST_REQUIRE_EQUAL(success(), push_action(N(producvotera), N(voteproducer), mvo() + ("voter", "producvotera") ("proxy", name(0).to_string()) ("producers", vector(producer_names.begin(), producer_names.begin()+10)) ) ); - BOOST_REQUIRE_EQUAL(success(), push_action(N(votb), N(voteproducer), mvo() - ("voter", "votb") + BOOST_REQUIRE_EQUAL(success(), push_action(N(producvoterb), N(voteproducer), mvo() + ("voter", "producvoterb") ("proxy", name(0).to_string()) ("producers", vector(producer_names.begin(), producer_names.begin()+21)) ) ); - BOOST_REQUIRE_EQUAL(success(), push_action(N(votc), N(voteproducer), mvo() - ("voter", "votc") + BOOST_REQUIRE_EQUAL(success(), push_action(N(producvoterc), N(voteproducer), mvo() + ("voter", "producvoterc") ("proxy", name(0).to_string()) ("producers", vector(producer_names.begin(), producer_names.end())) ) @@ -1525,12 +1525,12 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni } { - auto proda = get_producer_info( N(inita) ); - auto prodj = get_producer_info( N(initj) ); - auto prodk = get_producer_info( N(initk) ); - auto produ = get_producer_info( N(initu) ); - auto prodv = get_producer_info( N(initv) ); - auto prodz = get_producer_info( N(initz) ); + auto proda = get_producer_info( N(defproducera) ); + auto prodj = get_producer_info( N(defproducerj) ); + auto prodk = get_producer_info( N(defproducerk) ); + auto produ = get_producer_info( N(defproduceru) ); + auto prodv = get_producer_info( N(defproducerv) ); + auto prodz = get_producer_info( N(defproducerz) ); BOOST_REQUIRE (0 == proda["produced_blocks"].as() && 0 == prodz["produced_blocks"].as()); BOOST_REQUIRE (0 == proda["last_claim_time"].as() && 0 == prodz["last_claim_time"].as()); @@ -1731,26 +1731,26 @@ BOOST_FIXTURE_TEST_CASE(producer_onblock_check, eosio_system_tester) try { const auto tol = boost::test_tools::tolerance(0.0000000001); const asset large_asset = asset::from_string("100000000.0000 EOS"); - create_account_with_resources( N(vota), N(eosio), asset::from_string("1.0000 EOS"), false, large_asset, large_asset ); - create_account_with_resources( N(votb), N(eosio), asset::from_string("1.0000 EOS"), false, large_asset, large_asset ); - create_account_with_resources( N(votc), N(eosio), asset::from_string("1.0000 EOS"), false, large_asset, large_asset ); - - // create accounts {inita, initb, ..., initz} and register as producers - std::vector producer_names={N(inita),N(initb),N(initc),N(initd),N(inite),N(initf),N(initg),N(inith), - N(initi),N(initj),N(initk),N(initl),N(initm),N(initn),N(inito),N(initp),N(initq),N(initr),N(inits),N(initt), - N(initu),N(initv),N(initw),N(initx),N(inity),N(initz)}; + create_account_with_resources( N(producvotera), N(eosio), asset::from_string("1.0000 EOS"), false, large_asset, large_asset ); + create_account_with_resources( N(producvoterb), N(eosio), asset::from_string("1.0000 EOS"), false, large_asset, large_asset ); + create_account_with_resources( N(producvoterc), N(eosio), asset::from_string("1.0000 EOS"), false, large_asset, large_asset ); + + // create accounts {defproducera, defproducerb, ..., defproducerz} and register as producers + std::vector producer_names={N(defproducera),N(defproducerb),N(defproducerc),N(defproducerd),N(defproducere),N(defproducerf),N(defproducerg),N(defproducerh), + N(defproduceri),N(defproducerj),N(defproducerk),N(defproducerl),N(defproducerm),N(defproducern),N(defproducero),N(defproducerp),N(defproducerq),N(defproducerr),N(defproducers),N(defproducert), + N(defproduceru),N(defproducerv),N(defproducerw),N(defproducerx),N(defproducery),N(defproducerz)}; setup_producer_accounts(producer_names); for (auto a:producer_names) regproducer(a); - BOOST_REQUIRE_EQUAL(0, get_producer_info( N(inita) )["total_votes"].as()); - BOOST_REQUIRE_EQUAL(0, get_producer_info( N(initz) )["total_votes"].as()); + BOOST_REQUIRE_EQUAL(0, get_producer_info( N(defproducera) )["total_votes"].as()); + BOOST_REQUIRE_EQUAL(0, get_producer_info( N(defproducerz) )["total_votes"].as()); - issue( "vota", "100000000.0000 EOS", config::system_account_name); - BOOST_REQUIRE_EQUAL(success(), stake("vota", "30000000.0000 EOS", "30000000.0000 EOS")); - BOOST_REQUIRE_EQUAL(success(), push_action(N(vota), N(voteproducer), mvo() - ("voter", "vota") + issue( "producvotera", "100000000.0000 EOS", config::system_account_name); + BOOST_REQUIRE_EQUAL(success(), stake("producvotera", "30000000.0000 EOS", "30000000.0000 EOS")); + BOOST_REQUIRE_EQUAL(success(), push_action(N(producvotera), N(voteproducer), mvo() + ("voter", "producvotera") ("proxy", name(0).to_string()) ("producers", vector(producer_names.begin(), producer_names.begin()+10)) )); @@ -1775,20 +1775,20 @@ BOOST_FIXTURE_TEST_CASE(producer_onblock_check, eosio_system_tester) try { } // issue across 15% boundary - issue( "votb", "100000000.0000 EOS", config::system_account_name); - BOOST_REQUIRE_EQUAL(success(), stake("votb", "30000000.0000 EOS", "30000000.0000 EOS")); - issue( "votc", "100000000.0000 EOS", config::system_account_name); - BOOST_REQUIRE_EQUAL(success(), stake("votc", "30000000.0000 EOS", "30000000.0000 EOS")); + issue( "producvoterb", "100000000.0000 EOS", config::system_account_name); + BOOST_REQUIRE_EQUAL(success(), stake("producvoterb", "30000000.0000 EOS", "30000000.0000 EOS")); + issue( "producvoterc", "100000000.0000 EOS", config::system_account_name); + BOOST_REQUIRE_EQUAL(success(), stake("producvoterc", "30000000.0000 EOS", "30000000.0000 EOS")); - BOOST_REQUIRE_EQUAL(success(), push_action(N(votb), N(voteproducer), mvo() - ("voter", "votb") + BOOST_REQUIRE_EQUAL(success(), push_action(N(producvoterb), N(voteproducer), mvo() + ("voter", "producvoterb") ("proxy", name(0).to_string()) ("producers", vector(producer_names.begin(), producer_names.begin()+21)) ) ); - BOOST_REQUIRE_EQUAL(success(), push_action(N(votc), N(voteproducer), mvo() - ("voter", "votc") + BOOST_REQUIRE_EQUAL(success(), push_action(N(producvoterc), N(voteproducer), mvo() + ("voter", "producvoterc") ("proxy", name(0).to_string()) ("producers", vector(producer_names.begin(), producer_names.end())) ) @@ -1816,130 +1816,130 @@ BOOST_FIXTURE_TEST_CASE(producer_onblock_check, eosio_system_tester) try { } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( voters_actions_affect_proxy_and_producers, eosio_system_tester, * boost::unit_test::tolerance(1e+6) ) try { - create_accounts_with_resources( { N(donald), N(producer1), N(producer2), N(producer3) } ); - BOOST_REQUIRE_EQUAL( success(), regproducer( "producer1", 1) ); - BOOST_REQUIRE_EQUAL( success(), regproducer( "producer2", 2) ); - BOOST_REQUIRE_EQUAL( success(), regproducer( "producer3", 3) ); - - //alice becomes a producer - BOOST_REQUIRE_EQUAL( success(), push_action( N(alice), N(regproxy), mvo() - ("proxy", "alice") + create_accounts_with_resources( { N(donald111111), N(defproducer1), N(defproducer2), N(defproducer3) } ); + BOOST_REQUIRE_EQUAL( success(), regproducer( "defproducer1", 1) ); + BOOST_REQUIRE_EQUAL( success(), regproducer( "defproducer2", 2) ); + BOOST_REQUIRE_EQUAL( success(), regproducer( "defproducer3", 3) ); + + //alice1111111 becomes a producer + BOOST_REQUIRE_EQUAL( success(), push_action( N(alice1111111), N(regproxy), mvo() + ("proxy", "alice1111111") ("isproxy", true) ) ); - REQUIRE_MATCHING_OBJECT( proxy( "alice" ), get_voter_info( "alice" ) ); + REQUIRE_MATCHING_OBJECT( proxy( "alice1111111" ), get_voter_info( "alice1111111" ) ); - //alice makes stake and votes - issue( "alice", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "alice", "30.0001 EOS", "20.0001 EOS" ) ); - BOOST_REQUIRE_EQUAL( success(), push_action(N(alice), N(voteproducer), mvo() - ("voter", "alice") + //alice1111111 makes stake and votes + issue( "alice1111111", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "30.0001 EOS", "20.0001 EOS" ) ); + BOOST_REQUIRE_EQUAL( success(), push_action(N(alice1111111), N(voteproducer), mvo() + ("voter", "alice1111111") ("proxy", name(0).to_string() ) - ("producers", vector{ N(producer1), N(producer2) } ) + ("producers", vector{ N(defproducer1), N(defproducer2) } ) ) ); - BOOST_TEST_REQUIRE( stake2votes("50.0002 EOS") == get_producer_info( "producer1" )["total_votes"].as_double() ); - BOOST_TEST_REQUIRE( stake2votes("50.0002 EOS") == get_producer_info( "producer2" )["total_votes"].as_double() ); - BOOST_REQUIRE_EQUAL( 0, get_producer_info( "producer3" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("50.0002 EOS") == get_producer_info( "defproducer1" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("50.0002 EOS") == get_producer_info( "defproducer2" )["total_votes"].as_double() ); + BOOST_REQUIRE_EQUAL( 0, get_producer_info( "defproducer3" )["total_votes"].as_double() ); - BOOST_REQUIRE_EQUAL( success(), push_action( N(donald), N(regproxy), mvo() - ("proxy", "donald") + BOOST_REQUIRE_EQUAL( success(), push_action( N(donald111111), N(regproxy), mvo() + ("proxy", "donald111111") ("isproxy", true) ) ); - REQUIRE_MATCHING_OBJECT( proxy( "donald" ), get_voter_info( "donald" ) ); + REQUIRE_MATCHING_OBJECT( proxy( "donald111111" ), get_voter_info( "donald111111" ) ); - //bob chooses alice as a proxy - issue( "bob", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "bob", "100.0002 EOS", "50.0001 EOS" ) ); - BOOST_REQUIRE_EQUAL( success(), push_action( N(bob), N(voteproducer), mvo() - ("voter", "bob") - ("proxy", "alice" ) + //bob111111111 chooses alice1111111 as a proxy + issue( "bob111111111", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", "100.0002 EOS", "50.0001 EOS" ) ); + BOOST_REQUIRE_EQUAL( success(), push_action( N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") + ("proxy", "alice1111111" ) ("producers", vector() ) ) ); - BOOST_TEST_REQUIRE( stake2votes("150.0003 EOS") == get_voter_info( "alice" )["proxied_vote_weight"].as_double() ); - BOOST_TEST_REQUIRE( stake2votes("200.0005 EOS") == get_producer_info( "producer1" )["total_votes"].as_double() ); - BOOST_TEST_REQUIRE( stake2votes("200.0005 EOS") == get_producer_info( "producer2" )["total_votes"].as_double() ); - BOOST_REQUIRE_EQUAL( 0, get_producer_info( "producer3" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("150.0003 EOS") == get_voter_info( "alice1111111" )["proxied_vote_weight"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("200.0005 EOS") == get_producer_info( "defproducer1" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("200.0005 EOS") == get_producer_info( "defproducer2" )["total_votes"].as_double() ); + BOOST_REQUIRE_EQUAL( 0, get_producer_info( "defproducer3" )["total_votes"].as_double() ); - //carol chooses alice as a proxy - issue( "carol", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "carol", "30.0001 EOS", "20.0001 EOS" ) ); - BOOST_REQUIRE_EQUAL( success(), push_action( N(carol), N(voteproducer), mvo() - ("voter", "carol") - ("proxy", "alice" ) + //carol1111111 chooses alice1111111 as a proxy + issue( "carol1111111", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "carol1111111", "30.0001 EOS", "20.0001 EOS" ) ); + BOOST_REQUIRE_EQUAL( success(), push_action( N(carol1111111), N(voteproducer), mvo() + ("voter", "carol1111111") + ("proxy", "alice1111111" ) ("producers", vector() ) ) ); - BOOST_TEST_REQUIRE( stake2votes("200.0005 EOS") == get_voter_info( "alice" )["proxied_vote_weight"].as_double() ); - BOOST_TEST_REQUIRE( stake2votes("250.0007 EOS") == get_producer_info( "producer1" )["total_votes"].as_double() ); - BOOST_TEST_REQUIRE( stake2votes("250.0007 EOS") == get_producer_info( "producer2" )["total_votes"].as_double() ); - BOOST_REQUIRE_EQUAL( 0, get_producer_info( "producer3" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("200.0005 EOS") == get_voter_info( "alice1111111" )["proxied_vote_weight"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("250.0007 EOS") == get_producer_info( "defproducer1" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("250.0007 EOS") == get_producer_info( "defproducer2" )["total_votes"].as_double() ); + BOOST_REQUIRE_EQUAL( 0, get_producer_info( "defproducer3" )["total_votes"].as_double() ); - //proxied voter carol increases stake - BOOST_REQUIRE_EQUAL( success(), stake( "carol", "50.0000 EOS", "70.0000 EOS" ) ); - BOOST_TEST_REQUIRE( stake2votes("320.0005 EOS") == get_voter_info( "alice" )["proxied_vote_weight"].as_double() ); - BOOST_TEST_REQUIRE( stake2votes("370.0007 EOS") == get_producer_info( "producer1" )["total_votes"].as_double() ); - BOOST_TEST_REQUIRE( stake2votes("370.0007 EOS") == get_producer_info( "producer2" )["total_votes"].as_double() ); - BOOST_REQUIRE_EQUAL( 0, get_producer_info( "producer3" )["total_votes"].as_double() ); + //proxied voter carol1111111 increases stake + BOOST_REQUIRE_EQUAL( success(), stake( "carol1111111", "50.0000 EOS", "70.0000 EOS" ) ); + BOOST_TEST_REQUIRE( stake2votes("320.0005 EOS") == get_voter_info( "alice1111111" )["proxied_vote_weight"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("370.0007 EOS") == get_producer_info( "defproducer1" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("370.0007 EOS") == get_producer_info( "defproducer2" )["total_votes"].as_double() ); + BOOST_REQUIRE_EQUAL( 0, get_producer_info( "defproducer3" )["total_votes"].as_double() ); - //proxied voter bob decreases stake - BOOST_REQUIRE_EQUAL( success(), unstake( "bob", "50.0001 EOS", "50.0001 EOS" ) ); - BOOST_TEST_REQUIRE( stake2votes("220.0003 EOS") == get_voter_info( "alice" )["proxied_vote_weight"].as_double() ); - BOOST_TEST_REQUIRE( stake2votes("270.0005 EOS") == get_producer_info( "producer1" )["total_votes"].as_double() ); - BOOST_TEST_REQUIRE( stake2votes("270.0005 EOS") == get_producer_info( "producer2" )["total_votes"].as_double() ); - BOOST_REQUIRE_EQUAL( 0, get_producer_info( "producer3" )["total_votes"].as_double() ); + //proxied voter bob111111111 decreases stake + BOOST_REQUIRE_EQUAL( success(), unstake( "bob111111111", "50.0001 EOS", "50.0001 EOS" ) ); + BOOST_TEST_REQUIRE( stake2votes("220.0003 EOS") == get_voter_info( "alice1111111" )["proxied_vote_weight"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("270.0005 EOS") == get_producer_info( "defproducer1" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("270.0005 EOS") == get_producer_info( "defproducer2" )["total_votes"].as_double() ); + BOOST_REQUIRE_EQUAL( 0, get_producer_info( "defproducer3" )["total_votes"].as_double() ); - //proxied voter carol chooses another proxy - BOOST_REQUIRE_EQUAL( success(), push_action( N(carol), N(voteproducer), mvo() - ("voter", "carol") - ("proxy", "donald" ) + //proxied voter carol1111111 chooses another proxy + BOOST_REQUIRE_EQUAL( success(), push_action( N(carol1111111), N(voteproducer), mvo() + ("voter", "carol1111111") + ("proxy", "donald111111" ) ("producers", vector() ) ) ); - BOOST_TEST_REQUIRE( stake2votes("50.0001 EOS"), get_voter_info( "alice" )["proxied_vote_weight"].as_double() ); - BOOST_TEST_REQUIRE( stake2votes("170.0002 EOS"), get_voter_info( "donald" )["proxied_vote_weight"].as_double() ); - BOOST_TEST_REQUIRE( stake2votes("100.0003 EOS"), get_producer_info( "producer1" )["total_votes"].as_double() ); - BOOST_TEST_REQUIRE( stake2votes("100.0003 EOS"), get_producer_info( "producer2" )["total_votes"].as_double() ); - BOOST_REQUIRE_EQUAL( 0, get_producer_info( "producer3" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("50.0001 EOS"), get_voter_info( "alice1111111" )["proxied_vote_weight"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("170.0002 EOS"), get_voter_info( "donald111111" )["proxied_vote_weight"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("100.0003 EOS"), get_producer_info( "defproducer1" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("100.0003 EOS"), get_producer_info( "defproducer2" )["total_votes"].as_double() ); + BOOST_REQUIRE_EQUAL( 0, get_producer_info( "defproducer3" )["total_votes"].as_double() ); - //bob switches to direct voting and votes for one of the same producers, but not for another one - BOOST_REQUIRE_EQUAL( success(), push_action( N(bob), N(voteproducer), mvo() - ("voter", "bob") + //bob111111111 switches to direct voting and votes for one of the same producers, but not for another one + BOOST_REQUIRE_EQUAL( success(), push_action( N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") ("proxy", "") - ("producers", vector{ N(producer2) } ) + ("producers", vector{ N(defproducer2) } ) ) ); - BOOST_TEST_REQUIRE( 0.0 == get_voter_info( "alice" )["proxied_vote_weight"].as_double() ); - BOOST_TEST_REQUIRE( stake2votes("50.0002 EOS"), get_producer_info( "producer1" )["total_votes"].as_double() ); - BOOST_TEST_REQUIRE( stake2votes("100.0003 EOS"), get_producer_info( "producer2" )["total_votes"].as_double() ); - BOOST_TEST_REQUIRE( 0.0 == get_producer_info( "producer3" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( 0.0 == get_voter_info( "alice1111111" )["proxied_vote_weight"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("50.0002 EOS"), get_producer_info( "defproducer1" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( stake2votes("100.0003 EOS"), get_producer_info( "defproducer2" )["total_votes"].as_double() ); + BOOST_TEST_REQUIRE( 0.0 == get_producer_info( "defproducer3" )["total_votes"].as_double() ); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( vote_both_proxy_and_producers, eosio_system_tester ) try { - //alice becomes a proxy - BOOST_REQUIRE_EQUAL( success(), push_action( N(alice), N(regproxy), mvo() - ("proxy", "alice") + //alice1111111 becomes a proxy + BOOST_REQUIRE_EQUAL( success(), push_action( N(alice1111111), N(regproxy), mvo() + ("proxy", "alice1111111") ("isproxy", true) ) ); - REQUIRE_MATCHING_OBJECT( proxy( "alice" ), get_voter_info( "alice" ) ); + REQUIRE_MATCHING_OBJECT( proxy( "alice1111111" ), get_voter_info( "alice1111111" ) ); - //carol becomes a producer - BOOST_REQUIRE_EQUAL( success(), regproducer( "carol", 1) ); + //carol1111111 becomes a producer + BOOST_REQUIRE_EQUAL( success(), regproducer( "carol1111111", 1) ); - //bob chooses alice as a proxy - issue( "bob", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "bob", "100.0002 EOS", "50.0001 EOS" ) ); + //bob111111111 chooses alice1111111 as a proxy + issue( "bob111111111", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", "100.0002 EOS", "50.0001 EOS" ) ); BOOST_REQUIRE_EQUAL( error("condition: assertion failed: cannot vote for producers and proxy at same time"), - push_action( N(bob), N(voteproducer), mvo() - ("voter", "bob") - ("proxy", "alice" ) - ("producers", vector{ N(carol) } ) + push_action( N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") + ("proxy", "alice1111111" ) + ("producers", vector{ N(carol1111111) } ) ) ); @@ -1948,22 +1948,22 @@ BOOST_FIXTURE_TEST_CASE( vote_both_proxy_and_producers, eosio_system_tester ) tr BOOST_FIXTURE_TEST_CASE( select_invalid_proxy, eosio_system_tester ) try { //accumulate proxied votes - issue( "bob", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "bob", "100.0002 EOS", "50.0001 EOS" ) ); + issue( "bob111111111", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", "100.0002 EOS", "50.0001 EOS" ) ); //selecting account not registered as a proxy BOOST_REQUIRE_EQUAL( error( "condition: assertion failed: invalid proxy specified" ), - push_action(N(bob), N(voteproducer), mvo() - ("voter", "bob") - ("proxy", "alice" ) + push_action(N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") + ("proxy", "alice1111111" ) ("producers", vector() ) ) ); //selecting not existing account as a proxy BOOST_REQUIRE_EQUAL( error( "condition: assertion failed: invalid proxy specified" ), - push_action(N(bob), N(voteproducer), mvo() - ("voter", "bob") + push_action(N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") ("proxy", "notexist" ) ("producers", vector() ) ) @@ -1973,103 +1973,103 @@ BOOST_FIXTURE_TEST_CASE( select_invalid_proxy, eosio_system_tester ) try { BOOST_FIXTURE_TEST_CASE( double_register_unregister_proxy_keeps_votes, eosio_system_tester ) try { - //alice becomes a proxy - BOOST_REQUIRE_EQUAL( success(), push_action( N(alice), N(regproxy), mvo() - ("proxy", "alice") + //alice1111111 becomes a proxy + BOOST_REQUIRE_EQUAL( success(), push_action( N(alice1111111), N(regproxy), mvo() + ("proxy", "alice1111111") ("isproxy", 1) ) ); - issue( "alice", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "alice", "5.0000 EOS", "5.0000 EOS" ) ); - edump((get_voter_info("alice"))); - REQUIRE_MATCHING_OBJECT( proxy( "alice" )( "staked", 100000 ), get_voter_info( "alice" ) ); + issue( "alice1111111", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "5.0000 EOS", "5.0000 EOS" ) ); + edump((get_voter_info("alice1111111"))); + REQUIRE_MATCHING_OBJECT( proxy( "alice1111111" )( "staked", 100000 ), get_voter_info( "alice1111111" ) ); - //bob stakes and selects alice as a proxy - issue( "bob", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "bob", "100.0002 EOS", "50.0001 EOS" ) ); - BOOST_REQUIRE_EQUAL( success(), push_action( N(bob), N(voteproducer), mvo() - ("voter", "bob") - ("proxy", "alice" ) + //bob111111111 stakes and selects alice1111111 as a proxy + issue( "bob111111111", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", "100.0002 EOS", "50.0001 EOS" ) ); + BOOST_REQUIRE_EQUAL( success(), push_action( N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") + ("proxy", "alice1111111" ) ("producers", vector() ) ) ); - REQUIRE_MATCHING_OBJECT( proxy( "alice" )( "proxied_vote_weight", stake2votes( "150.0003 EOS" ))( "staked", 100000 ), get_voter_info( "alice" ) ); + REQUIRE_MATCHING_OBJECT( proxy( "alice1111111" )( "proxied_vote_weight", stake2votes( "150.0003 EOS" ))( "staked", 100000 ), get_voter_info( "alice1111111" ) ); //double regestering should fail without affecting total votes and stake BOOST_REQUIRE_EQUAL( error( "condition: assertion failed: action has no effect" ), - push_action( N(alice), N(regproxy), mvo() - ("proxy", "alice") + push_action( N(alice1111111), N(regproxy), mvo() + ("proxy", "alice1111111") ("isproxy", 1) ) ); - REQUIRE_MATCHING_OBJECT( proxy( "alice" )( "proxied_vote_weight", stake2votes("150.0003 EOS") )( "staked", 100000 ), get_voter_info( "alice" ) ); + REQUIRE_MATCHING_OBJECT( proxy( "alice1111111" )( "proxied_vote_weight", stake2votes("150.0003 EOS") )( "staked", 100000 ), get_voter_info( "alice1111111" ) ); //uregister - BOOST_REQUIRE_EQUAL( success(), push_action( N(alice), N(regproxy), mvo() - ("proxy", "alice") + BOOST_REQUIRE_EQUAL( success(), push_action( N(alice1111111), N(regproxy), mvo() + ("proxy", "alice1111111") ("isproxy", 0) ) ); - REQUIRE_MATCHING_OBJECT( voter( "alice" )( "proxied_vote_weight", stake2votes("150.0003 EOS") )( "staked", 100000 ), get_voter_info( "alice" ) ); + REQUIRE_MATCHING_OBJECT( voter( "alice1111111" )( "proxied_vote_weight", stake2votes("150.0003 EOS") )( "staked", 100000 ), get_voter_info( "alice1111111" ) ); //double unregistering should not affect proxied_votes and stake BOOST_REQUIRE_EQUAL( error( "condition: assertion failed: action has no effect" ), - push_action( N(alice), N(regproxy), mvo() - ("proxy", "alice") + push_action( N(alice1111111), N(regproxy), mvo() + ("proxy", "alice1111111") ("isproxy", 0) ) ); - REQUIRE_MATCHING_OBJECT( voter( "alice" )( "proxied_vote_weight", stake2votes("150.0003 EOS"))( "staked", 100000 ), get_voter_info( "alice" ) ); + REQUIRE_MATCHING_OBJECT( voter( "alice1111111" )( "proxied_vote_weight", stake2votes("150.0003 EOS"))( "staked", 100000 ), get_voter_info( "alice1111111" ) ); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( proxy_cannot_use_another_proxy, eosio_system_tester ) try { - //alice becomes a proxy - BOOST_REQUIRE_EQUAL( success(), push_action( N(alice), N(regproxy), mvo() - ("proxy", "alice") + //alice1111111 becomes a proxy + BOOST_REQUIRE_EQUAL( success(), push_action( N(alice1111111), N(regproxy), mvo() + ("proxy", "alice1111111") ("isproxy", 1) ) ); - //bob becomes a proxy - BOOST_REQUIRE_EQUAL( success(), push_action( N(bob), N(regproxy), mvo() - ("proxy", "bob") + //bob111111111 becomes a proxy + BOOST_REQUIRE_EQUAL( success(), push_action( N(bob111111111), N(regproxy), mvo() + ("proxy", "bob111111111") ("isproxy", 1) ) ); //proxy should not be able to use a proxy - issue( "bob", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "bob", "100.0002 EOS", "50.0001 EOS" ) ); + issue( "bob111111111", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", "100.0002 EOS", "50.0001 EOS" ) ); BOOST_REQUIRE_EQUAL( error( "condition: assertion failed: account registered as a proxy is not allowed to use a proxy" ), - push_action( N(bob), N(voteproducer), mvo() - ("voter", "bob") - ("proxy", "alice" ) + push_action( N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") + ("proxy", "alice1111111" ) ("producers", vector() ) ) ); //voter that uses a proxy should not be allowed to become a proxy - issue( "carol", "1000.0000 EOS", config::system_account_name ); - BOOST_REQUIRE_EQUAL( success(), stake( "carol", "100.0002 EOS", "50.0001 EOS" ) ); - BOOST_REQUIRE_EQUAL( success(), push_action( N(carol), N(voteproducer), mvo() - ("voter", "carol") - ("proxy", "alice" ) + issue( "carol1111111", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( success(), stake( "carol1111111", "100.0002 EOS", "50.0001 EOS" ) ); + BOOST_REQUIRE_EQUAL( success(), push_action( N(carol1111111), N(voteproducer), mvo() + ("voter", "carol1111111") + ("proxy", "alice1111111" ) ("producers", vector() ) ) ); BOOST_REQUIRE_EQUAL( error( "condition: assertion failed: account that uses a proxy is not allowed to become a proxy" ), - push_action( N(carol), N(regproxy), mvo() - ("proxy", "carol") + push_action( N(carol1111111), N(regproxy), mvo() + ("proxy", "carol1111111") ("isproxy", 1) ) ); //proxy should not be able to use itself as a proxy BOOST_REQUIRE_EQUAL( error( "condition: assertion failed: cannot proxy to self" ), - push_action( N(bob), N(voteproducer), mvo() - ("voter", "bob") - ("proxy", "bob" ) + push_action( N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") + ("proxy", "bob111111111" ) ("producers", vector() ) ) ); @@ -2103,80 +2103,80 @@ fc::mutable_variant_object config_to_variant( const eosio::chain::chain_config& } BOOST_FIXTURE_TEST_CASE( elect_producers /*_and_parameters*/, eosio_system_tester ) try { - create_accounts_with_resources( { N(producer1), N(producer2), N(producer3) } ); - BOOST_REQUIRE_EQUAL( success(), regproducer( "producer1", 1) ); - BOOST_REQUIRE_EQUAL( success(), regproducer( "producer2", 2) ); - BOOST_REQUIRE_EQUAL( success(), regproducer( "producer3", 3) ); + create_accounts_with_resources( { N(defproducer1), N(defproducer2), N(defproducer3) } ); + BOOST_REQUIRE_EQUAL( success(), regproducer( "defproducer1", 1) ); + BOOST_REQUIRE_EQUAL( success(), regproducer( "defproducer2", 2) ); + BOOST_REQUIRE_EQUAL( success(), regproducer( "defproducer3", 3) ); //stake more than 15% of total EOS supply to activate chain - transfer( "eosio", "alice", "600000000.0000 EOS", "eosio" ); - BOOST_REQUIRE_EQUAL( success(), stake( "alice", "alice", "300000000.0000 EOS", "300000000.0000 EOS" ) ); + transfer( "eosio", "alice1111111", "600000000.0000 EOS", "eosio" ); + BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "alice1111111", "300000000.0000 EOS", "300000000.0000 EOS" ) ); // 1000000000.0000 //vote for producers - BOOST_REQUIRE_EQUAL( success(), push_action(N(alice), N(voteproducer), mvo() - ("voter", "alice") + BOOST_REQUIRE_EQUAL( success(), push_action(N(alice1111111), N(voteproducer), mvo() + ("voter", "alice1111111") ("proxy", name(0).to_string() ) - ("producers", vector{ N(producer1) } ) + ("producers", vector{ N(defproducer1) } ) ) ); produce_blocks(250); auto producer_keys = control->head_block_state()->active_schedule.producers; BOOST_REQUIRE_EQUAL( 1, producer_keys.size() ); - BOOST_REQUIRE_EQUAL( name("producer1"), producer_keys[0].producer_name ); + BOOST_REQUIRE_EQUAL( name("defproducer1"), producer_keys[0].producer_name ); //auto config = config_to_variant( control->get_global_properties().configuration ); //auto prod1_config = testing::filter_fields( config, producer_parameters_example( 1 ) ); //REQUIRE_EQUAL_OBJECTS(prod1_config, config); // elect 2 producers - issue( "bob", "80000.0000 EOS", config::system_account_name ); + issue( "bob111111111", "80000.0000 EOS", config::system_account_name ); ilog("stake"); - BOOST_REQUIRE_EQUAL( success(), stake( "bob", "40000.0000 EOS", "40000.0000 EOS" ) ); + BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", "40000.0000 EOS", "40000.0000 EOS" ) ); ilog("start vote"); - BOOST_REQUIRE_EQUAL( success(), push_action(N(bob), N(voteproducer), mvo() - ("voter", "bob") + BOOST_REQUIRE_EQUAL( success(), push_action(N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") ("proxy", name(0).to_string() ) - ("producers", vector{ N(producer2) } ) + ("producers", vector{ N(defproducer2) } ) ) ); ilog("."); produce_blocks(250); producer_keys = control->head_block_state()->active_schedule.producers; BOOST_REQUIRE_EQUAL( 2, producer_keys.size() ); - BOOST_REQUIRE_EQUAL( name("producer1"), producer_keys[0].producer_name ); - BOOST_REQUIRE_EQUAL( name("producer2"), producer_keys[1].producer_name ); + BOOST_REQUIRE_EQUAL( name("defproducer1"), producer_keys[0].producer_name ); + BOOST_REQUIRE_EQUAL( name("defproducer2"), producer_keys[1].producer_name ); //config = config_to_variant( control->get_global_properties().configuration ); //auto prod2_config = testing::filter_fields( config, producer_parameters_example( 2 ) ); //REQUIRE_EQUAL_OBJECTS(prod2_config, config); // elect 3 producers - BOOST_REQUIRE_EQUAL( success(), push_action(N(bob), N(voteproducer), mvo() - ("voter", "bob") + BOOST_REQUIRE_EQUAL( success(), push_action(N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") ("proxy", name(0).to_string() ) - ("producers", vector{ N(producer2), N(producer3) } ) + ("producers", vector{ N(defproducer2), N(defproducer3) } ) ) ); produce_blocks(250); producer_keys = control->head_block_state()->active_schedule.producers; BOOST_REQUIRE_EQUAL( 3, producer_keys.size() ); - BOOST_REQUIRE_EQUAL( name("producer1"), producer_keys[0].producer_name ); - BOOST_REQUIRE_EQUAL( name("producer2"), producer_keys[1].producer_name ); - BOOST_REQUIRE_EQUAL( name("producer3"), producer_keys[2].producer_name ); + BOOST_REQUIRE_EQUAL( name("defproducer1"), producer_keys[0].producer_name ); + BOOST_REQUIRE_EQUAL( name("defproducer2"), producer_keys[1].producer_name ); + BOOST_REQUIRE_EQUAL( name("defproducer3"), producer_keys[2].producer_name ); //config = config_to_variant( control->get_global_properties().configuration ); //REQUIRE_EQUAL_OBJECTS(prod2_config, config); //back to 2 producers - BOOST_REQUIRE_EQUAL( success(), push_action(N(bob), N(voteproducer), mvo() - ("voter", "bob") + BOOST_REQUIRE_EQUAL( success(), push_action(N(bob111111111), N(voteproducer), mvo() + ("voter", "bob111111111") ("proxy", name(0).to_string() ) - ("producers", vector{ N(producer3) } ) + ("producers", vector{ N(defproducer3) } ) ) ); produce_blocks(250); producer_keys = control->head_block_state()->active_schedule.producers; BOOST_REQUIRE_EQUAL( 2, producer_keys.size() ); - BOOST_REQUIRE_EQUAL( name("producer1"), producer_keys[0].producer_name ); - BOOST_REQUIRE_EQUAL( name("producer3"), producer_keys[1].producer_name ); + BOOST_REQUIRE_EQUAL( name("defproducer1"), producer_keys[0].producer_name ); + BOOST_REQUIRE_EQUAL( name("defproducer3"), producer_keys[1].producer_name ); //config = config_to_variant( control->get_global_properties().configuration ); //auto prod3_config = testing::filter_fields( config, producer_parameters_example( 3 ) ); //REQUIRE_EQUAL_OBJECTS(prod3_config, config); From f4bdd61d2734563bf36dd47e8cc156812fc33e8a Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Mon, 14 May 2018 11:47:08 -0400 Subject: [PATCH 10/27] gelf_appender now owns its mutex #3035 --- libraries/fc/src/log/gelf_appender.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/libraries/fc/src/log/gelf_appender.cpp b/libraries/fc/src/log/gelf_appender.cpp index d5274f80da4..78c9e5bcd7f 100644 --- a/libraries/fc/src/log/gelf_appender.cpp +++ b/libraries/fc/src/log/gelf_appender.cpp @@ -34,6 +34,7 @@ namespace fc config cfg; optional gelf_endpoint; udp_socket gelf_socket; + boost::mutex gelf_log_mutex; impl(const config& c) : cfg(c) @@ -100,14 +101,6 @@ namespace fc gelf_appender::~gelf_appender() {} - boost::mutex& gelf_log_mutex() { - //this mutex should live longer than any other static variables - //which may want to write logs from destructor (for example, nodeos`appbase::application) - //so, make it live forever (it's a memory leak, but memory usage doesn't grow over time) - static boost::mutex* m_ptr = new boost::mutex; - return *m_ptr; - } - void gelf_appender::log(const log_message& message) { if (!my->gelf_endpoint) @@ -171,7 +164,7 @@ namespace fc gelf_message_as_string[1] = (char)0x9c; assert(gelf_message_as_string[1] == (char)0x9c); - std::unique_lock lock(gelf_log_mutex()); + std::unique_lock lock(my->gelf_log_mutex); // packets are sent by UDP, and they tend to disappear if they // get too large. It's hard to find any solid numbers on how From 21edbc36ee34e2494864f6d15b67f873112a0522 Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Mon, 14 May 2018 12:57:45 -0400 Subject: [PATCH 11/27] console_appender now owns its mutex #3035 --- libraries/fc/src/log/console_appender.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/libraries/fc/src/log/console_appender.cpp b/libraries/fc/src/log/console_appender.cpp index fa3c45a047a..e583fb38f45 100644 --- a/libraries/fc/src/log/console_appender.cpp +++ b/libraries/fc/src/log/console_appender.cpp @@ -20,6 +20,7 @@ namespace fc { class console_appender::impl { public: config cfg; + boost::mutex log_mutex; color::type lc[log_level::off+1]; #ifdef WIN32 HANDLE console_handle; @@ -82,14 +83,6 @@ namespace fc { } } - boost::mutex& log_mutex() { - //this mutex should live longer than any other static variables - //which may want to write logs from destructor (for example, nodeos`appbase::application) - //so, make it live forever (it's a memory leak, but memory usage doesn't grow over time) - static boost::mutex* m_ptr = new boost::mutex; - return *m_ptr; - } - void console_appender::log( const log_message& m ) { //fc::string message = fc::format_string( m.get_format(), m.get_data() ); //fc::variant lmsg(m); @@ -122,7 +115,7 @@ namespace fc { fc::string message = fc::format_string( m.get_format(), m.get_data() ); line << message;//.c_str(); - std::unique_lock lock(log_mutex()); + std::unique_lock lock(my->log_mutex); print( line.str(), my->lc[m.get_context().get_log_level()] ); From c4721fd89116138ccb84ac2cf9082fd362be0628 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Mon, 14 May 2018 13:42:48 -0400 Subject: [PATCH 12/27] Fix div by 0 error #3015 in resource_limits --- libraries/chain/resource_limits.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/chain/resource_limits.cpp b/libraries/chain/resource_limits.cpp index 24b5c179800..c408a22ca40 100644 --- a/libraries/chain/resource_limits.cpp +++ b/libraries/chain/resource_limits.cpp @@ -426,7 +426,7 @@ int64_t resource_limits_manager::get_account_net_limit( const account_name& name int64_t net_weight; get_account_limits( name, unused, net_weight, unused ); - if( net_weight < 0 ) { + if( net_weight < 0 || state.total_net_weight == 0 ) { return -1; } @@ -465,6 +465,7 @@ account_resource_limit resource_limits_manager::get_account_net_limit_ex( const uint128_t user_weight = net_weight; uint128_t all_user_weight = state.total_net_weight; + auto max_user_use_in_window = (virtual_network_capacity_in_window * user_weight) / all_user_weight; auto net_used_in_window = (usage.net_usage.value_ex * window_size) / config::rate_limiting_precision; From 3deffcc2b2fe389fb9c58a8e4719dec6391b238a Mon Sep 17 00:00:00 2001 From: Todd Fleming Date: Mon, 14 May 2018 13:48:47 -0400 Subject: [PATCH 13/27] Darwin: fix brew handling --- scripts/eosio_build_darwin.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/eosio_build_darwin.sh b/scripts/eosio_build_darwin.sh index e4cba0fa92c..347562d8b47 100644 --- a/scripts/eosio_build_darwin.sh +++ b/scripts/eosio_build_darwin.sh @@ -78,6 +78,8 @@ then echo "Unable to install homebrew at this time. Exiting now." exit 1; + else + BREW=$( command -v brew ) fi break;; [Nn]* ) echo "User aborted homebrew installation. Exiting now."; @@ -151,13 +153,13 @@ exit 1; fi printf "\\tInstalling Dependencies.\\n" - if ! "${BREW}" install --force "${DEP}" + if ! "${BREW}" install --force ${DEP} then printf "\\tHomebrew exited with the above errors.\\n" printf "\\tExiting now.\\n\\n" exit 1; fi - if ! "${BREW}" unlink "{DEP}" && "${BREW}" link --force "${DEP}" + if ! "${BREW}" unlink {DEP} && "${BREW}" link --force ${DEP} then printf "\\tHomebrew exited with the above errors.\\n" printf "\\tExiting now.\\n\\n" From bee198ce734395a0f603d2c2d09b862526fbb440 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Mon, 14 May 2018 14:31:42 -0400 Subject: [PATCH 14/27] Fix #3026 - vote_info record is not required for all accounts --- plugins/chain_plugin/chain_plugin.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index 5ea59174f32..f5b5223a1ac 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -503,6 +503,7 @@ read_only::get_account_results read_only::get_account( const get_account_params& const auto& d = db.db(); const auto& rm = db.get_resource_limits_manager(); + rm.get_account_limits( result.account_name, result.ram_quota, result.net_weight, result.cpu_weight ); const auto& a = db.get_account(result.account_name); @@ -543,7 +544,7 @@ read_only::get_account_results read_only::get_account( const get_account_params& const auto* t_id = d.find(boost::make_tuple( config::system_account_name, params.account_name, N(userres) )); if (t_id != nullptr) { const auto &idx = d.get_index(); - auto it = idx.lower_bound(boost::make_tuple( t_id->id, params.account_name )); + auto it = idx.find(boost::make_tuple( t_id->id, params.account_name )); if ( it != idx.end() ) { vector data; copy_inline_row(*it, data); @@ -554,7 +555,7 @@ read_only::get_account_results read_only::get_account( const get_account_params& t_id = d.find(boost::make_tuple( config::system_account_name, params.account_name, N(delband) )); if (t_id != nullptr) { const auto &idx = d.get_index(); - auto it = idx.lower_bound(boost::make_tuple( t_id->id, params.account_name )); + auto it = idx.find(boost::make_tuple( t_id->id, params.account_name )); if ( it != idx.end() ) { vector data; copy_inline_row(*it, data); @@ -565,7 +566,7 @@ read_only::get_account_results read_only::get_account( const get_account_params& t_id = d.find(boost::make_tuple( config::system_account_name, config::system_account_name, N(voters) )); if (t_id != nullptr) { const auto &idx = d.get_index(); - auto it = idx.lower_bound(boost::make_tuple( t_id->id, params.account_name )); + auto it = idx.find(boost::make_tuple( t_id->id, params.account_name )); if ( it != idx.end() ) { vector data; copy_inline_row(*it, data); From f35c1373ccb23cf07e87f7ced1ce0e99f47642ee Mon Sep 17 00:00:00 2001 From: Bucky Kittinger Date: Mon, 14 May 2018 15:07:43 -0400 Subject: [PATCH 15/27] Fix for eos #2900 --- libraries/chain/apply_context.cpp | 14 +- libraries/chain/authorization_manager.cpp | 12 +- libraries/chain/controller.cpp | 2 +- .../include/eosio/chain/apply_context.hpp | 2 - .../include/eosio/chain/authority_checker.hpp | 8 +- .../eosio/chain/authorization_manager.hpp | 6 +- .../eosio/chain/transaction_context.hpp | 2 +- .../eosio/chain/wasm_eosio_injection.hpp | 277 +++++------------- .../eosio/chain/webassembly/common.hpp | 14 + libraries/chain/transaction_context.cpp | 4 +- libraries/chain/wasm_interface.cpp | 8 +- 11 files changed, 107 insertions(+), 242 deletions(-) diff --git a/libraries/chain/apply_context.cpp b/libraries/chain/apply_context.cpp index fdf7397a446..a116bf8266f 100644 --- a/libraries/chain/apply_context.cpp +++ b/libraries/chain/apply_context.cpp @@ -189,7 +189,7 @@ void apply_context::execute_inline( action&& a ) { {}, {{receiver, config::eosio_code_name}}, control.pending_block_time() - trx_context.published, - std::bind(&apply_context::checktime, this, std::placeholders::_1), + std::bind(&transaction_context::checktime, &this->trx_context), false ); @@ -248,7 +248,7 @@ void apply_context::schedule_deferred_transaction( const uint128_t& sender_id, a {}, {{receiver, config::eosio_code_name}}, delay, - std::bind(&apply_context::checktime, this, std::placeholders::_1), + std::bind(&transaction_context::checktime, &this->trx_context), false ); } @@ -283,7 +283,7 @@ void apply_context::schedule_deferred_transaction( const uint128_t& sender_id, a } trx_context.add_ram_usage( payer, (config::billable_size_v + trx_size) ); - checktime( trx_size * 4 ); /// 4 instructions per byte of packed generated trx (estimated) + trx_context.checktime(); } void apply_context::cancel_deferred_transaction( const uint128_t& sender_id, account_name sender ) { @@ -295,7 +295,7 @@ void apply_context::cancel_deferred_transaction( const uint128_t& sender_id, acc trx_context.add_ram_usage( gto->payer, -(config::billable_size_v + gto->packed_trx.size()) ); generated_transaction_idx.remove(*gto); - checktime( 100 ); + trx_context.checktime(); } const table_id_object* apply_context::find_table( name code, name scope, name table ) { @@ -338,13 +338,9 @@ void apply_context::reset_console() { _pending_console_output.setf( std::ios::scientific, std::ios::floatfield ); } -void apply_context::checktime(uint32_t instruction_count) { - trx_context.check_time(); -} - bytes apply_context::get_packed_transaction() { auto r = fc::raw::pack( static_cast(trx_context.trx) ); - checktime( r.size() ); + trx_context.checktime(); return r; } diff --git a/libraries/chain/authorization_manager.cpp b/libraries/chain/authorization_manager.cpp index 4dceb7658a1..b3839a1ff44 100644 --- a/libraries/chain/authorization_manager.cpp +++ b/libraries/chain/authorization_manager.cpp @@ -314,16 +314,16 @@ namespace eosio { namespace chain { return (itr->delay_until - itr->published); } - void noop_checktime( uint32_t ) {} + void noop_checktime() {} - std::function authorization_manager::_noop_checktime{std::bind(&noop_checktime, std::placeholders::_1)}; + std::function authorization_manager::_noop_checktime{&noop_checktime}; void authorization_manager::check_authorization( const vector& actions, const flat_set& provided_keys, const flat_set& provided_permissions, fc::microseconds provided_delay, - const std::function& _checktime, + const std::function& _checktime, bool allow_unused_keys )const { @@ -367,7 +367,7 @@ namespace eosio { namespace chain { for( const auto& declared_auth : act.authorization ) { - checktime( config::base_check_authorization_cpu_per_authorization ); + checktime(); if( !special_case ) { auto min_permission_name = lookup_minimum_permission(declared_auth.actor, act.account, act.name); @@ -396,7 +396,7 @@ namespace eosio { namespace chain { // The permission_levels are traversed in ascending order, which is: // ascending order of the actor name with ties broken by ascending order of the permission name. for( const auto& p : permissions_to_satisfy ) { - checktime( config::base_authority_checker_cpu_per_permission ); // TODO: this should eventually move into authority_checker instead + checktime(); // TODO: this should eventually move into authority_checker instead EOS_ASSERT( checker.satisfied( p.first, p.second ), unsatisfied_authorization, "transaction declares authority '${auth}', " "but does not have signatures for it under a provided delay of ${provided_delay} ms", @@ -419,7 +419,7 @@ namespace eosio { namespace chain { const flat_set& provided_keys, const flat_set& provided_permissions, fc::microseconds provided_delay, - const std::function& _checktime, + const std::function& _checktime, bool allow_unused_keys )const { diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index 6eb89b52c78..4d568961359 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -600,7 +600,7 @@ struct controller_impl { trx->recover_keys(), {}, trx_context.delay, - [](uint32_t){} + [](){} /*std::bind(&transaction_context::add_cpu_usage_and_check_time, &trx_context, std::placeholders::_1)*/, false diff --git a/libraries/chain/include/eosio/chain/apply_context.hpp b/libraries/chain/include/eosio/chain/apply_context.hpp index 8c7a186fe66..65f89e61ce9 100644 --- a/libraries/chain/include/eosio/chain/apply_context.hpp +++ b/libraries/chain/include/eosio/chain/apply_context.hpp @@ -568,8 +568,6 @@ class apply_context { vector get_active_producers() const; bytes get_packed_transaction(); - void checktime(uint32_t instruction_count); - uint64_t next_global_sequence(); uint64_t next_recv_sequence( account_name receiver ); uint64_t next_auth_sequence( account_name actor ); diff --git a/libraries/chain/include/eosio/chain/authority_checker.hpp b/libraries/chain/include/eosio/chain/authority_checker.hpp index 3076c8ad2d6..460c9d5dc59 100644 --- a/libraries/chain/include/eosio/chain/authority_checker.hpp +++ b/libraries/chain/include/eosio/chain/authority_checker.hpp @@ -62,7 +62,7 @@ namespace detail { class authority_checker { private: PermissionToAuthorityFunc permission_to_authority; - const std::function& checktime; + const std::function& checktime; vector provided_keys; // Making this a flat_set causes runtime problems with utilities::filter_data_by_marker for some reason. TODO: Figure out why. flat_set provided_permissions; vector _used_keys; @@ -75,7 +75,7 @@ namespace detail { const flat_set& provided_keys, const flat_set& provided_permissions, fc::microseconds provided_delay, - const std::function& checktime + const std::function& checktime ) :permission_to_authority(permission_to_authority) ,checktime( checktime ) @@ -277,10 +277,10 @@ namespace detail { const flat_set& provided_keys, const flat_set& provided_permissions = flat_set(), fc::microseconds provided_delay = fc::microseconds(0), - const std::function& _checktime = std::function() + const std::function& _checktime = std::function() ) { - auto noop_checktime = []( uint32_t ) {}; + auto noop_checktime = []() {}; const auto& checktime = ( static_cast(_checktime) ? _checktime : noop_checktime ); return authority_checker< PermissionToAuthorityFunc>( std::forward(pta), recursion_depth_limit, diff --git a/libraries/chain/include/eosio/chain/authorization_manager.hpp b/libraries/chain/include/eosio/chain/authorization_manager.hpp index ef87af18d36..e244475b996 100644 --- a/libraries/chain/include/eosio/chain/authorization_manager.hpp +++ b/libraries/chain/include/eosio/chain/authorization_manager.hpp @@ -80,7 +80,7 @@ namespace eosio { namespace chain { const flat_set& provided_keys, const flat_set& provided_permissions = flat_set(), fc::microseconds provided_delay = fc::microseconds(0), - const std::function& checktime = std::function(), + const std::function& checktime = std::function(), bool allow_unused_keys = false )const; @@ -102,7 +102,7 @@ namespace eosio { namespace chain { const flat_set& provided_keys, const flat_set& provided_permissions = flat_set(), fc::microseconds provided_delay = fc::microseconds(0), - const std::function& checktime = std::function(), + const std::function& checktime = std::function(), bool allow_unused_keys = false )const; @@ -112,7 +112,7 @@ namespace eosio { namespace chain { )const; - static std::function _noop_checktime; + static std::function _noop_checktime; private: const controller& _control; diff --git a/libraries/chain/include/eosio/chain/transaction_context.hpp b/libraries/chain/include/eosio/chain/transaction_context.hpp index 3c49ae73d8b..a4200246fb3 100644 --- a/libraries/chain/include/eosio/chain/transaction_context.hpp +++ b/libraries/chain/include/eosio/chain/transaction_context.hpp @@ -30,7 +30,7 @@ namespace eosio { namespace chain { inline void add_net_usage( uint64_t u ) { net_usage += u; check_net_usage(); } void check_net_usage()const; - void check_time()const; + void checktime()const; void add_ram_usage( account_name account, int64_t ram_delta ); diff --git a/libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp b/libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp index ed7df9b0325..d9f09b61719 100644 --- a/libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp +++ b/libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp @@ -246,11 +246,8 @@ namespace eosio { namespace chain { namespace wasm_injections { static void accept( wasm_ops::instr* inst, wasm_ops::visitor_arg& arg ) { auto mapped_index = injector_utils::injected_index_mapping.find(chktm_idx); - wasm_ops::op_types<>::i32_const_t cnt; - cnt.field = checktime_block_type::bcnt_tables.front()[checktime_block_type::orderings.front()[idx++]]; wasm_ops::op_types<>::call_t chktm; chktm.field = mapped_index->second; - cnt.pack(arg.new_code); chktm.pack(arg.new_code); } @@ -683,202 +680,79 @@ namespace eosio { namespace chain { namespace wasm_injections { }; struct pre_op_injectors : wasm_ops::op_types { - using block_t = wasm_ops::block ; - using loop_t = wasm_ops::loop ; - using if__t = wasm_ops::if_ ; - using else__t = wasm_ops::else_ ; + using call_t = wasm_ops::call ; + using call_indirect_t = wasm_ops::call_indirect ; - using end_t = wasm_ops::end ; - using unreachable_t = wasm_ops::unreachable ; - using br_t = wasm_ops::br ; - using br_if_t = wasm_ops::br_if ; - using br_table_t = wasm_ops::br_table ; - using return__t = wasm_ops::return_ ; - using call_t = wasm_ops::call ; - using call_indirect_t = wasm_ops::call_indirect ; - using drop_t = wasm_ops::drop ; - using select_t = wasm_ops::select ; - - using get_local_t = wasm_ops::get_local ; - using set_local_t = wasm_ops::set_local ; - using tee_local_t = wasm_ops::tee_local ; - using get_global_t = wasm_ops::get_global ; - using set_global_t = wasm_ops::set_global ; - - using nop_t = wasm_ops::nop ; - using i32_load_t = wasm_ops::i32_load ; - using i64_load_t = wasm_ops::i64_load ; - using f32_load_t = wasm_ops::f32_load ; - using f64_load_t = wasm_ops::f64_load ; - using i32_load8_s_t = wasm_ops::i32_load8_s ; - using i32_load8_u_t = wasm_ops::i32_load8_u ; - using i32_load16_s_t = wasm_ops::i32_load16_s ; - using i32_load16_u_t = wasm_ops::i32_load16_u ; - using i64_load8_s_t = wasm_ops::i64_load8_s ; - using i64_load8_u_t = wasm_ops::i64_load8_u ; - using i64_load16_s_t = wasm_ops::i64_load16_s ; - using i64_load16_u_t = wasm_ops::i64_load16_u ; - using i64_load32_s_t = wasm_ops::i64_load32_s ; - using i64_load32_u_t = wasm_ops::i64_load32_u ; - using i32_store_t = wasm_ops::i32_store ; - using i64_store_t = wasm_ops::i64_store ; - using f32_store_t = wasm_ops::f32_store ; - using f64_store_t = wasm_ops::f64_store ; - using i32_store8_t = wasm_ops::i32_store8 ; - using i32_store16_t = wasm_ops::i32_store16 ; - using i64_store8_t = wasm_ops::i64_store8 ; - using i64_store16_t = wasm_ops::i64_store16 ; - using i64_store32_t = wasm_ops::i64_store32 ; - - using i32_const_t = wasm_ops::i32_const ; - using i64_const_t = wasm_ops::i64_const ; - using f32_const_t = wasm_ops::f32_const ; - using f64_const_t = wasm_ops::f64_const ; - - using i32_eqz_t = wasm_ops::i32_eqz ; - using i32_eq_t = wasm_ops::i32_eq ; - using i32_ne_t = wasm_ops::i32_ne ; - using i32_lt_s_t = wasm_ops::i32_lt_s ; - using i32_lt_u_t = wasm_ops::i32_lt_u ; - using i32_gt_s_t = wasm_ops::i32_gt_s ; - using i32_gt_u_t = wasm_ops::i32_gt_u ; - using i32_le_s_t = wasm_ops::i32_le_s ; - using i32_le_u_t = wasm_ops::i32_le_u ; - using i32_ge_s_t = wasm_ops::i32_ge_s ; - using i32_ge_u_t = wasm_ops::i32_ge_u ; - - using i32_clz_t = wasm_ops::i32_clz ; - using i32_ctz_t = wasm_ops::i32_ctz ; - using i32_popcnt_t = wasm_ops::i32_popcnt ; - - using i32_add_t = wasm_ops::i32_add ; - using i32_sub_t = wasm_ops::i32_sub ; - using i32_mul_t = wasm_ops::i32_mul ; - using i32_div_s_t = wasm_ops::i32_div_s ; - using i32_div_u_t = wasm_ops::i32_div_u ; - using i32_rem_s_t = wasm_ops::i32_rem_s ; - using i32_rem_u_t = wasm_ops::i32_rem_u ; - using i32_and_t = wasm_ops::i32_and ; - using i32_or_t = wasm_ops::i32_or ; - using i32_xor_t = wasm_ops::i32_xor ; - using i32_shl_t = wasm_ops::i32_shl ; - using i32_shr_s_t = wasm_ops::i32_shr_s ; - using i32_shr_u_t = wasm_ops::i32_shr_u ; - using i32_rotl_t = wasm_ops::i32_rotl ; - using i32_rotr_t = wasm_ops::i32_rotr ; - - using i64_eqz_t = wasm_ops::i64_eqz ; - using i64_eq_t = wasm_ops::i64_eq ; - using i64_ne_t = wasm_ops::i64_ne ; - using i64_lt_s_t = wasm_ops::i64_lt_s ; - using i64_lt_u_t = wasm_ops::i64_lt_u ; - using i64_gt_s_t = wasm_ops::i64_gt_s ; - using i64_gt_u_t = wasm_ops::i64_gt_u ; - using i64_le_s_t = wasm_ops::i64_le_s ; - using i64_le_u_t = wasm_ops::i64_le_u ; - using i64_ge_s_t = wasm_ops::i64_ge_s ; - using i64_ge_u_t = wasm_ops::i64_ge_u ; - - using i64_clz_t = wasm_ops::i64_clz ; - using i64_ctz_t = wasm_ops::i64_ctz ; - using i64_popcnt_t = wasm_ops::i64_popcnt ; - - using i64_add_t = wasm_ops::i64_add ; - using i64_sub_t = wasm_ops::i64_sub ; - using i64_mul_t = wasm_ops::i64_mul ; - using i64_div_s_t = wasm_ops::i64_div_s ; - using i64_div_u_t = wasm_ops::i64_div_u ; - using i64_rem_s_t = wasm_ops::i64_rem_s ; - using i64_rem_u_t = wasm_ops::i64_rem_u ; - using i64_and_t = wasm_ops::i64_and ; - using i64_or_t = wasm_ops::i64_or ; - using i64_xor_t = wasm_ops::i64_xor ; - using i64_shl_t = wasm_ops::i64_shl ; - using i64_shr_s_t = wasm_ops::i64_shr_s ; - using i64_shr_u_t = wasm_ops::i64_shr_u ; - using i64_rotl_t = wasm_ops::i64_rotl ; - using i64_rotr_t = wasm_ops::i64_rotr ; - // float binops - using f32_add_t = wasm_ops::f32_add >; - using f32_sub_t = wasm_ops::f32_sub >; - using f32_div_t = wasm_ops::f32_div >; - using f32_mul_t = wasm_ops::f32_mul >; - using f32_min_t = wasm_ops::f32_min >; - using f32_max_t = wasm_ops::f32_max >; - using f32_copysign_t = wasm_ops::f32_copysign >; + using f32_add_t = wasm_ops::f32_add >; + using f32_sub_t = wasm_ops::f32_sub >; + using f32_div_t = wasm_ops::f32_div >; + using f32_mul_t = wasm_ops::f32_mul >; + using f32_min_t = wasm_ops::f32_min >; + using f32_max_t = wasm_ops::f32_max >; + using f32_copysign_t = wasm_ops::f32_copysign >; // float unops - using f32_abs_t = wasm_ops::f32_abs >; - using f32_neg_t = wasm_ops::f32_neg >; - using f32_sqrt_t = wasm_ops::f32_sqrt >; - using f32_floor_t = wasm_ops::f32_floor >; - using f32_ceil_t = wasm_ops::f32_ceil >; - using f32_trunc_t = wasm_ops::f32_trunc >; - using f32_nearest_t = wasm_ops::f32_nearest >; + using f32_abs_t = wasm_ops::f32_abs >; + using f32_neg_t = wasm_ops::f32_neg >; + using f32_sqrt_t = wasm_ops::f32_sqrt >; + using f32_floor_t = wasm_ops::f32_floor >; + using f32_ceil_t = wasm_ops::f32_ceil >; + using f32_trunc_t = wasm_ops::f32_trunc >; + using f32_nearest_t = wasm_ops::f32_nearest >; // float relops - using f32_eq_t = wasm_ops::f32_eq >; - using f32_ne_t = wasm_ops::f32_ne >; - using f32_lt_t = wasm_ops::f32_lt >; - using f32_le_t = wasm_ops::f32_le >; - using f32_gt_t = wasm_ops::f32_gt >; - using f32_ge_t = wasm_ops::f32_ge >; + using f32_eq_t = wasm_ops::f32_eq >; + using f32_ne_t = wasm_ops::f32_ne >; + using f32_lt_t = wasm_ops::f32_lt >; + using f32_le_t = wasm_ops::f32_le >; + using f32_gt_t = wasm_ops::f32_gt >; + using f32_ge_t = wasm_ops::f32_ge >; // float binops - using f64_add_t = wasm_ops::f64_add >; - using f64_sub_t = wasm_ops::f64_sub >; - using f64_div_t = wasm_ops::f64_div >; - using f64_mul_t = wasm_ops::f64_mul >; - using f64_min_t = wasm_ops::f64_min >; - using f64_max_t = wasm_ops::f64_max >; - using f64_copysign_t = wasm_ops::f64_copysign >; + using f64_add_t = wasm_ops::f64_add >; + using f64_sub_t = wasm_ops::f64_sub >; + using f64_div_t = wasm_ops::f64_div >; + using f64_mul_t = wasm_ops::f64_mul >; + using f64_min_t = wasm_ops::f64_min >; + using f64_max_t = wasm_ops::f64_max >; + using f64_copysign_t = wasm_ops::f64_copysign >; // float unops - using f64_abs_t = wasm_ops::f64_abs >; - using f64_neg_t = wasm_ops::f64_neg >; - using f64_sqrt_t = wasm_ops::f64_sqrt >; - using f64_floor_t = wasm_ops::f64_floor >; - using f64_ceil_t = wasm_ops::f64_ceil >; - using f64_trunc_t = wasm_ops::f64_trunc >; - using f64_nearest_t = wasm_ops::f64_nearest >; + using f64_abs_t = wasm_ops::f64_abs >; + using f64_neg_t = wasm_ops::f64_neg >; + using f64_sqrt_t = wasm_ops::f64_sqrt >; + using f64_floor_t = wasm_ops::f64_floor >; + using f64_ceil_t = wasm_ops::f64_ceil >; + using f64_trunc_t = wasm_ops::f64_trunc >; + using f64_nearest_t = wasm_ops::f64_nearest >; // float relops - using f64_eq_t = wasm_ops::f64_eq >; - using f64_ne_t = wasm_ops::f64_ne >; - using f64_lt_t = wasm_ops::f64_lt >; - using f64_le_t = wasm_ops::f64_le >; - using f64_gt_t = wasm_ops::f64_gt >; - using f64_ge_t = wasm_ops::f64_ge >; + using f64_eq_t = wasm_ops::f64_eq >; + using f64_ne_t = wasm_ops::f64_ne >; + using f64_lt_t = wasm_ops::f64_lt >; + using f64_le_t = wasm_ops::f64_le >; + using f64_gt_t = wasm_ops::f64_gt >; + using f64_ge_t = wasm_ops::f64_ge >; - using f64_promote_f32_t = wasm_ops::f64_promote_f32 ; - using f32_demote_f64_t = wasm_ops::f32_demote_f64 ; + using f64_promote_f32_t = wasm_ops::f64_promote_f32 ; + using f32_demote_f64_t = wasm_ops::f32_demote_f64 ; - using i32_trunc_s_f32_t = wasm_ops::i32_trunc_s_f32 >; - using i32_trunc_u_f32_t = wasm_ops::i32_trunc_u_f32 >; - using i32_trunc_s_f64_t = wasm_ops::i32_trunc_s_f64 >; - using i32_trunc_u_f64_t = wasm_ops::i32_trunc_u_f64 >; - using i64_trunc_s_f32_t = wasm_ops::i64_trunc_s_f32 >; - using i64_trunc_u_f32_t = wasm_ops::i64_trunc_u_f32 >; - using i64_trunc_s_f64_t = wasm_ops::i64_trunc_s_f64 >; - using i64_trunc_u_f64_t = wasm_ops::i64_trunc_u_f64 >; + using i32_trunc_s_f32_t = wasm_ops::i32_trunc_s_f32 >; + using i32_trunc_u_f32_t = wasm_ops::i32_trunc_u_f32 >; + using i32_trunc_s_f64_t = wasm_ops::i32_trunc_s_f64 >; + using i32_trunc_u_f64_t = wasm_ops::i32_trunc_u_f64 >; + using i64_trunc_s_f32_t = wasm_ops::i64_trunc_s_f32 >; + using i64_trunc_u_f32_t = wasm_ops::i64_trunc_u_f32 >; + using i64_trunc_s_f64_t = wasm_ops::i64_trunc_s_f64 >; + using i64_trunc_u_f64_t = wasm_ops::i64_trunc_u_f64 >; - using f32_convert_s_i32 = wasm_ops::f32_convert_s_i32 >; - using f32_convert_s_i64 = wasm_ops::f32_convert_s_i64 >; - using f32_convert_u_i32 = wasm_ops::f32_convert_u_i32 >; - using f32_convert_u_i64 = wasm_ops::f32_convert_u_i64 >; - using f64_convert_s_i32 = wasm_ops::f64_convert_s_i32 >; - using f64_convert_s_i64 = wasm_ops::f64_convert_s_i64 >; - using f64_convert_u_i32 = wasm_ops::f64_convert_u_i32 >; - using f64_convert_u_i64 = wasm_ops::f64_convert_u_i64 >; - - using i32_wrap_i64_t = wasm_ops::i32_wrap_i64 ; - using i64_extend_s_i32_t = wasm_ops::i64_extend_s_i32 ; - using i64_extend_u_i32_t = wasm_ops::i64_extend_u_i32 ; - - using i32_reinterpret_f32_t = wasm_ops::i32_reinterpret_f32 ; - using f32_reinterpret_i32_t = wasm_ops::f32_reinterpret_i32 ; - using i64_reinterpret_f64_t = wasm_ops::i64_reinterpret_f64 ; - using f64_reinterpret_i64_t = wasm_ops::f64_reinterpret_i64 ; - + using f32_convert_s_i32 = wasm_ops::f32_convert_s_i32 >; + using f32_convert_s_i64 = wasm_ops::f32_convert_s_i64 >; + using f32_convert_u_i32 = wasm_ops::f32_convert_u_i32 >; + using f32_convert_u_i64 = wasm_ops::f32_convert_u_i64 >; + using f64_convert_s_i32 = wasm_ops::f64_convert_s_i32 >; + using f64_convert_s_i64 = wasm_ops::f64_convert_s_i64 >; + using f64_convert_u_i32 = wasm_ops::f64_convert_u_i32 >; + using f64_convert_u_i64 = wasm_ops::f64_convert_u_i64 >; }; // pre_op_injectors @@ -911,26 +785,19 @@ namespace eosio { namespace chain { namespace wasm_injections { _module_injectors.init(); // initialize static fields of injectors injector_utils::init( mod ); - instruction_counter::init(); checktime_injection::init(); - checktime_block_type::init(); - checktime_function_end::init(); call_depth_check::init(); } void inject() { _module_injectors.inject( *_module ); // inject checktime first - injector_utils::add_import( *_module, u8"checktime", checktime_injection::chktm_idx ); + injector_utils::add_import( *_module, u8"checktime", checktime_injection::chktm_idx ); for ( auto& fd : _module->functions.defs ) { wasm_ops::EOSIO_OperatorDecoderStream pre_decoder(fd.code); wasm_ops::instruction_stream pre_code(fd.code.size()*2); - checktime_block_type::orderings.emplace(); - checktime_block_type::bcnt_tables.emplace(); - instruction_counter::icnt = 0; - instruction_counter::tcnt = 0; - instruction_counter::bcnt = 0; + while ( pre_decoder ) { auto op = pre_decoder.decodeOp(); if (op->is_post()) { @@ -943,24 +810,18 @@ namespace eosio { namespace chain { namespace wasm_injections { op->pack(&pre_code); } } - instruction_counter::fcnts.push(instruction_counter::tcnt - instruction_counter::bcnt); fd.code = pre_code.get(); } for ( auto& fd : _module->functions.defs ) { wasm_ops::EOSIO_OperatorDecoderStream post_decoder(fd.code); wasm_ops::instruction_stream post_code(fd.code.size()*2); - bool is_start = true; + + wasm_ops::op_types<>::call_t chktm; + chktm.field = injector_utils::injected_index_mapping.find(checktime_injection::chktm_idx)->second; + chktm.pack(&post_code); + while ( post_decoder ) { auto op = post_decoder.decodeOp(); - if ( is_start ) { - is_start = false; - wasm_ops::op_types<>::i32_const_t cnt; - cnt.field = instruction_counter::fcnts.front(); - wasm_ops::op_types<>::call_t chktm; - chktm.field = injector_utils::injected_index_mapping.find(checktime_injection::chktm_idx)->second; - cnt.pack(&post_code); - chktm.pack(&post_code); - } if (op->is_post()) { op->pack(&post_code); op->visit( { _module, &post_code, &fd, post_decoder.index() } ); @@ -972,10 +833,6 @@ namespace eosio { namespace chain { namespace wasm_injections { } } fd.code = post_code.get(); - instruction_counter::fcnts.pop(); - checktime_block_type::orderings.pop(); - checktime_block_type::bcnt_tables.pop(); - checktime_injection::idx = 0; } } private: diff --git a/libraries/chain/include/eosio/chain/webassembly/common.hpp b/libraries/chain/include/eosio/chain/webassembly/common.hpp index 84211d9b638..723bd3039b6 100644 --- a/libraries/chain/include/eosio/chain/webassembly/common.hpp +++ b/libraries/chain/include/eosio/chain/webassembly/common.hpp @@ -10,6 +10,7 @@ using namespace fc; namespace eosio { namespace chain { class apply_context; + class transaction_context; template struct class_from_wasm { @@ -22,6 +23,19 @@ namespace eosio { namespace chain { return T(ctx); } }; + + template<> + struct class_from_wasm { + /** + * by default this is just constructing an object + * @param wasm - the wasm_interface to use + * @return + */ + template + static auto &value(ApplyCtx& ctx) { + return ctx.trx_context; + } + }; template<> struct class_from_wasm { diff --git a/libraries/chain/transaction_context.cpp b/libraries/chain/transaction_context.cpp index 2f2b8d3eea7..67c50660663 100644 --- a/libraries/chain/transaction_context.cpp +++ b/libraries/chain/transaction_context.cpp @@ -124,7 +124,7 @@ namespace eosio { namespace chain { if( billed_cpu_time_us > 0 ) deadline = original_deadline; // Only change deadline if billed_cpu_time_us is not set - check_time(); // Fail early if deadline has already been exceeded + checktime(); // Fail early if deadline has already been exceeded is_initialized = true; } @@ -275,7 +275,7 @@ namespace eosio { namespace chain { } } - void transaction_context::check_time()const { + void transaction_context::checktime()const { auto now = fc::time_point::now(); if( BOOST_UNLIKELY( now > deadline ) ) { if( billed_cpu_time_us > 0 || deadline_exception_code == deadline_exception::code_value ) { diff --git a/libraries/chain/wasm_interface.cpp b/libraries/chain/wasm_interface.cpp index 63eb7c681be..632d7a55aa7 100644 --- a/libraries/chain/wasm_interface.cpp +++ b/libraries/chain/wasm_interface.cpp @@ -782,7 +782,7 @@ class permission_api : public context_aware_api { provided_keys, provided_permissions, fc::seconds(trx.delay_sec), - std::bind(&apply_context::checktime, &context, std::placeholders::_1), + std::bind(&transaction_context::checktime, &context.trx_context), false ); return true; @@ -814,7 +814,7 @@ class permission_api : public context_aware_api { provided_keys, provided_permissions, fc::microseconds(delay_us), - std::bind(&apply_context::checktime, &context, std::placeholders::_1), + std::bind(&transaction_context::checktime, &context.trx_context), false ); return true; @@ -1630,8 +1630,8 @@ REGISTER_INTRINSICS(privileged_api, (set_privileged, void(int64_t, int) ) ); -REGISTER_INJECTED_INTRINSICS(apply_context, - (checktime, void(int)) +REGISTER_INJECTED_INTRINSICS(transaction_context, + (checktime, void()) ); REGISTER_INTRINSICS(producer_api, From f5461c8bb8bbf8f1d1c88b8b05a04102542cb7e6 Mon Sep 17 00:00:00 2001 From: Bill Hamilton Date: Mon, 14 May 2018 19:12:40 +0000 Subject: [PATCH 16/27] amazon: fixed globbing issue in yum dependency list --- scripts/eosio_build_amazon.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/eosio_build_amazon.sh b/scripts/eosio_build_amazon.sh index 3f597f649b7..f280d693eba 100644 --- a/scripts/eosio_build_amazon.sh +++ b/scripts/eosio_build_amazon.sh @@ -79,13 +79,13 @@ if [ "${COUNT}" -gt 1 ]; then printf "\\n\\tThe following dependencies are required to install EOSIO.\\n" - printf "\\n\\t%s\\n\\n" "${DISPLAY}" + printf "\\n\\t${DISPLAY}\\n\\n" printf "\\tDo you wish to install these dependencies?\\n" select yn in "Yes" "No"; do case $yn in [Yy]* ) printf "\\n\\n\\tInstalling dependencies.\\n\\n" - if ! sudo "${YUM}" -y install "${DEP}" + if ! sudo "${YUM}" -y install ${DEP} then printf "\\n\\tYUM dependency installation failed.\\n" printf "\\n\\tExiting now.\\n" From 934c1e855f9b40e0822294f7beec4ad555944a57 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 14 May 2018 14:15:09 -0500 Subject: [PATCH 17/27] Add transaction id to packed_transaction abi --- libraries/chain/include/eosio/chain/abi_serializer.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/chain/include/eosio/chain/abi_serializer.hpp b/libraries/chain/include/eosio/chain/abi_serializer.hpp index 926c33ba354..b590b4475e6 100644 --- a/libraries/chain/include/eosio/chain/abi_serializer.hpp +++ b/libraries/chain/include/eosio/chain/abi_serializer.hpp @@ -268,12 +268,14 @@ namespace impl { template static void add(mutable_variant_object &out, const char* name, const packed_transaction& ptrx, Resolver resolver) { mutable_variant_object mvo; + auto trx = ptrx.get_transaction(); + mvo("id", trx.id()); mvo("signatures", ptrx.signatures); mvo("compression", ptrx.compression); mvo("packed_context_free_data", ptrx.packed_context_free_data); mvo("context_free_data", ptrx.get_context_free_data()); mvo("packed_trx", ptrx.packed_trx); - add(mvo, "transaction", ptrx.get_transaction(), resolver); + add(mvo, "transaction", trx, resolver); out(name, std::move(mvo)); } From 254b86c191c44f4ded6290a4bfa4ccc2cb32326b Mon Sep 17 00:00:00 2001 From: Eric Iles Date: Mon, 14 May 2018 15:38:07 -0400 Subject: [PATCH 18/27] Docker fixes, and use Ubuntu 18.04 --- Docker/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index da52f0700f5..f8bb8ee3092 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,14 +1,14 @@ FROM eosio/builder as builder ARG branch=master -RUN git clone -b $branch --depth 1 https://github.com/EOSIO/eos.git --recursive \ +RUN git clone -b $branch https://github.com/EOSIO/eos.git --recursive \ && cd eos && echo "$branch:$(git rev-parse HEAD)" > /etc/eosio-version \ && cmake -H. -B"/tmp/build" -GNinja -DCMAKE_BUILD_TYPE=Release -DWASM_ROOT=/opt/wasm -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_C_COMPILER=clang -DCMAKE_INSTALL_PREFIX=/tmp/build -DSecp256k1_ROOT_DIR=/usr/local -DBUILD_MONGO_DB_PLUGIN=true \ && cmake --build /tmp/build --target install -FROM ubuntu:16.04 +FROM ubuntu:18.04 RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install openssl && rm -rf /var/lib/apt/lists/* COPY --from=builder /usr/local/lib/* /usr/local/lib/ @@ -16,7 +16,7 @@ COPY --from=builder /tmp/build/bin /opt/eosio/bin COPY --from=builder /tmp/build/contracts /contracts COPY --from=builder /eos/Docker/config.ini / COPY --from=builder /etc/eosio-version /etc -COPY nodeosd.sh /opt/eosio/bin/nodeosd.sh +COPY --from=builder /eos/Docker/nodeosd.sh /opt/eosio/bin/nodeosd.sh ENV EOSIO_ROOT=/opt/eosio RUN chmod +x /opt/eosio/bin/nodeosd.sh ENV LD_LIBRARY_PATH /usr/local/lib From 5a7d1fbd06202cc676b60d7670dab79a1f1dff1d Mon Sep 17 00:00:00 2001 From: Eric Iles Date: Mon, 14 May 2018 15:47:44 -0400 Subject: [PATCH 19/27] Increase timeout for coverage reports --- .buildkite/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/coverage.yml b/.buildkite/coverage.yml index 122fd0662a4..99c0e064c7a 100644 --- a/.buildkite/coverage.yml +++ b/.buildkite/coverage.yml @@ -26,4 +26,4 @@ steps: - WASM_ROOT=/root/opt/wasm - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/opt/wasm/bin - CI=true - timeout: 30 + timeout: 60 From 764812d5d79b3ec0b4c2567f3a7b255f61172a88 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Mon, 14 May 2018 15:51:31 -0400 Subject: [PATCH 20/27] Fix #3047 - static variant with neg which causes crash --- libraries/fc/include/fc/static_variant.hpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libraries/fc/include/fc/static_variant.hpp b/libraries/fc/include/fc/static_variant.hpp index e8f4b91fcd5..19a423949da 100644 --- a/libraries/fc/include/fc/static_variant.hpp +++ b/libraries/fc/include/fc/static_variant.hpp @@ -339,12 +339,17 @@ class static_variant { return impl::storage_ops<0, Types...>::apply(_tag, storage, v); } - static int count() { return impl::type_info::count; } - void set_which( int w ) { - FC_ASSERT( w < count() ); + static uint32_t count() { return impl::type_info::count; } + void set_which( uint32_t w ) { + FC_ASSERT( w < count() ); this->~static_variant(); - _tag = w; - impl::storage_ops<0, Types...>::con(_tag, storage); + try { + _tag = w; + impl::storage_ops<0, Types...>::con(_tag, storage); + } catch ( ... ) { + _tag = 0; + impl::storage_ops<0, Types...>::con(_tag, storage); + } } int which() const {return _tag;} From cb501ad0bbca7fb6d64dd891549127d7787300f3 Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Mon, 14 May 2018 16:52:14 -0400 Subject: [PATCH 21/27] update cleos to get account response format (seems like it changed recently), unit-test for delegatebw with transfer, avoid devision by 0 in resource_limits.cpp #3001 --- libraries/chain/resource_limits.cpp | 8 ++-- programs/cleos/main.cpp | 8 ++-- unittests/eosio.system_tests.cpp | 60 +++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 8 deletions(-) diff --git a/libraries/chain/resource_limits.cpp b/libraries/chain/resource_limits.cpp index c408a22ca40..2030e72c3b0 100644 --- a/libraries/chain/resource_limits.cpp +++ b/libraries/chain/resource_limits.cpp @@ -345,7 +345,7 @@ int64_t resource_limits_manager::get_account_cpu_limit( const account_name& name uint128_t user_weight = cpu_weight; uint128_t all_user_weight = state.total_cpu_weight; - auto max_user_use_in_window = (virtual_cpu_capacity_in_window * user_weight) / all_user_weight; + auto max_user_use_in_window = all_user_weight > 0 ? (uint128_t(virtual_cpu_capacity_in_window) * user_weight) / all_user_weight : uint128_t(virtual_cpu_capacity_in_window); auto cpu_used_in_window = (usage.cpu_usage.value_ex * window_size) / config::rate_limiting_precision; if( max_user_use_in_window <= cpu_used_in_window ) return 0; @@ -403,7 +403,7 @@ account_resource_limit resource_limits_manager::get_account_cpu_limit_ex( const wdump((cpu_weight)); - auto max_user_use_in_window = (uint128_t(virtual_cpu_capacity_in_window) * user_weight) / all_user_weight; + auto max_user_use_in_window = all_user_weight > 0 ? (uint128_t(virtual_cpu_capacity_in_window) * user_weight) / all_user_weight : uint128_t(virtual_cpu_capacity_in_window); auto cpu_used_in_window = (usage.cpu_usage.value_ex * window_size) / config::rate_limiting_precision; if( max_user_use_in_window <= cpu_used_in_window ) @@ -436,7 +436,7 @@ int64_t resource_limits_manager::get_account_net_limit( const account_name& name uint128_t user_weight = net_weight; uint128_t all_user_weight = state.total_net_weight; - auto max_user_use_in_window = (virtual_network_capacity_in_window * user_weight) / all_user_weight; + auto max_user_use_in_window = all_user_weight > 0 ? (virtual_network_capacity_in_window * user_weight) / all_user_weight : virtual_network_capacity_in_window; auto net_used_in_window = (usage.net_usage.value_ex * window_size) / config::rate_limiting_precision; if( max_user_use_in_window <= net_used_in_window ) return 0; @@ -466,7 +466,7 @@ account_resource_limit resource_limits_manager::get_account_net_limit_ex( const uint128_t all_user_weight = state.total_net_weight; - auto max_user_use_in_window = (virtual_network_capacity_in_window * user_weight) / all_user_weight; + auto max_user_use_in_window = all_user_weight > 0 ? (virtual_network_capacity_in_window * user_weight) / all_user_weight : virtual_network_capacity_in_window; auto net_used_in_window = (usage.net_usage.value_ex * window_size) / config::rate_limiting_precision; if( max_user_use_in_window <= net_used_in_window ) diff --git a/programs/cleos/main.cpp b/programs/cleos/main.cpp index 60014805c46..edfc7451db1 100644 --- a/programs/cleos/main.cpp +++ b/programs/cleos/main.cpp @@ -833,7 +833,7 @@ struct create_account_subcommand { createAccount->add_option("--buy-ram-EOS", buy_ram_eos, (localized("The amount of RAM bytes to purchase for the new account in EOS"))); createAccount->add_flag("--transfer", transfer, - (localized("Transfer?"))); + (localized("Transfer voting power and right to unstake EOS to receiver"))); } add_standard_transaction_options(createAccount); @@ -988,7 +988,7 @@ struct delegate_bandwidth_subcommand { delegate_bandwidth->add_option("receiver", receiver_str, localized("The account to receive the delegated bandwidth"))->required(); delegate_bandwidth->add_option("stake_net_quantity", stake_net_amount, localized("The amount of EOS to stake for network bandwidth"))->required(); delegate_bandwidth->add_option("stake_cpu_quantity", stake_cpu_amount, localized("The amount of EOS to stake for CPU bandwidth"))->required(); - delegate_bandwidth->add_flag("--transfer", transfer, localized("specify to stake in name of receiver rather than in name of from"))->required(); + delegate_bandwidth->add_flag("--transfer", transfer, localized("Transfer voting power and right to unstake EOS to receiver")); add_standard_transaction_options(delegate_bandwidth); delegate_bandwidth->set_callback([this] { @@ -1223,7 +1223,7 @@ void get_account( const string& accountName, bool json_format ) { std::cout << "net bandwidth: (averaged over 3 days)" << std::endl; if ( res.total_resources.is_object() ) { - asset net_own( res.delegated_bandwidth.is_object() ? stoll( res.delegated_bandwidth.get_object()["net_weight"].as_string() ) : 0 ); + asset net_own = res.delegated_bandwidth.is_object() ? asset::from_string( res.delegated_bandwidth.get_object()["net_weight"].as_string() ) : asset(0) ; auto net_others = to_asset(res.total_resources.get_object()["net_weight"].as_string()) - net_own; std::cout << indent << "staked:" << std::setw(20) << net_own << std::string(11, ' ') << "(total stake delegated from account to self)" << std::endl @@ -1269,7 +1269,7 @@ void get_account( const string& accountName, bool json_format ) { if ( res.total_resources.is_object() ) { - asset cpu_own( res.delegated_bandwidth.is_object() ? stoll( res.delegated_bandwidth.get_object()["cpu_weight"].as_string() ) : 0 ); + asset cpu_own = res.delegated_bandwidth.is_object() ? asset::from_string( res.delegated_bandwidth.get_object()["cpu_weight"].as_string() ) : asset(0) ; auto cpu_others = to_asset(res.total_resources.get_object()["cpu_weight"].as_string()) - cpu_own; std::cout << indent << "staked:" << std::setw(20) << cpu_own << std::string(11, ' ') << "(total stake delegated from account to self)" << std::endl diff --git a/unittests/eosio.system_tests.cpp b/unittests/eosio.system_tests.cpp index a600c56a180..2f9b4c9722c 100644 --- a/unittests/eosio.system_tests.cpp +++ b/unittests/eosio.system_tests.cpp @@ -238,6 +238,20 @@ class eosio_system_tester : public TESTER { return stake( acnt, acnt, net, cpu ); } + action_result stake_with_transfer( const account_name& from, const account_name& to, const string& net, const string& cpu ) { + return push_action( name(from), N(delegatebw), mvo() + ("from", from) + ("receiver", to) + ("stake_net_quantity", net) + ("stake_cpu_quantity", cpu) + ("transfer", true ) + ); + } + + action_result stake_with_transfer( const account_name& acnt, const string& net, const string& cpu ) { + return stake_with_transfer( acnt, acnt, net, cpu ); + } + action_result unstake( const account_name& from, const account_name& to, const string& net, const string& cpu ) { return push_action( name(from), N(undelegatebw), mvo() ("from", from) @@ -529,6 +543,52 @@ BOOST_FIXTURE_TEST_CASE( stake_unstake, eosio_system_tester ) try { BOOST_REQUIRE_EQUAL( asset::from_string("1000.0000 EOS"), get_balance( "alice1111111" ) ); } FC_LOG_AND_RETHROW() +BOOST_FIXTURE_TEST_CASE( stake_unstake_with_transfer, eosio_system_tester ) try { + //issue( "eosio", "1000.0000 EOS", config::system_account_name ); + BOOST_REQUIRE_EQUAL( asset::from_string("1000000000.0000 EOS"), get_balance( "eosio" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("0.0000 EOS"), get_balance( "alice1111111" ) ); + + //eosio stakes for alice with transfer flag + BOOST_REQUIRE_EQUAL( success(), stake_with_transfer( "eosio", "alice1111111", "200.0000 EOS", "100.0000 EOS" ) ); + + //check that alice has both bandwidth and voting power + auto total = get_total_stake("alice1111111"); + BOOST_REQUIRE_EQUAL( asset::from_string("210.0000 EOS"), total["net_weight"].as()); + BOOST_REQUIRE_EQUAL( asset::from_string("110.0000 EOS"), total["cpu_weight"].as()); + REQUIRE_MATCHING_OBJECT( voter( "alice1111111", "300.0000 EOS"), get_voter_info( "alice1111111" ) ); + + //BOOST_REQUIRE_EQUAL( asset::from_string("999999700.0000 EOS"), get_balance( "eosio" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("0.0000 EOS"), get_balance( "alice1111111" ) ); + + //alice stakes for herself + transfer( "eosio", "alice1111111", "1000.0000 EOS", "eosio" ); + BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "alice1111111", "200.0000 EOS", "100.0000 EOS" ) ); + //now alice's stake should be equal to transfered from eosio + own stake + total = get_total_stake("alice1111111"); + BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice1111111" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("410.0000 EOS"), total["net_weight"].as()); + BOOST_REQUIRE_EQUAL( asset::from_string("210.0000 EOS"), total["cpu_weight"].as()); + REQUIRE_MATCHING_OBJECT( voter( "alice1111111", "600.0000 EOS"), get_voter_info( "alice1111111" ) ); + + //alice can unstake everything (including what was transfered) + BOOST_REQUIRE_EQUAL( success(), unstake( "alice1111111", "alice1111111", "400.0000 EOS", "200.0000 EOS" ) ); + BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice1111111" ) ); + + produce_block( fc::hours(3*24-1) ); + produce_blocks(1); + BOOST_REQUIRE_EQUAL( asset::from_string("700.0000 EOS"), get_balance( "alice1111111" ) ); + //after 3 days funds should be released + produce_block( fc::hours(1) ); + produce_blocks(1); + BOOST_REQUIRE_EQUAL( asset::from_string("1300.0000 EOS"), get_balance( "alice1111111" ) ); + + //stake should be equal to what was staked in constructor, votring power should be 0 + total = get_total_stake("alice1111111"); + BOOST_REQUIRE_EQUAL( asset::from_string("10.0000 EOS"), total["net_weight"].as()); + BOOST_REQUIRE_EQUAL( asset::from_string("10.0000 EOS"), total["cpu_weight"].as()); + REQUIRE_MATCHING_OBJECT( voter( "alice1111111", "0.0000 EOS"), get_voter_info( "alice1111111" ) ); +} FC_LOG_AND_RETHROW() + BOOST_FIXTURE_TEST_CASE( fail_without_auth, eosio_system_tester ) try { issue( "alice1111111", "1000.0000 EOS", config::system_account_name ); From 93d085115b4934c80f65a77dfddad311549faed5 Mon Sep 17 00:00:00 2001 From: arhag Date: Mon, 14 May 2018 17:13:01 -0400 Subject: [PATCH 22/27] update LIB before promoting schedules (also added unit test) --- libraries/chain/block_header_state.cpp | 48 ++++++++------ libraries/chain/controller.cpp | 8 ++- .../eosio/chain/block_header_state.hpp | 1 + unittests/producer_schedule_tests.cpp | 63 +++++++++++++++++++ 4 files changed, 97 insertions(+), 23 deletions(-) diff --git a/libraries/chain/block_header_state.cpp b/libraries/chain/block_header_state.cpp index ae2e29f09de..4dec36ea167 100644 --- a/libraries/chain/block_header_state.cpp +++ b/libraries/chain/block_header_state.cpp @@ -52,23 +52,6 @@ namespace eosio { namespace chain { result.dpos_irreversible_blocknum = dpos_irreversible_blocknum; result.bft_irreversible_blocknum = bft_irreversible_blocknum; - if( result.pending_schedule.producers.size() && - result.dpos_irreversible_blocknum >= pending_schedule_lib_num ) { - result.active_schedule = move( result.pending_schedule ); - - flat_map new_producer_to_last_produced; - for( const auto& pro : result.active_schedule.producers ) { - auto existing = producer_to_last_produced.find( pro.producer_name ); - if( existing != producer_to_last_produced.end() ) { - new_producer_to_last_produced[pro.producer_name] = existing->second; - } else { - new_producer_to_last_produced[pro.producer_name] = result.dpos_irreversible_blocknum; - } - } - result.producer_to_last_produced = move( new_producer_to_last_produced ); - result.producer_to_last_produced[prokey.producer_name] = result.block_num; - } - /// grow the confirmed count static_assert(std::numeric_limits::max() >= (config::max_producers * 2 / 3) + 1, "8bit confirmations may not be able to hold all of the needed confirmations"); @@ -90,6 +73,28 @@ namespace eosio { namespace chain { return result; } /// generate_next + bool block_header_state::maybe_promote_pending() { + if( pending_schedule.producers.size() && + dpos_irreversible_blocknum >= pending_schedule_lib_num ) + { + active_schedule = move( pending_schedule ); + + flat_map new_producer_to_last_produced; + for( const auto& pro : active_schedule.producers ) { + auto existing = producer_to_last_produced.find( pro.producer_name ); + if( existing != producer_to_last_produced.end() ) { + new_producer_to_last_produced[pro.producer_name] = existing->second; + } else { + new_producer_to_last_produced[pro.producer_name] = dpos_irreversible_blocknum; + } + } + producer_to_last_produced = move( new_producer_to_last_produced ); + producer_to_last_produced[header.producer] = block_num; + + return true; + } + return false; + } void block_header_state::set_new_producers( producer_schedule_type pending ) { FC_ASSERT( pending.version == active_schedule.version + 1, "wrong producer schedule version specified" ); @@ -129,12 +134,15 @@ namespace eosio { namespace chain { /// below this point is state changes that cannot be validated with headers alone, but never-the-less, /// must result in header state changes - if( h.new_producers ) { - result.set_new_producers( *h.new_producers ); - } result.set_confirmed( h.confirmed ); + auto was_pending_promoted = result.maybe_promote_pending(); + + if( h.new_producers ) { + FC_ASSERT( !was_pending_promoted, "cannot set pending producer schedule in the same block in which pending was promoted to active" ); + result.set_new_producers( *h.new_producers ); + } result.header.action_mroot = h.action_mroot; result.header.transaction_mroot = h.transaction_mroot; diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index 193081356eb..1c37ebd0a51 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -661,11 +661,15 @@ struct controller_impl { pending->_pending_block_state = std::make_shared( *head, when ); // promotes pending schedule (if any) to active pending->_pending_block_state->in_current_chain = true; + pending->_pending_block_state->set_confirmed(confirm_block_count); + + auto was_pending_promoted = pending->_pending_block_state->maybe_promote_pending(); + const auto& gpo = db.get(); if( gpo.proposed_schedule_block_num.valid() && // if there is a proposed schedule that was proposed in a block ... ( *gpo.proposed_schedule_block_num <= pending->_pending_block_state->dpos_irreversible_blocknum ) && // ... that has now become irreversible ... pending->_pending_block_state->pending_schedule.producers.size() == 0 && // ... and there is room for a new pending schedule ... - head->pending_schedule.producers.size() == 0 // ... and not just because it was promoted to active at the start of this block, then: + !was_pending_promoted // ... and not just because it was promoted to active at the start of this block, then: ) { // Promote proposed schedule to pending schedule. @@ -680,8 +684,6 @@ struct controller_impl { }); } - pending->_pending_block_state->set_confirmed(confirm_block_count); - try { auto onbtrx = std::make_shared( get_on_block_transaction() ); push_transaction( onbtrx, fc::time_point::maximum(), true, config::default_min_transaction_cpu_usage_us); diff --git a/libraries/chain/include/eosio/chain/block_header_state.hpp b/libraries/chain/include/eosio/chain/block_header_state.hpp index 59da9f7322d..b3a921f4fb9 100644 --- a/libraries/chain/include/eosio/chain/block_header_state.hpp +++ b/libraries/chain/include/eosio/chain/block_header_state.hpp @@ -30,6 +30,7 @@ struct block_header_state { void set_new_producers( producer_schedule_type next_pending ); void set_confirmed( uint16_t num_prev_blocks ); void add_confirmation( const header_confirmation& c ); + bool maybe_promote_pending(); bool has_pending_producers()const { return pending_schedule.producers.size(); } diff --git a/unittests/producer_schedule_tests.cpp b/unittests/producer_schedule_tests.cpp index c70fee6aa35..e7b4cb0f328 100644 --- a/unittests/producer_schedule_tests.cpp +++ b/unittests/producer_schedule_tests.cpp @@ -195,4 +195,67 @@ BOOST_AUTO_TEST_SUITE(producer_schedule_tests) } FC_LOG_AND_RETHROW() #endif + + +BOOST_FIXTURE_TEST_CASE( producer_schedule_promotion_test, TESTER ) try { + create_accounts( {N(alice),N(bob),N(carol)} ); + produce_block(); + + auto compare_schedules = [&]( const vector& a, const producer_schedule_type& b ) { + return std::equal( a.begin(), a.end(), b.producers.begin(), b.producers.end() ); + }; + + auto res = set_producers( {N(alice),N(bob)} ); + vector sch1 = { + {N(alice), get_public_key(N(alice), "active")}, + {N(bob), get_public_key(N(bob), "active")} + }; + //wdump((fc::json::to_pretty_string(res))); + wlog("set producer schedule to [alice,bob]"); + BOOST_REQUIRE_EQUAL( true, control->proposed_producers().valid() ); + BOOST_CHECK_EQUAL( true, compare_schedules( sch1, *control->proposed_producers() ) ); + BOOST_CHECK_EQUAL( control->pending_producers().version, 0 ); + produce_block(); // Starts new block which promotes the proposed schedule to pending + BOOST_CHECK_EQUAL( control->pending_producers().version, 1 ); + BOOST_CHECK_EQUAL( true, compare_schedules( sch1, control->pending_producers() ) ); + BOOST_CHECK_EQUAL( control->active_producers().version, 0 ); + produce_block(); // Starts new block which promotes the pending schedule to active + BOOST_CHECK_EQUAL( control->active_producers().version, 1 ); + BOOST_CHECK_EQUAL( true, compare_schedules( sch1, control->active_producers() ) ); + produce_blocks(7); + + res = set_producers( {N(alice),N(bob),N(carol)} ); + vector sch2 = { + {N(alice), get_public_key(N(alice), "active")}, + {N(bob), get_public_key(N(bob), "active")}, + {N(carol), get_public_key(N(carol), "active")} + }; + wlog("set producer schedule to [alice,bob,carol]"); + BOOST_REQUIRE_EQUAL( true, control->proposed_producers().valid() ); + BOOST_CHECK_EQUAL( true, compare_schedules( sch2, *control->proposed_producers() ) ); + + produce_block(); // Alice produces the last block of her first round. + // Bob's first block (which advances LIB to Alice's last block) is started but not finalized. + BOOST_REQUIRE_EQUAL( control->head_block_producer(), N(alice) ); + BOOST_REQUIRE_EQUAL( control->pending_block_state()->header.producer, N(bob) ); + BOOST_CHECK_EQUAL( control->pending_producers().version, 2 ); + + produce_blocks(11); // Bob produces his first 11 blocks + BOOST_CHECK_EQUAL( control->active_producers().version, 1 ); + produce_block(); // Bob produces his 12th block. + // Alice's first block of the second round is started but not finalized (which advances LIB to Bob's last block). + BOOST_REQUIRE_EQUAL( control->head_block_producer(), N(bob) ); + BOOST_REQUIRE_EQUAL( control->pending_block_state()->header.producer, N(alice) ); + BOOST_CHECK_EQUAL( control->active_producers().version, 2 ); + BOOST_CHECK_EQUAL( true, compare_schedules( sch2, control->active_producers() ) ); + + produce_block(); // Alice produces the first block of her second round which has changed the active schedule. + + // The next block will be produced according to the new schedule + produce_block(); + BOOST_CHECK_EQUAL( control->head_block_producer(), N(carol) ); // And that next block happens to be produced by Carol. + + BOOST_REQUIRE_EQUAL( validate(), true ); +} FC_LOG_AND_RETHROW() + BOOST_AUTO_TEST_SUITE_END() From b66ffd066f4c4cb4e0a51b6f158b7dae233ad459 Mon Sep 17 00:00:00 2001 From: Paul Calabrese Date: Mon, 14 May 2018 16:20:04 -0500 Subject: [PATCH 23/27] Properly preserve any messages passed to boost asio --- plugins/net_plugin/net_plugin.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 3b26458943e..95af31fbef4 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -733,7 +733,7 @@ namespace eosio { void connection::flush_queues() { if (write_depth > 0) { - while (write_queue.size() > 1) { + while (write_queue.size() > write_depth) { write_queue.pop_back(); } } else { @@ -956,11 +956,11 @@ namespace eosio { my_impl->close(c.lock()); return; } - write_depth++; size_t num_buffs = write_queue.size(); std::vector bufs; - for (auto m: write_queue) { + for (auto& m: write_queue) { bufs.push_back(boost::asio::buffer(*m.buff)); + write_depth++; } boost::asio::async_write(*socket, bufs, [c, num_buffs](boost::system::error_code ec, std::size_t w) { try { @@ -971,9 +971,9 @@ namespace eosio { if (conn->write_queue.size() >= num_buffs ) { for (size_t i = 0; i < num_buffs; i++) { conn->write_queue[i].callback(ec, w); + conn->write_depth--; } } - conn->write_depth--; if(ec) { string pname = conn ? conn->peer_name() : "no connection name"; @@ -1065,10 +1065,8 @@ namespace eosio { fc::datastream ds( send_buffer->data(), buffer_size); ds.write( header, header_size ); fc::raw::pack( ds, m ); - write_depth++; queue_write(send_buffer,trigger_send, [this, close_after_send](boost::system::error_code ec, std::size_t ) { - write_depth--; if(close_after_send != no_reason) { elog ("sent a go away message: ${r}, closing connection to ${p}",("r",reason_str(close_after_send))("p",peer_name())); my_impl->close(shared_from_this()); From e2fa445348f896989d7dee3fe9cf129a4b2e2781 Mon Sep 17 00:00:00 2001 From: Bart Wyatt Date: Mon, 14 May 2018 17:25:09 -0400 Subject: [PATCH 24/27] conservative captures of this in a lot of cases. conservative capture of the iterator of multi-index-containers --- plugins/net_plugin/net_plugin.cpp | 53 ++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 3b26458943e..2588af7eafe 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -778,8 +778,12 @@ namespace eosio { my_impl->local_txns.modify(tx,incr_in_flight); queue_write(std::make_shared>(tx->serialized_txn), true, - [this, tx](boost::system::error_code ec, std::size_t ) { - my_impl->local_txns.modify(tx, decr_in_flight); + [tx_id=tx->id](boost::system::error_code ec, std::size_t ) { + auto& local_txns = my_impl->local_txns; + auto tx = local_txns.get().find(tx_id); + if (tx != local_txns.end()) { + local_txns.modify(tx, decr_in_flight); + } }); } } @@ -793,8 +797,12 @@ namespace eosio { my_impl->local_txns.modify( tx,incr_in_flight); queue_write(std::make_shared>(tx->serialized_txn), true, - [this, tx](boost::system::error_code ec, std::size_t ) { - my_impl->local_txns.modify(tx, decr_in_flight); + [t](boost::system::error_code ec, std::size_t ) { + auto& local_txns = my_impl->local_txns; + auto tx = local_txns.get().find(t); + if (tx != local_txns.end()) { + local_txns.modify(tx, decr_in_flight); + } }); } } @@ -1066,13 +1074,17 @@ namespace eosio { ds.write( header, header_size ); fc::raw::pack( ds, m ); write_depth++; + connection_wptr weak_this = shared_from_this(); queue_write(send_buffer,trigger_send, - [this, close_after_send](boost::system::error_code ec, std::size_t ) { - write_depth--; - if(close_after_send != no_reason) { - elog ("sent a go away message: ${r}, closing connection to ${p}",("r",reason_str(close_after_send))("p",peer_name())); - my_impl->close(shared_from_this()); - return; + [weak_this, close_after_send](boost::system::error_code ec, std::size_t ) { + connection_ptr conn = weak_this.lock(); + if (conn) { + conn->write_depth--; + if (close_after_send != no_reason) { + elog ("sent a go away message: ${r}, closing connection to ${p}",("r", reason_str(close_after_send))("p", conn->peer_name())); + my_impl->close(conn); + return; + } } }); } @@ -1571,8 +1583,9 @@ namespace eosio { // skip will be empty if our producer emitted this block so just send it if (msgsiz > just_send_it_max && skip) { fc_ilog(logger, "block size is ${ms}, sending notify",("ms", msgsiz)); - my_impl->send_all(pending_notify, [skip, bid, bnum](connection_ptr c) -> bool { - if (c == skip || !c->current()) + connection_wptr weak_skip = skip; + my_impl->send_all(pending_notify, [weak_skip, bid, bnum](connection_ptr c) -> bool { + if (c == weak_skip.lock() || !c->current()) return false; const auto& bs = c->blk_state.find(bid); bool unknown = bs == c->blk_state.end(); @@ -1665,8 +1678,9 @@ namespace eosio { my_impl->local_txns.insert(std::move(nts)); if(bufsiz <= just_send_it_max) { - my_impl->send_all( trx, [skip, id](connection_ptr c) -> bool { - if(c == skip || c->syncing ) { + connection_wptr weak_skip = skip; + my_impl->send_all( trx, [weak_skip, id](connection_ptr c) -> bool { + if(c == weak_skip.lock() || c->syncing ) { return false; } const auto& bs = c->trx_state.find(id); @@ -1683,8 +1697,9 @@ namespace eosio { pending_notify.known_trx.mode = normal; pending_notify.known_trx.ids.push_back( id ); pending_notify.known_blocks.mode = none; - my_impl->send_all(pending_notify, [skip, id](connection_ptr c) -> bool { - if (c == skip || c->syncing) { + connection_wptr weak_skip = skip; + my_impl->send_all(pending_notify, [weak_skip, id](connection_ptr c) -> bool { + if (c == weak_skip.lock() || c->syncing) { return false; } const auto& bs = c->trx_state.find(id); @@ -2504,7 +2519,7 @@ namespace eosio { void net_plugin_impl::start_conn_timer( ) { connector_check->expires_from_now( connector_period); - connector_check->async_wait( [&](boost::system::error_code ec) { + connector_check->async_wait( [this](boost::system::error_code ec) { if( !ec) { connection_monitor( ); } @@ -2517,7 +2532,7 @@ namespace eosio { void net_plugin_impl::start_txn_timer() { transaction_check->expires_from_now( txn_exp_period); - transaction_check->async_wait( [&](boost::system::error_code ec) { + transaction_check->async_wait( [this](boost::system::error_code ec) { if( !ec) { expire_txns( ); } @@ -2530,7 +2545,7 @@ namespace eosio { void net_plugin_impl::ticker() { keepalive_timer->expires_from_now (keepalive_interval); - keepalive_timer->async_wait ([&](boost::system::error_code ec) { + keepalive_timer->async_wait ([this](boost::system::error_code ec) { ticker (); if (ec) { wlog ("Peer keepalive ticked sooner than expected: ${m}", ("m", ec.message())); From 7d2dedfe6444e5cd5440d15c583aa03c0d69b993 Mon Sep 17 00:00:00 2001 From: Bart Wyatt Date: Mon, 14 May 2018 17:32:08 -0400 Subject: [PATCH 25/27] add logging messages to catch cases which may have caused unexpected corruption before --- plugins/net_plugin/net_plugin.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 2588af7eafe..26832b8403d 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -783,6 +783,8 @@ namespace eosio { auto tx = local_txns.get().find(tx_id); if (tx != local_txns.end()) { local_txns.modify(tx, decr_in_flight); + } else { + fc_wlog(logger, "Local pending TX erased before queued_write called callback"); } }); } @@ -802,6 +804,8 @@ namespace eosio { auto tx = local_txns.get().find(t); if (tx != local_txns.end()) { local_txns.modify(tx, decr_in_flight); + } else { + fc_wlog(logger, "Local TX erased before queued_write called callback"); } }); } @@ -1085,6 +1089,8 @@ namespace eosio { my_impl->close(conn); return; } + } else { + fc_wlog(logger, "connection expired before enqueued net_message called callback!"); } }); } From 5e5fb28f583556e847feacb8a8640cb3719ec667 Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Mon, 14 May 2018 17:34:37 -0400 Subject: [PATCH 26/27] reverting change in resource_limits.cpp, bug was already fixed by Dan #3001 --- libraries/chain/resource_limits.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/chain/resource_limits.cpp b/libraries/chain/resource_limits.cpp index 2030e72c3b0..c408a22ca40 100644 --- a/libraries/chain/resource_limits.cpp +++ b/libraries/chain/resource_limits.cpp @@ -345,7 +345,7 @@ int64_t resource_limits_manager::get_account_cpu_limit( const account_name& name uint128_t user_weight = cpu_weight; uint128_t all_user_weight = state.total_cpu_weight; - auto max_user_use_in_window = all_user_weight > 0 ? (uint128_t(virtual_cpu_capacity_in_window) * user_weight) / all_user_weight : uint128_t(virtual_cpu_capacity_in_window); + auto max_user_use_in_window = (virtual_cpu_capacity_in_window * user_weight) / all_user_weight; auto cpu_used_in_window = (usage.cpu_usage.value_ex * window_size) / config::rate_limiting_precision; if( max_user_use_in_window <= cpu_used_in_window ) return 0; @@ -403,7 +403,7 @@ account_resource_limit resource_limits_manager::get_account_cpu_limit_ex( const wdump((cpu_weight)); - auto max_user_use_in_window = all_user_weight > 0 ? (uint128_t(virtual_cpu_capacity_in_window) * user_weight) / all_user_weight : uint128_t(virtual_cpu_capacity_in_window); + auto max_user_use_in_window = (uint128_t(virtual_cpu_capacity_in_window) * user_weight) / all_user_weight; auto cpu_used_in_window = (usage.cpu_usage.value_ex * window_size) / config::rate_limiting_precision; if( max_user_use_in_window <= cpu_used_in_window ) @@ -436,7 +436,7 @@ int64_t resource_limits_manager::get_account_net_limit( const account_name& name uint128_t user_weight = net_weight; uint128_t all_user_weight = state.total_net_weight; - auto max_user_use_in_window = all_user_weight > 0 ? (virtual_network_capacity_in_window * user_weight) / all_user_weight : virtual_network_capacity_in_window; + auto max_user_use_in_window = (virtual_network_capacity_in_window * user_weight) / all_user_weight; auto net_used_in_window = (usage.net_usage.value_ex * window_size) / config::rate_limiting_precision; if( max_user_use_in_window <= net_used_in_window ) return 0; @@ -466,7 +466,7 @@ account_resource_limit resource_limits_manager::get_account_net_limit_ex( const uint128_t all_user_weight = state.total_net_weight; - auto max_user_use_in_window = all_user_weight > 0 ? (virtual_network_capacity_in_window * user_weight) / all_user_weight : virtual_network_capacity_in_window; + auto max_user_use_in_window = (virtual_network_capacity_in_window * user_weight) / all_user_weight; auto net_used_in_window = (usage.net_usage.value_ex * window_size) / config::rate_limiting_precision; if( max_user_use_in_window <= net_used_in_window ) From dcd2b74ee6b42d7602e8ac16d932111d501ad189 Mon Sep 17 00:00:00 2001 From: Paul Calabrese Date: Mon, 14 May 2018 17:03:34 -0500 Subject: [PATCH 27/27] Clean up write_queue management --- plugins/net_plugin/net_plugin.cpp | 32 +++++++++++-------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 95af31fbef4..dfa566d5732 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -452,6 +452,7 @@ namespace eosio { std::function callback; }; deque write_queue; + deque out_queue; fc::sha256 node_id; handshake_message last_handshake_recv; @@ -460,7 +461,6 @@ namespace eosio { bool connecting; bool syncing; uint16_t protocol_version; - int write_depth; string peer_addr; unique_ptr response_expected; optional pending_fetch; @@ -666,7 +666,6 @@ namespace eosio { connecting(false), syncing(false), protocol_version(0), - write_depth(0), peer_addr(endpoint), response_expected(), pending_fetch(), @@ -691,7 +690,6 @@ namespace eosio { connecting(true), syncing(false), protocol_version(0), - write_depth(0), peer_addr(), response_expected(), pending_fetch(), @@ -732,13 +730,7 @@ namespace eosio { } void connection::flush_queues() { - if (write_depth > 0) { - while (write_queue.size() > write_depth) { - write_queue.pop_back(); - } - } else { - write_queue.clear(); - } + write_queue.clear(); } void connection::close() { @@ -956,23 +948,21 @@ namespace eosio { my_impl->close(c.lock()); return; } - size_t num_buffs = write_queue.size(); std::vector bufs; - for (auto& m: write_queue) { + while (write_queue.size() > 0) { + auto& m = write_queue.front(); bufs.push_back(boost::asio::buffer(*m.buff)); - write_depth++; + out_queue.push_back(m); + write_queue.pop_front(); } - boost::asio::async_write(*socket, bufs, [c, num_buffs](boost::system::error_code ec, std::size_t w) { + boost::asio::async_write(*socket, bufs, [c](boost::system::error_code ec, std::size_t w) { try { auto conn = c.lock(); if(!conn) return; - if (conn->write_queue.size() >= num_buffs ) { - for (size_t i = 0; i < num_buffs; i++) { - conn->write_queue[i].callback(ec, w); - conn->write_depth--; - } + for (auto& m: conn->out_queue) { + m.callback(ec, w); } if(ec) { @@ -986,8 +976,8 @@ namespace eosio { my_impl->close(conn); return; } - for (size_t i = 0; i < num_buffs; i++) { - conn->write_queue.pop_front(); + while (conn->out_queue.size() > 0) { + conn->out_queue.pop_front(); } conn->enqueue_sync_block(); conn->do_queue_write();