Cap auto-cancel fees at deferred_fee #549
This commit is contained in:
parent
3646754fe5
commit
59503acde9
3 changed files with 20 additions and 4 deletions
|
|
@ -264,6 +264,17 @@ void database::clear_expired_orders()
|
|||
canceler.fee_paying_account = order.seller;
|
||||
canceler.order = order.id;
|
||||
canceler.fee = current_fee_schedule().calculate_fee( canceler );
|
||||
if( canceler.fee.amount > order.deferred_fee )
|
||||
{
|
||||
// Cap auto-cancel fees at deferred_fee; see #549
|
||||
wlog( "At block ${b}, fee for clearing expired order ${oid} was capped at deferred_fee ${fee}", ("b", head_block_num())("oid", order.id)("fee", order.deferred_fee) );
|
||||
canceler.fee = asset( order.deferred_fee, asset_id_type() );
|
||||
}
|
||||
// we know the fee for this op is set correctly since it is set by the chain.
|
||||
// this allows us to avoid a hung chain:
|
||||
// - if #549 case above triggers
|
||||
// - if the fee is incorrect, which may happen due to #435 (although since cancel is a fixed-fee op, it shouldn't)
|
||||
cancel_context.skip_fee_schedule_check = true;
|
||||
apply_operation(cancel_context, canceler);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
#pragma once
|
||||
#include <graphene/chain/exceptions.hpp>
|
||||
#include <graphene/chain/transaction_evaluation_state.hpp>
|
||||
#include <graphene/chain/protocol/operations.hpp>
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
|
|
@ -224,10 +225,13 @@ namespace graphene { namespace chain {
|
|||
const auto& op = o.get<typename DerivedEvaluator::operation_type>();
|
||||
|
||||
prepare_fee(op.fee_payer(), op.fee);
|
||||
GRAPHENE_ASSERT( core_fee_paid >= db().current_fee_schedule().calculate_fee( op ).amount,
|
||||
insufficient_fee,
|
||||
"Insufficient Fee Paid",
|
||||
("core_fee_paid",core_fee_paid)("required",db().current_fee_schedule().calculate_fee( op ).amount) );
|
||||
if( !trx_state->skip_fee_schedule_check )
|
||||
{
|
||||
GRAPHENE_ASSERT( core_fee_paid >= db().current_fee_schedule().calculate_fee( op ).amount,
|
||||
insufficient_fee,
|
||||
"Insufficient Fee Paid",
|
||||
("core_fee_paid",core_fee_paid)("required",db().current_fee_schedule().calculate_fee( op ).amount) );
|
||||
}
|
||||
|
||||
return eval->do_evaluate(op);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,5 +43,6 @@ namespace graphene { namespace chain {
|
|||
database* _db = nullptr;
|
||||
bool _is_proposed_trx = false;
|
||||
bool skip_fee = false;
|
||||
bool skip_fee_schedule_check = false;
|
||||
};
|
||||
} } // namespace graphene::chain
|
||||
|
|
|
|||
Loading…
Reference in a new issue