From a884b8baa95f8544d9cf25f687af4b0f4c100f69 Mon Sep 17 00:00:00 2001 From: victorylee Date: Sat, 8 Dec 2018 23:04:57 +0800 Subject: [PATCH 1/7] restart sync list db --- libraries/chain/controller.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index 6bea61766be..cb824cf45ba 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -394,7 +394,11 @@ struct controller_impl { ilog( "database initialized with hash: ${hash}", ("hash", hash) ); } - + //*bos begin* + sync_name_list(list_type::actor_blacklist_type,true); + sync_name_list(list_type::contract_blacklist_type,true); + sync_name_list(list_type::resource_greylist_type,true); + //*bos end* } ~controller_impl() { @@ -649,9 +653,7 @@ struct controller_impl { gpo.gmr.ram_byte = config::default_gmr_ram_limit; }); - sync_name_list(list_type::actor_blacklist_type,true); - sync_name_list(list_type::contract_blacklist_type,true); - sync_name_list(list_type::resource_greylist_type,true); + // *bos end* authorization.initialize_database(); From 58ab31a6e77732a293f18267aed4666bff9000cd Mon Sep 17 00:00:00 2001 From: victorylee Date: Wed, 12 Dec 2018 18:10:37 +0800 Subject: [PATCH 2/7] recovery system account bos to eosio --- contracts/eosio.system/eosio.system.cpp | 2 +- contracts/eosio.system/producer_pay.cpp | 18 +++++++++--------- contracts/eosiolib/dispatcher.hpp | 2 +- contracts/proxy/proxy.cpp | 2 +- contracts/test_api/test_api.cpp | 2 +- libraries/chain/include/eosio/chain/config.hpp | 2 +- plugins/chain_plugin/chain_plugin.cpp | 2 +- tests/get_table_tests.cpp | 2 +- .../contracts/deferred_test/deferred_test.cpp | 2 +- unittests/misc_tests.cpp | 2 ++ 10 files changed, 19 insertions(+), 17 deletions(-) diff --git a/contracts/eosio.system/eosio.system.cpp b/contracts/eosio.system/eosio.system.cpp index daf40efbb84..fc39edd16c8 100644 --- a/contracts/eosio.system/eosio.system.cpp +++ b/contracts/eosio.system/eosio.system.cpp @@ -74,7 +74,7 @@ namespace eosiosystem { } void system_contract::setparams( const eosio::blockchain_parameters& params ) { - require_auth( N(eosio) ); + require_auth( N(bos) ); (eosio::blockchain_parameters&)(_gstate) = params; eosio_assert( 3 <= _gstate.max_authority_depth, "max_authority_depth should be at least 3" ); set_blockchain_parameters( params ); diff --git a/contracts/eosio.system/producer_pay.cpp b/contracts/eosio.system/producer_pay.cpp index 1d0af68d432..f481c394344 100644 --- a/contracts/eosio.system/producer_pay.cpp +++ b/contracts/eosio.system/producer_pay.cpp @@ -20,7 +20,7 @@ namespace eosiosystem { void system_contract::onblock( block_timestamp timestamp, account_name producer ) { using namespace eosio; - require_auth(N(eosio)); + require_auth(N(bos)); /** until activated stake crosses this threshold no new rewards are paid */ if( _gstate.total_activated_stake < min_activated_stake ) @@ -89,17 +89,17 @@ namespace eosiosystem { auto to_per_block_pay = to_producers / 4; auto to_per_vote_pay = to_producers - to_per_block_pay; - INLINE_ACTION_SENDER(eosio::token, issue)( N(eosio.token), {{N(eosio),N(active)}}, - {N(eosio), asset(new_tokens), std::string("issue tokens for producer pay and savings")} ); + INLINE_ACTION_SENDER(eosio::token, issue)( N(eosio.token), {{N(bos),N(active)}}, + {N(bos), asset(new_tokens), std::string("issue tokens for producer pay and savings")} ); - INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(eosio),N(active)}, - { N(eosio), N(eosio.saving), asset(to_savings), "unallocated inflation" } ); + INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(bos),N(active)}, + { N(bos), N(eosio.saving), asset(to_savings), "unallocated inflation" } ); - INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(eosio),N(active)}, - { N(eosio), N(eosio.bpay), asset(to_per_block_pay), "fund per-block bucket" } ); + INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(bos),N(active)}, + { N(bos), N(eosio.bpay), asset(to_per_block_pay), "fund per-block bucket" } ); - INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(eosio),N(active)}, - { N(eosio), N(eosio.vpay), asset(to_per_vote_pay), "fund per-vote bucket" } ); + INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(bos),N(active)}, + { N(bos), N(eosio.vpay), asset(to_per_vote_pay), "fund per-vote bucket" } ); _gstate.pervote_bucket += to_per_vote_pay; _gstate.perblock_bucket += to_per_block_pay; diff --git a/contracts/eosiolib/dispatcher.hpp b/contracts/eosiolib/dispatcher.hpp index eadc55bc3e8..627544d5d3f 100644 --- a/contracts/eosiolib/dispatcher.hpp +++ b/contracts/eosiolib/dispatcher.hpp @@ -123,7 +123,7 @@ extern "C" { \ auto self = receiver; \ if( action == N(onerror)) { \ /* onerror is only valid if it is for the "eosio" code account and authorized by "eosio"'s "active permission */ \ - eosio_assert(code == N(eosio), "onerror action's are only valid from the \"eosio\" system account"); \ + eosio_assert(code == N(bos), "onerror action's are only valid from the \"eosio\" system account"); \ } \ if( code == self || action == N(onerror) ) { \ TYPE thiscontract( self ); \ diff --git a/contracts/proxy/proxy.cpp b/contracts/proxy/proxy.cpp index ff27e5d5af2..7810a6d5684 100644 --- a/contracts/proxy/proxy.cpp +++ b/contracts/proxy/proxy.cpp @@ -91,7 +91,7 @@ extern "C" { /// The apply method implements the dispatch of events to this contract void apply( uint64_t receiver, uint64_t code, uint64_t action ) { - if( code == N(eosio) && action == N(onerror) ) { + if( code == N(bos) && action == N(onerror) ) { apply_onerror( receiver, onerror::from_current_action() ); } else if( code == N(eosio.token) ) { if( action == N(transfer) ) { diff --git a/contracts/test_api/test_api.cpp b/contracts/test_api/test_api.cpp index 9ddcb712752..49bc5c95a9a 100644 --- a/contracts/test_api/test_api.cpp +++ b/contracts/test_api/test_api.cpp @@ -22,7 +22,7 @@ account_name global_receiver; extern "C" { void apply( uint64_t receiver, uint64_t code, uint64_t action ) { - if( code == N(eosio) && action == N(onerror) ) { + if( code == N(bos) && action == N(onerror) ) { auto error = eosio::onerror::from_current_action(); eosio::print("onerror called\n"); auto error_trx = error.unpack_sent_trx(); diff --git a/libraries/chain/include/eosio/chain/config.hpp b/libraries/chain/include/eosio/chain/config.hpp index 6aea7c3e3bd..dbd9ea639fa 100644 --- a/libraries/chain/include/eosio/chain/config.hpp +++ b/libraries/chain/include/eosio/chain/config.hpp @@ -24,7 +24,7 @@ const static auto default_state_size = 1*1024*1024*1024ll; const static auto default_state_guard_size = 128*1024*1024ll; -const static uint64_t system_account_name = N(eosio); +const static uint64_t system_account_name = N(bos); const static uint64_t null_account_name = N(eosio.null); const static uint64_t producers_account_name = N(eosio.prods); diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index 2603a87178b..c74e3c42b30 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -1833,7 +1833,7 @@ chain::symbol read_only::extract_core_symbol()const { // The following code makes assumptions about the contract deployed on eosio account (i.e. the system contract) and how it stores its data. const auto& d = db.db(); - const auto* t_id = d.find(boost::make_tuple( N(eosio), N(eosio), N(rammarket) )); + const auto* t_id = d.find(boost::make_tuple( N(bos), N(bos), N(rammarket) )); if( t_id != nullptr ) { const auto &idx = d.get_index(); auto it = idx.find(boost::make_tuple( t_id->id, eosio::chain::string_to_symbol_c(4,"RAMCORE") )); diff --git a/tests/get_table_tests.cpp b/tests/get_table_tests.cpp index 818ca5562d2..125e137314b 100644 --- a/tests/get_table_tests.cpp +++ b/tests/get_table_tests.cpp @@ -85,7 +85,7 @@ BOOST_FIXTURE_TEST_CASE( get_scope_test, TESTER ) try { BOOST_REQUIRE_EQUAL(name(N(eosio.token)), result.rows[0].code); BOOST_REQUIRE_EQUAL(name(N(inita)), result.rows[0].scope); BOOST_REQUIRE_EQUAL(name(N(accounts)), result.rows[0].table); - BOOST_REQUIRE_EQUAL(name(N(eosio)), result.rows[0].payer); + BOOST_REQUIRE_EQUAL(name(N(bos)), result.rows[0].payer); BOOST_REQUIRE_EQUAL(1, result.rows[0].count); BOOST_REQUIRE_EQUAL(name(N(initb)), result.rows[1].scope); diff --git a/unittests/contracts/deferred_test/deferred_test.cpp b/unittests/contracts/deferred_test/deferred_test.cpp index e216aa8483a..aa337e11746 100644 --- a/unittests/contracts/deferred_test/deferred_test.cpp +++ b/unittests/contracts/deferred_test/deferred_test.cpp @@ -45,7 +45,7 @@ void apply_onerror(uint64_t receiver, const onerror& error ) { extern "C" { /// The apply method implements the dispatch of events to this contract void apply( uint64_t receiver, uint64_t code, uint64_t action ) { - if( code == N(eosio) && action == N(onerror) ) { + if( code == N(bos) && action == N(onerror) ) { apply_onerror( receiver, onerror::from_current_action() ); } else if( code == receiver ) { deferred_test thiscontract(receiver); diff --git a/unittests/misc_tests.cpp b/unittests/misc_tests.cpp index 9f87bdbeb2d..0aa1333ac48 100644 --- a/unittests/misc_tests.cpp +++ b/unittests/misc_tests.cpp @@ -63,6 +63,8 @@ static constexpr uint64_t name_suffix( uint64_t n ) { return ( ((n & mask) << shift) + (thirteenth_character << (shift-1)) ); } + + BOOST_AUTO_TEST_SUITE(misc_tests) BOOST_AUTO_TEST_CASE(name_suffix_tests) From 5b58ecb1defe0305bf2956314909cc9bcfc44e15 Mon Sep 17 00:00:00 2001 From: victorylee Date: Wed, 12 Dec 2018 19:26:55 +0800 Subject: [PATCH 3/7] recovery system account bos to eosio --- contracts/eosio.system/eosio.system.cpp | 2 +- contracts/eosio.system/producer_pay.cpp | 18 +++++++++--------- contracts/eosiolib/dispatcher.hpp | 2 +- contracts/proxy/proxy.cpp | 2 +- contracts/test_api/test_api.cpp | 2 +- libraries/chain/include/eosio/chain/config.hpp | 2 +- plugins/chain_plugin/chain_plugin.cpp | 2 +- tests/get_table_tests.cpp | 2 +- .../contracts/deferred_test/deferred_test.cpp | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/contracts/eosio.system/eosio.system.cpp b/contracts/eosio.system/eosio.system.cpp index fc39edd16c8..daf40efbb84 100644 --- a/contracts/eosio.system/eosio.system.cpp +++ b/contracts/eosio.system/eosio.system.cpp @@ -74,7 +74,7 @@ namespace eosiosystem { } void system_contract::setparams( const eosio::blockchain_parameters& params ) { - require_auth( N(bos) ); + require_auth( N(eosio) ); (eosio::blockchain_parameters&)(_gstate) = params; eosio_assert( 3 <= _gstate.max_authority_depth, "max_authority_depth should be at least 3" ); set_blockchain_parameters( params ); diff --git a/contracts/eosio.system/producer_pay.cpp b/contracts/eosio.system/producer_pay.cpp index f481c394344..1d0af68d432 100644 --- a/contracts/eosio.system/producer_pay.cpp +++ b/contracts/eosio.system/producer_pay.cpp @@ -20,7 +20,7 @@ namespace eosiosystem { void system_contract::onblock( block_timestamp timestamp, account_name producer ) { using namespace eosio; - require_auth(N(bos)); + require_auth(N(eosio)); /** until activated stake crosses this threshold no new rewards are paid */ if( _gstate.total_activated_stake < min_activated_stake ) @@ -89,17 +89,17 @@ namespace eosiosystem { auto to_per_block_pay = to_producers / 4; auto to_per_vote_pay = to_producers - to_per_block_pay; - INLINE_ACTION_SENDER(eosio::token, issue)( N(eosio.token), {{N(bos),N(active)}}, - {N(bos), asset(new_tokens), std::string("issue tokens for producer pay and savings")} ); + INLINE_ACTION_SENDER(eosio::token, issue)( N(eosio.token), {{N(eosio),N(active)}}, + {N(eosio), asset(new_tokens), std::string("issue tokens for producer pay and savings")} ); - INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(bos),N(active)}, - { N(bos), N(eosio.saving), asset(to_savings), "unallocated inflation" } ); + INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(eosio),N(active)}, + { N(eosio), N(eosio.saving), asset(to_savings), "unallocated inflation" } ); - INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(bos),N(active)}, - { N(bos), N(eosio.bpay), asset(to_per_block_pay), "fund per-block bucket" } ); + INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(eosio),N(active)}, + { N(eosio), N(eosio.bpay), asset(to_per_block_pay), "fund per-block bucket" } ); - INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(bos),N(active)}, - { N(bos), N(eosio.vpay), asset(to_per_vote_pay), "fund per-vote bucket" } ); + INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(eosio),N(active)}, + { N(eosio), N(eosio.vpay), asset(to_per_vote_pay), "fund per-vote bucket" } ); _gstate.pervote_bucket += to_per_vote_pay; _gstate.perblock_bucket += to_per_block_pay; diff --git a/contracts/eosiolib/dispatcher.hpp b/contracts/eosiolib/dispatcher.hpp index 627544d5d3f..eadc55bc3e8 100644 --- a/contracts/eosiolib/dispatcher.hpp +++ b/contracts/eosiolib/dispatcher.hpp @@ -123,7 +123,7 @@ extern "C" { \ auto self = receiver; \ if( action == N(onerror)) { \ /* onerror is only valid if it is for the "eosio" code account and authorized by "eosio"'s "active permission */ \ - eosio_assert(code == N(bos), "onerror action's are only valid from the \"eosio\" system account"); \ + eosio_assert(code == N(eosio), "onerror action's are only valid from the \"eosio\" system account"); \ } \ if( code == self || action == N(onerror) ) { \ TYPE thiscontract( self ); \ diff --git a/contracts/proxy/proxy.cpp b/contracts/proxy/proxy.cpp index 7810a6d5684..ff27e5d5af2 100644 --- a/contracts/proxy/proxy.cpp +++ b/contracts/proxy/proxy.cpp @@ -91,7 +91,7 @@ extern "C" { /// The apply method implements the dispatch of events to this contract void apply( uint64_t receiver, uint64_t code, uint64_t action ) { - if( code == N(bos) && action == N(onerror) ) { + if( code == N(eosio) && action == N(onerror) ) { apply_onerror( receiver, onerror::from_current_action() ); } else if( code == N(eosio.token) ) { if( action == N(transfer) ) { diff --git a/contracts/test_api/test_api.cpp b/contracts/test_api/test_api.cpp index 49bc5c95a9a..9ddcb712752 100644 --- a/contracts/test_api/test_api.cpp +++ b/contracts/test_api/test_api.cpp @@ -22,7 +22,7 @@ account_name global_receiver; extern "C" { void apply( uint64_t receiver, uint64_t code, uint64_t action ) { - if( code == N(bos) && action == N(onerror) ) { + if( code == N(eosio) && action == N(onerror) ) { auto error = eosio::onerror::from_current_action(); eosio::print("onerror called\n"); auto error_trx = error.unpack_sent_trx(); diff --git a/libraries/chain/include/eosio/chain/config.hpp b/libraries/chain/include/eosio/chain/config.hpp index dbd9ea639fa..6aea7c3e3bd 100644 --- a/libraries/chain/include/eosio/chain/config.hpp +++ b/libraries/chain/include/eosio/chain/config.hpp @@ -24,7 +24,7 @@ const static auto default_state_size = 1*1024*1024*1024ll; const static auto default_state_guard_size = 128*1024*1024ll; -const static uint64_t system_account_name = N(bos); +const static uint64_t system_account_name = N(eosio); const static uint64_t null_account_name = N(eosio.null); const static uint64_t producers_account_name = N(eosio.prods); diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index c74e3c42b30..2603a87178b 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -1833,7 +1833,7 @@ chain::symbol read_only::extract_core_symbol()const { // The following code makes assumptions about the contract deployed on eosio account (i.e. the system contract) and how it stores its data. const auto& d = db.db(); - const auto* t_id = d.find(boost::make_tuple( N(bos), N(bos), N(rammarket) )); + const auto* t_id = d.find(boost::make_tuple( N(eosio), N(eosio), N(rammarket) )); if( t_id != nullptr ) { const auto &idx = d.get_index(); auto it = idx.find(boost::make_tuple( t_id->id, eosio::chain::string_to_symbol_c(4,"RAMCORE") )); diff --git a/tests/get_table_tests.cpp b/tests/get_table_tests.cpp index 125e137314b..818ca5562d2 100644 --- a/tests/get_table_tests.cpp +++ b/tests/get_table_tests.cpp @@ -85,7 +85,7 @@ BOOST_FIXTURE_TEST_CASE( get_scope_test, TESTER ) try { BOOST_REQUIRE_EQUAL(name(N(eosio.token)), result.rows[0].code); BOOST_REQUIRE_EQUAL(name(N(inita)), result.rows[0].scope); BOOST_REQUIRE_EQUAL(name(N(accounts)), result.rows[0].table); - BOOST_REQUIRE_EQUAL(name(N(bos)), result.rows[0].payer); + BOOST_REQUIRE_EQUAL(name(N(eosio)), result.rows[0].payer); BOOST_REQUIRE_EQUAL(1, result.rows[0].count); BOOST_REQUIRE_EQUAL(name(N(initb)), result.rows[1].scope); diff --git a/unittests/contracts/deferred_test/deferred_test.cpp b/unittests/contracts/deferred_test/deferred_test.cpp index aa337e11746..e216aa8483a 100644 --- a/unittests/contracts/deferred_test/deferred_test.cpp +++ b/unittests/contracts/deferred_test/deferred_test.cpp @@ -45,7 +45,7 @@ void apply_onerror(uint64_t receiver, const onerror& error ) { extern "C" { /// The apply method implements the dispatch of events to this contract void apply( uint64_t receiver, uint64_t code, uint64_t action ) { - if( code == N(bos) && action == N(onerror) ) { + if( code == N(eosio) && action == N(onerror) ) { apply_onerror( receiver, onerror::from_current_action() ); } else if( code == receiver ) { deferred_test thiscontract(receiver); From c88462752fe6ac5f4480b1b05d9541304c779dec Mon Sep 17 00:00:00 2001 From: victorylee Date: Wed, 12 Dec 2018 19:30:09 +0800 Subject: [PATCH 4/7] recovery system account bos to eosio --- unittests/misc_tests.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/unittests/misc_tests.cpp b/unittests/misc_tests.cpp index 0aa1333ac48..9f87bdbeb2d 100644 --- a/unittests/misc_tests.cpp +++ b/unittests/misc_tests.cpp @@ -63,8 +63,6 @@ static constexpr uint64_t name_suffix( uint64_t n ) { return ( ((n & mask) << shift) + (thirteenth_character << (shift-1)) ); } - - BOOST_AUTO_TEST_SUITE(misc_tests) BOOST_AUTO_TEST_CASE(name_suffix_tests) From b9d89d48a5c3918395bc293aae2da6e57232ece3 Mon Sep 17 00:00:00 2001 From: vlbos Date: Fri, 4 Jan 2019 09:06:43 +0800 Subject: [PATCH 5/7] catch exception plugin initialize sync list before initialize database --- contracts/eosio.system/eosio.system.hpp | 1 + libraries/chain/controller.cpp | 15 ++++++++---- unittests/database_gmr_blklst_tests.cpp | 31 ++++++++++++++----------- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/contracts/eosio.system/eosio.system.hpp b/contracts/eosio.system/eosio.system.hpp index 66964e39659..a33238a1eaa 100644 --- a/contracts/eosio.system/eosio.system.hpp +++ b/contracts/eosio.system/eosio.system.hpp @@ -172,6 +172,7 @@ namespace eosiosystem { void undelegatebw( account_name from, account_name receiver, asset unstake_net_quantity, asset unstake_cpu_quantity ); + /** * Increases receiver's ram quota based upon current price and quantity of * tokens provided. An inline transfer from receiver to system contract of diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index cb824cf45ba..dd5a85ba2df 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -741,10 +741,17 @@ struct controller_impl { void sync_name_list(list_type list,bool isMerge=false) { - const auto &gpo2 = db.get(); - db.modify(gpo2, [&](auto &gprops2) { - sync_list_and_db(list, gprops2,isMerge); - }); + try + { + const auto &gpo2 = db.get(); + db.modify(gpo2, [&](auto &gprops2) { + sync_list_and_db(list, gprops2, isMerge); + }); + } + catch (...) + { + wlog("plugin initialize sync list ignore before initialize database"); + } } // "bos end" diff --git a/unittests/database_gmr_blklst_tests.cpp b/unittests/database_gmr_blklst_tests.cpp index f448ba5a172..148a7d7bace 100644 --- a/unittests/database_gmr_blklst_tests.cpp +++ b/unittests/database_gmr_blklst_tests.cpp @@ -73,20 +73,25 @@ BOOST_AUTO_TEST_CASE(set_name_list_test) vector list = parse_list_string(str); flat_set nameset(list.begin(), list.end()); + // Create an account + db.create([](account_object &a) { + a.name = "alice"; + }); - test.control->set_actor_blacklist(nameset); + + test.control->add_resource_greylist(N(alice)); // Make sure we can retrieve that account by name const global_property2_object &ptr = db.get(); // Create an account db.modify(ptr, [&](global_property2_object &a) { - a.cfg.actor_blacklist = {N(a)}; - a.cfg.contract_blacklist = {N(a)}; - a.cfg.resource_greylist = {N(a)}; + // a.cfg.actor_blacklist = {N(a)}; + // a.cfg.contract_blacklist = {N(a)}; + // a.cfg.resource_greylist = {N(a)}; }); - int64_t lt = static_cast(list_type::actor_blacklist_type); + int64_t lt = static_cast(list_type::resource_greylist_type); int64_t lat = static_cast(list_action_type::insert_type); test.control->set_name_list(lt, lat, list); @@ -114,24 +119,24 @@ BOOST_AUTO_TEST_CASE(set_name_list_test) const global_property2_object &ptr1 = db.get(); chain_config2 c = ptr1.cfg; - BOOST_TEST(c.actor_blacklist.size() == 4); - BOOST_TEST(ab.size() == 4); + BOOST_TEST(c.resource_greylist.size() == 1); + BOOST_TEST(rg.size() == 1); convert_names(c.actor_blacklist, aab); convert_names(c.contract_blacklist, acb); convert_names(c.resource_greylist, arg); - if (c.actor_blacklist.size() == 4) + if (c.resource_greylist.size() == 1) { - bool b = (aab.find(N(a)) != aab.end()); - BOOST_TEST(b); + // bool b = (aab.find(N(a)) != aab.end()); + // BOOST_TEST(b); } - bool d = ab.find(N(a)) != ab.end(); - BOOST_TEST(d); - bool m = aab.find(N(alice)) != aab.end(); + // bool d = ab.find(N(a)) != ab.end(); + // BOOST_TEST(d); + bool m = arg.find(N(alice)) != arg.end(); BOOST_TEST(m); // Undo creation of the account From 057b8a332a5dcf96486b2f094ae54e20c5586d95 Mon Sep 17 00:00:00 2001 From: vlbos Date: Fri, 4 Jan 2019 09:11:35 +0800 Subject: [PATCH 6/7] catch exception plugin initialize sync list before initialize database --- contracts/eosio.system/eosio.system.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/eosio.system/eosio.system.hpp b/contracts/eosio.system/eosio.system.hpp index a33238a1eaa..66964e39659 100644 --- a/contracts/eosio.system/eosio.system.hpp +++ b/contracts/eosio.system/eosio.system.hpp @@ -172,7 +172,6 @@ namespace eosiosystem { void undelegatebw( account_name from, account_name receiver, asset unstake_net_quantity, asset unstake_cpu_quantity ); - /** * Increases receiver's ram quota based upon current price and quantity of * tokens provided. An inline transfer from receiver to system contract of From dd06ca49415d3c41e82561df2e9a284df842fe1f Mon Sep 17 00:00:00 2001 From: vlbos Date: Wed, 9 Jan 2019 22:09:32 +0800 Subject: [PATCH 7/7] fixed bidnameinfo could not parse uint64_t --- programs/cleos/main.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/programs/cleos/main.cpp b/programs/cleos/main.cpp index 7124357f158..af70e0683b8 100644 --- a/programs/cleos/main.cpp +++ b/programs/cleos/main.cpp @@ -1285,33 +1285,38 @@ struct bidname_subcommand { struct bidname_info_subcommand { bool print_json = false; - string newname_str; + name newname; bidname_info_subcommand(CLI::App* actionRoot) { auto list_producers = actionRoot->add_subcommand("bidnameinfo", localized("Get bidname info")); list_producers->add_flag("--json,-j", print_json, localized("Output in JSON format")); - list_producers->add_option("newname", newname_str, localized("The bidding name"))->required(); + list_producers->add_option("newname", newname, localized("The bidding name"))->required(); list_producers->set_callback([this] { auto rawResult = call(get_table_func, fc::mutable_variant_object("json", true) ("code", "eosio")("scope", "eosio")("table", "namebids") - ("lower_bound", eosio::chain::string_to_name(newname_str.c_str()))("limit", 1)); + ("lower_bound", newname.value)("limit", 1)); if ( print_json ) { std::cout << fc::json::to_pretty_string(rawResult) << std::endl; return; } auto result = rawResult.as(); - if ( result.rows.empty() ) { + // Condition in if statement below can simply be res.rows.empty() when cleos no longer needs to support nodeos versions older than 1.5.0 + if( result.rows.empty() || result.rows[0].get_object()["newname"].as_string() != newname.to_string() ) { std::cout << "No bidname record found" << std::endl; return; } - for ( auto& row : result.rows ) { - fc::time_point time(fc::microseconds(row["last_bid_time"].as_uint64())); - int64_t bid = row["high_bid"].as_int64(); - std::cout << std::left << std::setw(18) << "bidname:" << std::right << std::setw(24) << row["newname"].as_string() << "\n" - << std::left << std::setw(18) << "highest bidder:" << std::right << std::setw(24) << row["high_bidder"].as_string() << "\n" - << std::left << std::setw(18) << "highest bid:" << std::right << std::setw(24) << (bid > 0 ? bid : -bid) << "\n" - << std::left << std::setw(18) << "last bid time:" << std::right << std::setw(24) << ((std::string)time).c_str() << std::endl; - if (bid < 0) std::cout << "This auction has already closed" << std::endl; + const auto& row = result.rows[0]; + string time = row["last_bid_time"].as_string(); + try { + time = (string)fc::time_point(fc::microseconds(to_uint64(time))); + } catch (fc::parse_error_exception&) { } + int64_t bid = row["high_bid"].as_int64(); + std::cout << std::left << std::setw(18) << "bidname:" << std::right << std::setw(24) << row["newname"].as_string() << "\n" + << std::left << std::setw(18) << "highest bidder:" << std::right << std::setw(24) << row["high_bidder"].as_string() << "\n" + << std::left << std::setw(18) << "highest bid:" << std::right << std::setw(24) << (bid > 0 ? bid : -bid) << "\n" + << std::left << std::setw(18) << "last bid time:" << std::right << std::setw(24) << time << std::endl; + if (bid < 0) std::cout << "This auction has already closed" << std::endl; + }); } };