From a4906b5758aeebe8782604ca9396697d7799681d Mon Sep 17 00:00:00 2001 From: John Jones Date: Wed, 1 May 2019 06:38:15 -0500 Subject: [PATCH 01/25] Removed hf 516 --- libraries/chain/account_evaluator.cpp | 10 ---------- libraries/chain/hardfork.d/516.hf | 4 ---- tests/tests/operation_tests2.cpp | 2 -- 3 files changed, 16 deletions(-) delete mode 100644 libraries/chain/hardfork.d/516.hf diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index 674de46c43..598e400182 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -120,11 +120,6 @@ void verify_account_votes( const database& db, const account_options& options ) void_result account_create_evaluator::do_evaluate( const account_create_operation& op ) { try { database& d = db(); - if( d.head_block_time() < HARDFORK_516_TIME ) - { - FC_ASSERT( !op.extensions.value.owner_special_authority.valid() ); - FC_ASSERT( !op.extensions.value.active_special_authority.valid() ); - } FC_ASSERT( fee_paying_account->is_lifetime_member(), "Only Lifetime members may register an account." ); FC_ASSERT( op.referrer(d).is_member(d.head_block_time()), "The referrer must be either a lifetime or annual subscriber." ); @@ -268,11 +263,6 @@ object_id_type account_create_evaluator::do_apply( const account_create_operatio void_result account_update_evaluator::do_evaluate( const account_update_operation& o ) { try { database& d = db(); - if( d.head_block_time() < HARDFORK_516_TIME ) - { - FC_ASSERT( !o.extensions.value.owner_special_authority.valid() ); - FC_ASSERT( !o.extensions.value.active_special_authority.valid() ); - } try { diff --git a/libraries/chain/hardfork.d/516.hf b/libraries/chain/hardfork.d/516.hf deleted file mode 100644 index 8085972402..0000000000 --- a/libraries/chain/hardfork.d/516.hf +++ /dev/null @@ -1,4 +0,0 @@ -// #516 Special authorities -#ifndef HARDFORK_516_TIME -#define HARDFORK_516_TIME (fc::time_point_sec( 1456250400 )) -#endif diff --git a/tests/tests/operation_tests2.cpp b/tests/tests/operation_tests2.cpp index 3d50c66e56..bb7d153a53 100644 --- a/tests/tests/operation_tests2.cpp +++ b/tests/tests/operation_tests2.cpp @@ -2009,8 +2009,6 @@ BOOST_AUTO_TEST_CASE( top_n_special ) { ACTORS( (alice)(bob)(chloe)(dan)(izzy)(stan) ); - generate_blocks( HARDFORK_516_TIME ); - try { { From 36276852c4209ed65e502bd67a9e1362bbb60910 Mon Sep 17 00:00:00 2001 From: John Jones Date: Thu, 2 May 2019 14:40:26 -0500 Subject: [PATCH 02/25] Partial cleanup of HF 1268 --- libraries/chain/account_evaluator.cpp | 11 --- libraries/chain/asset_evaluator.cpp | 18 ---- libraries/chain/proposal_evaluator.cpp | 17 ---- libraries/chain/vesting_balance_evaluator.cpp | 13 --- tests/tests/market_fee_sharing_tests.cpp | 91 ------------------- 5 files changed, 150 deletions(-) diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index 598e400182..4480d48530 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -208,17 +208,6 @@ object_id_type account_create_evaluator::do_apply( const account_create_operatio } }); - /* - if( has_small_percent ) - { - wlog( "Account affected by #453 registered in block ${n}: ${na} reg=${reg} ref=${ref}:${refp} ltr=${ltr}:${ltrp}", - ("n", db().head_block_num()) ("na", new_acnt_object.id) - ("reg", o.registrar) ("ref", o.referrer) ("ltr", new_acnt_object.lifetime_referrer) - ("refp", new_acnt_object.referrer_rewards_percentage) ("ltrp", new_acnt_object.lifetime_referrer_fee_percentage) ); - wlog( "Affected account object is ${o}", ("o", new_acnt_object) ); - } - */ - const auto& dynamic_properties = d.get_dynamic_global_properties(); d.modify(dynamic_properties, [](dynamic_global_property_object& p) { ++p.accounts_registered_this_interval; diff --git a/libraries/chain/asset_evaluator.cpp b/libraries/chain/asset_evaluator.cpp index e970790c7d..19022929b2 100644 --- a/libraries/chain/asset_evaluator.cpp +++ b/libraries/chain/asset_evaluator.cpp @@ -35,20 +35,6 @@ #include namespace graphene { namespace chain { -namespace detail { - // TODO review and remove code below and links to it after hf_1268 - void check_asset_options_hf_1268(const fc::time_point_sec& block_time, const asset_options& options) - { - if( block_time < HARDFORK_1268_TIME ) - { - FC_ASSERT( !options.extensions.value.reward_percent.valid(), - "Asset extension reward percent is only available after HARDFORK_1268_TIME!"); - - FC_ASSERT( !options.extensions.value.whitelist_market_fee_sharing.valid(), - "Asset extension whitelist_market_fee_sharing is only available after HARDFORK_1268_TIME!"); - } - } -} void_result asset_create_evaluator::do_evaluate( const asset_create_operation& op ) { try { @@ -59,8 +45,6 @@ void_result asset_create_evaluator::do_evaluate( const asset_create_operation& o FC_ASSERT( op.common_options.whitelist_authorities.size() <= chain_parameters.maximum_asset_whitelist_authorities ); FC_ASSERT( op.common_options.blacklist_authorities.size() <= chain_parameters.maximum_asset_whitelist_authorities ); - detail::check_asset_options_hf_1268(d.head_block_time(), op.common_options); - // Check that all authorities do exist for( auto id : op.common_options.whitelist_authorities ) d.get_object(id); @@ -288,8 +272,6 @@ void_result asset_update_evaluator::do_evaluate(const asset_update_operation& o) validate_new_issuer( d, a, *o.new_issuer ); } - detail::check_asset_options_hf_1268(d.head_block_time(), o.new_options); - if( (d.head_block_time() < HARDFORK_572_TIME) || (a.dynamic_asset_data_id(d).current_supply != 0) ) { // new issuer_permissions must be subset of old issuer permissions diff --git a/libraries/chain/proposal_evaluator.cpp b/libraries/chain/proposal_evaluator.cpp index 4e9a3ea656..e471cbc476 100644 --- a/libraries/chain/proposal_evaluator.cpp +++ b/libraries/chain/proposal_evaluator.cpp @@ -28,11 +28,6 @@ namespace graphene { namespace chain { -namespace detail { - void check_asset_options_hf_1268(const fc::time_point_sec& block_time, const asset_options& options); - void check_vesting_balance_policy_hf_1268(const fc::time_point_sec& block_time, const vesting_policy_initializer& policy); -} - struct proposal_operation_hardfork_visitor { typedef void result_type; @@ -57,18 +52,6 @@ struct proposal_operation_hardfork_visitor && (*(v.delta_debt.asset_id( db ).bitasset_data_id))( db ).is_prediction_market ) , "Soft fork - preventing proposal with call_order_update!" ); } - // hf_1268 - void operator()(const graphene::chain::asset_create_operation &v) const { - detail::check_asset_options_hf_1268(block_time, v.common_options); - } - // hf_1268 - void operator()(const graphene::chain::asset_update_operation &v) const { - detail::check_asset_options_hf_1268(block_time, v.new_options); - } - // hf_1268 - void operator()(const graphene::chain::vesting_balance_create_operation &v) const { - detail::check_vesting_balance_policy_hf_1268(block_time, v.policy); - } // hf_588 // issue #588 // diff --git a/libraries/chain/vesting_balance_evaluator.cpp b/libraries/chain/vesting_balance_evaluator.cpp index 5e99c316ea..6d3891758c 100644 --- a/libraries/chain/vesting_balance_evaluator.cpp +++ b/libraries/chain/vesting_balance_evaluator.cpp @@ -29,17 +29,6 @@ #include namespace graphene { namespace chain { -namespace detail { - // TODO review and remove code below and links to it after hf_1268 - void check_vesting_balance_policy_hf_1268(const fc::time_point_sec& block_time, const vesting_policy_initializer& policy) - { - if( block_time < HARDFORK_1268_TIME ) - { - FC_ASSERT( !policy.is_type(), - "Instant vesting policy is only available after HARDFORK_1268_TIME!"); - } - } -} void_result vesting_balance_create_evaluator::do_evaluate( const vesting_balance_create_operation& op ) { try { @@ -54,8 +43,6 @@ void_result vesting_balance_create_evaluator::do_evaluate( const vesting_balance FC_ASSERT( d.get_balance( creator_account.id, op.amount.asset_id ) >= op.amount ); FC_ASSERT( !op.amount.asset_id(d).is_transfer_restricted() ); - detail::check_vesting_balance_policy_hf_1268(d.head_block_time(), op.policy); - return void_result(); } FC_CAPTURE_AND_RETHROW( (op) ) } diff --git a/tests/tests/market_fee_sharing_tests.cpp b/tests/tests/market_fee_sharing_tests.cpp index 2ba95b2c5b..33205eb392 100644 --- a/tests/tests/market_fee_sharing_tests.cpp +++ b/tests/tests/market_fee_sharing_tests.cpp @@ -114,31 +114,6 @@ struct reward_database_fixture : database_fixture BOOST_FIXTURE_TEST_SUITE( fee_sharing_tests, reward_database_fixture ) -BOOST_AUTO_TEST_CASE(cannot_create_asset_with_additional_options_before_hf) -{ - try - { - ACTOR(issuer); - - price price(asset(1, asset_id_type(1)), asset(1)); - uint16_t market_fee_percent = 100; - - additional_asset_options_t options; - options.value.reward_percent = 100; - options.value.whitelist_market_fee_sharing = flat_set{issuer_id}; - - GRAPHENE_CHECK_THROW(create_user_issued_asset("USD", - issuer, - charge_market_fee, - price, - 2, - market_fee_percent, - options), - fc::assert_exception); - } - FC_LOG_AND_RETHROW() -} - BOOST_AUTO_TEST_CASE(create_asset_with_additional_options_after_hf) { try @@ -193,22 +168,6 @@ BOOST_AUTO_TEST_CASE(create_asset_with_additional_options_after_hf) FC_LOG_AND_RETHROW() } -BOOST_AUTO_TEST_CASE(cannot_update_additional_options_before_hf) -{ - try - { - ACTOR(issuer); - - asset_object usd_asset = create_user_issued_asset("USD", issuer, charge_market_fee); - - flat_set whitelist = {issuer_id}; - GRAPHENE_CHECK_THROW( - update_asset(issuer_id, issuer_private_key, usd_asset.get_id(), 40, whitelist), - fc::assert_exception ); - } - FC_LOG_AND_RETHROW() -} - BOOST_AUTO_TEST_CASE(update_additional_options_after_hf) { try @@ -608,15 +567,6 @@ BOOST_AUTO_TEST_CASE(create_asset_via_proposal_test) prop.expiration_time = db.head_block_time() + fc::days(1); prop.fee = asset( proposal_create_fees.fee + proposal_create_fees.price_per_kbyte ); - { - signed_transaction tx; - tx.operations.push_back( prop ); - db.current_fee_schedule().set_fee( tx.operations.back() ); - set_expiration( db, tx ); - sign( tx, issuer_private_key ); - GRAPHENE_CHECK_THROW(PUSH_TX( db, tx ), fc::exception); - } - generate_blocks_past_hf1268(); { @@ -658,15 +608,6 @@ BOOST_AUTO_TEST_CASE(update_asset_via_proposal_test) prop.expiration_time = db.head_block_time() + fc::days(1); prop.fee = asset( proposal_create_fees.fee + proposal_create_fees.price_per_kbyte ); - { - signed_transaction tx; - tx.operations.push_back( prop ); - db.current_fee_schedule().set_fee( tx.operations.back() ); - set_expiration( db, tx ); - sign( tx, issuer_private_key ); - GRAPHENE_CHECK_THROW(PUSH_TX( db, tx ), fc::exception); - } - generate_blocks_past_hf1268(); { @@ -791,29 +732,6 @@ BOOST_AUTO_TEST_CASE(accumulated_fees_with_additional_options_after_hf_test) FC_LOG_AND_RETHROW() } -BOOST_AUTO_TEST_CASE( create_vesting_balance_with_instant_vesting_policy_before_hf1268_test ) -{ try { - - ACTOR(alice); - fund(alice); - - const asset_object& core = asset_id_type()(db); - - vesting_balance_create_operation op; - op.fee = core.amount( 0 ); - op.creator = alice_id; - op.owner = alice_id; - op.amount = core.amount( 100 ); - op.policy = instant_vesting_policy_initializer{}; - - trx.operations.push_back(op); - set_expiration( db, trx ); - sign(trx, alice_private_key); - - GRAPHENE_REQUIRE_THROW(PUSH_TX( db, trx, ~0 ), fc::exception); - -} FC_LOG_AND_RETHROW() } - BOOST_AUTO_TEST_CASE( create_vesting_balance_with_instant_vesting_policy_after_hf1268_test ) { try { @@ -880,15 +798,6 @@ BOOST_AUTO_TEST_CASE( create_vesting_balance_with_instant_vesting_policy_via_pro prop.expiration_time = db.head_block_time() + fc::days(1); prop.fee = asset( proposal_create_fees.fee + proposal_create_fees.price_per_kbyte ); - { - signed_transaction tx; - tx.operations.push_back( prop ); - db.current_fee_schedule().set_fee( tx.operations.back() ); - set_expiration( db, tx ); - sign( tx, actor_private_key ); - GRAPHENE_CHECK_THROW(PUSH_TX( db, tx ), fc::exception); - } - generate_blocks_past_hf1268(); { From fdde75b46e752ca4aea2e2ae76e9814892efe831 Mon Sep 17 00:00:00 2001 From: John Jones Date: Thu, 2 May 2019 15:29:40 -0500 Subject: [PATCH 03/25] code cleanup for HF_922_931 --- libraries/chain/asset_evaluator.cpp | 141 +++------------------------- 1 file changed, 12 insertions(+), 129 deletions(-) diff --git a/libraries/chain/asset_evaluator.cpp b/libraries/chain/asset_evaluator.cpp index 19022929b2..e936822c01 100644 --- a/libraries/chain/asset_evaluator.cpp +++ b/libraries/chain/asset_evaluator.cpp @@ -376,7 +376,7 @@ void_result asset_update_issuer_evaluator::do_apply(const asset_update_issuer_op * should be removed). */ void check_children_of_bitasset(database& d, const asset_update_bitasset_operation& op, - const asset_object& new_backing_asset, bool after_hf_922_931) + const asset_object& new_backing_asset) { // no need to do these checks if the new backing asset is CORE if ( new_backing_asset.get_id() == asset_id_type() ) @@ -388,49 +388,17 @@ void check_children_of_bitasset(database& d, const asset_update_bitasset_operati .get(); auto backed_range = idx.equal_range(op.asset_to_update); std::for_each( backed_range.first, backed_range.second, - [after_hf_922_931, &new_backing_asset, &d, &op](const asset_bitasset_data_object& bitasset_data) + [&new_backing_asset, &d, &op](const asset_bitasset_data_object& bitasset_data) { const auto& child = bitasset_data.asset_id(d); - if ( after_hf_922_931 ) - { - FC_ASSERT( child.get_id() != op.new_options.short_backing_asset, - "A BitAsset would be invalidated by changing this backing asset ('A' backed by 'B' backed by 'A')." ); - - FC_ASSERT( child.issuer != GRAPHENE_COMMITTEE_ACCOUNT, - "A blockchain-controlled market asset would be invalidated by changing this backing asset." ); + FC_ASSERT( child.get_id() != op.new_options.short_backing_asset, + "A BitAsset would be invalidated by changing this backing asset ('A' backed by 'B' backed by 'A')." ); - FC_ASSERT( !new_backing_asset.is_market_issued(), - "A non-blockchain controlled BitAsset would be invalidated by changing this backing asset."); + FC_ASSERT( child.issuer != GRAPHENE_COMMITTEE_ACCOUNT, + "A blockchain-controlled market asset would be invalidated by changing this backing asset." ); - } - else - { - if( child.get_id() == op.new_options.short_backing_asset ) - { - wlog( "Before hf-922-931, modified an asset to be backed by another, but would cause a continuous " - "loop. A cannot be backed by B which is backed by A." ); - return; - } - - if( child.issuer == GRAPHENE_COMMITTEE_ACCOUNT ) - { - wlog( "before hf-922-931, modified an asset to be backed by a non-CORE, but this asset " - "is a backing asset for a committee-issued asset. This occurred at block ${b}", - ("b", d.head_block_num())); - return; - } - else - { - if ( new_backing_asset.is_market_issued() ) // a.k.a. !UIA - { - wlog( "before hf-922-931, modified an asset to be backed by an MPA, but this asset " - "is a backing asset for another MPA, which would cause MPA backed by MPA backed by MPA. " - "This occurred at block ${b}", - ("b", d.head_block_num())); - return; - } - } // if child.issuer - } // if hf 922/931 + FC_ASSERT( !new_backing_asset.is_market_issued(), + "A non-blockchain controlled BitAsset would be invalidated by changing this backing asset."); } ); // end of lambda and std::for_each() } // check_children_of_bitasset @@ -458,7 +426,7 @@ void_result asset_update_bitasset_evaluator::do_evaluate(const asset_update_bita const asset_object& new_backing_asset = op.new_options.short_backing_asset(d); // check if the asset exists - if( after_hf_core_922_931 ) // TODO remove this check after hard fork if things in `else` did not occur + if( after_hf_core_922_931 ) { FC_ASSERT( op.new_options.short_backing_asset != asset_obj.get_id(), "Cannot update an asset to be backed by itself." ); @@ -477,7 +445,7 @@ void_result asset_update_bitasset_evaluator::do_evaluate(const asset_update_bita "May not modify a blockchain-controlled market asset to be backed by an asset which is not " "backed by CORE." ); - check_children_of_bitasset( d, op, new_backing_asset, after_hf_core_922_931 ); + check_children_of_bitasset( d, op, new_backing_asset ); } else { @@ -496,7 +464,7 @@ void_result asset_update_bitasset_evaluator::do_evaluate(const asset_update_bita // asset must be either CORE or a UIA. if ( new_backing_asset.get_id() != asset_id_type() ) // not backed by CORE { - check_children_of_bitasset( d, op, new_backing_asset, after_hf_core_922_931 ); + check_children_of_bitasset( d, op, new_backing_asset ); } } @@ -509,101 +477,16 @@ void_result asset_update_bitasset_evaluator::do_evaluate(const asset_update_bita "A BitAsset cannot be backed by a BitAsset that itself is backed by a BitAsset."); } } - else // prior to HF 922 / 931 - { - // code to check if issues occurred before hard fork. TODO cleanup after hard fork - if( op.new_options.short_backing_asset == asset_obj.get_id() ) - { - wlog( "before hf-922-931, op.new_options.short_backing_asset == asset_obj.get_id() at block ${b}", - ("b",d.head_block_num()) ); - } - if( current_bitasset_data.is_prediction_market && asset_obj.precision != new_backing_asset.precision ) - { - wlog( "before hf-922-931, for a PM, asset_obj.precision != new_backing_asset.precision at block ${b}", - ("b",d.head_block_num()) ); - } - - if( asset_obj.issuer == GRAPHENE_COMMITTEE_ACCOUNT ) - { - // code to check if issues occurred before hard fork. TODO cleanup after hard fork - if( new_backing_asset.is_market_issued() ) - { - if( new_backing_asset.bitasset_data(d).options.short_backing_asset != asset_id_type() ) - wlog( "before hf-922-931, modified a blockchain-controlled market asset to be backed by an asset " - "which is not backed by CORE at block ${b}", - ("b",d.head_block_num()) ); - - check_children_of_bitasset( d, op, new_backing_asset, after_hf_core_922_931 ); - } - else - { - if( new_backing_asset.get_id() != asset_id_type() ) - wlog( "before hf-922-931, modified a blockchain-controlled market asset to be backed by an asset " - "which is not market issued asset nor CORE at block ${b}", - ("b",d.head_block_num()) ); - } - - //prior to HF 922_931, these checks were mistakenly using the old backing_asset - const asset_object& old_backing_asset = current_bitasset_data.options.short_backing_asset(d); - - if( old_backing_asset.is_market_issued() ) - { - FC_ASSERT( old_backing_asset.bitasset_data(d).options.short_backing_asset == asset_id_type(), - "May not modify a blockchain-controlled market asset to be backed by an asset which is not " - "backed by CORE." ); - } - else - { - FC_ASSERT( old_backing_asset.get_id() == asset_id_type(), - "May not modify a blockchain-controlled market asset to be backed by an asset which is not " - "market issued asset nor CORE." ); - } - } - else - { - // not a committee issued asset - - // If we're changing to a backing_asset that is not CORE, we need to look at any - // asset ( "CHILD" ) that has this one as a backing asset. If CHILD is committee-owned, - // the change is not allowed. If CHILD is user-owned, then this asset's backing - // asset must be either CORE or a UIA. - if ( new_backing_asset.get_id() != asset_id_type() ) // not backed by CORE - { - check_children_of_bitasset( d, op, new_backing_asset, after_hf_core_922_931 ); - } - } - // if the new backing asset is backed by something which is not CORE and not a UIA, this is not allowed - // Check if the new backing asset is itself backed by something. It must be CORE or a UIA - if ( new_backing_asset.is_market_issued() ) - { - asset_id_type backing_backing_asset_id = new_backing_asset.bitasset_data(d).options.short_backing_asset; - if ( backing_backing_asset_id != asset_id_type() && backing_backing_asset_id(d).is_market_issued() ) - { - wlog( "before hf-922-931, a BitAsset cannot be backed by a BitAsset that itself " - "is backed by a BitAsset. This occurred at block ${b}", - ("b", d.head_block_num() ) ); - } // not core, not UIA - } // if market issued - } } const auto& chain_parameters = d.get_global_properties().parameters; - if( after_hf_core_922_931 ) // TODO remove this check after hard fork if things in `else` did not occur + if( after_hf_core_922_931 ) { FC_ASSERT( op.new_options.feed_lifetime_sec > chain_parameters.block_interval, "Feed lifetime must exceed block interval." ); FC_ASSERT( op.new_options.force_settlement_delay_sec > chain_parameters.block_interval, "Force settlement delay must exceed block interval." ); } - else // code to check if issues occurred before hard fork. TODO cleanup after hard fork - { - if( op.new_options.feed_lifetime_sec <= chain_parameters.block_interval ) - wlog( "before hf-922-931, op.new_options.feed_lifetime_sec <= chain_parameters.block_interval at block ${b}", - ("b",d.head_block_num()) ); - if( op.new_options.force_settlement_delay_sec <= chain_parameters.block_interval ) - wlog( "before hf-922-931, op.new_options.force_settlement_delay_sec <= chain_parameters.block_interval at block ${b}", - ("b",d.head_block_num()) ); - } bitasset_to_update = ¤t_bitasset_data; asset_to_update = &asset_obj; From 7b2a4d22e08acc36f62c2d30a255681d343b0ac3 Mon Sep 17 00:00:00 2001 From: John Jones Date: Thu, 2 May 2019 15:39:49 -0500 Subject: [PATCH 04/25] Comment cleanup for 583 & 385 --- libraries/chain/asset_evaluator.cpp | 7 +------ libraries/chain/market_evaluator.cpp | 1 + 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/libraries/chain/asset_evaluator.cpp b/libraries/chain/asset_evaluator.cpp index e936822c01..63c2c3f1a6 100644 --- a/libraries/chain/asset_evaluator.cpp +++ b/libraries/chain/asset_evaluator.cpp @@ -55,6 +55,7 @@ void_result asset_create_evaluator::do_evaluate( const asset_create_operation& o auto asset_symbol_itr = asset_indx.find( op.symbol ); FC_ASSERT( asset_symbol_itr == asset_indx.end() ); + // This must remain due to "BOND.CNY" being allowed before this HF if( d.head_block_time() > HARDFORK_385_TIME ) { auto dotpos = op.symbol.rfind( '.' ); @@ -68,12 +69,6 @@ void_result asset_create_evaluator::do_evaluate( const asset_create_operation& o ("s",op.symbol)("p",prefix)("i", op.issuer(d).name) ); } } - else - { - auto dotpos = op.symbol.find( '.' ); - if( dotpos != std::string::npos ) - wlog( "Asset ${s} has a name which requires hardfork 385", ("s",op.symbol) ); - } if( op.bitasset_opts ) { diff --git a/libraries/chain/market_evaluator.cpp b/libraries/chain/market_evaluator.cpp index 848075da4d..1c4117fb26 100644 --- a/libraries/chain/market_evaluator.cpp +++ b/libraries/chain/market_evaluator.cpp @@ -348,6 +348,7 @@ object_id_type call_order_update_evaluator::do_apply(const call_order_update_ope call_obj = d.find(call_order_id); // we know no black swan event has occurred FC_ASSERT( call_obj, "no margin call was executed and yet the call object was deleted" ); + // this HF must remain as-is, as the assert inside the "if" was triggered if( d.head_block_time() <= HARDFORK_CORE_583_TIME ) { // We didn't fill any call orders. This may be because we From feb033c55c3c9640bc72aa4f5071606861f89c55 Mon Sep 17 00:00:00 2001 From: John Jones Date: Thu, 2 May 2019 16:17:05 -0500 Subject: [PATCH 05/25] hf_834 comment cleanup --- libraries/chain/db_market.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index 01579a87e3..8376372d75 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -643,7 +643,7 @@ int database::match( const limit_order_object& bid, const call_order_object& ask bool before_core_hardfork_184 = ( maint_time <= HARDFORK_CORE_184_TIME ); // something-for-nothing // TODO remove when we're sure it's always false bool before_core_hardfork_342 = ( maint_time <= HARDFORK_CORE_342_TIME ); // better rounding - // TODO remove when we're sure it's always false + if( before_core_hardfork_184 ) ilog( "match(limit,call) is called before hardfork core-184 at block #${block}", ("block",head_block_num()) ); if( before_core_hardfork_342 ) From 65b066707f601eff6b40e13e08dfae4f4086dbdc Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 13 May 2019 15:03:20 -0500 Subject: [PATCH 06/25] Fix 1465, clean comments --- libraries/chain/asset_evaluator.cpp | 1 + libraries/chain/hardfork.d/CORE_1465.hf | 1 - libraries/chain/market_evaluator.cpp | 15 +++------------ libraries/chain/proposal_evaluator.cpp | 7 ++----- 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/libraries/chain/asset_evaluator.cpp b/libraries/chain/asset_evaluator.cpp index 63c2c3f1a6..b0e79dc303 100644 --- a/libraries/chain/asset_evaluator.cpp +++ b/libraries/chain/asset_evaluator.cpp @@ -411,6 +411,7 @@ void_result asset_update_bitasset_evaluator::do_evaluate(const asset_update_bita FC_ASSERT( !current_bitasset_data.has_settlement(), "Cannot update a bitasset after a global settlement has executed" ); + // hf 922_931 is a consensus/logic change. This hf cannot be removed. bool after_hf_core_922_931 = ( d.get_dynamic_global_properties().next_maintenance_time > HARDFORK_CORE_922_931_TIME ); // Are we changing the backing asset? diff --git a/libraries/chain/hardfork.d/CORE_1465.hf b/libraries/chain/hardfork.d/CORE_1465.hf index 9ae9387931..2de93f3eeb 100644 --- a/libraries/chain/hardfork.d/CORE_1465.hf +++ b/libraries/chain/hardfork.d/CORE_1465.hf @@ -1,5 +1,4 @@ // bitshares-core issue #1465 check max_supply before processing call_order_update #ifndef HARDFORK_CORE_1465_TIME #define HARDFORK_CORE_1465_TIME (fc::time_point_sec( 1556028120 ) ) // 2019-04-23T14:02:00Z -#define SOFTFORK_CORE_1465_TIME (fc::time_point_sec( 1545350400 )) // 2018-12-21 00:00:00 #endif diff --git a/libraries/chain/market_evaluator.cpp b/libraries/chain/market_evaluator.cpp index 1c4117fb26..99b9b2e4f4 100644 --- a/libraries/chain/market_evaluator.cpp +++ b/libraries/chain/market_evaluator.cpp @@ -192,18 +192,9 @@ void_result call_order_update_evaluator::do_evaluate(const call_order_update_ope _dynamic_data_obj = &_debt_asset->dynamic_asset_data_id(d); /*** - * We have softfork code already in production to prevent exceeding MAX_SUPPLY between 2018-12-21 until HF 1465. - * But we must allow this in replays until 2018-12-21. The HF 1465 code will correct the problem. - * After HF 1465, we MAY be able to remove the cleanup code IF it never executes. We MAY be able to clean - * up the softfork code IF it never executes. We MAY be able to turn the hardfork code into regular code IF - * noone ever attempted this before HF 1465. + * There are instances of assets exceeding max_supply before hf 1465, therefore this code must remain. */ - if (next_maintenance_time <= SOFTFORK_CORE_1465_TIME) - { - if ( _dynamic_data_obj->current_supply + o.delta_debt.amount > _debt_asset->options.max_supply ) - ilog("Issue 1465... Borrowing and exceeding MAX_SUPPLY. Will be corrected at hardfork time."); - } - else + if (next_maintenance_time > HARDFORK_CORE_1465_TIME) { FC_ASSERT( _dynamic_data_obj->current_supply + o.delta_debt.amount <= _debt_asset->options.max_supply, "Borrowing this quantity would exceed MAX_SUPPLY" ); @@ -348,7 +339,7 @@ object_id_type call_order_update_evaluator::do_apply(const call_order_update_ope call_obj = d.find(call_order_id); // we know no black swan event has occurred FC_ASSERT( call_obj, "no margin call was executed and yet the call object was deleted" ); - // this HF must remain as-is, as the assert inside the "if" was triggered + // this HF must remain as-is, as the assert inside the "if" was triggered during push_proposal() if( d.head_block_time() <= HARDFORK_CORE_583_TIME ) { // We didn't fill any call orders. This may be because we diff --git a/libraries/chain/proposal_evaluator.cpp b/libraries/chain/proposal_evaluator.cpp index e471cbc476..5afa2abe3d 100644 --- a/libraries/chain/proposal_evaluator.cpp +++ b/libraries/chain/proposal_evaluator.cpp @@ -42,15 +42,12 @@ struct proposal_operation_hardfork_visitor void operator()(const T &v) const {} void operator()(const graphene::chain::call_order_update_operation &v) const { - - // TODO If this never ASSERTs before HF 1465, it can be removed - FC_ASSERT( block_time < SOFTFORK_CORE_1465_TIME - || block_time > HARDFORK_CORE_1465_TIME + FC_ASSERT( block_time > HARDFORK_CORE_1465_TIME || v.delta_debt.asset_id == asset_id_type(113) // CNY || v.delta_debt.amount < 0 || (v.delta_debt.asset_id( db ).bitasset_data_id && (*(v.delta_debt.asset_id( db ).bitasset_data_id))( db ).is_prediction_market ) - , "Soft fork - preventing proposal with call_order_update!" ); + , "Preventing proposal with call_order_update!" ); } // hf_588 // issue #588 From 2f4f1f0d6823665a78ec4b7b0dc0be0c8802b026 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 14 May 2019 15:26:39 -0500 Subject: [PATCH 07/25] more 1465 cleanup --- libraries/chain/proposal_evaluator.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/libraries/chain/proposal_evaluator.cpp b/libraries/chain/proposal_evaluator.cpp index 5afa2abe3d..20089df666 100644 --- a/libraries/chain/proposal_evaluator.cpp +++ b/libraries/chain/proposal_evaluator.cpp @@ -41,14 +41,6 @@ struct proposal_operation_hardfork_visitor template void operator()(const T &v) const {} - void operator()(const graphene::chain::call_order_update_operation &v) const { - FC_ASSERT( block_time > HARDFORK_CORE_1465_TIME - || v.delta_debt.asset_id == asset_id_type(113) // CNY - || v.delta_debt.amount < 0 - || (v.delta_debt.asset_id( db ).bitasset_data_id - && (*(v.delta_debt.asset_id( db ).bitasset_data_id))( db ).is_prediction_market ) - , "Preventing proposal with call_order_update!" ); - } // hf_588 // issue #588 // From 613098844bba99d776971784c533a6cc2f3b4110 Mon Sep 17 00:00:00 2001 From: John Jones Date: Thu, 16 May 2019 14:18:55 -0500 Subject: [PATCH 08/25] More cleanup of hf 1268 --- libraries/chain/db_market.cpp | 26 ++----------- libraries/chain/hardfork.d/CORE_1268.hf | 4 -- .../performance/market_fee_sharing_tests.cpp | 1 - tests/tests/market_fee_sharing_tests.cpp | 39 +++---------------- 4 files changed, 10 insertions(+), 60 deletions(-) delete mode 100644 libraries/chain/hardfork.d/CORE_1268.hf diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index 8376372d75..9318705a93 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -821,9 +821,7 @@ bool database::fill_limit_order( const limit_order_object& order, const asset& p const account_object& seller = order.seller(*this); const asset_object& recv_asset = receives.asset_id(*this); - auto issuer_fees = ( head_block_time() < HARDFORK_1268_TIME ) ? - pay_market_fees(recv_asset, receives) : - pay_market_fees(seller, recv_asset, receives); + auto issuer_fees = pay_market_fees(seller, recv_asset, receives); pay_order( seller, receives - issuer_fees, pays ); @@ -934,7 +932,7 @@ bool database::fill_settle_order( const force_settlement_object& settle, const a { try { bool filled = false; - auto issuer_fees = pay_market_fees(get(receives.asset_id), receives); + auto issuer_fees = pay_market_fees( account_object(), get(receives.asset_id), receives); if( pays < settle.balance ) { @@ -1206,24 +1204,6 @@ asset database::calculate_market_fee( const asset_object& trade_asset, const ass return percent_fee; } -asset database::pay_market_fees( const asset_object& recv_asset, const asset& receives ) -{ - auto issuer_fees = calculate_market_fee( recv_asset, receives ); - FC_ASSERT( issuer_fees <= receives, "Market fee shouldn't be greater than receives"); - - //Don't dirty undo state if not actually collecting any fees - if( issuer_fees.amount > 0 ) - { - const auto& recv_dyn_data = recv_asset.dynamic_asset_data_id(*this); - modify( recv_dyn_data, [&]( asset_dynamic_data_object& obj ){ - //idump((issuer_fees)); - obj.accumulated_fees += issuer_fees.amount; - }); - } - - return issuer_fees; -} - asset database::pay_market_fees(const account_object& seller, const asset_object& recv_asset, const asset& receives ) { const auto issuer_fees = calculate_market_fee( recv_asset, receives ); @@ -1235,6 +1215,8 @@ asset database::pay_market_fees(const account_object& seller, const asset_object asset reward = recv_asset.amount(0); auto is_rewards_allowed = [&recv_asset, &seller]() { + if (seller.id == account_object().id) + return false; const auto &white_list = recv_asset.options.extensions.value.whitelist_market_fee_sharing; return ( !white_list || (*white_list).empty() || ( (*white_list).find(seller.registrar) != (*white_list).end() ) ); }; diff --git a/libraries/chain/hardfork.d/CORE_1268.hf b/libraries/chain/hardfork.d/CORE_1268.hf deleted file mode 100644 index 6318a2a560..0000000000 --- a/libraries/chain/hardfork.d/CORE_1268.hf +++ /dev/null @@ -1,4 +0,0 @@ -// #1268 Distribute Asset Market Fees to Referral Program -#ifndef HARDFORK_1268_TIME -#define HARDFORK_1268_TIME (fc::time_point_sec( 1556028120 ) ) // 2019-04-23T14:02:00Z -#endif diff --git a/tests/performance/market_fee_sharing_tests.cpp b/tests/performance/market_fee_sharing_tests.cpp index 5c431595ea..9718bb0613 100644 --- a/tests/performance/market_fee_sharing_tests.cpp +++ b/tests/performance/market_fee_sharing_tests.cpp @@ -48,7 +48,6 @@ BOOST_FIXTURE_TEST_CASE(mfs_performance_test, database_fixture) registrators.push_back(std::move(account)); } - generate_blocks(HARDFORK_1268_TIME); generate_block(); additional_asset_options_t options; diff --git a/tests/tests/market_fee_sharing_tests.cpp b/tests/tests/market_fee_sharing_tests.cpp index 33205eb392..7276d87e60 100644 --- a/tests/tests/market_fee_sharing_tests.cpp +++ b/tests/tests/market_fee_sharing_tests.cpp @@ -27,7 +27,7 @@ struct reward_database_fixture : database_fixture using whitelist_market_fee_sharing_t = fc::optional>; reward_database_fixture() - : database_fixture(HARDFORK_1268_TIME - 100) + : database_fixture() { } @@ -90,12 +90,6 @@ struct reward_database_fixture : database_fixture PUSH_TX( db, tx); } - void generate_blocks_past_hf1268() - { - database_fixture::generate_blocks( HARDFORK_1268_TIME ); - database_fixture::generate_block(); - } - asset core_asset(int64_t x ) { return asset( x*core_precision ); @@ -120,8 +114,6 @@ BOOST_AUTO_TEST_CASE(create_asset_with_additional_options_after_hf) { ACTOR(issuer); - generate_blocks_past_hf1268(); - uint16_t reward_percent = GRAPHENE_100_PERCENT + 1; // 100.01% flat_set whitelist = {issuer_id}; price price(asset(1, asset_id_type(1)), asset(1)); @@ -176,8 +168,6 @@ BOOST_AUTO_TEST_CASE(update_additional_options_after_hf) asset_object usd_asset = create_user_issued_asset("USD", issuer, charge_market_fee); - generate_blocks_past_hf1268(); - uint16_t reward_percent = GRAPHENE_100_PERCENT + 1; // 100.01% flat_set whitelist = {issuer_id}; GRAPHENE_CHECK_THROW( @@ -204,6 +194,10 @@ BOOST_AUTO_TEST_CASE(asset_rewards_test) { try { + // handle small percentages + generate_blocks(HARDFORK_453_TIME + 10); + set_expiration(db, trx); + ACTORS((registrar)(alicereferrer)(bobreferrer)(izzy)(jill)); auto register_account = [&](const string& name, const account_object& referrer) -> const account_object& @@ -239,8 +233,6 @@ BOOST_AUTO_TEST_CASE(asset_rewards_test) asset_id_type izzycoin_id = create_bitasset( "IZZYCOIN", izzy_id, izzycoin_market_percent ).id; asset_id_type jillcoin_id = create_bitasset( "JILLCOIN", jill_id, jillcoin_market_percent ).id; - generate_blocks_past_hf1268(); - update_asset(izzy_id, izzy_private_key, izzycoin_id, izzycoin_reward_percent); update_asset(jill_id, jill_private_key, jillcoin_id, jillcoin_reward_percent); @@ -337,7 +329,6 @@ BOOST_AUTO_TEST_CASE(asset_claim_reward_test) transfer( committee_account, bob.get_id(), core_asset(1000) ); transfer( committee_account, izzy.get_id(), core_asset(1000) ); - generate_blocks_past_hf1268(); // update_asset: set referrer percent update_asset(jill_id, jill_private_key, jillcoin.get_id(), jillcoin_reward_percent); @@ -408,7 +399,6 @@ BOOST_AUTO_TEST_CASE(white_list_is_empty_test) { INVOKE(create_actors); - generate_blocks_past_hf1268(); GET_ACTOR(jill); constexpr auto jillcoin_reward_percent = 2*GRAPHENE_1_PERCENT; @@ -442,7 +432,6 @@ BOOST_AUTO_TEST_CASE(white_list_contains_registrar_test) { INVOKE(create_actors); - generate_blocks_past_hf1268(); GET_ACTOR(jill); constexpr auto jillcoin_reward_percent = 2*GRAPHENE_1_PERCENT; @@ -477,7 +466,6 @@ BOOST_AUTO_TEST_CASE(white_list_contains_referrer_test) { INVOKE(create_actors); - generate_blocks_past_hf1268(); GET_ACTOR(jill); constexpr auto jillcoin_reward_percent = 2*GRAPHENE_1_PERCENT; @@ -510,7 +498,6 @@ BOOST_AUTO_TEST_CASE(white_list_doesnt_contain_registrar_test) { INVOKE(create_actors); - generate_blocks_past_hf1268(); GET_ACTOR(jill); constexpr auto jillcoin_reward_percent = 2*GRAPHENE_1_PERCENT; @@ -567,8 +554,6 @@ BOOST_AUTO_TEST_CASE(create_asset_via_proposal_test) prop.expiration_time = db.head_block_time() + fc::days(1); prop.fee = asset( proposal_create_fees.fee + proposal_create_fees.price_per_kbyte ); - generate_blocks_past_hf1268(); - { prop.expiration_time = db.head_block_time() + fc::days(1); signed_transaction tx; @@ -608,8 +593,6 @@ BOOST_AUTO_TEST_CASE(update_asset_via_proposal_test) prop.expiration_time = db.head_block_time() + fc::days(1); prop.fee = asset( proposal_create_fees.fee + proposal_create_fees.price_per_kbyte ); - generate_blocks_past_hf1268(); - { prop.expiration_time = db.head_block_time() + fc::days(1); signed_transaction tx; @@ -679,8 +662,6 @@ BOOST_AUTO_TEST_CASE(accumulated_fees_after_hf_test) { INVOKE(issue_asset); - generate_blocks_past_hf1268(); - const asset_object &jillcoin = get_asset("JILLCOIN"); const asset_object &izzycoin = get_asset("IZZYCOIN"); @@ -705,8 +686,6 @@ BOOST_AUTO_TEST_CASE(accumulated_fees_with_additional_options_after_hf_test) { INVOKE(issue_asset); - generate_blocks_past_hf1268(); - GET_ACTOR(jill); GET_ACTOR(izzy); @@ -732,14 +711,12 @@ BOOST_AUTO_TEST_CASE(accumulated_fees_with_additional_options_after_hf_test) FC_LOG_AND_RETHROW() } -BOOST_AUTO_TEST_CASE( create_vesting_balance_with_instant_vesting_policy_after_hf1268_test ) +BOOST_AUTO_TEST_CASE( create_vesting_balance_with_instant_vesting_policy_test ) { try { ACTOR(alice); fund(alice); - generate_blocks_past_hf1268(); - const asset_object& core = asset_id_type()(db); vesting_balance_create_operation op; @@ -798,8 +775,6 @@ BOOST_AUTO_TEST_CASE( create_vesting_balance_with_instant_vesting_policy_via_pro prop.expiration_time = db.head_block_time() + fc::days(1); prop.fee = asset( proposal_create_fees.fee + proposal_create_fees.price_per_kbyte ); - generate_blocks_past_hf1268(); - { prop.expiration_time = db.head_block_time() + fc::days(1); signed_transaction tx; @@ -848,8 +823,6 @@ BOOST_AUTO_TEST_CASE(white_list_asset_rewards_test) issue_uia( alice, izzycoin_id(db).amount( 200000 ) ); issue_uia( bob, jillcoin_id(db).amount( 200000 ) ); - generate_blocks_past_hf1268(); - constexpr auto izzycoin_reward_percent = 50*GRAPHENE_1_PERCENT; constexpr auto jillcoin_reward_percent = 50*GRAPHENE_1_PERCENT; From 55373359a7d6151d74824882b1932edef5612dbc Mon Sep 17 00:00:00 2001 From: jmjatlanta Date: Mon, 27 May 2019 09:25:26 -0500 Subject: [PATCH 09/25] pass pointer to object - pay_market_fees --- libraries/chain/db_market.cpp | 25 ++++++++++--------- .../chain/include/graphene/chain/database.hpp | 3 +-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index 9318705a93..a13d360b3f 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -821,7 +821,7 @@ bool database::fill_limit_order( const limit_order_object& order, const asset& p const account_object& seller = order.seller(*this); const asset_object& recv_asset = receives.asset_id(*this); - auto issuer_fees = pay_market_fees(seller, recv_asset, receives); + auto issuer_fees = pay_market_fees(&seller, recv_asset, receives); pay_order( seller, receives - issuer_fees, pays ); @@ -932,7 +932,7 @@ bool database::fill_settle_order( const force_settlement_object& settle, const a { try { bool filled = false; - auto issuer_fees = pay_market_fees( account_object(), get(receives.asset_id), receives); + auto issuer_fees = pay_market_fees( nullptr, get(receives.asset_id), receives); if( pays < settle.balance ) { @@ -1204,7 +1204,7 @@ asset database::calculate_market_fee( const asset_object& trade_asset, const ass return percent_fee; } -asset database::pay_market_fees(const account_object& seller, const asset_object& recv_asset, const asset& receives ) +asset database::pay_market_fees(const account_object* seller, const asset_object& recv_asset, const asset& receives ) { const auto issuer_fees = calculate_market_fee( recv_asset, receives ); FC_ASSERT( issuer_fees <= receives, "Market fee shouldn't be greater than receives"); @@ -1214,11 +1214,12 @@ asset database::pay_market_fees(const account_object& seller, const asset_object // calculate and pay rewards asset reward = recv_asset.amount(0); - auto is_rewards_allowed = [&recv_asset, &seller]() { - if (seller.id == account_object().id) + auto is_rewards_allowed = [&recv_asset, seller]() { + if (seller == nullptr) return false; const auto &white_list = recv_asset.options.extensions.value.whitelist_market_fee_sharing; - return ( !white_list || (*white_list).empty() || ( (*white_list).find(seller.registrar) != (*white_list).end() ) ); + return ( !white_list || (*white_list).empty() + || ( (*white_list).find(seller->registrar) != (*white_list).end() ) ); }; if ( is_rewards_allowed() ) @@ -1227,27 +1228,27 @@ asset database::pay_market_fees(const account_object& seller, const asset_object if ( reward_percent && *reward_percent ) { const auto reward_value = detail::calculate_percent(issuer_fees.amount, *reward_percent); - if ( reward_value > 0 && is_authorized_asset(*this, seller.registrar(*this), recv_asset) ) + if ( reward_value > 0 && is_authorized_asset(*this, seller->registrar(*this), recv_asset) ) { reward = recv_asset.amount(reward_value); FC_ASSERT( reward < issuer_fees, "Market reward should be less than issuer fees"); // cut referrer percent from reward auto registrar_reward = reward; - if( seller.referrer != seller.registrar ) + if( seller->referrer != seller->registrar ) { const auto referrer_rewards_value = detail::calculate_percent( reward.amount, - seller.referrer_rewards_percentage ); + seller->referrer_rewards_percentage ); - if ( referrer_rewards_value > 0 && is_authorized_asset(*this, seller.referrer(*this), recv_asset) ) + if ( referrer_rewards_value > 0 && is_authorized_asset(*this, seller->referrer(*this), recv_asset) ) { FC_ASSERT ( referrer_rewards_value <= reward.amount.value, "Referrer reward shouldn't be greater than total reward" ); const asset referrer_reward = recv_asset.amount(referrer_rewards_value); registrar_reward -= referrer_reward; - deposit_market_fee_vesting_balance(seller.referrer, referrer_reward); + deposit_market_fee_vesting_balance(seller->referrer, referrer_reward); } } - deposit_market_fee_vesting_balance(seller.registrar, registrar_reward); + deposit_market_fee_vesting_balance(seller->registrar, registrar_reward); } } } diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index 5afb83ab1e..a5444396d2 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -420,8 +420,7 @@ namespace graphene { namespace chain { void pay_order( const account_object& receiver, const asset& receives, const asset& pays ); asset calculate_market_fee(const asset_object& recv_asset, const asset& trade_amount); - asset pay_market_fees( const asset_object& recv_asset, const asset& receives ); - asset pay_market_fees( const account_object& seller, const asset_object& recv_asset, const asset& receives ); + asset pay_market_fees(const account_object* seller, const asset_object& recv_asset, const asset& receives ); ///@} From d960984855ab8e753d36d40979df1a89f11af299 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 9 Jul 2019 06:16:30 -0500 Subject: [PATCH 10/25] Remove HF 572 --- libraries/chain/asset_evaluator.cpp | 2 +- libraries/chain/hardfork.d/572.hf | 4 ---- tests/tests/fee_tests.cpp | 1 - tests/tests/operation_tests.cpp | 9 ++++++++- 4 files changed, 9 insertions(+), 7 deletions(-) delete mode 100644 libraries/chain/hardfork.d/572.hf diff --git a/libraries/chain/asset_evaluator.cpp b/libraries/chain/asset_evaluator.cpp index b0e79dc303..5546e4a61d 100644 --- a/libraries/chain/asset_evaluator.cpp +++ b/libraries/chain/asset_evaluator.cpp @@ -267,7 +267,7 @@ void_result asset_update_evaluator::do_evaluate(const asset_update_operation& o) validate_new_issuer( d, a, *o.new_issuer ); } - if( (d.head_block_time() < HARDFORK_572_TIME) || (a.dynamic_asset_data_id(d).current_supply != 0) ) + if( a.dynamic_asset_data_id(d).current_supply != 0 ) { // new issuer_permissions must be subset of old issuer permissions FC_ASSERT(!(o.new_options.issuer_permissions & ~a.options.issuer_permissions), diff --git a/libraries/chain/hardfork.d/572.hf b/libraries/chain/hardfork.d/572.hf deleted file mode 100644 index a466ef72c5..0000000000 --- a/libraries/chain/hardfork.d/572.hf +++ /dev/null @@ -1,4 +0,0 @@ -// #572 Allow asset to update permission flags when no supply exists -#ifndef HARDFORK_572_TIME -#define HARDFORK_572_TIME (fc::time_point_sec( 1456250400 )) -#endif diff --git a/tests/tests/fee_tests.cpp b/tests/tests/fee_tests.cpp index 4e509a5dbb..83b7557425 100644 --- a/tests/tests/fee_tests.cpp +++ b/tests/tests/fee_tests.cpp @@ -3425,7 +3425,6 @@ BOOST_AUTO_TEST_CASE( stealth_fba_test ) generate_blocks( HARDFORK_555_TIME ); generate_blocks( HARDFORK_563_TIME ); - generate_blocks( HARDFORK_572_TIME ); // Philbin (registrar who registers Rex) diff --git a/tests/tests/operation_tests.cpp b/tests/tests/operation_tests.cpp index f5deed6ddd..09aa4085d4 100644 --- a/tests/tests/operation_tests.cpp +++ b/tests/tests/operation_tests.cpp @@ -1211,7 +1211,14 @@ BOOST_AUTO_TEST_CASE( update_uia ) PUSH_TX( db, trx, ~0 ); } - BOOST_TEST_MESSAGE( "Make sure white_list can't be re-enabled" ); + asset_issue_operation issue_op; + issue_op.issuer = op.issuer; + issue_op.asset_to_issue = asset(5000000,op.asset_to_update); + issue_op.issue_to_account = nathan.get_id(); + trx.operations.push_back(issue_op); + PUSH_TX(db, trx, ~0); + + BOOST_TEST_MESSAGE( "Make sure white_list can't be re-enabled (after tokens issued)" ); op.new_options.issuer_permissions = test.options.issuer_permissions; op.new_options.flags = test.options.flags; BOOST_CHECK(!(test.options.issuer_permissions & white_list)); From 1946cfe8de07bb4d755b21f9abe66c8d4a44df8c Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 26 Jul 2019 15:48:24 -0500 Subject: [PATCH 11/25] Remove HF 588 --- libraries/chain/hardfork.d/CORE_588.hf | 4 ---- libraries/chain/proposal_evaluator.cpp | 24 ------------------- .../include/graphene/protocol/asset_ops.hpp | 9 +++---- tests/tests/operation_tests.cpp | 4 ---- 4 files changed, 5 insertions(+), 36 deletions(-) delete mode 100644 libraries/chain/hardfork.d/CORE_588.hf diff --git a/libraries/chain/hardfork.d/CORE_588.hf b/libraries/chain/hardfork.d/CORE_588.hf deleted file mode 100644 index 87cd88fd0c..0000000000 --- a/libraries/chain/hardfork.d/CORE_588.hf +++ /dev/null @@ -1,4 +0,0 @@ -// Issue #588: Virtual operations should be excluded from transactions -#ifndef HARDFORK_CORE_588_TIME -#define HARDFORK_CORE_588_TIME (fc::time_point_sec( 1532008920 )) // Thu, 19 Jul 2018 14:02:00 UTC -#endif diff --git a/libraries/chain/proposal_evaluator.cpp b/libraries/chain/proposal_evaluator.cpp index 20089df666..72ff49eeb8 100644 --- a/libraries/chain/proposal_evaluator.cpp +++ b/libraries/chain/proposal_evaluator.cpp @@ -41,30 +41,6 @@ struct proposal_operation_hardfork_visitor template void operator()(const T &v) const {} - // hf_588 - // issue #588 - // - // As a virtual operation which has no evaluator `asset_settle_cancel_operation` - // originally won't be packed into blocks, yet its loose `validate()` method - // make it able to slip into blocks. - // - // We need to forbid this operation being packed into blocks via proposal but - // this will lead to a hardfork (this operation in proposal will denied by new - // node while accept by old node), so a hardfork guard code needed and a - // consensus upgrade over all nodes needed in future. And because the - // `validate()` method not suitable to check database status, so we put the - // code here. - // - // After the hardfork, all nodes will deny packing this operation into a block, - // and then we will check whether exists a proposal containing this kind of - // operation, if not exists, we can harden the `validate()` method to deny - // it in a earlier stage. - // - void operator()(const graphene::chain::asset_settle_cancel_operation &v) const { - if (block_time > HARDFORK_CORE_588_TIME) { - FC_ASSERT(!"Virtual operation"); - } - } void operator()(const graphene::chain::committee_member_update_global_parameters_operation &op) const { if (block_time < HARDFORK_CORE_1468_TIME) { FC_ASSERT(!op.new_parameters.extensions.value.updatable_htlc_options.valid(), "Unable to set HTLC options before hardfork 1468"); diff --git a/libraries/protocol/include/graphene/protocol/asset_ops.hpp b/libraries/protocol/include/graphene/protocol/asset_ops.hpp index 6dd4545481..78c204ac06 100644 --- a/libraries/protocol/include/graphene/protocol/asset_ops.hpp +++ b/libraries/protocol/include/graphene/protocol/asset_ops.hpp @@ -222,7 +222,6 @@ namespace graphene { namespace protocol { /** * Virtual op generated when force settlement is cancelled. */ - struct asset_settle_cancel_operation : public base_operation { struct fee_parameters_type { }; @@ -236,9 +235,11 @@ namespace graphene { namespace protocol { extensions_type extensions; account_id_type fee_payer()const { return account; } - void validate()const { - FC_ASSERT( amount.amount > 0, "Must settle at least 1 unit" ); - } + /*** + * This is a virtual operation and should never be placed in a block + * (i.e. in a proposal) + */ + void validate() const { FC_ASSERT( !"Virtual operation"); } share_type calculate_fee(const fee_parameters_type& params)const { return 0; } diff --git a/tests/tests/operation_tests.cpp b/tests/tests/operation_tests.cpp index 09aa4085d4..205adb8281 100644 --- a/tests/tests/operation_tests.cpp +++ b/tests/tests/operation_tests.cpp @@ -286,10 +286,6 @@ BOOST_AUTO_TEST_CASE( old_call_order_update_test_after_hardfork_583 ) BOOST_AUTO_TEST_CASE( asset_settle_cancel_operation_test_after_hf588 ) { - // fast jump to hardfork time - generate_blocks( HARDFORK_CORE_588_TIME ); - // one more block to pass hardfork time - generate_block(); set_expiration( db, trx ); BOOST_TEST_MESSAGE( "Creating a proposal containing a asset_settle_cancel_operation" ); From 26ca087db7ce1f0d8ac575c99da0abf3f3b282c7 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 5 Aug 2019 10:32:55 -0500 Subject: [PATCH 12/25] Remove outdated comment of HF 604 --- libraries/chain/db_market.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index a13d360b3f..d5e4238b4b 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -331,8 +331,7 @@ bool maybe_cull_small_order( database& db, const limit_order_object& order ) if( order.amount_to_receive().amount == 0 ) { if( order.deferred_fee > 0 && db.head_block_time() <= HARDFORK_CORE_604_TIME ) - { // TODO remove this warning after hard fork core-604 - wlog( "At block ${n}, cancelling order without charging a fee: ${o}", ("n",db.head_block_num())("o",order) ); + { db.cancel_limit_order( order, true, true ); } else From f0e6943e82a1380190527cf00abb6c1ac4d99365 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 19 Aug 2019 08:27:04 -0500 Subject: [PATCH 13/25] Remove warnings of hf 184 --- libraries/chain/db_market.cpp | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index d5e4238b4b..1a2b848f01 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -639,12 +639,8 @@ int database::match( const limit_order_object& bid, const call_order_object& ask auto maint_time = get_dynamic_global_properties().next_maintenance_time; // TODO remove when we're sure it's always false - bool before_core_hardfork_184 = ( maint_time <= HARDFORK_CORE_184_TIME ); // something-for-nothing - // TODO remove when we're sure it's always false bool before_core_hardfork_342 = ( maint_time <= HARDFORK_CORE_342_TIME ); // better rounding - if( before_core_hardfork_184 ) - ilog( "match(limit,call) is called before hardfork core-184 at block #${block}", ("block",head_block_num()) ); if( before_core_hardfork_342 ) ilog( "match(limit,call) is called before hardfork core-342 at block #${block}", ("block",head_block_num()) ); @@ -661,8 +657,7 @@ int database::match( const limit_order_object& bid, const call_order_object& ask // Be here, it's possible that taker is paying something for nothing due to partially filled in last loop. // In this case, we see it as filled and cancel it later - // TODO remove hardfork check when we're sure it's always after hard fork (but keep the zero amount check) - if( order_receives.amount == 0 && !before_core_hardfork_184 ) + if( order_receives.amount == 0 ) return 1; if( before_core_hardfork_342 ) // TODO remove this "if" when we're sure it's always false (keep the code in else) @@ -683,8 +678,7 @@ int database::match( const limit_order_object& bid, const call_order_object& ask if( before_core_hardfork_342 ) // TODO remove this "if" when we're sure it's always false (keep the code in else) { order_receives = usd_to_buy * match_price; // round down here, in favor of call order - // TODO remove hardfork check when we're sure it's always after hard fork (but keep the zero amount check) - if( order_receives.amount == 0 && !before_core_hardfork_184 ) + if( order_receives.amount == 0 ) return 1; } else // has hardfork core-342 @@ -1035,7 +1029,6 @@ bool database::check_call_orders( const asset_object& mia, bool enable_black_swa bool before_hardfork_615 = ( head_time < HARDFORK_615_TIME ); bool after_hardfork_436 = ( head_time > HARDFORK_436_TIME ); - bool before_core_hardfork_184 = ( maint_time <= HARDFORK_CORE_184_TIME ); // something-for-nothing bool before_core_hardfork_342 = ( maint_time <= HARDFORK_CORE_342_TIME ); // better rounding bool before_core_hardfork_343 = ( maint_time <= HARDFORK_CORE_343_TIME ); // update call_price after partially filled bool before_core_hardfork_453 = ( maint_time <= HARDFORK_CORE_453_TIME ); // multiple matching issue @@ -1105,13 +1098,6 @@ bool database::check_call_orders( const asset_object& mia, bool enable_black_swa // * when the limit order is a taker, it could be paying something for nothing only when // the call order is smaller and is too small // * when the limit order is a maker, it won't be paying something for nothing - if( order_receives.amount == 0 ) // TODO this should not happen. remove the warning after confirmed - { - if( before_core_hardfork_184 ) - wlog( "Something for nothing issue (#184, variant D-1) occurred at block #${block}", ("block",head_num) ); - else - wlog( "Something for nothing issue (#184, variant D-2) occurred at block #${block}", ("block",head_num) ); - } if( before_core_hardfork_342 ) call_receives = usd_for_sale; From 0cefb5bb0d7b827fe57322a283f6a2e1ea0702d6 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 19 Aug 2019 08:32:42 -0500 Subject: [PATCH 14/25] clean hf342/warnings --- libraries/chain/db_market.cpp | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index 1a2b848f01..ab13d1dda1 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -638,12 +638,6 @@ int database::match( const limit_order_object& bid, const call_order_object& ask FC_ASSERT( bid.for_sale > 0 && ask.debt > 0 && ask.collateral > 0 ); auto maint_time = get_dynamic_global_properties().next_maintenance_time; - // TODO remove when we're sure it's always false - bool before_core_hardfork_342 = ( maint_time <= HARDFORK_CORE_342_TIME ); // better rounding - - if( before_core_hardfork_342 ) - ilog( "match(limit,call) is called before hardfork core-342 at block #${block}", ("block",head_block_num()) ); - bool cull_taker = false; asset usd_for_sale = bid.amount_for_sale(); @@ -660,29 +654,17 @@ int database::match( const limit_order_object& bid, const call_order_object& ask if( order_receives.amount == 0 ) return 1; - if( before_core_hardfork_342 ) // TODO remove this "if" when we're sure it's always false (keep the code in else) - call_receives = usd_for_sale; - else - { - // The remaining amount in the limit order would be too small, - // so we should cull the order in fill_limit_order() below. - // The order would receive 0 even at `match_price`, so it would receive 0 at its own price, - // so calling maybe_cull_small() will always cull it. - call_receives = order_receives.multiply_and_round_up( match_price ); - cull_taker = true; - } + // The remaining amount in the limit order would be too small, + // so we should cull the order in fill_limit_order() below. + // The order would receive 0 even at `match_price`, so it would receive 0 at its own price, + // so calling maybe_cull_small() will always cull it. + call_receives = order_receives.multiply_and_round_up( match_price ); + cull_taker = true; } else { // fill call order call_receives = usd_to_buy; - if( before_core_hardfork_342 ) // TODO remove this "if" when we're sure it's always false (keep the code in else) - { - order_receives = usd_to_buy * match_price; // round down here, in favor of call order - if( order_receives.amount == 0 ) - return 1; - } - else // has hardfork core-342 - order_receives = usd_to_buy.multiply_and_round_up( match_price ); // round up here, in favor of limit order + order_receives = usd_to_buy.multiply_and_round_up( match_price ); // round up here, in favor of limit order } call_pays = order_receives; From 3e1356ebd17c3e42256ff4764e5a4851bbe4fbf4 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 19 Aug 2019 08:34:28 -0500 Subject: [PATCH 15/25] remove unused variable --- libraries/chain/db_market.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index ab13d1dda1..84c93cafa0 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -637,7 +637,6 @@ int database::match( const limit_order_object& bid, const call_order_object& ask FC_ASSERT( bid.receive_asset_id() == ask.collateral_type() ); FC_ASSERT( bid.for_sale > 0 && ask.debt > 0 && ask.collateral > 0 ); - auto maint_time = get_dynamic_global_properties().next_maintenance_time; bool cull_taker = false; asset usd_for_sale = bid.amount_for_sale(); From b8849cec78d4a76e94be89b0e23d60d998bf3362 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 6 Sep 2019 06:45:51 -0500 Subject: [PATCH 16/25] Remove old warnings --- libraries/chain/db_maint.cpp | 17 ----------------- libraries/chain/db_market.cpp | 18 ++---------------- libraries/chain/proposal_evaluator.cpp | 2 +- 3 files changed, 3 insertions(+), 34 deletions(-) diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 7618fda50b..5e92b49fd8 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -877,7 +877,6 @@ void update_call_orders_hf_343( database& db ) void update_call_orders_hf_1270( database& db ) { // Update call_price - wlog( "Updating all call orders for hardfork core-1270 at block ${n}", ("n",db.head_block_num()) ); for( const auto& call_obj : db.get_index_type().indices().get() ) { db.modify( call_obj, []( call_order_object& call ) { @@ -885,7 +884,6 @@ void update_call_orders_hf_1270( database& db ) call.call_price.quote.amount = 1; }); } - wlog( "Done updating all call orders for hardfork core-1270 at block ${n}", ("n",db.head_block_num()) ); } /// Match call orders for all bitAssets, including PMs. @@ -949,7 +947,6 @@ void database::process_bitassets() void process_hf_1465( database& db ) { const auto head_num = db.head_block_num(); - wlog( "Processing hard fork core-1465 at block ${n}", ("n",head_num) ); // for each market issued asset const auto& asset_idx = db.get_index_type().indices().get(); for( auto asset_itr = asset_idx.lower_bound(true); asset_itr != asset_idx.end(); ++asset_itr ) @@ -1010,7 +1007,6 @@ void process_hf_868_890( database& db, bool skip_check_call_orders ) const auto next_maint_time = db.get_dynamic_global_properties().next_maintenance_time; const auto head_time = db.head_block_time(); const auto head_num = db.head_block_num(); - wlog( "Processing hard fork core-868-890 at block ${n}", ("n",head_num) ); // for each market issued asset const auto& asset_idx = db.get_index_type().indices().get(); for( auto asset_itr = asset_idx.lower_bound(true); asset_itr != asset_idx.end(); ++asset_itr ) @@ -1059,13 +1055,6 @@ void process_hf_868_890( database& db, bool skip_check_call_orders ) } } // end loop of each feed - // if any feed was modified, print a warning message - if( feeds_changed ) - { - wlog( "Found invalid feed for asset ${asset_sym} (${asset_id}) during hardfork core-868-890", - ("asset_sym", current_asset.symbol)("asset_id", current_asset.id) ); - } - // always update the median feed due to https://github.com/bitshares/bitshares-core/issues/890 db.modify( bitasset_data, [head_time,next_maint_time]( asset_bitasset_data_object &obj ) { obj.update_median_feeds( head_time, next_maint_time ); @@ -1073,11 +1062,6 @@ void process_hf_868_890( database& db, bool skip_check_call_orders ) bool median_changed = ( old_feed.settlement_price != bitasset_data.current_feed.settlement_price ); bool median_feed_changed = ( !( old_feed == bitasset_data.current_feed ) ); - if( median_feed_changed ) - { - wlog( "Median feed for asset ${asset_sym} (${asset_id}) changed during hardfork core-868-890", - ("asset_sym", current_asset.symbol)("asset_id", current_asset.id) ); - } // Note: due to bitshares-core issue #935, the check below (using median_changed) is incorrect. // However, `skip_check_call_orders` will likely be true in both testnet and mainnet, @@ -1094,7 +1078,6 @@ void process_hf_868_890( database& db, bool skip_check_call_orders ) ("asset_sym", current_asset.symbol)("asset_id", current_asset.id) ); } } // for each market issued asset - wlog( "Done processing hard fork core-868-890 at block ${n}", ("n",head_num) ); } /****** diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index 84c93cafa0..51cb197d27 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -79,10 +79,6 @@ void database::globally_settle_asset( const asset_object& mia, const price& sett if( before_core_hardfork_342 ) { pays = call_itr->get_debt() * settlement_price; // round down, in favor of call order - - // Be here, the call order can be paying nothing - if( pays.amount == 0 && !bitasset.is_prediction_market ) // TODO remove this warning after hard fork core-342 - wlog( "Something for nothing issue (#184, variant E) occurred at block #${block}", ("block",head_block_num()) ); } else pays = call_itr->get_debt().multiply_and_round_up( settlement_price ); // round up, in favor of global settlement fund @@ -705,14 +701,12 @@ asset database::match( const call_order_object& call, { if( call_receives == call_debt ) // the call order is smaller than or equal to the settle order { - wlog( "Something for nothing issue (#184, variant C-1) handled at block #${block}", ("block",head_block_num()) ); call_pays.amount = 1; } else { if( call_receives == settle.balance ) // the settle order is smaller { - wlog( "Something for nothing issue (#184, variant C-2) handled at block #${block}", ("block",head_block_num()) ); cancel_settle_order( settle ); } // else do nothing: neither order will be completely filled, perhaps due to max_settlement too small @@ -720,8 +714,7 @@ asset database::match( const call_order_object& call, return asset( 0, settle.balance.asset_id ); } } - else // TODO remove this warning after hard fork core-184 - wlog( "Something for nothing issue (#184, variant C) occurred at block #${block}", ("block",head_block_num()) ); + } else // the call order is not paying nothing, but still possible it's paying more than minimum required due to rounding { @@ -767,8 +760,6 @@ asset database::match( const call_order_object& call, if( before_core_hardfork_342 ) { auto call_collateral = call.get_collateral(); - if( call_pays == call_collateral ) // TODO remove warning after hard fork core-342 - wlog( "Incorrectly captured black swan event at block #${block}", ("block",head_block_num()) ); GRAPHENE_ASSERT( call_pays < call_collateral, black_swan_exception, "" ); assert( settle_pays == settle_for_sale || call_receives == call.get_debt() ); @@ -1097,10 +1088,6 @@ bool database::check_call_orders( const asset_object& mia, bool enable_black_swa if( before_core_hardfork_342 ) { order_receives = usd_to_buy * match_price; // round down, in favor of call order - - // Be here, the limit order would be paying something for nothing - if( order_receives.amount == 0 ) // TODO remove warning after hard fork core-342 - wlog( "Something for nothing issue (#184, variant D) occurred at block #${block}", ("block",head_num) ); } else order_receives = usd_to_buy.multiply_and_round_up( match_price ); // round up, in favor of limit order @@ -1109,9 +1096,8 @@ bool database::check_call_orders( const asset_object& mia, bool enable_black_swa if( usd_to_buy == usd_for_sale ) filled_limit = true; - else if( filled_limit && maint_time <= HARDFORK_CORE_453_TIME ) // TODO remove warning after hard fork core-453 + else if( filled_limit && maint_time <= HARDFORK_CORE_453_TIME ) { - wlog( "Multiple limit match problem (issue 453) occurred at block #${block}", ("block",head_num) ); if( before_hardfork_615 ) _issue_453_affected_assets.insert( bitasset.asset_id ); } diff --git a/libraries/chain/proposal_evaluator.cpp b/libraries/chain/proposal_evaluator.cpp index 72ff49eeb8..08e2ad9d64 100644 --- a/libraries/chain/proposal_evaluator.cpp +++ b/libraries/chain/proposal_evaluator.cpp @@ -206,7 +206,7 @@ object_id_type proposal_create_evaluator::do_apply(const proposal_create_operati top.to = GRAPHENE_RELAXED_COMMITTEE_ACCOUNT; top.amount = asset( GRAPHENE_MAX_SHARE_SUPPLY ); proposal.proposed_transaction.operations.emplace_back( top ); - wlog( "Issue 1479: ${p}", ("p",proposal) ); + wlog( "Issue 1479: ${p}", ("p",proposal) ); // Note: This happened on mainnet 1.10.17503 } }); From 198861d5edebc6b7ba79b1b7a1aa57c2fb91997e Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 9 Sep 2019 08:20:06 -0500 Subject: [PATCH 17/25] Added comments in place of warnings --- libraries/chain/db_market.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index 51cb197d27..c772a8997d 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -78,6 +78,7 @@ void database::globally_settle_asset( const asset_object& mia, const price& sett { if( before_core_hardfork_342 ) { + //Note: If here, the call order may be paying nothing (Yes, this happened) pays = call_itr->get_debt() * settlement_price; // round down, in favor of call order } else @@ -760,6 +761,7 @@ asset database::match( const call_order_object& call, if( before_core_hardfork_342 ) { auto call_collateral = call.get_collateral(); + // NOTE: incorrectly captured a black swan event. Unfortunately, this happened. GRAPHENE_ASSERT( call_pays < call_collateral, black_swan_exception, "" ); assert( settle_pays == settle_for_sale || call_receives == call.get_debt() ); @@ -1087,6 +1089,7 @@ bool database::check_call_orders( const asset_object& mia, bool enable_black_swa if( before_core_hardfork_342 ) { + // NOTE: To be here, limit order could paying something for nothing (Yes, this happened) order_receives = usd_to_buy * match_price; // round down, in favor of call order } else @@ -1098,6 +1101,7 @@ bool database::check_call_orders( const asset_object& mia, bool enable_black_swa filled_limit = true; else if( filled_limit && maint_time <= HARDFORK_CORE_453_TIME ) { + //NOTE: Multiple limit match problem (see issue 453, yes this happened) if( before_hardfork_615 ) _issue_453_affected_assets.insert( bitasset.asset_id ); } From b2c39447650dbc8614fb7529150de3c9113578f6 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 9 Sep 2019 08:25:39 -0500 Subject: [PATCH 18/25] Cleanup of hf 935 --- libraries/chain/asset_evaluator.cpp | 16 ++------- libraries/chain/db_maint.cpp | 51 ----------------------------- tests/tests/bitasset_tests.cpp | 7 +--- 3 files changed, 3 insertions(+), 71 deletions(-) diff --git a/libraries/chain/asset_evaluator.cpp b/libraries/chain/asset_evaluator.cpp index 5546e4a61d..151d85ab0a 100644 --- a/libraries/chain/asset_evaluator.cpp +++ b/libraries/chain/asset_evaluator.cpp @@ -559,24 +559,12 @@ static bool update_bitasset_object_options( const auto old_feed = bdo.current_feed; bdo.update_median_feeds( db.head_block_time(), next_maint_time ); - // TODO review and refactor / cleanup after hard fork: - // 1. if hf_core_868_890 and core-935 occurred at same time - // 2. if wlog did not actually get called - - // We need to call check_call_orders if the price feed changes after hardfork core-935 - if( next_maint_time > HARDFORK_CORE_935_TIME ) - return ( !( old_feed == bdo.current_feed ) ); - // We need to call check_call_orders if the settlement price changes after hardfork core-868-890 if( after_hf_core_868_890 ) { - if( old_feed.settlement_price != bdo.current_feed.settlement_price ) + if( old_feed.settlement_price != bdo.current_feed.settlement_price || + !( old_feed == bdo.current_feed ) ) return true; - else - { - if( !( old_feed == bdo.current_feed ) ) - wlog( "Settlement price did not change but current_feed changed at block ${b}", ("b",db.head_block_num()) ); - } } } diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 5e92b49fd8..7126a09620 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -1080,52 +1080,6 @@ void process_hf_868_890( database& db, bool skip_check_call_orders ) } // for each market issued asset } -/****** - * @brief one-time data process for hard fork core-935 - * - * Prior to hardfork 935, `check_call_orders` may be unintendedly skipped when - * median price feed has changed. This method will run at the hardfork time, and - * call `check_call_orders` for all markets. - * https://github.com/bitshares/bitshares-core/issues/935 - * - * @param db the database - */ -// TODO: for better performance, this function can be removed if it actually updated nothing at hf time. -// * Also need to update related test cases -// * NOTE: perhaps the removal can't be applied to testnet -void process_hf_935( database& db ) -{ - bool changed_something = false; - const asset_bitasset_data_object* bitasset = nullptr; - bool settled_before_check_call; - bool settled_after_check_call; - // for each market issued asset - const auto& asset_idx = db.get_index_type().indices().get(); - for( auto asset_itr = asset_idx.lower_bound(true); asset_itr != asset_idx.end(); ++asset_itr ) - { - const auto& current_asset = *asset_itr; - - if( !changed_something ) - { - bitasset = ¤t_asset.bitasset_data( db ); - settled_before_check_call = bitasset->has_settlement(); // whether already force settled - } - - bool called_some = db.check_call_orders( current_asset ); - - if( !changed_something ) - { - settled_after_check_call = bitasset->has_settlement(); // whether already force settled - - if( settled_before_check_call != settled_after_check_call || called_some ) - { - changed_something = true; - wlog( "process_hf_935 changed something" ); - } - } - } -} - void database::perform_chain_maintenance(const signed_block& next_block, const global_property_object& global_props) { const auto& gpo = get_global_properties(); @@ -1271,11 +1225,6 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g if( (dgpo.next_maintenance_time <= HARDFORK_CORE_868_890_TIME) && (next_maintenance_time > HARDFORK_CORE_868_890_TIME) ) process_hf_868_890( *this, to_update_and_match_call_orders_for_hf_343 ); - // Explicitly call check_call_orders of all markets - if( (dgpo.next_maintenance_time <= HARDFORK_CORE_935_TIME) && (next_maintenance_time > HARDFORK_CORE_935_TIME) - && !to_update_and_match_call_orders_for_hf_343 ) - process_hf_935( *this ); - // To reset call_price of all call orders, then match by new rule, for hard fork core-1270 bool to_update_and_match_call_orders_for_hf_1270 = false; if( (dgpo.next_maintenance_time <= HARDFORK_CORE_1270_TIME) && (next_maintenance_time > HARDFORK_CORE_1270_TIME) ) diff --git a/tests/tests/bitasset_tests.cpp b/tests/tests/bitasset_tests.cpp index 2c07857e76..92d030713f 100644 --- a/tests/tests/bitasset_tests.cpp +++ b/tests/tests/bitasset_tests.cpp @@ -933,16 +933,11 @@ BOOST_AUTO_TEST_CASE( hf_935_test ) int blocks = 0; auto mi = db.get_global_properties().parameters.maintenance_interval; - if( i == 2 ) // go beyond hard fork 890 + if( i == 2) // go beyond hard fork 890 (which is the same as 935 BTW) { generate_blocks( HARDFORK_CORE_868_890_TIME - mi, true, skip ); generate_blocks( db.get_dynamic_global_properties().next_maintenance_time, true, skip ); } - else if( i == 4 ) // go beyond hard fork 935 - { - generate_blocks( HARDFORK_CORE_935_TIME - mi, true, skip ); - generate_blocks( db.get_dynamic_global_properties().next_maintenance_time, true, skip ); - } else if( i == 6 ) // go beyond hard fork 1270 { generate_blocks( HARDFORK_CORE_1270_TIME - mi, true, skip ); From 7dcdd8bf45d791e96546f0c517864d959deb01ee Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 9 Sep 2019 08:47:42 -0500 Subject: [PATCH 19/25] replace warning with comment, HF 1479 --- libraries/chain/proposal_evaluator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chain/proposal_evaluator.cpp b/libraries/chain/proposal_evaluator.cpp index 08e2ad9d64..29e77bb142 100644 --- a/libraries/chain/proposal_evaluator.cpp +++ b/libraries/chain/proposal_evaluator.cpp @@ -200,13 +200,13 @@ object_id_type proposal_create_evaluator::do_apply(const proposal_create_operati "Cannot update/delete a proposal with a future id!" ); else if( vtor_1479.nested_update_count > 0 && proposal.id.instance() <= vtor_1479.max_update_instance ) { + // Note: This happened on mainnet, proposal 1.10.17503 // prevent approval transfer_operation top; top.from = GRAPHENE_NULL_ACCOUNT; top.to = GRAPHENE_RELAXED_COMMITTEE_ACCOUNT; top.amount = asset( GRAPHENE_MAX_SHARE_SUPPLY ); proposal.proposed_transaction.operations.emplace_back( top ); - wlog( "Issue 1479: ${p}", ("p",proposal) ); // Note: This happened on mainnet 1.10.17503 } }); From b8cba58305cf61549e01460c4558ebace0266ea8 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 10 Sep 2019 10:05:10 -0500 Subject: [PATCH 20/25] more cleanup of hf 890 and comments --- libraries/chain/asset_evaluator.cpp | 7 +------ libraries/chain/db_maint.cpp | 29 +++++------------------------ libraries/chain/db_market.cpp | 2 -- 3 files changed, 6 insertions(+), 32 deletions(-) diff --git a/libraries/chain/asset_evaluator.cpp b/libraries/chain/asset_evaluator.cpp index 151d85ab0a..d3d4df1254 100644 --- a/libraries/chain/asset_evaluator.cpp +++ b/libraries/chain/asset_evaluator.cpp @@ -560,12 +560,7 @@ static bool update_bitasset_object_options( bdo.update_median_feeds( db.head_block_time(), next_maint_time ); // We need to call check_call_orders if the settlement price changes after hardfork core-868-890 - if( after_hf_core_868_890 ) - { - if( old_feed.settlement_price != bdo.current_feed.settlement_price || - !( old_feed == bdo.current_feed ) ) - return true; - } + return ( after_hf_core_868_890 && ! (old_feed == bdo.current_feed) ); } return false; diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 7126a09620..3690bd226d 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -943,10 +943,12 @@ void database::process_bitassets() /**** * @brief a one-time data process to correct max_supply + * + * NOTE: while exceeding max_supply happened in mainnet, it seemed to have corrected + * itself before HF 1465. But this method must remain to correct some assets in testnet */ void process_hf_1465( database& db ) { - const auto head_num = db.head_block_num(); // for each market issued asset const auto& asset_idx = db.get_index_type().indices().get(); for( auto asset_itr = asset_idx.lower_bound(true); asset_itr != asset_idx.end(); ++asset_itr ) @@ -999,14 +1001,12 @@ void update_median_feeds(database& db) * @param db the database * @param skip_check_call_orders true if check_call_orders() should not be called */ -// TODO: for better performance, this function can be removed if it actually updated nothing at hf time. -// * Also need to update related test cases -// * NOTE: the removal can't be applied to testnet +// NOTE: Unable to remove this function for testnet nor mainnet. Unfortunately, bad +// feeds were found. void process_hf_868_890( database& db, bool skip_check_call_orders ) { const auto next_maint_time = db.get_dynamic_global_properties().next_maintenance_time; const auto head_time = db.head_block_time(); - const auto head_num = db.head_block_num(); // for each market issued asset const auto& asset_idx = db.get_index_type().indices().get(); for( auto asset_itr = asset_idx.lower_bound(true); asset_itr != asset_idx.end(); ++asset_itr ) @@ -1024,7 +1024,6 @@ void process_hf_868_890( database& db, bool skip_check_call_orders ) const asset_bitasset_data_object& bitasset_data = current_asset.bitasset_data(db); // NOTE: We'll only need old_feed if HF343 hasn't rolled out yet auto old_feed = bitasset_data.current_feed; - bool feeds_changed = false; // did any feed change auto itr = bitasset_data.feeds.begin(); while( itr != bitasset_data.feeds.end() ) { @@ -1032,7 +1031,6 @@ void process_hf_868_890( database& db, bool skip_check_call_orders ) if ( itr->second.second.settlement_price.quote.asset_id != bitasset_data.options.short_backing_asset && ( is_witness_or_committee_fed || itr->second.second.settlement_price != price() ) ) { - feeds_changed = true; db.modify( bitasset_data, [&itr, is_witness_or_committee_fed]( asset_bitasset_data_object& obj ) { if( is_witness_or_committee_fed ) @@ -1060,23 +1058,6 @@ void process_hf_868_890( database& db, bool skip_check_call_orders ) obj.update_median_feeds( head_time, next_maint_time ); }); - bool median_changed = ( old_feed.settlement_price != bitasset_data.current_feed.settlement_price ); - bool median_feed_changed = ( !( old_feed == bitasset_data.current_feed ) ); - - // Note: due to bitshares-core issue #935, the check below (using median_changed) is incorrect. - // However, `skip_check_call_orders` will likely be true in both testnet and mainnet, - // so effectively the incorrect code won't make a difference. - // Additionally, we have code to update all call orders again during hardfork core-935 - // TODO cleanup after hard fork - if( !skip_check_call_orders && median_changed ) // check_call_orders should be called - { - db.check_call_orders( current_asset ); - } - else if( !skip_check_call_orders && median_feed_changed ) - { - wlog( "Incorrectly skipped check_call_orders for asset ${asset_sym} (${asset_id}) during hardfork core-868-890", - ("asset_sym", current_asset.symbol)("asset_id", current_asset.id) ); - } } // for each market issued asset } diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index c772a8997d..d87bba24ac 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -761,7 +761,6 @@ asset database::match( const call_order_object& call, if( before_core_hardfork_342 ) { auto call_collateral = call.get_collateral(); - // NOTE: incorrectly captured a black swan event. Unfortunately, this happened. GRAPHENE_ASSERT( call_pays < call_collateral, black_swan_exception, "" ); assert( settle_pays == settle_for_sale || call_receives == call.get_debt() ); @@ -1089,7 +1088,6 @@ bool database::check_call_orders( const asset_object& mia, bool enable_black_swa if( before_core_hardfork_342 ) { - // NOTE: To be here, limit order could paying something for nothing (Yes, this happened) order_receives = usd_to_buy * match_price; // round down, in favor of call order } else From 0a76088557e2c34976c2d33baef328bd95cd47af Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 10 Sep 2019 15:04:54 -0500 Subject: [PATCH 21/25] fix hf 1270 test --- tests/common/database_fixture.cpp | 3 ++- tests/tests/bitasset_tests.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index 06c1803db7..3c2e6b8330 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -94,7 +94,8 @@ database_fixture::database_fixture(const fc::time_point_sec &initial_timestamp) genesis_state.initial_timestamp = initial_timestamp; - if(current_test_name == "hf_935_test") { + if(boost::unit_test::framework::current_test_case().p_name.value == "hf_1270_test") + { genesis_state.initial_active_witnesses = 20; } else { diff --git a/tests/tests/bitasset_tests.cpp b/tests/tests/bitasset_tests.cpp index 92d030713f..ff696fec60 100644 --- a/tests/tests/bitasset_tests.cpp +++ b/tests/tests/bitasset_tests.cpp @@ -914,7 +914,7 @@ BOOST_AUTO_TEST_CASE( bitasset_evaluator_test_after_922_931 ) /********* * @brief Call check_call_orders after current_feed changed but not only settlement_price changed. */ -BOOST_AUTO_TEST_CASE( hf_935_test ) +BOOST_AUTO_TEST_CASE( hf_1270_test ) { try { uint32_t skip = database::skip_witness_signature | database::skip_transaction_signatures From cfe27a07ceca18fa2ea8b99f6623082e2ac632d5 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 10 Sep 2019 15:06:32 -0500 Subject: [PATCH 22/25] Fix comment --- libraries/chain/db_maint.cpp | 2 -- libraries/chain/db_market.cpp | 3 --- tests/tests/bitasset_tests.cpp | 2 +- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 3690bd226d..bb644053aa 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -1022,8 +1022,6 @@ void process_hf_868_890( database& db, bool skip_check_call_orders ) // for each feed const asset_bitasset_data_object& bitasset_data = current_asset.bitasset_data(db); - // NOTE: We'll only need old_feed if HF343 hasn't rolled out yet - auto old_feed = bitasset_data.current_feed; auto itr = bitasset_data.feeds.begin(); while( itr != bitasset_data.feeds.end() ) { diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index d87bba24ac..2a028dbe33 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -77,10 +77,7 @@ void database::globally_settle_asset( const asset_object& mia, const price& sett while( call_itr != call_end ) { if( before_core_hardfork_342 ) - { - //Note: If here, the call order may be paying nothing (Yes, this happened) pays = call_itr->get_debt() * settlement_price; // round down, in favor of call order - } else pays = call_itr->get_debt().multiply_and_round_up( settlement_price ); // round up, in favor of global settlement fund diff --git a/tests/tests/bitasset_tests.cpp b/tests/tests/bitasset_tests.cpp index ff696fec60..0c58af042d 100644 --- a/tests/tests/bitasset_tests.cpp +++ b/tests/tests/bitasset_tests.cpp @@ -912,7 +912,7 @@ BOOST_AUTO_TEST_CASE( bitasset_evaluator_test_after_922_931 ) } /********* - * @brief Call check_call_orders after current_feed changed but not only settlement_price changed. + * @brief Call price inconsistent when MCR changed */ BOOST_AUTO_TEST_CASE( hf_1270_test ) { try { From 8b04d0dc568c74f3685655e6fdc44a86d515c74e Mon Sep 17 00:00:00 2001 From: John Jones Date: Wed, 11 Sep 2019 09:49:11 -0500 Subject: [PATCH 23/25] added missing bracket From 514d4a715a3c8f7283d004e0a3bf6eb6c7d1b107 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 13 Sep 2019 06:28:54 -0500 Subject: [PATCH 24/25] add clarifying comment --- libraries/chain/db_maint.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index bb644053aa..fdf756f184 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -1054,6 +1054,8 @@ void process_hf_868_890( database& db, bool skip_check_call_orders ) // always update the median feed due to https://github.com/bitshares/bitshares-core/issues/890 db.modify( bitasset_data, [head_time,next_maint_time]( asset_bitasset_data_object &obj ) { obj.update_median_feeds( head_time, next_maint_time ); + // NOTE: Normally we should call check_call_orders() after called update_median_feeds(), but for + // mainnet actually check_call_orders() would do nothing, so we skipped it for better performance. }); } // for each market issued asset From fd2587fcff895abe2ff03136cfb502dff52eeead Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Tue, 15 Oct 2019 17:45:53 +0200 Subject: [PATCH 25/25] Use "current_test_name" variable --- tests/common/database_fixture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index 3c2e6b8330..0648587423 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -94,7 +94,7 @@ database_fixture::database_fixture(const fc::time_point_sec &initial_timestamp) genesis_state.initial_timestamp = initial_timestamp; - if(boost::unit_test::framework::current_test_case().p_name.value == "hf_1270_test") + if(current_test_name == "hf_1270_test") { genesis_state.initial_active_witnesses = 20; }