diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index c009d0b830..e0af516b00 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -1249,6 +1249,11 @@ asset database::pay_market_fees(const account_object& seller, const asset_object FC_ASSERT( reward < issuer_fees, "Market reward should be less than issuer fees"); // cut referrer percent from reward auto registrar_reward = reward; + + auto registrar = ( seller.registrar == GRAPHENE_TEMP_ACCOUNT && head_block_time() >= HARDFORK_CORE_1800_TIME ) + ? GRAPHENE_COMMITTEE_ACCOUNT + : seller.registrar; + if( seller.referrer != seller.registrar ) { const auto referrer_rewards_value = detail::calculate_percent( reward.amount, @@ -1263,7 +1268,8 @@ asset database::pay_market_fees(const account_object& seller, const asset_object deposit_market_fee_vesting_balance(seller.referrer, referrer_reward); } } - deposit_market_fee_vesting_balance(seller.registrar, registrar_reward); + deposit_market_fee_vesting_balance(registrar, registrar_reward); + } } } diff --git a/libraries/chain/hardfork.d/CORE_1800.hf b/libraries/chain/hardfork.d/CORE_1800.hf new file mode 100644 index 0000000000..39d8334cc8 --- /dev/null +++ b/libraries/chain/hardfork.d/CORE_1800.hf @@ -0,0 +1,4 @@ +// bitshares-core issue #1800 Fix "Temp-account market fee sharing" +#ifndef HARDFORK_CORE_1800_TIME +#define HARDFORK_CORE_1800_TIME (fc::time_point_sec( 1600000000 )) // Tue, 23 Jul 2019 13:35:00 UTC +#endif diff --git a/tests/tests/market_fee_sharing_tests.cpp b/tests/tests/market_fee_sharing_tests.cpp index 2ba95b2c5b..378c8f63dc 100644 --- a/tests/tests/market_fee_sharing_tests.cpp +++ b/tests/tests/market_fee_sharing_tests.cpp @@ -96,6 +96,12 @@ struct reward_database_fixture : database_fixture database_fixture::generate_block(); } + void generate_blocks_past_hf1800() + { + database_fixture::generate_blocks( HARDFORK_CORE_1800_TIME ); + database_fixture::generate_block(); + } + asset core_asset(int64_t x ) { return asset( x*core_precision ); @@ -431,18 +437,85 @@ BOOST_AUTO_TEST_CASE(create_actors) const account_object alice = create_account("alice", izzyregistrar, izzyreferrer, 50/*0.5%*/); const account_object bob = create_account("bob", izzyregistrar, izzyreferrer, 50/*0.5%*/); + const account_object old = create_account("old", GRAPHENE_TEMP_ACCOUNT(db), GRAPHENE_COMMITTEE_ACCOUNT(db), 50u); // prepare users' balance issue_uia( alice, jillcoin.amount( 20000000 ) ); transfer( committee_account, alice.get_id(), core_asset(1000) ); transfer( committee_account, bob.get_id(), core_asset(1000) ); + transfer( committee_account, old.get_id(), core_asset(1000) ); transfer( committee_account, izzyregistrar.get_id(), core_asset(1000) ); transfer( committee_account, izzyreferrer.get_id(), core_asset(1000) ); } FC_LOG_AND_RETHROW() } +BOOST_AUTO_TEST_CASE(fee_shares_between_temp_acc_and_committee_acc) +{ + try + { + INVOKE(create_actors); + + generate_blocks_past_hf1268(); + GET_ACTOR(jill); + + constexpr auto jillcoin_reward_percent = 2*GRAPHENE_1_PERCENT; + const asset_object &jillcoin = get_asset("JCOIN"); + + flat_set whitelist; + update_asset(jill_id, jill_private_key, jillcoin.get_id(), jillcoin_reward_percent, whitelist); + + BOOST_CHECK_EQUAL( get_market_fee_reward( GRAPHENE_TEMP_ACCOUNT(db), jillcoin), 0); + BOOST_CHECK_EQUAL( get_market_fee_reward( GRAPHENE_COMMITTEE_ACCOUNT(db), jillcoin), 0); + + GET_ACTOR(alice); + GET_ACTOR(old); + + create_sell_order( alice, jillcoin.amount(100000), core_asset(1) ); + create_sell_order( old, core_asset(1), jillcoin.amount(100000) ); + + BOOST_CHECK_GT( get_market_fee_reward( GRAPHENE_TEMP_ACCOUNT(db), jillcoin), 0); + BOOST_CHECK_GT( get_market_fee_reward( GRAPHENE_COMMITTEE_ACCOUNT(db), jillcoin), 0); + + } + FC_LOG_AND_RETHROW() + +} + +BOOST_AUTO_TEST_CASE(fee_do_not_shares_between_temp_acc_and_committee_acc) +{ + try + { + INVOKE(create_actors); + + generate_blocks_past_hf1800(); + GET_ACTOR(jill); + + constexpr auto jillcoin_reward_percent = 2*GRAPHENE_1_PERCENT; + const asset_object &jillcoin = get_asset("JCOIN"); + + flat_set whitelist; + update_asset(jill_id, jill_private_key, jillcoin.get_id(), jillcoin_reward_percent, whitelist); + + BOOST_CHECK_EQUAL( get_market_fee_reward( GRAPHENE_TEMP_ACCOUNT(db), jillcoin), 0); + BOOST_CHECK_EQUAL( get_market_fee_reward( GRAPHENE_COMMITTEE_ACCOUNT(db), jillcoin), 0); + + GET_ACTOR(alice); + GET_ACTOR(old); + + create_sell_order( alice, jillcoin.amount(100000), core_asset(1) ); + create_sell_order( old, core_asset(1), jillcoin.amount(100000) ); + + + BOOST_CHECK_EQUAL( get_market_fee_reward( GRAPHENE_TEMP_ACCOUNT(db), jillcoin), 0); + BOOST_CHECK_GT( get_market_fee_reward( GRAPHENE_COMMITTEE_ACCOUNT(db), jillcoin), 0); + + } + FC_LOG_AND_RETHROW() + +} + BOOST_AUTO_TEST_CASE(white_list_is_empty_test) { try