HARDFORK Move fee blacklist check to evaluator #419

This commit is contained in:
theoreticalbts 2015-10-30 14:22:02 -04:00
parent d821d4a993
commit 4f2b8bd6f6
3 changed files with 28 additions and 9 deletions

View file

@ -21,6 +21,7 @@
#include <graphene/chain/database.hpp>
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/hardfork.hpp>
#include <graphene/chain/transaction_evaluation_state.hpp>
#include <graphene/chain/asset_object.hpp>
@ -46,17 +47,25 @@ database& generic_evaluator::db()const { return trx_state->db(); }
void generic_evaluator::prepare_fee(account_id_type account_id, asset fee)
{
const database& d = db();
fee_from_account = fee;
FC_ASSERT( fee.amount >= 0 );
fee_paying_account = &account_id(db());
fee_paying_account_statistics = &fee_paying_account->statistics(db());
fee_paying_account = &account_id(d);
fee_paying_account_statistics = &fee_paying_account->statistics(d);
fee_asset = &fee.asset_id(db());
fee_asset_dyn_data = &fee_asset->dynamic_asset_data_id(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( fee_paying_account->is_authorized_asset( *fee_asset, d ), "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;
else {
else
{
asset fee_from_pool = fee_from_account * fee_asset->options.core_exchange_rate;
FC_ASSERT( fee_from_pool.asset_id == asset_id_type() );
core_fee_paid = fee_from_pool.amount;

View file

@ -24,3 +24,4 @@
#define HARDFORK_359_TIME (fc::time_point_sec( 1444416300 ))
#define HARDFORK_415_TIME (fc::time_point_sec( 1446652800 ))
#define HARDFORK_416_TIME (fc::time_point_sec( 1446652800 ))
#define HARDFORK_419_TIME (fc::time_point_sec( 1446652800 ))

View file

@ -21,6 +21,7 @@
#include <graphene/chain/transfer_evaluator.hpp>
#include <graphene/chain/account_object.hpp>
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/hardfork.hpp>
namespace graphene { namespace chain {
void_result transfer_evaluator::do_evaluate( const transfer_operation& op )
@ -53,8 +54,12 @@ void_result transfer_evaluator::do_evaluate( const transfer_operation& op )
);
}
if( fee_asset_type.options.flags & white_list )
FC_ASSERT( from_account.is_authorized_asset( asset_type, d ) );
if( d.head_block_time() <= HARDFORK_419_TIME )
{
if( fee_asset_type.options.flags & white_list )
FC_ASSERT( from_account.is_authorized_asset( asset_type, d ) );
}
// the above becomes no-op after hardfork because this check will then be performed in evaluator
if( asset_type.is_transfer_restricted() )
{
@ -108,8 +113,12 @@ void_result override_transfer_evaluator::do_evaluate( const override_transfer_op
FC_ASSERT( from_account.is_authorized_asset( asset_type, d ) );
}
if( fee_asset_type.options.flags & white_list )
FC_ASSERT( from_account.is_authorized_asset( asset_type, d ) );
if( d.head_block_time() <= HARDFORK_419_TIME )
{
if( fee_asset_type.options.flags & white_list )
FC_ASSERT( from_account.is_authorized_asset( asset_type, d ) );
}
// 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) );