From e773214bada635907cafca04a2a6d3b7bdc249a3 Mon Sep 17 00:00:00 2001 From: Khaled Al-Hassanieh Date: Thu, 31 May 2018 11:54:07 -0400 Subject: [PATCH 01/26] Clean up eosio.system tests --- unittests/eosio.system_tests.cpp | 349 +++++------------------------- unittests/eosio_system_tester.hpp | 7 + 2 files changed, 58 insertions(+), 298 deletions(-) diff --git a/unittests/eosio.system_tests.cpp b/unittests/eosio.system_tests.cpp index 94a94b38d16..fa998b5aee0 100644 --- a/unittests/eosio.system_tests.cpp +++ b/unittests/eosio.system_tests.cpp @@ -638,12 +638,7 @@ BOOST_FIXTURE_TEST_CASE( vote_for_producer, eosio_system_tester, * boost::unit_t REQUIRE_MATCHING_OBJECT( voter( "bob111111111", core_from_string("11.1111") ), get_voter_info( "bob111111111" ) ); //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(alice1111111) } ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(bob111111111), { N(alice1111111) } ) ); //check that producer parameters stay the same after voting prod = get_producer_info( "alice1111111" ); @@ -656,12 +651,8 @@ BOOST_FIXTURE_TEST_CASE( vote_for_producer, eosio_system_tester, * boost::unit_t REQUIRE_MATCHING_OBJECT( voter( "carol1111111", core_from_string("22.2222") ), get_voter_info( "carol1111111" ) ); BOOST_REQUIRE_EQUAL( core_from_string("2977.7778"), 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(alice1111111) } ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(carol1111111), { N(alice1111111) } ) ); + //new stake votes be added to alice1111111's total_votes prod = get_producer_info( "alice1111111" ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("33.3333")) == prod["total_votes"].as_double() ); @@ -681,12 +672,8 @@ BOOST_FIXTURE_TEST_CASE( vote_for_producer, eosio_system_tester, * boost::unit_t BOOST_TEST_REQUIRE( stake2votes(core_from_string("86.8886")) == prod["total_votes"].as_double() ); //bob111111111 revokes his vote - BOOST_REQUIRE_EQUAL( success(), push_action( N(bob111111111), N(voteproducer), mvo() - ("voter", "bob111111111") - ("proxy", name(0).to_string() ) - ("producers", vector() ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(bob111111111), vector() ) ); + //should decrease alice1111111's total_votes prod = get_producer_info( "alice1111111" ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("20.2220")) == prod["total_votes"].as_double() ); @@ -714,12 +701,7 @@ BOOST_FIXTURE_TEST_CASE( unregistered_producer_voting, eosio_system_tester, * bo //bob111111111 should not be able to vote for alice1111111 who is not a producer BOOST_REQUIRE_EQUAL( wasm_assert_msg( "producer is not registered" ), - push_action( N(bob111111111), N(voteproducer), mvo() - ("voter", "bob111111111") - ("proxy", name(0).to_string() ) - ("producers", vector{ N(alice1111111) } ) - ) - ); + vote( N(bob111111111), { N(alice1111111) } ) ); //alice1111111 registers as a producer issue( "alice1111111", core_from_string("1000.0000"), config::system_account_name ); @@ -742,12 +724,7 @@ BOOST_FIXTURE_TEST_CASE( unregistered_producer_voting, eosio_system_tester, * bo //bob111111111 should not be able to vote for alice1111111 who is an unregistered producer BOOST_REQUIRE_EQUAL( wasm_assert_msg( "producer is not currently registered" ), - push_action( N(bob111111111), N(voteproducer), mvo() - ("voter", "bob111111111") - ("proxy", name(0).to_string() ) - ("producers", vector{ N(alice1111111) } ) - ) - ); + vote( N(bob111111111), { N(alice1111111) } ) ); } FC_LOG_AND_RETHROW() @@ -759,12 +736,7 @@ BOOST_FIXTURE_TEST_CASE( more_than_30_producer_voting, eosio_system_tester ) try //bob111111111 should not be able to vote for alice1111111 who is not a producer BOOST_REQUIRE_EQUAL( wasm_assert_msg( "attempt to vote for too many producers" ), - push_action( N(bob111111111), N(voteproducer), mvo() - ("voter", "bob111111111") - ("proxy", name(0).to_string() ) - ("producers", vector(31, N(alice1111111)) ) - ) - ); + vote( N(bob111111111), vector(31, N(alice1111111)) ) ); } FC_LOG_AND_RETHROW() @@ -787,12 +759,7 @@ BOOST_FIXTURE_TEST_CASE( vote_same_producer_30_times, eosio_system_tester ) try //bob111111111 should not be able to vote for alice1111111 who is not a producer BOOST_REQUIRE_EQUAL( wasm_assert_msg( "producer votes must be unique and sorted" ), - push_action( N(bob111111111), N(voteproducer), mvo() - ("voter", "bob111111111") - ("proxy", name(0).to_string() ) - ("producers", vector(30, N(alice1111111)) ) - ) - ); + vote( N(bob111111111), vector(30, N(alice1111111)) ) ); auto prod = get_producer_info( "alice1111111" ); BOOST_TEST_REQUIRE( 0 == prod["total_votes"].as_double() ); @@ -818,12 +785,7 @@ BOOST_FIXTURE_TEST_CASE( producer_keep_votes, eosio_system_tester, * boost::unit REQUIRE_MATCHING_OBJECT( voter( "bob111111111", core_from_string("13.5791") ), get_voter_info( "bob111111111" ) ); //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(alice1111111) } ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote(N(bob111111111), { N(alice1111111) } ) ); auto prod = get_producer_info( "alice1111111" ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("13.5791")) == prod["total_votes"].as_double() ); @@ -897,12 +859,7 @@ BOOST_FIXTURE_TEST_CASE( vote_for_two_producers, eosio_system_tester, * boost::u //carol1111111 votes for alice1111111 and bob111111111 issue( "carol1111111", core_from_string("1000.0000"), config::system_account_name ); BOOST_REQUIRE_EQUAL( success(), stake( "carol1111111", core_from_string("15.0005"), core_from_string("5.0000") ) ); - BOOST_REQUIRE_EQUAL( success(), push_action(N(carol1111111), N(voteproducer), mvo() - ("voter", "carol1111111") - ("proxy", name(0).to_string() ) - ("producers", vector{ N(alice1111111), N(bob111111111) } ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(carol1111111), { N(alice1111111), N(bob111111111) } ) ); auto alice_info = get_producer_info( "alice1111111" ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("20.0005")) == alice_info["total_votes"].as_double() ); @@ -910,12 +867,7 @@ BOOST_FIXTURE_TEST_CASE( vote_for_two_producers, eosio_system_tester, * boost::u BOOST_TEST_REQUIRE( stake2votes(core_from_string("20.0005")) == bob_info["total_votes"].as_double() ); //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(alice1111111) } ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(carol1111111), { N(alice1111111) } ) ); alice_info = get_producer_info( "alice1111111" ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("20.0005")) == alice_info["total_votes"].as_double() ); @@ -925,12 +877,7 @@ BOOST_FIXTURE_TEST_CASE( vote_for_two_producers, eosio_system_tester, * boost::u //alice1111111 votes for herself and bob111111111 issue( "alice1111111", core_from_string("2.0000"), config::system_account_name ); BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", core_from_string("1.0000"), core_from_string("1.0000") ) ); - BOOST_REQUIRE_EQUAL( success(), push_action(N(alice1111111), N(voteproducer), mvo() - ("voter", "alice1111111") - ("proxy", name(0).to_string() ) - ("producers", vector{ N(alice1111111), N(bob111111111) } ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote(N(alice1111111), { N(alice1111111), N(bob111111111) } ) ); alice_info = get_producer_info( "alice1111111" ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("22.0005")) == alice_info["total_votes"].as_double() ); @@ -1047,32 +994,17 @@ BOOST_FIXTURE_TEST_CASE( proxy_actions_affect_producers, eosio_system_tester, * //accumulate proxied votes issue( "bob111111111", core_from_string("1000.0000"), config::system_account_name ); BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", core_from_string("100.0002"), core_from_string("50.0001") ) ); - BOOST_REQUIRE_EQUAL( success(), push_action(N(bob111111111), N(voteproducer), mvo() - ("voter", "bob111111111") - ("proxy", "alice1111111" ) - ("producers", vector() ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote(N(bob111111111), vector(), N(alice1111111) ) ); REQUIRE_MATCHING_OBJECT( proxy( "alice1111111" )( "proxied_vote_weight", stake2votes(core_from_string("150.0003")) ), get_voter_info( "alice1111111" ) ); //vote for producers - BOOST_REQUIRE_EQUAL( success(), push_action(N(alice1111111), N(voteproducer), mvo() - ("voter", "alice1111111") - ("proxy", name(0).to_string() ) - ("producers", vector{ N(defproducer1), N(defproducer2) } ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote(N(alice1111111), { N(defproducer1), N(defproducer2) } ) ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("150.0003")) == get_producer_info( "defproducer1" )["total_votes"].as_double() ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("150.0003")) == 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(alice1111111), N(voteproducer), mvo() - ("voter", "alice1111111") - ("proxy", name(0).to_string() ) - ("producers", vector{ N(defproducer1), N(defproducer3) } ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(alice1111111), { N(defproducer1), N(defproducer3) } ) ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("150.0003")) == get_producer_info( "defproducer1" )["total_votes"].as_double() ); BOOST_REQUIRE_EQUAL( 0, get_producer_info( "defproducer2" )["total_votes"].as_double() ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("150.0003")) == get_producer_info( "defproducer3" )["total_votes"].as_double() ); @@ -1135,13 +1067,7 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t transfer( config::system_account_name, "producvotera", core_from_string("400000000.0000"), config::system_account_name); BOOST_REQUIRE_EQUAL(success(), stake("producvotera", core_from_string("100000000.0000"), core_from_string("100000000.0000"))); - - BOOST_REQUIRE_EQUAL(success(), push_action(N(producvotera), N(voteproducer), mvo() - ("voter", "producvotera") - ("proxy", name(0).to_string()) - ("producers", vector{ N(defproducera) }) - ) - ); + BOOST_REQUIRE_EQUAL(success(), vote( N(producvotera), { N(defproducera) })); // defproducera is the only active producer // produce enough blocks so new schedule kicks in and defproducera produces some blocks @@ -1167,14 +1093,13 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t BOOST_REQUIRE_EQUAL(success(), push_action(N(defproducera), N(claimrewards), mvo()("owner", "defproducera"))); - const auto global_state = get_global_state(); + const auto global_state = get_global_state(); const uint64_t claim_time = global_state["last_pervote_bucket_fill"].as_uint64(); const int64_t pervote_bucket = global_state["pervote_bucket"].as(); const int64_t perblock_bucket = global_state["perblock_bucket"].as(); const int64_t savings = get_balance(N(eosio.saving)).get_amount(); const uint32_t tot_unpaid_blocks = global_state["total_unpaid_blocks"].as(); - prod = get_producer_info("defproducera"); BOOST_REQUIRE_EQUAL(1, prod["unpaid_blocks"].as()); BOOST_REQUIRE_EQUAL(1, tot_unpaid_blocks); @@ -1247,7 +1172,6 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t const asset initial_supply = get_token_supply(); const asset initial_balance = get_balance(N(defproducera)); - BOOST_REQUIRE_EQUAL(success(), push_action(N(defproducera), N(claimrewards), mvo()("owner", "defproducera"))); const auto global_state = get_global_state(); @@ -1257,7 +1181,6 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t const int64_t savings = get_balance(N(eosio.saving)).get_amount(); const uint32_t tot_unpaid_blocks = global_state["total_unpaid_blocks"].as(); - prod = get_producer_info("defproducera"); BOOST_REQUIRE_EQUAL(1, prod["unpaid_blocks"].as()); BOOST_REQUIRE_EQUAL(1, tot_unpaid_blocks); @@ -1364,33 +1287,10 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni // producvoterc votes for defproducera ... defproducerz // producvoterd votes for abcproducera ... abcproducern { - 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(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(producvoterc), N(voteproducer), mvo() - ("voter", "producvoterc") - ("proxy", name(0).to_string()) - ("producers", vector(producer_names.begin(), producer_names.begin()+26)) - ) - ); - - BOOST_REQUIRE_EQUAL(success(), push_action(N(producvoterd), N(voteproducer), mvo() - ("voter", "producvoterd") - ("proxy", name(0).to_string()) - ("producers", vector(producer_names.begin()+26, producer_names.end())) - ) - ); + BOOST_REQUIRE_EQUAL(success(), vote(N(producvotera), vector(producer_names.begin(), producer_names.begin()+10))); + BOOST_REQUIRE_EQUAL(success(), vote(N(producvoterb), vector(producer_names.begin(), producer_names.begin()+21))); + BOOST_REQUIRE_EQUAL(success(), vote(N(producvoterc), vector(producer_names.begin(), producer_names.begin()+26))); + BOOST_REQUIRE_EQUAL(success(), vote(N(producvoterd), vector(producer_names.begin()+26, producer_names.end()))); } { @@ -1751,15 +1651,8 @@ BOOST_FIXTURE_TEST_CASE(producer_onblock_check, eosio_system_tester) try { transfer(config::system_account_name, "producvotera", core_from_string("200000000.0000"), config::system_account_name); - BOOST_REQUIRE_EQUAL(success(), stake("producvotera", core_from_string("70000000.0000"), core_from_string("70000000.0000") )); - - 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(), vote( N(producvotera), vector(producer_names.begin(), producer_names.begin()+10))); BOOST_CHECK_EQUAL( wasm_assert_msg("not enough has been staked for users to unstake"), unstake( "producvotera", core_from_string("50.0000"), core_from_string("50.0000") ) ); // give a chance for everyone to produce blocks @@ -1797,19 +1690,8 @@ BOOST_FIXTURE_TEST_CASE(producer_onblock_check, eosio_system_tester) try { transfer(config::system_account_name, "producvoterc", core_from_string("100000000.0000"), config::system_account_name); BOOST_REQUIRE_EQUAL(success(), stake("producvoterc", core_from_string("2000000.0000"), core_from_string("2000000.0000"))); - 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(producvoterc), N(voteproducer), mvo() - ("voter", "producvoterc") - ("proxy", name(0).to_string()) - ("producers", vector(producer_names.begin(), producer_names.end())) - ) - ); + BOOST_REQUIRE_EQUAL(success(), vote( N(producvoterb), vector(producer_names.begin(), producer_names.begin()+21))); + BOOST_REQUIRE_EQUAL(success(), vote( N(producvoterc), vector(producer_names.begin(), producer_names.end()))); // give a chance for everyone to produce blocks { @@ -1856,12 +1738,7 @@ BOOST_FIXTURE_TEST_CASE( voters_actions_affect_proxy_and_producers, eosio_system //alice1111111 makes stake and votes issue( "alice1111111", core_from_string("1000.0000"), config::system_account_name ); BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", core_from_string("30.0001"), core_from_string("20.0001") ) ); - BOOST_REQUIRE_EQUAL( success(), push_action(N(alice1111111), N(voteproducer), mvo() - ("voter", "alice1111111") - ("proxy", name(0).to_string() ) - ("producers", vector{ N(defproducer1), N(defproducer2) } ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(alice1111111), { N(defproducer1), N(defproducer2) } ) ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("50.0002")) == get_producer_info( "defproducer1" )["total_votes"].as_double() ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("50.0002")) == get_producer_info( "defproducer2" )["total_votes"].as_double() ); BOOST_REQUIRE_EQUAL( 0, get_producer_info( "defproducer3" )["total_votes"].as_double() ); @@ -1876,12 +1753,7 @@ BOOST_FIXTURE_TEST_CASE( voters_actions_affect_proxy_and_producers, eosio_system //bob111111111 chooses alice1111111 as a proxy issue( "bob111111111", core_from_string("1000.0000"), config::system_account_name ); BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", core_from_string("100.0002"), core_from_string("50.0001") ) ); - BOOST_REQUIRE_EQUAL( success(), push_action( N(bob111111111), N(voteproducer), mvo() - ("voter", "bob111111111") - ("proxy", "alice1111111" ) - ("producers", vector() ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(bob111111111), vector(), "alice1111111" ) ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("150.0003")) == get_voter_info( "alice1111111" )["proxied_vote_weight"].as_double() ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("200.0005")) == get_producer_info( "defproducer1" )["total_votes"].as_double() ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("200.0005")) == get_producer_info( "defproducer2" )["total_votes"].as_double() ); @@ -1890,18 +1762,12 @@ BOOST_FIXTURE_TEST_CASE( voters_actions_affect_proxy_and_producers, eosio_system //carol1111111 chooses alice1111111 as a proxy issue( "carol1111111", core_from_string("1000.0000"), config::system_account_name ); BOOST_REQUIRE_EQUAL( success(), stake( "carol1111111", core_from_string("30.0001"), core_from_string("20.0001") ) ); - BOOST_REQUIRE_EQUAL( success(), push_action( N(carol1111111), N(voteproducer), mvo() - ("voter", "carol1111111") - ("proxy", "alice1111111" ) - ("producers", vector() ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(carol1111111), vector(), "alice1111111" ) ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("200.0005")) == get_voter_info( "alice1111111" )["proxied_vote_weight"].as_double() ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("250.0007")) == get_producer_info( "defproducer1" )["total_votes"].as_double() ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("250.0007")) == get_producer_info( "defproducer2" )["total_votes"].as_double() ); BOOST_REQUIRE_EQUAL( 0, get_producer_info( "defproducer3" )["total_votes"].as_double() ); - //proxied voter carol1111111 increases stake BOOST_REQUIRE_EQUAL( success(), stake( "carol1111111", core_from_string("50.0000"), core_from_string("70.0000") ) ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("320.0005")) == get_voter_info( "alice1111111" )["proxied_vote_weight"].as_double() ); @@ -1917,12 +1783,7 @@ BOOST_FIXTURE_TEST_CASE( voters_actions_affect_proxy_and_producers, eosio_system BOOST_REQUIRE_EQUAL( 0, get_producer_info( "defproducer3" )["total_votes"].as_double() ); //proxied voter carol1111111 chooses another proxy - BOOST_REQUIRE_EQUAL( success(), push_action( N(carol1111111), N(voteproducer), mvo() - ("voter", "carol1111111") - ("proxy", "donald111111" ) - ("producers", vector() ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(carol1111111), vector(), "donald111111" ) ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("50.0001")), get_voter_info( "alice1111111" )["proxied_vote_weight"].as_double() ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("170.0002")), get_voter_info( "donald111111" )["proxied_vote_weight"].as_double() ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("100.0003")), get_producer_info( "defproducer1" )["total_votes"].as_double() ); @@ -1930,12 +1791,7 @@ BOOST_FIXTURE_TEST_CASE( voters_actions_affect_proxy_and_producers, eosio_system BOOST_REQUIRE_EQUAL( 0, get_producer_info( "defproducer3" )["total_votes"].as_double() ); //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(defproducer2) } ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(bob111111111), { N(defproducer2) } ) ); BOOST_TEST_REQUIRE( 0.0 == get_voter_info( "alice1111111" )["proxied_vote_weight"].as_double() ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("50.0002")), get_producer_info( "defproducer1" )["total_votes"].as_double() ); BOOST_TEST_REQUIRE( stake2votes(core_from_string("100.0003")), get_producer_info( "defproducer2" )["total_votes"].as_double() ); @@ -1961,13 +1817,7 @@ BOOST_FIXTURE_TEST_CASE( vote_both_proxy_and_producers, eosio_system_tester ) tr issue( "bob111111111", core_from_string("1000.0000"), config::system_account_name ); BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", core_from_string("100.0002"), core_from_string("50.0001") ) ); BOOST_REQUIRE_EQUAL( wasm_assert_msg("cannot vote for producers and proxy at same time"), - - push_action( N(bob111111111), N(voteproducer), mvo() - ("voter", "bob111111111") - ("proxy", "alice1111111" ) - ("producers", vector{ N(carol1111111) } ) - ) - ); + vote( N(bob111111111), { N(carol1111111) }, "alice1111111" ) ); } FC_LOG_AND_RETHROW() @@ -1979,21 +1829,11 @@ BOOST_FIXTURE_TEST_CASE( select_invalid_proxy, eosio_system_tester ) try { //selecting account not registered as a proxy BOOST_REQUIRE_EQUAL( wasm_assert_msg( "invalid proxy specified" ), - push_action(N(bob111111111), N(voteproducer), mvo() - ("voter", "bob111111111") - ("proxy", "alice1111111" ) - ("producers", vector() ) - ) - ); + vote( N(bob111111111), vector(), "alice1111111" ) ); //selecting not existing account as a proxy BOOST_REQUIRE_EQUAL( wasm_assert_msg( "invalid proxy specified" ), - push_action(N(bob111111111), N(voteproducer), mvo() - ("voter", "bob111111111") - ("proxy", "notexist" ) - ("producers", vector() ) - ) - ); + vote( N(bob111111111), vector(), "notexist" ) ); } FC_LOG_AND_RETHROW() @@ -2013,12 +1853,7 @@ BOOST_FIXTURE_TEST_CASE( double_register_unregister_proxy_keeps_votes, eosio_sys //bob111111111 stakes and selects alice1111111 as a proxy issue( "bob111111111", core_from_string("1000.0000"), config::system_account_name ); BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", core_from_string("100.0002"), core_from_string("50.0001") ) ); - BOOST_REQUIRE_EQUAL( success(), push_action( N(bob111111111), N(voteproducer), mvo() - ("voter", "bob111111111") - ("proxy", "alice1111111" ) - ("producers", vector() ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(bob111111111), vector(), "alice1111111" ) ); REQUIRE_MATCHING_OBJECT( proxy( "alice1111111" )( "proxied_vote_weight", stake2votes( core_from_string("150.0003") ))( "staked", 100000 ), get_voter_info( "alice1111111" ) ); //double regestering should fail without affecting total votes and stake @@ -2064,28 +1899,17 @@ BOOST_FIXTURE_TEST_CASE( proxy_cannot_use_another_proxy, eosio_system_tester ) t ("isproxy", 1) ) ); - //proxy should not be able to use a proxy + //proxy should not be able to use a proxy issue( "bob111111111", core_from_string("1000.0000"), config::system_account_name ); BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", core_from_string("100.0002"), core_from_string("50.0001") ) ); BOOST_REQUIRE_EQUAL( wasm_assert_msg( "account registered as a proxy is not allowed to use a proxy" ), - - push_action( N(bob111111111), N(voteproducer), mvo() - ("voter", "bob111111111") - ("proxy", "alice1111111" ) - ("producers", vector() ) - ) - ); + vote( N(bob111111111), vector(), "alice1111111" ) ); //voter that uses a proxy should not be allowed to become a proxy issue( "carol1111111", core_from_string("1000.0000"), config::system_account_name ); BOOST_REQUIRE_EQUAL( success(), stake( "carol1111111", core_from_string("100.0002"), core_from_string("50.0001") ) ); - BOOST_REQUIRE_EQUAL( success(), push_action( N(carol1111111), N(voteproducer), mvo() - ("voter", "carol1111111") - ("proxy", "alice1111111" ) - ("producers", vector() ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(carol1111111), vector(), "alice1111111" ) ); BOOST_REQUIRE_EQUAL( wasm_assert_msg( "account that uses a proxy is not allowed to become a proxy" ), push_action( N(carol1111111), N(regproxy), mvo() ("proxy", "carol1111111") @@ -2095,12 +1919,7 @@ BOOST_FIXTURE_TEST_CASE( proxy_cannot_use_another_proxy, eosio_system_tester ) t //proxy should not be able to use itself as a proxy BOOST_REQUIRE_EQUAL( wasm_assert_msg( "cannot proxy to self" ), - push_action( N(bob111111111), N(voteproducer), mvo() - ("voter", "bob111111111") - ("proxy", "bob111111111" ) - ("producers", vector() ) - ) - ); + vote( N(bob111111111), vector(), "bob111111111" ) ); } FC_LOG_AND_RETHROW() @@ -2133,14 +1952,8 @@ BOOST_FIXTURE_TEST_CASE( elect_producers /*_and_parameters*/, eosio_system_teste //stake more than 15% of total EOS supply to activate chain transfer( "eosio", "alice1111111", core_from_string("600000000.0000"), "eosio" ); BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "alice1111111", core_from_string("300000000.0000"), core_from_string("300000000.0000") ) ); - // 1000000000.0000 //vote for producers - BOOST_REQUIRE_EQUAL( success(), push_action(N(alice1111111), N(voteproducer), mvo() - ("voter", "alice1111111") - ("proxy", name(0).to_string() ) - ("producers", vector{ N(defproducer1) } ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(alice1111111), { N(defproducer1) } ) ); produce_blocks(250); auto producer_keys = control->head_block_state()->active_schedule.producers; BOOST_REQUIRE_EQUAL( 1, producer_keys.size() ); @@ -2155,12 +1968,7 @@ BOOST_FIXTURE_TEST_CASE( elect_producers /*_and_parameters*/, eosio_system_teste ilog("stake"); BOOST_REQUIRE_EQUAL( success(), stake( "bob111111111", core_from_string("40000.0000"), core_from_string("40000.0000") ) ); ilog("start vote"); - BOOST_REQUIRE_EQUAL( success(), push_action(N(bob111111111), N(voteproducer), mvo() - ("voter", "bob111111111") - ("proxy", name(0).to_string() ) - ("producers", vector{ N(defproducer2) } ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(bob111111111), { N(defproducer2) } ) ); ilog("."); produce_blocks(250); producer_keys = control->head_block_state()->active_schedule.producers; @@ -2172,12 +1980,7 @@ BOOST_FIXTURE_TEST_CASE( elect_producers /*_and_parameters*/, eosio_system_teste //REQUIRE_EQUAL_OBJECTS(prod2_config, config); // elect 3 producers - BOOST_REQUIRE_EQUAL( success(), push_action(N(bob111111111), N(voteproducer), mvo() - ("voter", "bob111111111") - ("proxy", name(0).to_string() ) - ("producers", vector{ N(defproducer2), N(defproducer3) } ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(bob111111111), { N(defproducer2), N(defproducer3) } ) ); produce_blocks(250); producer_keys = control->head_block_state()->active_schedule.producers; BOOST_REQUIRE_EQUAL( 3, producer_keys.size() ); @@ -2188,12 +1991,7 @@ BOOST_FIXTURE_TEST_CASE( elect_producers /*_and_parameters*/, eosio_system_teste //REQUIRE_EQUAL_OBJECTS(prod2_config, config); // try to go back to 2 producers and fail - BOOST_REQUIRE_EQUAL( success(), push_action(N(bob111111111), N(voteproducer), mvo() - ("voter", "bob111111111") - ("proxy", name(0).to_string() ) - ("producers", vector{ N(defproducer3) } ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(bob111111111), { N(defproducer3) } ) ); produce_blocks(250); producer_keys = control->head_block_state()->active_schedule.producers; BOOST_REQUIRE_EQUAL( 3, producer_keys.size() ); @@ -2219,10 +2017,7 @@ BOOST_FIXTURE_TEST_CASE( buyname, eosio_system_tester ) try { stake_with_transfer( config::system_account_name, "sam", core_from_string( "80000000.0000" ), core_from_string( "80000000.0000" ) ); regproducer( config::system_account_name ); - push_action( N(sam), N(voteproducer), mvo() - ("voter", "sam") - ("proxy", name(0).to_string() ) - ("producers", vector{ config::system_account_name } ) ); + BOOST_REQUIRE_EQUAL( success(), vote( N(sam), { config::system_account_name } ) ); // wait 14 days after min required amount has been staked produce_block( fc::days(14) ); produce_block(); @@ -2264,18 +2059,8 @@ BOOST_FIXTURE_TEST_CASE( multiple_namebids, eosio_system_tester ) try { // stake but but not enough to go live stake_with_transfer( config::system_account_name, "bob", core_from_string( "35000000.0000" ), core_from_string( "35000000.0000" ) ); stake_with_transfer( config::system_account_name, "carl", core_from_string( "35000000.0000" ), core_from_string( "35000000.0000" ) ); - BOOST_REQUIRE_EQUAL( success(),push_action( N(bob), N(voteproducer), mvo() - ("voter", "bob") - ("proxy", name(0).to_string() ) - ("producers", vector{ N(producer) } ) - ) - ); - BOOST_REQUIRE_EQUAL( success(), push_action( N(carl), N(voteproducer), mvo() - ("voter", "carl") - ("proxy", name(0).to_string() ) - ("producers", vector{ N(producer) } ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(bob), { N(producer) } ) ); + BOOST_REQUIRE_EQUAL( success(), vote( N(carl), { N(producer) } ) ); // start bids bidname( "bob", "prefa", core_from_string("1.0003") ); @@ -2331,12 +2116,7 @@ BOOST_FIXTURE_TEST_CASE( multiple_namebids, eosio_system_tester ) try { // stake enough to go above the 15% threshold stake_with_transfer( config::system_account_name, "alice", core_from_string( "10000000.0000" ), core_from_string( "10000000.0000" ) ); BOOST_REQUIRE_EQUAL(0, get_producer_info("producer")["unpaid_blocks"].as()); - BOOST_REQUIRE_EQUAL( success(), push_action( N(alice), N(voteproducer), mvo() - ("voter", "alice") - ("proxy", name(0).to_string() ) - ("producers", vector{ N(producer) } ) - ) - ); + BOOST_REQUIRE_EQUAL( success(), vote( N(alice), { N(producer) } ) ); // need to wait for 14 days after going live produce_blocks(10); @@ -2433,26 +2213,9 @@ BOOST_FIXTURE_TEST_CASE( vote_producers_in_and_out, eosio_system_tester ) try { } { - 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()+20)) - ) - ); - - 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(producvoterc), N(voteproducer), mvo() - ("voter", "producvoterc") - ("proxy", name(0).to_string()) - ("producers", vector(producer_names.begin(), producer_names.end())) - ) - ); + BOOST_REQUIRE_EQUAL(success(), vote(N(producvotera), vector(producer_names.begin(), producer_names.begin()+20))); + BOOST_REQUIRE_EQUAL(success(), vote(N(producvoterb), vector(producer_names.begin(), producer_names.begin()+21))); + BOOST_REQUIRE_EQUAL(success(), vote(N(producvoterc), vector(producer_names.begin(), producer_names.end()))); } // give a chance for everyone to produce blocks @@ -2478,12 +2241,7 @@ BOOST_FIXTURE_TEST_CASE( vote_producers_in_and_out, eosio_system_tester ) try { const uint32_t voted_out_index = 20; const uint32_t new_prod_index = 23; BOOST_REQUIRE_EQUAL(success(), stake("producvoterd", core_from_string("40000000.0000"), core_from_string("40000000.0000"))); - BOOST_REQUIRE_EQUAL(success(), push_action(N(producvoterd), N(voteproducer), mvo() - ("voter", "producvoterd") - ("proxy", name(0).to_string()) - ("producers", vector{ producer_names[new_prod_index] }) - ) - ); + BOOST_REQUIRE_EQUAL(success(), vote(N(producvoterd), { producer_names[new_prod_index] })); BOOST_REQUIRE_EQUAL(0, get_producer_info(producer_names[new_prod_index])["unpaid_blocks"].as()); produce_blocks(4 * 12 * 21); BOOST_REQUIRE(0 < get_producer_info(producer_names[new_prod_index])["unpaid_blocks"].as()); @@ -2491,12 +2249,7 @@ BOOST_FIXTURE_TEST_CASE( vote_producers_in_and_out, eosio_system_tester ) try { produce_blocks(2 * 12 * 21); BOOST_REQUIRE_EQUAL(initial_unpaid_blocks, get_producer_info(producer_names[voted_out_index])["unpaid_blocks"].as()); produce_block(fc::hours(24)); - BOOST_REQUIRE_EQUAL(success(), push_action(N(producvoterd), N(voteproducer), mvo() - ("voter", "producvoterd") - ("proxy", name(0).to_string()) - ("producers", vector{ producer_names[voted_out_index] }) - ) - ); + BOOST_REQUIRE_EQUAL(success(), vote(N(producvoterd), { producer_names[voted_out_index] })); produce_blocks(2 * 12 * 21); BOOST_REQUIRE(fc::crypto::public_key() != fc::crypto::public_key(get_producer_info(producer_names[voted_out_index])["producer_key"].as_string())); BOOST_REQUIRE_EQUAL(success(), push_action(producer_names[voted_out_index], N(claimrewards), mvo()("owner", producer_names[voted_out_index]))); diff --git a/unittests/eosio_system_tester.hpp b/unittests/eosio_system_tester.hpp index bdcf96b516d..b4f867de81d 100644 --- a/unittests/eosio_system_tester.hpp +++ b/unittests/eosio_system_tester.hpp @@ -317,6 +317,13 @@ class eosio_system_tester : public TESTER { return r; } + action_result vote( const account_name& voter, const std::vector& producers, const account_name& proxy = name(0) ) { + return push_action(voter, N(voteproducer), mvo() + ("voter", voter) + ("proxy", proxy) + ("producers", producers)); + } + uint32_t last_block_time() const { return time_point_sec( control->head_block_time() ).sec_since_epoch(); } From 437eb3c1cc969c221ec6a14a3db60326c3aef708 Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Thu, 31 May 2018 15:43:04 -0400 Subject: [PATCH 02/26] require either --buyram-bytes or --byuram-eos, don't call delegate bandwidth if both --stake-net and --stake-cpu are zeros #3684 --- programs/cleos/main.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/programs/cleos/main.cpp b/programs/cleos/main.cpp index 6875c17b6fc..3636157aad1 100644 --- a/programs/cleos/main.cpp +++ b/programs/cleos/main.cpp @@ -827,7 +827,7 @@ struct create_account_subcommand { string active_key_str; string stake_net; string stake_cpu; - uint32_t buy_ram_bytes_in_kbytes = 8; + uint32_t buy_ram_bytes_in_kbytes = 0; string buy_ram_eos; bool transfer; bool simple; @@ -866,10 +866,20 @@ struct create_account_subcommand { } EOS_RETHROW_EXCEPTIONS(public_key_type_exception, "Invalid active public key: ${public_key}", ("public_key", active_key_str)); auto create = create_newaccount(creator, account_name, owner_key, active_key); if (!simple) { + if ( buy_ram_eos.empty() && buy_ram_bytes_in_kbytes == 0) { + std::cerr << "ERROR: Either --buy-ram-EOS or --buy-ram-bytes with non-zero value is required" << std::endl; + return; + } action buyram = !buy_ram_eos.empty() ? create_buyram(creator, account_name, to_asset(buy_ram_eos)) : create_buyrambytes(creator, account_name, buy_ram_bytes_in_kbytes * 1024); - action delegate = create_delegate( creator, account_name, to_asset(stake_net), to_asset(stake_cpu), transfer); - send_actions( { create, buyram, delegate } ); + auto net = to_asset(stake_net); + auto cpu = to_asset(stake_cpu); + if ( 0 < net.get_amount() + cpu.get_amount() ) { + action delegate = create_delegate( creator, account_name, net, cpu, transfer); + send_actions( { create, buyram, delegate } ); + } else { + send_actions( { create, buyram } ); + } } else { send_actions( { create } ); } From 83a12317d5694c5f9523fcc1c59025cabcef7b11 Mon Sep 17 00:00:00 2001 From: Bart Wyatt Date: Thu, 31 May 2018 16:11:50 -0400 Subject: [PATCH 03/26] the signing timer log message was DEBUG but DEBUG is enabled by default. Now it is on the "producer_plugin" specific loggers DEBUG level --- plugins/producer_plugin/producer_plugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index eced3ff3d29..9b06cb7c2ef 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -1013,12 +1013,12 @@ bool producer_plugin_impl::maybe_produce_block() { static auto make_debug_time_logger() { auto start = fc::time_point::now(); return fc::make_scoped_exit([=](){ - dlog("Signing took ${ms}us", ("ms", fc::time_point::now() - start) ); + fc_dlog(_log, "Signing took ${ms}us", ("ms", fc::time_point::now() - start) ); }); } static auto maybe_make_debug_time_logger() -> fc::optional { - if ((fc::logger::get(DEFAULT_LOGGER)).is_enabled( fc::log_level::debug ) ){ + if (_log.is_enabled( fc::log_level::debug ) ){ return make_debug_time_logger(); } else { return {}; From 13c38a7e48aa839efa9cfe56b74f58f0de96b126 Mon Sep 17 00:00:00 2001 From: Bill Hamilton Date: Thu, 31 May 2018 13:17:04 -0700 Subject: [PATCH 04/26] Build: added CORE_SYMBOL_NAME option to main build script --- eosio_build.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/eosio_build.sh b/eosio_build.sh index 5fcc688e4fc..488f54b28ff 100755 --- a/eosio_build.sh +++ b/eosio_build.sh @@ -42,7 +42,7 @@ function usage() { - printf "\\tUsage: %s [Build Option -o ] [CodeCoverage -c ] [Doxygen -d]\\n\\n" "$0" 1>&2 + printf "\\tUsage: %s \\n\\t[Build Option -o ] \\n\\t[CodeCoverage -c ] \\n\\t[Doxygen -d] \\n\\t[CoreSymbolName -s <1-7 characters>]\\n\\n" "$0" 1>&2 exit 1 } @@ -52,6 +52,7 @@ DISK_MIN=20 DOXYGEN=false ENABLE_COVERAGE_TESTING=false + CORE_SYMBOL_NAME="SYS" TEMP_DIR="/tmp" TIME_BEGIN=$( date -u +%s ) VERSION=1.2 @@ -61,7 +62,7 @@ txtrst=$(tput sgr0) if [ $# -ne 0 ]; then - while getopts ":cdo:" opt; do + while getopts ":cdos:" opt; do case "${opt}" in o ) options=( "Debug" "Release" "RelWithDebInfo" "MinSizeRel" ) @@ -79,6 +80,15 @@ d ) DOXYGEN=true ;; + s) + if [ "${#OPTARG}" -gt 6 ] || [ -z "${#OPTARG}" ]; then + printf "\\n\\tInvalid argument: %s\\n" "${OPTARG}" 1>&2 + usage + exit 1 + else + CORE_SYMBOL_NAME="${OPTARG}" + fi + ;; \? ) printf "\\n\\tInvalid Option: %s\\n" "-${OPTARG}" 1>&2 usage @@ -96,7 +106,8 @@ esac done fi - +echo $CORE_SYMBOL_NAME +exit if [ ! -d .git ]; then printf "\\n\\tThis build script only works with sources cloned from git\\n" printf "\\tPlease clone a new eos directory with 'git clone https://github.com/EOSIO/eos --recursive'\\n" @@ -231,7 +242,7 @@ fi if ! "${CMAKE}" -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" -DCMAKE_CXX_COMPILER="${CXX_COMPILER}" \ - -DCMAKE_C_COMPILER="${C_COMPILER}" -DWASM_ROOT="${WASM_ROOT}" \ + -DCMAKE_C_COMPILER="${C_COMPILER}" -DWASM_ROOT="${WASM_ROOT}" -DCORE_SYMBOL_NAME="${CORE_SYMBOL_NAME}" \ -DOPENSSL_ROOT_DIR="${OPENSSL_ROOT_DIR}" -DBUILD_MONGO_DB_PLUGIN=true \ -DENABLE_COVERAGE_TESTING="${ENABLE_COVERAGE_TESTING}" -DBUILD_DOXYGEN="${DOXYGEN}" .. then From 8c65dfd7dd7f693a4b22e457cd63a3afcc0924a2 Mon Sep 17 00:00:00 2001 From: Bill Hamilton Date: Thu, 31 May 2018 13:19:36 -0700 Subject: [PATCH 05/26] removed debug code from build script --- eosio_build.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/eosio_build.sh b/eosio_build.sh index 63985323bab..ad1245c570e 100755 --- a/eosio_build.sh +++ b/eosio_build.sh @@ -106,8 +106,7 @@ esac done fi -echo $CORE_SYMBOL_NAME -exit + if [ ! -d .git ]; then printf "\\n\\tThis build script only works with sources cloned from git\\n" printf "\\tPlease clone a new eos directory with 'git clone https://github.com/EOSIO/eos --recursive'\\n" From 105863e0d5a089d462edede718314919794e7bb7 Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Thu, 31 May 2018 16:30:05 -0400 Subject: [PATCH 06/26] add ' (required)' to required parameter's description in help, microchange in cleos newaccount #3684 --- programs/cleos/CLI11.hpp | 1 + programs/cleos/main.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/programs/cleos/CLI11.hpp b/programs/cleos/CLI11.hpp index fc65bba64ef..e0268afee66 100644 --- a/programs/cleos/CLI11.hpp +++ b/programs/cleos/CLI11.hpp @@ -863,6 +863,7 @@ class Option { /// Set the option as required Option *required(bool value = true) { required_ = value; + description_ += " (required)"; return this; } diff --git a/programs/cleos/main.cpp b/programs/cleos/main.cpp index 3636157aad1..d3283e65452 100644 --- a/programs/cleos/main.cpp +++ b/programs/cleos/main.cpp @@ -874,7 +874,7 @@ struct create_account_subcommand { : create_buyrambytes(creator, account_name, buy_ram_bytes_in_kbytes * 1024); auto net = to_asset(stake_net); auto cpu = to_asset(stake_cpu); - if ( 0 < net.get_amount() + cpu.get_amount() ) { + if ( net.get_amount() == 0 && cpu.get_amount() == 0 ) { action delegate = create_delegate( creator, account_name, net, cpu, transfer); send_actions( { create, buyram, delegate } ); } else { From 009e9b16a9bcbd6f0b41ddcd3c8752e663fe5e9b Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Thu, 31 May 2018 16:32:38 -0400 Subject: [PATCH 07/26] cleos newaccount : buy-ram-bytes renames to buyram-kbytes, buy-ram-EOS renamed to buy_ram #3684 --- programs/cleos/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/cleos/main.cpp b/programs/cleos/main.cpp index d3283e65452..21d1697eac8 100644 --- a/programs/cleos/main.cpp +++ b/programs/cleos/main.cpp @@ -844,9 +844,9 @@ struct create_account_subcommand { (localized("The amount of EOS delegated for net bandwidth")))->required(); createAccount->add_option("--stake-cpu", stake_cpu, (localized("The amount of EOS delegated for CPU bandwidth")))->required(); - createAccount->add_option("--buy-ram-bytes", buy_ram_bytes_in_kbytes, + createAccount->add_option("--buy-ram-kbytes", buy_ram_bytes_in_kbytes, (localized("The amount of RAM bytes to purchase for the new account in kilobytes KiB, default is 8 KiB"))); - createAccount->add_option("--buy-ram-EOS", buy_ram_eos, + createAccount->add_option("--buy-ram", buy_ram_eos, (localized("The amount of RAM bytes to purchase for the new account in EOS"))); createAccount->add_flag("--transfer", transfer, (localized("Transfer voting power and right to unstake EOS to receiver"))); From 10ddddfae25a4a4a87daacffe5ed17e1a43fcabe Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Thu, 31 May 2018 16:34:19 -0400 Subject: [PATCH 08/26] cleos newaccount : error message updated #3684 --- programs/cleos/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/cleos/main.cpp b/programs/cleos/main.cpp index 21d1697eac8..769473366c5 100644 --- a/programs/cleos/main.cpp +++ b/programs/cleos/main.cpp @@ -867,7 +867,7 @@ struct create_account_subcommand { auto create = create_newaccount(creator, account_name, owner_key, active_key); if (!simple) { if ( buy_ram_eos.empty() && buy_ram_bytes_in_kbytes == 0) { - std::cerr << "ERROR: Either --buy-ram-EOS or --buy-ram-bytes with non-zero value is required" << std::endl; + std::cerr << "ERROR: Either --buy-ram or --buy-ram-kbytes with non-zero value is required" << std::endl; return; } action buyram = !buy_ram_eos.empty() ? create_buyram(creator, account_name, to_asset(buy_ram_eos)) From a9d46b9b8c0f6af680fc7cacff25fd35ad9bb1b8 Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Thu, 31 May 2018 16:39:29 -0400 Subject: [PATCH 09/26] cleos newaccount : bugfix #3684 --- programs/cleos/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/cleos/main.cpp b/programs/cleos/main.cpp index 769473366c5..30417064ac0 100644 --- a/programs/cleos/main.cpp +++ b/programs/cleos/main.cpp @@ -874,7 +874,7 @@ struct create_account_subcommand { : create_buyrambytes(creator, account_name, buy_ram_bytes_in_kbytes * 1024); auto net = to_asset(stake_net); auto cpu = to_asset(stake_cpu); - if ( net.get_amount() == 0 && cpu.get_amount() == 0 ) { + if ( net.get_amount() != 0 || cpu.get_amount() != 0 ) { action delegate = create_delegate( creator, account_name, net, cpu, transfer); send_actions( { create, buyram, delegate } ); } else { From 6d7289fae6563f8d10d2a0df05d34d8c637687ca Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Thu, 31 May 2018 16:45:02 -0400 Subject: [PATCH 10/26] cleos newaccount : small fix #3684 --- programs/cleos/CLI11.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/programs/cleos/CLI11.hpp b/programs/cleos/CLI11.hpp index e0268afee66..11dbe1ccfec 100644 --- a/programs/cleos/CLI11.hpp +++ b/programs/cleos/CLI11.hpp @@ -861,14 +861,16 @@ class Option { ///@{ /// Set the option as required - Option *required(bool value = true) { - required_ = value; - description_ += " (required)"; + Option *required() { + if( !required_ ) { + description_ += " (required)"; + } + required_ = true; return this; } /// Support Plubmum term - Option *mandatory(bool value = true) { return required(value); } + Option *mandatory() { return required(); } /// Set the number of expected arguments (Flags bypass this) Option *expected(int value) { From 0ea4d392f358b939f6d0b483ef2c00ba9a916a78 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Thu, 31 May 2018 16:08:34 -0500 Subject: [PATCH 11/26] Add producer name to double-confirm assert --- libraries/chain/block_header_state.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chain/block_header_state.cpp b/libraries/chain/block_header_state.cpp index d741ace2de1..785e7c8ebfd 100644 --- a/libraries/chain/block_header_state.cpp +++ b/libraries/chain/block_header_state.cpp @@ -155,7 +155,7 @@ namespace eosio { namespace chain { auto itr = producer_to_last_produced.find(h.producer); if( itr != producer_to_last_produced.end() ) { - FC_ASSERT( itr->second < result.block_num - h.confirmed, "producer double-confirming known range" ); + FC_ASSERT( itr->second < result.block_num - h.confirmed, "producer ${prod} double-confirming known range", ("prod", h.producer) ); } // FC_ASSERT( result.header.block_mroot == h.block_mroot, "mismatch block merkle root" ); From 727044588de83844f9e8d6512d31b1c522182793 Mon Sep 17 00:00:00 2001 From: arhag Date: Thu, 31 May 2018 17:10:46 -0400 Subject: [PATCH 12/26] workaround boost::filesystem::copy bug #3687 --- libraries/fc/src/filesystem.cpp | 71 ++++++++++++++------------- plugins/chain_plugin/chain_plugin.cpp | 9 ++-- 2 files changed, 44 insertions(+), 36 deletions(-) diff --git a/libraries/fc/src/filesystem.cpp b/libraries/fc/src/filesystem.cpp index 89edc00a81c..2337d101794 100644 --- a/libraries/fc/src/filesystem.cpp +++ b/libraries/fc/src/filesystem.cpp @@ -18,7 +18,7 @@ #include #include #include -# ifdef FC_HAS_SIMPLE_FILE_LOCK +# ifdef FC_HAS_SIMPLE_FILE_LOCK #include #include # endif @@ -26,7 +26,7 @@ namespace fc { // when converting to and from a variant, store utf-8 in the variant - void to_variant( const fc::path& path_to_convert, variant& variant_output ) + void to_variant( const fc::path& path_to_convert, variant& variant_output ) { std::wstring wide_string = path_to_convert.generic_wstring(); std::string utf8_string; @@ -38,7 +38,7 @@ namespace fc { //v = path; } - void from_variant( const fc::variant& variant_to_convert, fc::path& path_output ) + void from_variant( const fc::variant& variant_to_convert, fc::path& path_output ) { std::wstring wide_string; fc::decodeUtf8(variant_to_convert.as_string(), &wide_string); @@ -128,7 +128,7 @@ namespace fc { const size_t maxPath = 32*1024; std::vector short_path; short_path.resize(maxPath + 1); - + wchar_t* buffer = short_path.data(); DWORD res = GetShortPathNameW(path.c_str(), buffer, maxPath); if(res != 0) @@ -140,7 +140,7 @@ namespace fc { } /** - * @todo use iterators instead of indexes for + * @todo use iterators instead of indexes for * faster performance */ fc::string path::windows_string()const { @@ -209,11 +209,11 @@ namespace fc { return *r._p != *l._p; } - + bool exists( const path& p ) { return boost::filesystem::exists(p); } - void create_directories( const path& p ) { + void create_directories( const path& p ) { try { - boost::filesystem::create_directories(p); + boost::filesystem::create_directories(p); } catch ( ... ) { FC_THROW( "Unable to create directories ${path}", ("path", p )("inner", fc::except_str() ) ); } @@ -242,9 +242,10 @@ namespace fc { } void remove_all( const path& p ) { boost::filesystem::remove_all(p); } - void copy( const path& f, const path& t ) { + void copy( const path& f, const path& t ) { + boost::system::error_code ec; try { - boost::filesystem::copy( boost::filesystem::path(f), boost::filesystem::path(t) ); + boost::filesystem::copy( boost::filesystem::path(f), boost::filesystem::path(t), ec ); } catch ( boost::system::system_error& e ) { FC_THROW( "Copy from ${srcfile} to ${dstfile} failed because ${reason}", ("srcfile",f)("dstfile",t)("reason",e.what() ) ); @@ -252,18 +253,22 @@ namespace fc { FC_THROW( "Copy from ${srcfile} to ${dstfile} failed", ("srcfile",f)("dstfile",t)("inner", fc::except_str() ) ); } + if( ec ) { + FC_THROW( "Copy from ${srcfile} to ${dstfile} failed because ${reason}", + ("srcfile",f)("dstfile",t)("reason", ec.category().name() ) ); + } } - void resize_file( const path& f, size_t t ) - { + void resize_file( const path& f, size_t t ) + { try { boost::filesystem::resize_file( f, t ); - } + } catch ( boost::system::system_error& e ) { FC_THROW( "Resize file '${f}' to size ${s} failed: ${reason}", ("f",f)("s",t)( "reason", e.what() ) ); - } - catch ( ... ) + } + catch ( ... ) { FC_THROW( "Resize file '${f}' to size ${s} failed: ${reason}", ("f",f)("s",t)( "reason", fc::except_str() ) ); @@ -276,15 +281,15 @@ namespace fc { void chmod( const path& p, int perm ) { #ifndef WIN32 - mode_t actual_perm = + mode_t actual_perm = ((perm & 0400) ? S_IRUSR : 0) | ((perm & 0200) ? S_IWUSR : 0) | ((perm & 0100) ? S_IXUSR : 0) - + | ((perm & 0040) ? S_IRGRP : 0) | ((perm & 0020) ? S_IWGRP : 0) | ((perm & 0010) ? S_IXGRP : 0) - + | ((perm & 0004) ? S_IROTH : 0) | ((perm & 0002) ? S_IWOTH : 0) | ((perm & 0001) ? S_IXOTH : 0) @@ -297,13 +302,13 @@ namespace fc { return; } - void rename( const path& f, const path& t ) { + void rename( const path& f, const path& t ) { try { - boost::filesystem::rename( boost::filesystem::path(f), boost::filesystem::path(t) ); + boost::filesystem::rename( boost::filesystem::path(f), boost::filesystem::path(t) ); } catch ( boost::system::system_error& ) { try{ - boost::filesystem::copy( boost::filesystem::path(f), boost::filesystem::path(t) ); - boost::filesystem::remove( boost::filesystem::path(f)); + boost::filesystem::copy( boost::filesystem::path(f), boost::filesystem::path(t) ); + boost::filesystem::remove( boost::filesystem::path(f)); } catch ( boost::system::system_error& e ) { FC_THROW( "Rename from ${srcfile} to ${dstfile} failed because ${reason}", ("srcfile",f)("dstfile",t)("reason",e.what() ) ); @@ -313,24 +318,24 @@ namespace fc { ("srcfile",f)("dstfile",t)("inner", fc::except_str() ) ); } } - void create_hard_link( const path& f, const path& t ) { + void create_hard_link( const path& f, const path& t ) { try { - boost::filesystem::create_hard_link( f, t ); + boost::filesystem::create_hard_link( f, t ); } catch ( ... ) { - FC_THROW( "Unable to create hard link from '${from}' to '${to}'", + FC_THROW( "Unable to create hard link from '${from}' to '${to}'", ( "from", f )("to",t)("exception", fc::except_str() ) ); } } - bool remove( const path& f ) { + bool remove( const path& f ) { try { - return boost::filesystem::remove( f ); + return boost::filesystem::remove( f ); } catch ( ... ) { FC_THROW( "Unable to remove '${path}'", ( "path", f )("exception", fc::except_str() ) ); } } - fc::path canonical( const fc::path& p ) { + fc::path canonical( const fc::path& p ) { try { - return boost::filesystem::canonical(p); + return boost::filesystem::canonical(p); } catch ( ... ) { FC_THROW( "Unable to resolve path '${path}'", ( "path", p )("exception", fc::except_str() ) ); } @@ -477,7 +482,7 @@ namespace fc { const fc::path& app_path() { #ifdef __APPLE__ - static fc::path appdir = [](){ return home_path() / "Library" / "Application Support"; }(); + static fc::path appdir = [](){ return home_path() / "Library" / "Application Support"; }(); #elif defined( WIN32 ) static fc::path appdir = [](){ wchar_t app_data_dir[MAX_PATH]; @@ -499,7 +504,7 @@ namespace fc { } -#ifdef FC_HAS_SIMPLE_FILE_LOCK +#ifdef FC_HAS_SIMPLE_FILE_LOCK class simple_lock_file::impl { public: @@ -517,7 +522,7 @@ namespace fc { bool try_lock(); void unlock(); }; - + simple_lock_file::impl::impl(const path& lock_file_path) : #ifdef _WIN32 file_handle(INVALID_HANDLE_VALUE), @@ -527,7 +532,7 @@ namespace fc { is_locked(false), lock_file_path(lock_file_path) {} - + simple_lock_file::impl::~impl() { unlock(); diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index 7208e6c51ec..368756828e1 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -294,9 +294,12 @@ void chain_plugin::plugin_initialize(const variables_map& options) { my->chain_config->reversible_cache_size, my->chain_config->blocks_dir/config::reversible_blocks_dir_name ) ) { ilog("Reversible blocks database was not corrupted. Copying from backup to blocks directory."); - fc::copy( backup_dir/config::reversible_blocks_dir_name, my->chain_config->blocks_dir/config::reversible_blocks_dir_name ); - fc::copy( backup_dir/"reversible/shared_memory.bin", my->chain_config->blocks_dir/"reversible/shared_memory.bin" ); - fc::copy( backup_dir/"reversible/shared_memory.meta", my->chain_config->blocks_dir/"reversible/shared_memory.meta" ); + fc::copy( backup_dir / config::reversible_blocks_dir_name, + my->chain_config->blocks_dir / config::reversible_blocks_dir_name ); + fc::copy( backup_dir / config::reversible_blocks_dir_name / "shared_memory.bin", + my->chain_config->blocks_dir/ config::reversible_blocks_dir_name / "shared_memory.bin" ); + fc::copy( backup_dir / config::reversible_blocks_dir_name / "shared_memory.meta", + my->chain_config->blocks_dir/ config::reversible_blocks_dir_name / "shared_memory.meta" ); } } } else if( options.at("replay-blockchain").as() ) { From 0c7a6369283599e33ffdd70e6b3813e7f76eb818 Mon Sep 17 00:00:00 2001 From: Khaled Al-Hassanieh Date: Thu, 31 May 2018 17:21:50 -0400 Subject: [PATCH 13/26] Fixed multiple warnings --- contracts/asserter/asserter.cpp | 2 +- contracts/eosio.bios/eosio.bios.hpp | 2 +- contracts/eosio.system/delegate_bandwidth.cpp | 3 +- contracts/eosio.system/voting.cpp | 2 +- contracts/exchange/exchange.cpp | 2 +- .../multi_index_test/multi_index_test.cpp | 2 +- contracts/proxy/proxy.cpp | 2 +- contracts/test_api/test_datastream.cpp | 33 +++++++++++++++++-- contracts/test_api/test_permission.cpp | 4 +-- contracts/test_api/test_transaction.cpp | 6 ++-- contracts/test_api_db/test_db.cpp | 6 ++-- .../test_api_mem/test_extended_memory.cpp | 2 +- libraries/chain/eosio_contract.cpp | 2 +- plugins/chain_plugin/chain_plugin.cpp | 2 +- unittests/bootseq_tests.cpp | 2 +- unittests/resource_limits_test.cpp | 2 +- unittests/wasm_tests.cpp | 4 +-- 17 files changed, 52 insertions(+), 26 deletions(-) diff --git a/contracts/asserter/asserter.cpp b/contracts/asserter/asserter.cpp index aee8199c139..f64ea509a1f 100644 --- a/contracts/asserter/asserter.cpp +++ b/contracts/asserter/asserter.cpp @@ -11,7 +11,7 @@ static int global_variable = 45; extern "C" { /// The apply method implements the dispatch of events to this contract - void apply( uint64_t receiver, uint64_t code, uint64_t action ) { + void apply( uint64_t /* receiver */, uint64_t code, uint64_t action ) { require_auth(code); if( code == N(asserter) ) { if( action == N(procassert) ) { diff --git a/contracts/eosio.bios/eosio.bios.hpp b/contracts/eosio.bios/eosio.bios.hpp index 79de6f5d0d5..e5d6801da85 100644 --- a/contracts/eosio.bios/eosio.bios.hpp +++ b/contracts/eosio.bios/eosio.bios.hpp @@ -15,7 +15,7 @@ namespace eosio { void setalimits( account_name account, uint64_t ram_bytes, uint64_t net_weight, uint64_t cpu_weight ) { require_auth( _self ); - set_resource_limits( account, ram_bytes, net_weight, cpu_weight ); + set_resource_limits( account, (int64_t)ram_bytes, (int64_t)net_weight, (int64_t)cpu_weight ); } void setglimits( uint64_t ram, uint64_t net, uint64_t cpu ) { diff --git a/contracts/eosio.system/delegate_bandwidth.cpp b/contracts/eosio.system/delegate_bandwidth.cpp index 06f234b45d9..f837f954fa3 100644 --- a/contracts/eosio.system/delegate_bandwidth.cpp +++ b/contracts/eosio.system/delegate_bandwidth.cpp @@ -169,7 +169,7 @@ namespace eosiosystem { tokens_out = es.convert( asset(bytes,S(0,RAM)), CORE_SYMBOL); }); - _gstate.total_ram_bytes_reserved -= bytes; + _gstate.total_ram_bytes_reserved -= static_cast(bytes); // bytes > 0 is asserted above _gstate.total_ram_stake -= tokens_out.amount; //// this shouldn't happen, but just in case it does we should prevent it @@ -190,7 +190,6 @@ namespace eosiosystem { } void validate_b1_vesting( int64_t stake ) { - const int64_t seconds_per_year = 60*60*24*365; const int64_t base_time = 1527811200; /// 2018-06-01 const int64_t max_claimable = 100'000'000'0000ll; const int64_t claimable = int64_t(max_claimable * double(now()-base_time) / (10*seconds_per_year) ); diff --git a/contracts/eosio.system/voting.cpp b/contracts/eosio.system/voting.cpp index a00e20547fd..5ee572d8525 100644 --- a/contracts/eosio.system/voting.cpp +++ b/contracts/eosio.system/voting.cpp @@ -100,7 +100,7 @@ namespace eosiosystem { bytes packed_schedule = pack(producers); if( set_proposed_producers( packed_schedule.data(), packed_schedule.size() ) >= 0 ) { - _gstate.last_producer_schedule_size = top_producers.size(); + _gstate.last_producer_schedule_size = static_cast( top_producers.size() ); } } diff --git a/contracts/exchange/exchange.cpp b/contracts/exchange/exchange.cpp index d68484011c5..f90076cf3e1 100644 --- a/contracts/exchange/exchange.cpp +++ b/contracts/exchange/exchange.cpp @@ -112,7 +112,7 @@ namespace eosio { void exchange::createx( account_name creator, asset initial_supply, - uint32_t fee, + uint32_t /* fee */, extended_asset base_deposit, extended_asset quote_deposit ) { diff --git a/contracts/multi_index_test/multi_index_test.cpp b/contracts/multi_index_test/multi_index_test.cpp index 19bbf653de8..4b3c5a96702 100644 --- a/contracts/multi_index_test/multi_index_test.cpp +++ b/contracts/multi_index_test/multi_index_test.cpp @@ -168,7 +168,7 @@ struct limit_order { namespace multi_index_test { extern "C" { /// The apply method implements the dispatch of events to this contract - void apply( uint64_t receiver, uint64_t code, uint64_t action ) { + void apply( uint64_t /* receiver */, uint64_t code, uint64_t action ) { require_auth(code); eosio_assert(eosio::dispatch(code, action), "Could not dispatch"); diff --git a/contracts/proxy/proxy.cpp b/contracts/proxy/proxy.cpp index 5217ae51356..ff27e5d5af2 100644 --- a/contracts/proxy/proxy.cpp +++ b/contracts/proxy/proxy.cpp @@ -33,7 +33,7 @@ namespace proxy { }; template - void apply_transfer(uint64_t receiver, account_name code, const T& transfer) { + void apply_transfer(uint64_t receiver, account_name /* code */, const T& transfer) { config code_config; const auto self = receiver; auto get_res = configs::get(code_config, self); diff --git a/contracts/test_api/test_datastream.cpp b/contracts/test_api/test_datastream.cpp index 0ae56b5f5c8..23fc769d2f8 100644 --- a/contracts/test_api/test_datastream.cpp +++ b/contracts/test_api/test_datastream.cpp @@ -1,6 +1,7 @@ #include #include +#include #include "test_api.hpp" @@ -17,6 +18,32 @@ struct testtype { } }; +template <> +struct testtype { + static void run(const double &v, const char *errmsg = "") { + char buf[128]; + eosio::datastream ds(buf, sizeof(buf)); + ds << v; + double v2; + ds.seekp(0); + ds >> v2; + eosio_assert(std::abs(v - v2) < 1e-20, errmsg); + } +}; + +template <> +struct testtype { + static void run(const float &v, const char *errmsg = "") { + char buf[128]; + eosio::datastream ds(buf, sizeof(buf)); + ds << v; + float v2; + ds.seekp(0); + ds >> v2; + eosio_assert(std::abs(v - v2) < float(1e-10), errmsg); + } +}; + void test_datastream::test_basic() { @@ -28,7 +55,7 @@ void test_datastream::test_basic() testtype::run(12345, "uint16"); testtype::run(-1234567890, "int32"); testtype::run(3234567890u, "uint32"); - testtype::run(0x8000000000000000ull, "int64"); + testtype::run((long long)0x8000000000000000ll, "int64"); testtype::run(0x7fffffffffffffffull, "uint64"); testtype::run(1.234f, "float"); testtype::run(0.333333333333333333, "double"); @@ -39,7 +66,7 @@ void test_datastream::test_basic() struct Pair { int a; double d; - bool operator==(const Pair &p) const { return a == p.a && d == p.d;} + bool operator==(const Pair &p) const { return a == p.a && std::abs(d - p.d) < 1e-20;} }; testtype::run({1, 1.23456}, "struct"); @@ -47,7 +74,7 @@ void test_datastream::test_basic() int a[2]; bool operator==(const StaticArray &o) const { return a[0] == o.a[0] && a[1] == o.a[1]; } }; - testtype::run({10,20}, "staticArray"); + testtype::run({10,20}, "StaticArray"); testtype::run("hello", "string"); diff --git a/contracts/test_api/test_permission.cpp b/contracts/test_api/test_permission.cpp index b899bab9166..824e8434b7d 100644 --- a/contracts/test_api/test_permission.cpp +++ b/contracts/test_api/test_permission.cpp @@ -58,7 +58,7 @@ struct test_permission_last_used_msg { EOSLIB_SERIALIZE( test_permission_last_used_msg, (account)(permission)(last_used_time) ) }; -void test_permission::test_permission_last_used(uint64_t receiver, uint64_t code, uint64_t action) { +void test_permission::test_permission_last_used(uint64_t /* receiver */, uint64_t code, uint64_t action) { (void)code; (void)action; using namespace eosio; @@ -68,7 +68,7 @@ void test_permission::test_permission_last_used(uint64_t receiver, uint64_t code eosio_assert( get_permission_last_used(params.account, params.permission) == params.last_used_time, "unexpected last used permission time" ); } -void test_permission::test_account_creation_time(uint64_t receiver, uint64_t code, uint64_t action) { +void test_permission::test_account_creation_time(uint64_t /* receiver */, uint64_t code, uint64_t action) { (void)code; (void)action; using namespace eosio; diff --git a/contracts/test_api/test_transaction.cpp b/contracts/test_api/test_transaction.cpp index bc172163c50..76cfc7653f5 100644 --- a/contracts/test_api/test_transaction.cpp +++ b/contracts/test_api/test_transaction.cpp @@ -274,7 +274,7 @@ void test_transaction::send_deferred_tx_with_dtt_action() { void test_transaction::cancel_deferred_transaction_success() { using namespace eosio; auto r = cancel_deferred( 0xffffffffffffffff ); //use the same id (0) as in send_deferred_transaction - eosio_assert( r, "transaction was not found" ); + eosio_assert( (bool)r, "transaction was not found" ); } void test_transaction::cancel_deferred_transaction_not_found() { @@ -310,9 +310,9 @@ void test_transaction::context_free_api() { extern "C" { int is_feature_active(int64_t); } void test_transaction::new_feature() { - eosio_assert(false == is_feature_active(N(newfeature)), "we should not have new features unless hardfork"); + eosio_assert(false == is_feature_active((int64_t)N(newfeature)), "we should not have new features unless hardfork"); } void test_transaction::active_new_feature() { - activate_feature(N(newfeature)); + activate_feature((int64_t)N(newfeature)); } diff --git a/contracts/test_api_db/test_db.cpp b/contracts/test_api_db/test_db.cpp index 1743a907da7..c342c514c50 100644 --- a/contracts/test_api_db/test_db.cpp +++ b/contracts/test_api_db/test_db.cpp @@ -159,7 +159,7 @@ void test_db::primary_i64_general(uint64_t receiver, uint64_t code, uint64_t act buffer_len = 20; len = db_get_i64(itr, value, 0); - len = db_get_i64(itr, value, len); + len = db_get_i64(itr, value, (uint32_t)len); value[len] = '\0'; std::string sfull(value); eosio_assert(sfull == "bob's info", "primary_i64_general - db_get_i64 - full"); @@ -448,7 +448,7 @@ void test_db::test_invalid_access(uint64_t receiver, uint64_t code, uint64_t act uint64_t pk = scope; int32_t itr = -1; - uint64_t value; + uint64_t value = 0; switch( ia.index ) { case 1: itr = db_idx64_find_primary(ia.code, scope, table, &value, pk); @@ -536,7 +536,7 @@ void test_db::idx_double_nan_lookup_fail(uint64_t receiver, uint64_t, uint64_t) } } -void test_db::misaligned_secondary_key256_tests(uint64_t receiver, uint64_t, uint64_t) { +void test_db::misaligned_secondary_key256_tests(uint64_t /* receiver */, uint64_t, uint64_t) { auto key = eosio::key256::make_from_word_sequence(0ULL, 0ULL, 0ULL, 42ULL); char* ptr = (char*)(&key); ptr += 1; diff --git a/contracts/test_api_mem/test_extended_memory.cpp b/contracts/test_api_mem/test_extended_memory.cpp index 7fac1eeae2b..48740a1421f 100644 --- a/contracts/test_api_mem/test_extended_memory.cpp +++ b/contracts/test_api_mem/test_extended_memory.cpp @@ -90,7 +90,7 @@ void test_extended_memory::test_page_memory_exceeded() { } void test_extended_memory::test_page_memory_negative_bytes() { - eosio_assert(reinterpret_cast(sbrk(-1)) == -1, "Should have errored for trying to remove memory"); + eosio_assert(reinterpret_cast(sbrk((uint32_t)-1)) == -1, "Should have errored for trying to remove memory"); } void test_extended_memory::test_initial_buffer() { diff --git a/libraries/chain/eosio_contract.cpp b/libraries/chain/eosio_contract.cpp index bc68278cb69..3c77772a310 100644 --- a/libraries/chain/eosio_contract.cpp +++ b/libraries/chain/eosio_contract.cpp @@ -146,7 +146,7 @@ void apply_eosio_setcode(apply_context& context) { db.modify( account, [&]( auto& a ) { /** TODO: consider whether a microsecond level local timestamp is sufficient to detect code version changes*/ - #warning TODO: update setcode message to include the hash, then validate it in validate + // TODO: update setcode message to include the hash, then validate it in validate a.last_code_update = context.control.pending_block_time(); a.code_version = code_id; a.code.resize( code_size ); diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index 7208e6c51ec..b17b5bb58f7 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -140,7 +140,7 @@ void chain_plugin::set_program_options(options_description& cli, options_descrip "Contract account added to contract blacklist (may specify multiple times)") ; -#warning TODO: rate limiting +// TODO: rate limiting /*("per-authorized-account-transaction-msg-rate-limit-time-frame-sec", bpo::value()->default_value(default_per_auth_account_time_frame_seconds), "The time frame, in seconds, that the per-authorized-account-transaction-msg-rate-limit is imposed over.") ("per-authorized-account-transaction-msg-rate-limit", bpo::value()->default_value(default_per_auth_account), diff --git a/unittests/bootseq_tests.cpp b/unittests/bootseq_tests.cpp index 69d8929c5b4..a763b21e3b6 100644 --- a/unittests/bootseq_tests.cpp +++ b/unittests/bootseq_tests.cpp @@ -332,7 +332,7 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) { votepro( N(minow1), {N(p1), N(p2)} ); -#warning Complete this test +// TODO: Complete this test } FC_LOG_AND_RETHROW() } diff --git a/unittests/resource_limits_test.cpp b/unittests/resource_limits_test.cpp index e7461209e49..76c0d541699 100644 --- a/unittests/resource_limits_test.cpp +++ b/unittests/resource_limits_test.cpp @@ -140,7 +140,7 @@ BOOST_AUTO_TEST_SUITE(resource_limits_test) */ -#warning restore weighted capacity cpu tests +// TODO: restore weighted capacity cpu tests #if 0 BOOST_FIXTURE_TEST_CASE(weighted_capacity_cpu, resource_limits_fixture) try { const vector weights = { 234, 511, 672, 800, 1213 }; diff --git a/unittests/wasm_tests.cpp b/unittests/wasm_tests.cpp index 3cbd3186193..fb2e0d90ddb 100644 --- a/unittests/wasm_tests.cpp +++ b/unittests/wasm_tests.cpp @@ -589,7 +589,7 @@ BOOST_FIXTURE_TEST_CASE(cpu_usage_tests, tester ) try { // test weighted cpu limit BOOST_FIXTURE_TEST_CASE(weighted_cpu_limit_tests, tester ) try { -#warning This test does not appear to be very robust. +// TODO This test does not appear to be very robust. resource_limits_manager mgr = control->get_mutable_resource_limits_manager(); create_accounts( {N(f_tests)} ); create_accounts( {N(acc2)} ); @@ -1713,7 +1713,7 @@ BOOST_FIXTURE_TEST_CASE( fuzz, TESTER ) try { } FC_LOG_AND_RETHROW() -#warning restore net_usage_tests +// TODO: restore net_usage_tests #if 0 BOOST_FIXTURE_TEST_CASE(net_usage_tests, tester ) try { int count = 0; From 9393d4e1a9dfbd9e1426d79acb0a5a41809330ac Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Thu, 31 May 2018 17:38:26 -0400 Subject: [PATCH 14/26] python tests fixed (cleos parameter name changed) #3684 --- tests/testUtils.py | 2 +- tutorials/bios-boot-tutorial/bios-boot-tutorial.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testUtils.py b/tests/testUtils.py index 6556d8bd2fb..7a80aba9c64 100755 --- a/tests/testUtils.py +++ b/tests/testUtils.py @@ -553,7 +553,7 @@ def getMessageFromDb(self, transId, retry=True, silentErrors=False): # Create & initialize account and return creation transactions. Return transaction json object def createInitializeAccount(self, account, creatorAccount, stakedDeposit=1000, waitForTransBlock=False): - cmd='%s %s system newaccount -j %s %s %s %s --stake-net "100 %s" --stake-cpu "100 %s" --buy-ram-EOS "100 %s"' % ( + cmd='%s %s system newaccount -j %s %s %s %s --stake-net "100 %s" --stake-cpu "100 %s" --buy-ram "100 %s"' % ( Utils.EosClientPath, self.endpointArgs, creatorAccount.name, account.name, account.ownerPublicKey, account.activePublicKey, CORE_SYMBOL, CORE_SYMBOL, CORE_SYMBOL) diff --git a/tutorials/bios-boot-tutorial/bios-boot-tutorial.py b/tutorials/bios-boot-tutorial/bios-boot-tutorial.py index 0f3c30904d2..ec7585ad14d 100755 --- a/tutorials/bios-boot-tutorial/bios-boot-tutorial.py +++ b/tutorials/bios-boot-tutorial/bios-boot-tutorial.py @@ -168,7 +168,7 @@ def createStakedAccounts(b, e): stakeCpu = stake - stakeNet print('%s: total funds=%s, ram=%s, net=%s, cpu=%s, unstaked=%s' % (a['name'], intToCurrency(a['funds']), intToCurrency(ramFunds), intToCurrency(stakeNet), intToCurrency(stakeCpu), intToCurrency(unstaked))) assert(funds == ramFunds + stakeNet + stakeCpu + unstaked) - run(args.cleos + 'system newaccount --transfer eosio %s %s --stake-net "%s" --stake-cpu "%s" --buy-ram-EOS "%s" ' % + run(args.cleos + 'system newaccount --transfer eosio %s %s --stake-net "%s" --stake-cpu "%s" --buy-ram "%s" ' % (a['name'], a['pub'], intToCurrency(stakeNet), intToCurrency(stakeCpu), intToCurrency(ramFunds))) run(args.cleos + 'transfer eosio %s "%s"' % (a['name'], intToCurrency(unstaked))) From 7c50721a8e40e9655ee888b00fd35d7b1a4f3e7d Mon Sep 17 00:00:00 2001 From: Bart Wyatt Date: Thu, 31 May 2018 17:47:16 -0400 Subject: [PATCH 15/26] its poor form to log private data --- plugins/producer_plugin/producer_plugin.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index eced3ff3d29..064ef1d3d63 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -504,7 +504,8 @@ void producer_plugin::plugin_initialize(const boost::program_options::variables_ try { auto key_id_to_wif_pair = dejsonify>(key_id_to_wif_pair_string); my->_signature_providers[key_id_to_wif_pair.first] = make_key_signature_provider(key_id_to_wif_pair.second); - wlog("\"private-key\" is DEPRECATED, use \"signature-provider=${pub}=KEY:${priv}\"", ("pub",key_id_to_wif_pair.first)("priv", key_id_to_wif_pair.second)); + auto blanked_privkey = std::string(std::string(key_id_to_wif_pair.second).size(), '*' ); + wlog("\"private-key\" is DEPRECATED, use \"signature-provider=${pub}=KEY:${priv}\"", ("pub",key_id_to_wif_pair.first)("priv", blanked_privkey)); } catch ( fc::exception& e ) { elog("Malformed private key pair"); } From 46f4652274a647bd683e127a01699798cfef19b5 Mon Sep 17 00:00:00 2001 From: Khaled Al-Hassanieh Date: Thu, 31 May 2018 17:50:43 -0400 Subject: [PATCH 16/26] Fixed multiple warnings - 2 --- contracts/test_ram_limit/test_ram_limit.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/contracts/test_ram_limit/test_ram_limit.cpp b/contracts/test_ram_limit/test_ram_limit.cpp index f66bd5b0ad7..136c27aa72c 100644 --- a/contracts/test_ram_limit/test_ram_limit.cpp +++ b/contracts/test_ram_limit/test_ram_limit.cpp @@ -8,6 +8,11 @@ #include #include +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wsign-conversion" +#pragma clang diagnostic ignored "-Wshorten-64-to-32" +#pragma clang diagnostic ignored "-Wsign-compare" + class test_ram_limit : public eosio::contract { public: const uint32_t FIVE_MINUTES = 5*60; @@ -73,4 +78,6 @@ class test_ram_limit : public eosio::contract { typedef eosio::multi_index< N(test.table), test> test_table; }; +#pragma clang diagnostic pop + EOSIO_ABI( test_ram_limit, (setentry)(rmentry)(printentry) ) From 09c10f29bc059bc4b170d765d40cdc62e7194d37 Mon Sep 17 00:00:00 2001 From: Bart Wyatt Date: Thu, 31 May 2018 18:40:23 -0400 Subject: [PATCH 17/26] upgrade to appbase which handles newlines in options --- libraries/appbase | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/appbase b/libraries/appbase index ffd9adb2b6a..44d7d88e561 160000 --- a/libraries/appbase +++ b/libraries/appbase @@ -1 +1 @@ -Subproject commit ffd9adb2b6a06790f273560b0505dd7477a90920 +Subproject commit 44d7d88e561cc9708bcac9453686c8d0f0ffa41e From e18a1564928bae3aba57a18a1c202a79e02d6590 Mon Sep 17 00:00:00 2001 From: Khaled Al-Hassanieh Date: Thu, 31 May 2018 18:42:11 -0400 Subject: [PATCH 18/26] Fixed multiple warnings - 3 --- contracts/test_api/test_action.cpp | 2 +- contracts/test_api/test_datastream.cpp | 4 ++-- contracts/test_api_db/test_db.cpp | 5 +++++ libraries/fc/src/io/json.cpp | 2 +- programs/eosio-applesedemo/main.cpp | 4 ++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/contracts/test_api/test_action.cpp b/contracts/test_api/test_action.cpp index 22d3f59c5d2..adc517453fa 100644 --- a/contracts/test_api/test_action.cpp +++ b/contracts/test_api/test_action.cpp @@ -152,7 +152,7 @@ void test_action::test_cf_action() { publication_time(); eosio_assert( false, "system_api should not be allowed" ); } else if ( cfa.payload == 210 ) { - send_inline( "hello", 6 ); + send_inline( (char*)"hello", 6 ); eosio_assert( false, "transaction_api should not be allowed" ); } else if ( cfa.payload == 211 ) { send_deferred( N(testapi), N(testapi), "hello", 6 ); diff --git a/contracts/test_api/test_datastream.cpp b/contracts/test_api/test_datastream.cpp index 23fc769d2f8..3ad663ec48a 100644 --- a/contracts/test_api/test_datastream.cpp +++ b/contracts/test_api/test_datastream.cpp @@ -74,13 +74,13 @@ void test_datastream::test_basic() int a[2]; bool operator==(const StaticArray &o) const { return a[0] == o.a[0] && a[1] == o.a[1]; } }; - testtype::run({10,20}, "StaticArray"); + testtype::run({{10,20}}, "StaticArray"); testtype::run("hello", "string"); testtype >::run({10,20,30}, "vector"); testtype >::run({}, "empty vector"); - testtype >::run({10,20,30}, "std::array"); + testtype >::run({{10,20,30}}, "std::array"); testtype >::run({{1,"apple"}, {2,"cat"}, {3,"panda"}}, "map"); testtype >::run({1, "abc", 3.3333}, "tuple"); } diff --git a/contracts/test_api_db/test_db.cpp b/contracts/test_api_db/test_db.cpp index c342c514c50..d9ded6e233c 100644 --- a/contracts/test_api_db/test_db.cpp +++ b/contracts/test_api_db/test_db.cpp @@ -536,6 +536,9 @@ void test_db::idx_double_nan_lookup_fail(uint64_t receiver, uint64_t, uint64_t) } } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcast-align" + void test_db::misaligned_secondary_key256_tests(uint64_t /* receiver */, uint64_t, uint64_t) { auto key = eosio::key256::make_from_word_sequence(0ULL, 0ULL, 0ULL, 42ULL); char* ptr = (char*)(&key); @@ -545,3 +548,5 @@ void test_db::misaligned_secondary_key256_tests(uint64_t /* receiver */, uint64_ // test that find_primary doesn't crash on unaligned data db_idx256_find_primary( N(testapi), N(testtable), N(testapi), (eosio::key256*)(ptr), 2, 0); } + +#pragma clang diagnostic pop diff --git a/libraries/fc/src/io/json.cpp b/libraries/fc/src/io/json.cpp index 57c6462aa0c..1ef8c786245 100644 --- a/libraries/fc/src/io/json.cpp +++ b/libraries/fc/src/io/json.cpp @@ -657,7 +657,7 @@ namespace fc return; } default: - FC_THROW_EXCEPTION( fc::invalid_arg_exception, "Unsupported variant type: " + v.get_type() ); + FC_THROW_EXCEPTION( fc::invalid_arg_exception, "Unsupported variant type: " + std::to_string( v.get_type() ) ); } } diff --git a/programs/eosio-applesedemo/main.cpp b/programs/eosio-applesedemo/main.cpp index ca0018c532d..f43d83c3805 100644 --- a/programs/eosio-applesedemo/main.cpp +++ b/programs/eosio-applesedemo/main.cpp @@ -34,7 +34,7 @@ CFDictionaryRef CopyOurKeyInfo() { CFDictionaryRef keyAttrDic = CFDictionaryCreate(nullptr, keyAttrKeys, keyAttrValues, sizeof(keyAttrKeys)/sizeof(keyAttrKeys[0]), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CFDictionaryRef attributes = nullptr; - OSStatus ret = SecItemCopyMatching(keyAttrDic, (CFTypeRef*)&attributes); + SecItemCopyMatching(keyAttrDic, (CFTypeRef*)&attributes); CFRelease(keyAttrDic); return attributes; @@ -296,4 +296,4 @@ int main(int argc, char* argv[]) { cout << all_desc << endl; return 0; -} \ No newline at end of file +} From 4c70dea39238aa5406895ab7e4e226e62933cda2 Mon Sep 17 00:00:00 2001 From: Todd Fleming Date: Thu, 31 May 2018 18:52:24 -0400 Subject: [PATCH 19/26] bios-boot-tutorial: fix unlock timeout #3698 --- tutorials/bios-boot-tutorial/bios-boot-tutorial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/bios-boot-tutorial/bios-boot-tutorial.py b/tutorials/bios-boot-tutorial/bios-boot-tutorial.py index ec7585ad14d..1c0cf5998d0 100755 --- a/tutorials/bios-boot-tutorial/bios-boot-tutorial.py +++ b/tutorials/bios-boot-tutorial/bios-boot-tutorial.py @@ -13,7 +13,7 @@ args = None logFile = None -unlockTimeout = 99999999999 +unlockTimeout = 999999999 fastUnstakeSystem = './fast.refund/eosio.system/eosio.system.wasm' systemAccounts = [ From fcc50076256a1399e51767703467357d0e067dfb Mon Sep 17 00:00:00 2001 From: Khaled Al-Hassanieh Date: Thu, 31 May 2018 18:54:34 -0400 Subject: [PATCH 20/26] Fixed multiple warnings - 4 --- contracts/eosio.system/eosio.system.hpp | 4 ++-- contracts/exchange/test_exchange.cpp | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/contracts/eosio.system/eosio.system.hpp b/contracts/eosio.system/eosio.system.hpp index eab5266599a..9a495e5722c 100644 --- a/contracts/eosio.system/eosio.system.hpp +++ b/contracts/eosio.system/eosio.system.hpp @@ -26,8 +26,8 @@ namespace eosiosystem { int64_t high_bid = 0; ///< negative high_bid == closed auction waiting to be claimed uint64_t last_bid_time = 0; - auto primary_key()const { return newname; } - uint64_t by_high_bid()const { return -high_bid; } + auto primary_key()const { return newname; } + uint64_t by_high_bid()const { return static_cast(-high_bid); } }; typedef eosio::multi_index< N(namebids), name_bid, diff --git a/contracts/exchange/test_exchange.cpp b/contracts/exchange/test_exchange.cpp index f05948da961..a6a1f9dae96 100644 --- a/contracts/exchange/test_exchange.cpp +++ b/contracts/exchange/test_exchange.cpp @@ -344,6 +344,7 @@ exchange_state borrow( const exchange_state& current, account_name user, /// remove amount_to_borrow from exchange /// lock collateral for user /// simulate complete margin calls + return exchange_state(); } exchange_state cover( const exchange_state& current, account_name user, @@ -357,14 +358,14 @@ exchange_state cover( const exchange_state& current, account_name user, // - if borrowed from user, reduce borrowed from user /// calculate new call price and update least collateralized position /// simulate complete margin calls - + return exchange_state(); } exchange_state lend( const exchange_state& current, account_name lender, asset asset_to_lend ) { /// add to pool of funds available for lending and buy SHARES in /// interest pool at current rate. - + return exchange_state(); } exchange_state unlend( const exchange_state& current, account_name lender, @@ -372,7 +373,8 @@ exchange_state unlend( const exchange_state& current, account_name lender, /// sell shares in interest pool at current rate /// this is permitable so long as total borrowed from users remains less than /// total available to lend. Otherwise, margin is called on the least - /// collateralized position. + /// collateralized position. + return exchange_state(); } From 500ad183baa1dc39640ab046009029df1030ac81 Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Thu, 31 May 2018 18:56:51 -0400 Subject: [PATCH 21/26] default_target_block_cpu_usage_pct increased to 10% #3694 --- libraries/chain/include/eosio/chain/config.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chain/include/eosio/chain/config.hpp b/libraries/chain/include/eosio/chain/config.hpp index d9c7fc31f33..dc4d608c6de 100644 --- a/libraries/chain/include/eosio/chain/config.hpp +++ b/libraries/chain/include/eosio/chain/config.hpp @@ -69,7 +69,7 @@ const static uint32_t default_context_free_discount_net_usage_den = 100; const static uint32_t transaction_id_net_usage = 32; // 32 bytes for the size of a transaction id const static uint32_t default_max_block_cpu_usage = 200'000; /// max block cpu usage in microseconds -const static uint32_t default_target_block_cpu_usage_pct = percent_1; /// target 1000 TPS +const static uint32_t default_target_block_cpu_usage_pct = 10 * percent_1; const static uint32_t default_max_transaction_cpu_usage = 3*default_max_block_cpu_usage/4; /// max trx cpu usage in microseconds const static uint32_t default_min_transaction_cpu_usage = 100; /// min trx cpu usage in microseconds (10000 TPS equiv) From c0bbde78aca6b2c2b632be608b7e40df8b8909ea Mon Sep 17 00:00:00 2001 From: Khaled Al-Hassanieh Date: Thu, 31 May 2018 19:27:43 -0400 Subject: [PATCH 22/26] Test rmvproducer - 2 --- unittests/eosio.system_tests.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/unittests/eosio.system_tests.cpp b/unittests/eosio.system_tests.cpp index b1812b59ac3..f06dc2fe7de 100644 --- a/unittests/eosio.system_tests.cpp +++ b/unittests/eosio.system_tests.cpp @@ -1509,13 +1509,37 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni push_action(producer_names[rmv_index + 2], N(rmvproducer), mvo()("producer", prod_name) ) ); BOOST_REQUIRE_EQUAL( success(), push_action(config::system_account_name, N(rmvproducer), mvo()("producer", prod_name) ) ); + { + bool rest_didnt_produce = true; + for (uint32_t i = 21; i < producer_names.size(); ++i) { + if (0 < get_producer_info(producer_names[i])["unpaid_blocks"].as()) { + rest_didnt_produce = false; + } + } + BOOST_REQUIRE(rest_didnt_produce); + } + produce_blocks(3 * 21 * 12); info = get_producer_info(prod_name); + const uint32_t init_unpaid_blocks = info["unpaid_blocks"].as(); BOOST_REQUIRE( !info["is_active"].as() ); BOOST_REQUIRE( fc::crypto::public_key() == fc::crypto::public_key(info["producer_key"].as_string()) ); BOOST_REQUIRE_EQUAL( wasm_assert_msg("producer does not have an active key"), push_action(prod_name, N(claimrewards), mvo()("owner", prod_name) ) ); - + produce_blocks(3 * 21 * 12); + BOOST_REQUIRE_EQUAL( init_unpaid_blocks, get_producer_info(prod_name)["unpaid_blocks"].as() ); + { + bool prod_was_replaced = false; + for (uint32_t i = 21; i < producer_names.size(); ++i) { + if (0 < get_producer_info(producer_names[i])["unpaid_blocks"].as()) { + prod_was_replaced = true; + } + } + BOOST_REQUIRE(prod_was_replaced); + } + } + + { BOOST_REQUIRE_EQUAL( wasm_assert_msg("producer not found"), push_action( config::system_account_name, N(rmvproducer), mvo()("producer", "nonexistingp") ) ); } From 691b9de257f50ec6107c0b97f16a670593c29661 Mon Sep 17 00:00:00 2001 From: Khaled Al-Hassanieh Date: Thu, 31 May 2018 20:00:38 -0400 Subject: [PATCH 23/26] Small change in eosio.bios --- contracts/eosio.bios/eosio.bios.hpp | 4 ++-- unittests/wasm_tests.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/eosio.bios/eosio.bios.hpp b/contracts/eosio.bios/eosio.bios.hpp index e5d6801da85..ca0dc57f792 100644 --- a/contracts/eosio.bios/eosio.bios.hpp +++ b/contracts/eosio.bios/eosio.bios.hpp @@ -13,9 +13,9 @@ namespace eosio { set_privileged( account, ispriv ); } - void setalimits( account_name account, uint64_t ram_bytes, uint64_t net_weight, uint64_t cpu_weight ) { + void setalimits( account_name account, int64_t ram_bytes, int64_t net_weight, int64_t cpu_weight ) { require_auth( _self ); - set_resource_limits( account, (int64_t)ram_bytes, (int64_t)net_weight, (int64_t)cpu_weight ); + set_resource_limits( account, ram_bytes, net_weight, cpu_weight ); } void setglimits( uint64_t ram, uint64_t net, uint64_t cpu ) { diff --git a/unittests/wasm_tests.cpp b/unittests/wasm_tests.cpp index fb2e0d90ddb..57d8f34af82 100644 --- a/unittests/wasm_tests.cpp +++ b/unittests/wasm_tests.cpp @@ -589,7 +589,7 @@ BOOST_FIXTURE_TEST_CASE(cpu_usage_tests, tester ) try { // test weighted cpu limit BOOST_FIXTURE_TEST_CASE(weighted_cpu_limit_tests, tester ) try { -// TODO This test does not appear to be very robust. +// TODO Increase the robustness of this test. resource_limits_manager mgr = control->get_mutable_resource_limits_manager(); create_accounts( {N(f_tests)} ); create_accounts( {N(acc2)} ); From 9115d36c88a3682f71e91504e50a5f16bc68c18d Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Thu, 31 May 2018 20:51:10 -0400 Subject: [PATCH 24/26] Sanitize the return value of memcmp() to wasm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For wasm’s memcmp, we farm it out to the system's memcmp, however the c specification states that memcmp only needs to return less than 0, 0, or greater than 0. It's implementation specific how much less than or greater than 0 it is. So, sanitize the return value to only ever be -1, 0, 1. --- libraries/chain/wasm_interface.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/chain/wasm_interface.cpp b/libraries/chain/wasm_interface.cpp index 007b6b873c3..245c47d46c6 100644 --- a/libraries/chain/wasm_interface.cpp +++ b/libraries/chain/wasm_interface.cpp @@ -1281,7 +1281,12 @@ class memory_api : public context_aware_api { } int memcmp( array_ptr dest, array_ptr src, size_t length) { - return ::memcmp(dest, src, length); + int ret = ::memcmp(dest, src, length); + if(ret < 0) + return -1; + if(ret > 0) + return 1; + return 0; } char* memset( array_ptr dest, int value, size_t length ) { From 80d5f1786cce99f239f68612d61c9e9fbd6a06d2 Mon Sep 17 00:00:00 2001 From: enumivo Date: Fri, 1 Jun 2018 10:04:21 +0800 Subject: [PATCH 25/26] update appbase --- libraries/appbase | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/appbase b/libraries/appbase index 490959139d6..10d644c3bf2 160000 --- a/libraries/appbase +++ b/libraries/appbase @@ -1 +1 @@ -Subproject commit 490959139d6f58e6b0fc4fde3e965f347c26a1f4 +Subproject commit 10d644c3bf245ae91fa5f75075edd5ccf06a32de From 2176b0220d75a40a7a72ac19c75ab6f3f188ce48 Mon Sep 17 00:00:00 2001 From: enumivo Date: Fri, 1 Jun 2018 10:15:39 +0800 Subject: [PATCH 26/26] update SYS --- Docker/Dockerfile | 2 +- Docker/README.md | 2 +- contracts/enumivo.system/enumivo.system-buyrambytes-rc.md | 4 ++-- .../enumivo.system-clause-constitution-rc.md | 2 +- enumivo_build.sh | 2 +- tests/testUtils.py | 8 ++++---- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 74c1ad300fd..9b3d5e45890 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,6 +1,6 @@ FROM enumivo/builder as builder ARG branch=master -ARG symbol=SYS +ARG symbol=ENU RUN git clone -b $branch https://github.com/enumivo/enumivo.git --recursive \ && cd enumivo && echo "$branch:$(git rev-parse HEAD)" > /etc/enumivo-version \ diff --git a/Docker/README.md b/Docker/README.md index b4a2e8c574e..3bba6a293ee 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -26,7 +26,7 @@ The above will build off the most recent commit to the master branch by default. docker build -t enumivo/enumivo:dawn-v4.0.0 --build-arg branch=dawn-v4.0.0 . ``` -By default, the symbol in enumivo.system is set to SYS. You can override this using the symbol argument while building the docker image. +By default, the symbol in enumivo.system is set to ENU. You can override this using the symbol argument while building the docker image. ```bash docker build -t enumivo/enumivo --build-arg symbol= . diff --git a/contracts/enumivo.system/enumivo.system-buyrambytes-rc.md b/contracts/enumivo.system/enumivo.system-buyrambytes-rc.md index 63a60e83f58..79f5b1af844 100644 --- a/contracts/enumivo.system/enumivo.system-buyrambytes-rc.md +++ b/contracts/enumivo.system/enumivo.system-buyrambytes-rc.md @@ -4,9 +4,9 @@ This action will attempt to reserve about {{bytes}} bytes of RAM on behalf of {{receiver}}. -{{buyer}} authorizes this conrtact to transfer sufficient SYS tokens to buy the RAM based upon the current price as determined by the market maker algorithm. +{{buyer}} authorizes this conrtact to transfer sufficient ENU tokens to buy the RAM based upon the current price as determined by the market maker algorithm. -{{buyer}} accepts that a 0.5% fee will be charged on the SYS spent and that the actual RAM received may be slightly less than requested due to the approximations necessary to enable this service. +{{buyer}} accepts that a 0.5% fee will be charged on the ENU spent and that the actual RAM received may be slightly less than requested due to the approximations necessary to enable this service. {{buyer}} accepts that a 0.5% fee will be charged if and when they sell the RAM received. {{buyer}} accepts that rounding errors resulting from limits of computational precision may result in less RAM being allocated. {{buyer}} acknowledges that the supply of RAM may be increased at any time up to the limits of off-the-shelf computer equipment and that this may result in RAM selling for less than purchase price. diff --git a/contracts/enumivo.system/enumivo.system-clause-constitution-rc.md b/contracts/enumivo.system/enumivo.system-clause-constitution-rc.md index 0f4057b026a..f57a332849a 100644 --- a/contracts/enumivo.system/enumivo.system-clause-constitution-rc.md +++ b/contracts/enumivo.system/enumivo.system-clause-constitution-rc.md @@ -13,7 +13,7 @@ The Members grant the right of contract and of private property to each other, t No Member shall offer nor accept anything of value in exchange for a vote of any type, nor shall any Member unduly influence the vote of another. # Article V - No Fiduciary -No Member nor SYS token holder shall have fiduciary responsibility to support the value of the SYS token. The Members do not authorize anyone to hold assets, borrow, nor contract on behalf of SYS token holders collectively. This blockchain has no owners, managers or fiduciaries; therefore, no Member shall have beneficial interest in more than 10% of the SYS token supply. +No Member nor ENU token holder shall have fiduciary responsibility to support the value of the ENU token. The Members do not authorize anyone to hold assets, borrow, nor contract on behalf of ENU token holders collectively. This blockchain has no owners, managers or fiduciaries; therefore, no Member shall have beneficial interest in more than 20% of the ENU token supply. # Article VI - Restitution Each Member agrees that penalties for breach of contract may include, but are not limited to, fines, loss of account, and other restitution. diff --git a/enumivo_build.sh b/enumivo_build.sh index 679019361c5..d4f35450e5b 100755 --- a/enumivo_build.sh +++ b/enumivo_build.sh @@ -52,7 +52,7 @@ DISK_MIN=20 DOXYGEN=false ENABLE_COVERAGE_TESTING=false - CORE_SYMBOL_NAME="SYS" + CORE_SYMBOL_NAME="ENU" TEMP_DIR="/tmp" TIME_BEGIN=$( date -u +%s ) VERSION=1.2 diff --git a/tests/testUtils.py b/tests/testUtils.py index 769b3dfa8a1..8f2f8d6a5ab 100755 --- a/tests/testUtils.py +++ b/tests/testUtils.py @@ -761,7 +761,7 @@ def transferFunds(self, source, destination, amountStr, memo="memo", force=False @staticmethod def currencyStrToInt(balanceStr): - """Converts currency string of form "12.3456 SYS" to int 123456""" + """Converts currency string of form "12.3456 ENU" to int 123456""" assert(isinstance(balanceStr, str)) balanceStr=balanceStr.split()[0] #balance=int(decimal.Decimal(balanceStr[1:])*10000) @@ -771,7 +771,7 @@ def currencyStrToInt(balanceStr): @staticmethod def currencyIntToStr(balance, symbol): - """Converts currency int of form 123456 to string "12.3456 SYS" where SYS is symbol string""" + """Converts currency int of form 123456 to string "12.3456 ENU" where ENU is symbol string""" assert(isinstance(balance, int)) assert(isinstance(symbol, str)) balanceStr="%.04f %s" % (balance/10000.0, symbol) @@ -779,7 +779,7 @@ def currencyIntToStr(balance, symbol): return balanceStr def validateFunds(self, initialBalances, transferAmount, source, accounts): - """Validate each account has the expected SYS balance. Validate cumulative balance matches expectedTotal.""" + """Validate each account has the expected ENU balance. Validate cumulative balance matches expectedTotal.""" assert(source) assert(isinstance(source, Account)) assert(accounts) @@ -1752,7 +1752,7 @@ def validateSpreadFunds(self, initialBalances, transferAmount, source, accounts) def spreadFundsAndValidate(self, transferAmount=1): """Sprays 'transferAmount' funds across configured accounts and validates action. The spray is done in a trickle down fashion with account 1 - receiving transferAmount*n SYS and forwarding x-transferAmount funds. Transfer actions are spread round-robin across the cluster to vaidate system cohesiveness.""" + receiving transferAmount*n ENU and forwarding x-transferAmount funds. Transfer actions are spread round-robin across the cluster to vaidate system cohesiveness.""" if Utils.Debug: Utils.Print("Get initial system balances.") initialBalances=self.nodes[0].getEnuBalances([self.defproduceraAccount] + self.accounts)