Merge remote-tracking branch 'graphene/549-fork-cancel-order' into bitshares
This commit is contained in:
commit
a1d0339ccf
3 changed files with 20 additions and 4 deletions
|
|
@ -268,6 +268,17 @@ void database::clear_expired_orders()
|
||||||
canceler.fee_paying_account = order.seller;
|
canceler.fee_paying_account = order.seller;
|
||||||
canceler.order = order.id;
|
canceler.order = order.id;
|
||||||
canceler.fee = current_fee_schedule().calculate_fee( canceler );
|
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);
|
apply_operation(cancel_context, canceler);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <graphene/chain/exceptions.hpp>
|
#include <graphene/chain/exceptions.hpp>
|
||||||
|
#include <graphene/chain/transaction_evaluation_state.hpp>
|
||||||
#include <graphene/chain/protocol/operations.hpp>
|
#include <graphene/chain/protocol/operations.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
@ -227,10 +228,13 @@ namespace graphene { namespace chain {
|
||||||
const auto& op = o.get<typename DerivedEvaluator::operation_type>();
|
const auto& op = o.get<typename DerivedEvaluator::operation_type>();
|
||||||
|
|
||||||
prepare_fee(op.fee_payer(), op.fee);
|
prepare_fee(op.fee_payer(), op.fee);
|
||||||
GRAPHENE_ASSERT( core_fee_paid >= db().current_fee_schedule().calculate_fee( op ).amount,
|
if( !trx_state->skip_fee_schedule_check )
|
||||||
insufficient_fee,
|
{
|
||||||
"Insufficient Fee Paid",
|
GRAPHENE_ASSERT( core_fee_paid >= db().current_fee_schedule().calculate_fee( op ).amount,
|
||||||
("core_fee_paid",core_fee_paid)("required",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);
|
return eval->do_evaluate(op);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,5 +46,6 @@ namespace graphene { namespace chain {
|
||||||
database* _db = nullptr;
|
database* _db = nullptr;
|
||||||
bool _is_proposed_trx = false;
|
bool _is_proposed_trx = false;
|
||||||
bool skip_fee = false;
|
bool skip_fee = false;
|
||||||
|
bool skip_fee_schedule_check = false;
|
||||||
};
|
};
|
||||||
} } // namespace graphene::chain
|
} } // namespace graphene::chain
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue