Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up hardfork code #1718

Merged
merged 16 commits into from
Apr 29, 2019
13 changes: 0 additions & 13 deletions libraries/chain/account_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,6 @@ void_result account_create_evaluator::do_evaluate( const account_create_operatio
FC_ASSERT( !op.extensions.value.owner_special_authority.valid() );
FC_ASSERT( !op.extensions.value.active_special_authority.valid() );
jmjatlanta marked this conversation as resolved.
Show resolved Hide resolved
}
if( d.head_block_time() < HARDFORK_599_TIME )
{
FC_ASSERT( !op.extensions.value.null_ext.valid() );
FC_ASSERT( !op.extensions.value.owner_special_authority.valid() );
FC_ASSERT( !op.extensions.value.active_special_authority.valid() );
FC_ASSERT( !op.extensions.value.buyback_options.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." );
Expand Down Expand Up @@ -280,12 +273,6 @@ void_result account_update_evaluator::do_evaluate( const account_update_operatio
FC_ASSERT( !o.extensions.value.owner_special_authority.valid() );
jmjatlanta marked this conversation as resolved.
Show resolved Hide resolved
FC_ASSERT( !o.extensions.value.active_special_authority.valid() );
jmjatlanta marked this conversation as resolved.
Show resolved Hide resolved
}
if( d.head_block_time() < HARDFORK_599_TIME )
{
FC_ASSERT( !o.extensions.value.null_ext.valid() );
FC_ASSERT( !o.extensions.value.owner_special_authority.valid() );
FC_ASSERT( !o.extensions.value.active_special_authority.valid() );
}

try
{
Expand Down
14 changes: 0 additions & 14 deletions libraries/chain/asset_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ void_result asset_create_evaluator::do_evaluate( const asset_create_operation& o
FC_ASSERT( asset_symbol_itr->issuer == op.issuer, "Asset ${s} may only be created by issuer of ${p}, ${i}",
jmjatlanta marked this conversation as resolved.
Show resolved Hide resolved
("s",op.symbol)("p",prefix)("i", op.issuer(d).name) );
}

if(d.head_block_time() <= HARDFORK_CORE_620_TIME ) { // TODO: remove this check after hf_620
static const std::locale& loc = std::locale::classic();
FC_ASSERT(isalpha(op.symbol.back(), loc), "Asset ${s} must end with alpha character before hardfork 620", ("s",op.symbol));
}
}
else
{
Expand Down Expand Up @@ -375,12 +370,6 @@ void_result asset_update_issuer_evaluator::do_evaluate(const asset_update_issuer
"Incorrect issuer for asset! (${o.issuer} != ${a.issuer})",
jmjatlanta marked this conversation as resolved.
Show resolved Hide resolved
("o.issuer", o.issuer)("a.issuer", a.issuer) );

if( d.head_block_time() < HARDFORK_CORE_199_TIME )
{
// TODO: remove after HARDFORK_CORE_199_TIME has passed
FC_ASSERT(false, "Not allowed until hardfork 199");
}

return void_result();
} FC_CAPTURE_AND_RETHROW((o)) }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace the TODO comment on lines 479/609 with an explanation why it can't be removed.

Expand Down Expand Up @@ -1043,7 +1032,6 @@ void_result asset_publish_feeds_evaluator::do_apply(const asset_publish_feed_ope

void_result asset_claim_fees_evaluator::do_evaluate( const asset_claim_fees_operation& o )
{ try {
FC_ASSERT( db().head_block_time() > HARDFORK_413_TIME );
FC_ASSERT( o.amount_to_claim.asset_id(db()).issuer == o.issuer, "Asset fees may only be claimed by the issuer" );
return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) }
Expand All @@ -1069,8 +1057,6 @@ void_result asset_claim_fees_evaluator::do_apply( const asset_claim_fees_operati

void_result asset_claim_pool_evaluator::do_evaluate( const asset_claim_pool_operation& o )
{ try {
FC_ASSERT( db().head_block_time() >= HARDFORK_CORE_188_TIME,
"This operation is only available after Hardfork #188!" );
FC_ASSERT( o.asset_id(db()).issuer == o.issuer, "Asset fee pool may only be claimed by the issuer" );

return void_result();
Expand Down
1 change: 0 additions & 1 deletion libraries/chain/buyback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ namespace graphene { namespace chain {

void evaluate_buyback_account_options( const database& db, const buyback_account_options& bbo )
{
FC_ASSERT( db.head_block_time() >= HARDFORK_538_TIME );
const asset_object& a = bbo.asset_to_buy(db);
GRAPHENE_ASSERT( a.issuer == bbo.asset_to_buy_issuer,
account_create_buyback_incorrect_issuer, "Incorrect asset issuer specified in buyback_account_options", ("asset", a)("bbo", bbo) );
Expand Down
13 changes: 2 additions & 11 deletions libraries/chain/db_market.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,25 +641,16 @@ int database::match( const limit_order_object& bid, const call_order_object& ask
// TODO remove when we're sure it's always false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update this comment to indicate why we're sure it's not 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
jmjatlanta marked this conversation as resolved.
Show resolved Hide resolved
bool before_core_hardfork_834 = ( maint_time <= HARDFORK_CORE_834_TIME ); // target collateral ratio option
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()) );
if( before_core_hardfork_834 )
ilog( "match(limit,call) is called before hardfork core-834 at block #${block}", ("block",head_block_num()) );

bool cull_taker = false;

asset usd_for_sale = bid.amount_for_sale();
// TODO if we're sure `before_core_hardfork_834` is always false, remove the check
asset usd_to_buy = ( before_core_hardfork_834 ?
ask.get_debt() :
asset( ask.get_max_debt_to_cover( match_price,
feed_price,
maintenance_collateral_ratio,
maintenance_collateralization ),
ask.debt_type() ) );
asset usd_to_buy = asset( ask.get_max_debt_to_cover( match_price, feed_price,
maintenance_collateral_ratio, maintenance_collateralization ), ask.debt_type() );

asset call_pays, call_receives, order_pays, order_receives;
if( usd_to_buy > usd_for_sale )
Expand Down
10 changes: 5 additions & 5 deletions libraries/chain/evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ database& generic_evaluator::db()const { return trx_state->db(); }
fee_asset = &fee.asset_id(d);
fee_asset_dyn_data = &fee_asset->dynamic_asset_data_id(d);

if( d.head_block_time() > HARDFORK_419_TIME )
{
FC_ASSERT( is_authorized_asset( d, *fee_paying_account, *fee_asset ), "Account ${acct} '${name}' attempted to pay fee by using asset ${a} '${sym}', which is unauthorized due to whitelist / blacklist",
("acct", fee_paying_account->id)("name", fee_paying_account->name)("a", fee_asset->id)("sym", fee_asset->symbol) );
}
FC_ASSERT( is_authorized_asset( d, *fee_paying_account, *fee_asset ),
"Account ${acct} '${name}' attempted to pay fee by using asset ${a} '${sym}', "
"which is unauthorized due to whitelist / blacklist",
( "acct", fee_paying_account->id)("name", fee_paying_account->name)("a", fee_asset->id)
("sym", fee_asset->symbol) );

if( fee_from_account.asset_id == asset_id_type() )
core_fee_paid = fee_from_account.amount;
Expand Down
4 changes: 0 additions & 4 deletions libraries/chain/hardfork.d/23.hf

This file was deleted.

4 changes: 0 additions & 4 deletions libraries/chain/hardfork.d/357.hf

This file was deleted.

4 changes: 0 additions & 4 deletions libraries/chain/hardfork.d/359.hf

This file was deleted.

4 changes: 0 additions & 4 deletions libraries/chain/hardfork.d/409.hf

This file was deleted.

4 changes: 0 additions & 4 deletions libraries/chain/hardfork.d/413.hf

This file was deleted.

4 changes: 0 additions & 4 deletions libraries/chain/hardfork.d/415.hf

This file was deleted.

4 changes: 0 additions & 4 deletions libraries/chain/hardfork.d/416.hf

This file was deleted.

4 changes: 0 additions & 4 deletions libraries/chain/hardfork.d/419.hf

This file was deleted.

4 changes: 0 additions & 4 deletions libraries/chain/hardfork.d/538.hf

This file was deleted.

4 changes: 0 additions & 4 deletions libraries/chain/hardfork.d/599.hf

This file was deleted.

4 changes: 0 additions & 4 deletions libraries/chain/hardfork.d/CORE_1040.hf

This file was deleted.

4 changes: 0 additions & 4 deletions libraries/chain/hardfork.d/CORE_188.hf

This file was deleted.

4 changes: 0 additions & 4 deletions libraries/chain/hardfork.d/CORE_620.hf

This file was deleted.

5 changes: 0 additions & 5 deletions libraries/chain/hardfork.d/CORE_942.hf

This file was deleted.

7 changes: 2 additions & 5 deletions libraries/chain/is_authorized_asset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@ bool _is_authorized_asset(
return false;
}

if( d.head_block_time() > HARDFORK_415_TIME )
{
if( asset_obj.options.whitelist_authorities.size() == 0 )
return true;
}
if( asset_obj.options.whitelist_authorities.size() == 0 )
return true;

for( const auto id : acct.whitelisting_accounts )
{
Expand Down
7 changes: 1 addition & 6 deletions libraries/chain/market_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,6 @@ void_result call_order_update_evaluator::do_evaluate(const call_order_update_ope

auto next_maintenance_time = d.get_dynamic_global_properties().next_maintenance_time;

// TODO: remove this check and the assertion after hf_834
if( next_maintenance_time <= HARDFORK_CORE_834_TIME )
FC_ASSERT( !o.extensions.value.target_collateral_ratio.valid(),
"Can not set target_collateral_ratio in call_order_update_operation before hardfork 834." );

_paying_account = &o.funding_account(d);
_debt_asset = &o.delta_debt.asset_id(d);
FC_ASSERT( _debt_asset->is_market_issued(), "Unable to cover ${sym} as it is not a collateralized asset.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the comment in lines 172-176.

Copy link
Contributor Author

@jmjatlanta jmjatlanta May 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated comment about softfork 1465 as part of #1743
Update more work needed on this one.

Expand Down Expand Up @@ -330,7 +325,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" );
if( d.head_block_time() <= HARDFORK_CORE_583_TIME ) // TODO remove after hard fork core-583
if( d.head_block_time() <= HARDFORK_CORE_583_TIME )
jmjatlanta marked this conversation as resolved.
Show resolved Hide resolved
{
// We didn't fill any call orders. This may be because we
// aren't in margin call territory, or it may be because there
Expand Down
26 changes: 1 addition & 25 deletions libraries/chain/proposal_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,9 @@ struct proposal_operation_hardfork_visitor
|| (v.delta_debt.asset_id( db ).bitasset_data_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace the TODO comment in line 51

&& (*(v.delta_debt.asset_id( db ).bitasset_data_id))( db ).is_prediction_market )
, "Soft fork - preventing proposal with call_order_update!" );

// TODO review and cleanup code below after hard fork
// hf_834
if (next_maintenance_time <= HARDFORK_CORE_834_TIME) {
FC_ASSERT( !v.extensions.value.target_collateral_ratio.valid(),
"Can not set target_collateral_ratio in call_order_update_operation before hardfork 834." );
}
}
// hf_620
// hf_1268
void operator()(const graphene::chain::asset_create_operation &v) const {
if (block_time < HARDFORK_CORE_620_TIME) {
static const std::locale &loc = std::locale::classic();
FC_ASSERT(isalpha(v.symbol.back(), loc), "Asset ${s} must end with alpha character before hardfork 620", ("s", v.symbol));
}

detail::check_asset_options_hf_1268(block_time, v.common_options);
}
// hf_1268
Expand All @@ -81,18 +69,6 @@ struct proposal_operation_hardfork_visitor
void operator()(const graphene::chain::vesting_balance_create_operation &v) const {
detail::check_vesting_balance_policy_hf_1268(block_time, v.policy);
}
// hf_199
void operator()(const graphene::chain::asset_update_issuer_operation &v) const {
if (block_time < HARDFORK_CORE_199_TIME) {
FC_ASSERT(false, "Not allowed until hardfork 199");
}
}
// hf_188
void operator()(const graphene::chain::asset_claim_pool_operation &v) const {
if (block_time < HARDFORK_CORE_188_TIME) {
FC_ASSERT(false, "Not allowed until hardfork 188");
}
}
// hf_588
// issue #588
//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the rest of this comment to indicate why this can't be moved into asset_settle_cancel_operation::validate as suggested.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HARDFORK_CORE_1468 checks should be removed as well I think.

Expand Down
6 changes: 0 additions & 6 deletions libraries/chain/transfer_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ void_result override_transfer_evaluator::do_evaluate( const override_transfer_op
FC_ASSERT( is_authorized_asset( d, to_account, asset_type ) );
FC_ASSERT( is_authorized_asset( d, from_account, asset_type ) );

if( d.head_block_time() <= HARDFORK_419_TIME )
{
FC_ASSERT( is_authorized_asset( d, from_account, asset_type ) );
}
// the above becomes no-op after hardfork because this check will then be performed in evaluator

FC_ASSERT( d.get_balance( from_account, asset_type ).amount >= op.amount.amount,
"", ("total_transfer",op.amount)("balance",d.get_balance(from_account, asset_type).amount) );

Expand Down
18 changes: 4 additions & 14 deletions libraries/chain/withdraw_permission_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ void_result withdraw_permission_claim_evaluator::do_evaluate(const withdraw_perm
FC_ASSERT(permit.expiration > head_block_time);
FC_ASSERT(permit.authorized_account == op.withdraw_to_account);
FC_ASSERT(permit.withdraw_from_account == op.withdraw_from_account);
if (head_block_time >= HARDFORK_23_TIME) {
FC_ASSERT(permit.period_start_time <= head_block_time);
}
FC_ASSERT(permit.period_start_time <= head_block_time);
FC_ASSERT(op.amount_to_withdraw <= permit.available_this_period( head_block_time ) );
FC_ASSERT(d.get_balance(op.withdraw_from_account, op.amount_to_withdraw.asset_id) >= op.amount_to_withdraw);

Expand All @@ -86,17 +84,9 @@ void_result withdraw_permission_claim_evaluator::do_evaluate(const withdraw_perm

const account_object& from = op.withdraw_from_account(d);
bool from_is_authorized = ( is_authorized_asset( d, from, _asset ) );
if( head_block_time > HARDFORK_CORE_942_TIME ) // TODO remove this check after hard fork if things in `else` did not occur
{
FC_ASSERT( from_is_authorized,
"Account ${acct} '${name}' is unauthorized to withdraw asset ${a} '${sym}' due to whitelist / blacklist",
("acct", from.id)("name", from.name)("a", _asset.id)("sym", _asset.symbol) );
}
else
{
if( !from_is_authorized )
wlog( "Unauthorized asset withdrawal (issue #942) occurred at block ${b}", ("b", d.head_block_num()) );
}
FC_ASSERT( from_is_authorized,
"Account ${acct} '${name}' is unauthorized to withdraw asset ${a} '${sym}' due to whitelist / blacklist",
("acct", from.id)("name", from.name)("a", _asset.id)("sym", _asset.symbol) );

return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) }
Expand Down
5 changes: 1 addition & 4 deletions libraries/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1331,10 +1331,7 @@ class wallet_api_impl
optional<account_id_type> new_issuer_account_id;
if (new_issuer)
{
FC_ASSERT( _remote_db->get_dynamic_global_properties().time < HARDFORK_CORE_199_TIME,
"The use of 'new_issuer' is no longer supported. Please use `update_asset_issuer' instead!");
account_object new_issuer_account = get_account(*new_issuer);
new_issuer_account_id = new_issuer_account.id;
FC_ASSERT( false, "The use of 'new_issuer' is no longer supported. Please use `update_asset_issuer' instead!");
}

asset_update_operation update_op;
Expand Down
20 changes: 0 additions & 20 deletions tests/tests/fee_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,6 @@ BOOST_AUTO_TEST_CASE(asset_claim_fees_test)

}

if( db.head_block_time() <= HARDFORK_413_TIME )
{
// can't claim before hardfork
GRAPHENE_REQUIRE_THROW( claim_fees( izzy_id, _izzy(1) ), fc::exception );
generate_blocks( HARDFORK_413_TIME );
while( db.head_block_time() <= HARDFORK_413_TIME )
{
generate_block();
}
}

{
const asset_object& izzycoin = izzycoin_id(db);
const asset_object& jillcoin = jillcoin_id(db);
Expand Down Expand Up @@ -290,13 +279,6 @@ BOOST_AUTO_TEST_CASE(asset_claim_pool_test)
// deposit 100 BTS to the fee pool of ALICEUSD asset
fund_fee_pool( alice_id(db), aliceusd_id(db), _core(100).amount );

// Unable to claim pool before the hardfork
GRAPHENE_REQUIRE_THROW( claim_pool( alice_id, aliceusd_id, _core(1), core_asset), fc::exception );
GRAPHENE_REQUIRE_THROW( claim_pool_proposal( alice_id, aliceusd_id, _core(1), core_asset), fc::exception );

// Fast forward to hard fork date
generate_blocks( HARDFORK_CORE_188_TIME );

// New reference for core_asset after having produced blocks
const asset_object& core_asset_hf = asset_id_type()(db);

Expand Down Expand Up @@ -3443,11 +3425,9 @@ BOOST_AUTO_TEST_CASE( stealth_fba_test )
ACTORS( (alice)(bob)(chloe)(dan)(izzy)(philbin)(tom) );
upgrade_to_lifetime_member(philbin_id);

generate_blocks( HARDFORK_538_TIME );
generate_blocks( HARDFORK_555_TIME );
generate_blocks( HARDFORK_563_TIME );
generate_blocks( HARDFORK_572_TIME );
generate_blocks( HARDFORK_599_TIME );

// Philbin (registrar who registers Rex)

Expand Down
Loading