From 6f7f2605c1568464f852e930c75b5510f2d51337 Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Thu, 11 Feb 2016 03:12:18 -0500 Subject: [PATCH] Remove now-redundant white_list bit check from evaluators #566 --- libraries/chain/asset_evaluator.cpp | 12 +---- libraries/chain/market_evaluator.cpp | 12 +---- libraries/chain/transfer_evaluator.cpp | 44 ++++++++----------- .../chain/withdraw_permission_evaluator.cpp | 21 ++------- 4 files changed, 26 insertions(+), 63 deletions(-) diff --git a/libraries/chain/asset_evaluator.cpp b/libraries/chain/asset_evaluator.cpp index 30f5b83a..9a467bec 100644 --- a/libraries/chain/asset_evaluator.cpp +++ b/libraries/chain/asset_evaluator.cpp @@ -153,11 +153,7 @@ void_result asset_issue_evaluator::do_evaluate( const asset_issue_operation& o ) FC_ASSERT( !a.is_market_issued(), "Cannot manually issue a market-issued asset." ); to_account = &o.issue_to_account(d); - - if( a.options.flags & white_list ) - { - FC_ASSERT( is_authorized_asset( d, *to_account, a ) ); - } + FC_ASSERT( is_authorized_asset( d, *to_account, a ) ); asset_dyn_data = &a.dynamic_asset_data_id(d); FC_ASSERT( (asset_dyn_data->current_supply + o.asset_to_issue.amount) <= a.options.max_supply ); @@ -189,11 +185,7 @@ void_result asset_reserve_evaluator::do_evaluate( const asset_reserve_operation& ); from_account = &o.payer(d); - - if( a.options.flags & white_list ) - { - FC_ASSERT( is_authorized_asset( d, *from_account, a ) ); - } + FC_ASSERT( is_authorized_asset( d, *from_account, a ) ); asset_dyn_data = &a.dynamic_asset_data_id(d); FC_ASSERT( (asset_dyn_data->current_supply - o.amount_to_reserve.amount) >= 0 ); diff --git a/libraries/chain/market_evaluator.cpp b/libraries/chain/market_evaluator.cpp index d21f6fe0..27c31ae4 100644 --- a/libraries/chain/market_evaluator.cpp +++ b/libraries/chain/market_evaluator.cpp @@ -52,16 +52,8 @@ void_result limit_order_create_evaluator::do_evaluate(const limit_order_create_o if( _sell_asset->options.blacklist_markets.size() ) FC_ASSERT( _sell_asset->options.blacklist_markets.find(_receive_asset->id) == _sell_asset->options.blacklist_markets.end() ); - if( d.head_block_time() <= HARDFORK_416_TIME ) - { - if( _sell_asset->options.flags & white_list ) FC_ASSERT( is_authorized_asset( d, *_seller, *_sell_asset ) ); - if( _receive_asset->options.flags & white_list ) FC_ASSERT( is_authorized_asset( d, *_seller, *_receive_asset ) ); - } - else - { - FC_ASSERT( is_authorized_asset( d, *_seller, *_sell_asset ) ); - FC_ASSERT( is_authorized_asset( d, *_seller, *_receive_asset ) ); - } + FC_ASSERT( is_authorized_asset( d, *_seller, *_sell_asset ) ); + FC_ASSERT( is_authorized_asset( d, *_seller, *_receive_asset ) ); FC_ASSERT( d.get_balance( *_seller, *_sell_asset ) >= op.amount_to_sell, "insufficient balance", ("balance",d.get_balance(*_seller,*_sell_asset))("amount_to_sell",op.amount_to_sell) ); diff --git a/libraries/chain/transfer_evaluator.cpp b/libraries/chain/transfer_evaluator.cpp index 0f6e2419..4ec9e3e9 100644 --- a/libraries/chain/transfer_evaluator.cpp +++ b/libraries/chain/transfer_evaluator.cpp @@ -40,28 +40,24 @@ void_result transfer_evaluator::do_evaluate( const transfer_operation& op ) try { - if( asset_type.options.flags & white_list ) - { - GRAPHENE_ASSERT( - is_authorized_asset( d, from_account, asset_type ), - transfer_from_account_not_whitelisted, - "'from' account ${from} is not whitelisted for asset ${asset}", - ("from",op.from) - ("asset",op.amount.asset_id) - ); - GRAPHENE_ASSERT( - is_authorized_asset( d, to_account, asset_type ), - transfer_to_account_not_whitelisted, - "'to' account ${to} is not whitelisted for asset ${asset}", - ("to",op.to) - ("asset",op.amount.asset_id) - ); - } + GRAPHENE_ASSERT( + is_authorized_asset( d, from_account, asset_type ), + transfer_from_account_not_whitelisted, + "'from' account ${from} is not whitelisted for asset ${asset}", + ("from",op.from) + ("asset",op.amount.asset_id) + ); + GRAPHENE_ASSERT( + is_authorized_asset( d, to_account, asset_type ), + transfer_to_account_not_whitelisted, + "'to' account ${to} is not whitelisted for asset ${asset}", + ("to",op.to) + ("asset",op.amount.asset_id) + ); if( d.head_block_time() <= HARDFORK_419_TIME ) { - if( fee_asset_type.options.flags & white_list ) - FC_ASSERT( is_authorized_asset( d, from_account, asset_type ) ); + 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 @@ -111,16 +107,12 @@ void_result override_transfer_evaluator::do_evaluate( const override_transfer_op const account_object& to_account = op.to(d); const asset_object& fee_asset_type = op.fee.asset_id(d); - if( asset_type.options.flags & white_list ) - { - FC_ASSERT( is_authorized_asset( d, to_account, asset_type ) ); - FC_ASSERT( is_authorized_asset( d, from_account, asset_type ) ); - } + 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 ) { - if( fee_asset_type.options.flags & white_list ) - FC_ASSERT( is_authorized_asset( d, from_account, asset_type ) ); + 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 diff --git a/libraries/chain/withdraw_permission_evaluator.cpp b/libraries/chain/withdraw_permission_evaluator.cpp index 9014282d..d001b441 100644 --- a/libraries/chain/withdraw_permission_evaluator.cpp +++ b/libraries/chain/withdraw_permission_evaluator.cpp @@ -70,23 +70,10 @@ void_result withdraw_permission_claim_evaluator::do_evaluate(const withdraw_perm const asset_object& _asset = op.amount_to_withdraw.asset_id(d); if( _asset.is_transfer_restricted() ) FC_ASSERT( _asset.issuer == permit.authorized_account || _asset.issuer == permit.withdraw_from_account ); - if( d.head_block_time() <= HARDFORK_416_TIME ) - { - if( _asset.options.flags & white_list ) - { - const account_object& from = op.withdraw_to_account(d); - const account_object& to = permit.authorized_account(d); - FC_ASSERT( is_authorized_asset( d, to, _asset ) ); - FC_ASSERT( is_authorized_asset( d, from, _asset ) ); - } - } - else - { - const account_object& from = op.withdraw_to_account(d); - const account_object& to = permit.authorized_account(d); - FC_ASSERT( is_authorized_asset( d, to, _asset ) ); - FC_ASSERT( is_authorized_asset( d, from, _asset ) ); - } + const account_object& from = op.withdraw_to_account(d); + const account_object& to = permit.authorized_account(d); + FC_ASSERT( is_authorized_asset( d, to, _asset ) ); + FC_ASSERT( is_authorized_asset( d, from, _asset ) ); return void_result(); } FC_CAPTURE_AND_RETHROW( (op) ) }