Merge branch '549-fork-cancel-order' into 452-fork-stealth-fba
This commit is contained in:
commit
b67d223d17
5 changed files with 44 additions and 23 deletions
|
|
@ -296,14 +296,14 @@ signed_block database::generate_block(
|
|||
const fc::ecc::private_key& block_signing_private_key,
|
||||
uint32_t skip /* = 0 */
|
||||
)
|
||||
{
|
||||
{ try {
|
||||
signed_block result;
|
||||
detail::with_skip_flags( *this, skip, [&]()
|
||||
{
|
||||
result = _generate_block( when, witness_id, block_signing_private_key );
|
||||
} );
|
||||
return result;
|
||||
}
|
||||
} FC_CAPTURE_AND_RETHROW() }
|
||||
|
||||
signed_block database::_generate_block(
|
||||
fc::time_point_sec when,
|
||||
|
|
|
|||
|
|
@ -156,14 +156,14 @@ void database::update_last_irreversible_block()
|
|||
}
|
||||
|
||||
void database::clear_expired_transactions()
|
||||
{
|
||||
{ try {
|
||||
//Look for expired transactions in the deduplication list, and remove them.
|
||||
//Transactions must have expired by at least two forking windows in order to be removed.
|
||||
auto& transaction_idx = static_cast<transaction_index&>(get_mutable_index(implementation_ids, impl_transaction_object_type));
|
||||
const auto& dedupe_index = transaction_idx.indices().get<by_expiration>();
|
||||
while( (!dedupe_index.empty()) && (head_block_time() > dedupe_index.rbegin()->trx.expiration) )
|
||||
transaction_idx.remove(*dedupe_index.rbegin());
|
||||
}
|
||||
} FC_CAPTURE_AND_RETHROW() }
|
||||
|
||||
void database::clear_expired_proposals()
|
||||
{
|
||||
|
|
@ -254,7 +254,7 @@ bool database::check_for_blackswan( const asset_object& mia, bool enable_black_s
|
|||
}
|
||||
|
||||
void database::clear_expired_orders()
|
||||
{
|
||||
{ try {
|
||||
detail::with_skip_flags( *this,
|
||||
get_node_properties().skip_flags | skip_authority_check, [&](){
|
||||
transaction_evaluation_state cancel_context(this);
|
||||
|
|
@ -267,6 +267,18 @@ void database::clear_expired_orders()
|
|||
const limit_order_object& order = *limit_index.begin();
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
|
@ -406,7 +418,7 @@ void database::clear_expired_orders()
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
} FC_CAPTURE_AND_RETHROW() }
|
||||
|
||||
void database::update_expired_feeds()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -79,24 +79,27 @@ database& generic_evaluator::db()const { return trx_state->db(); }
|
|||
|
||||
void generic_evaluator::convert_fee()
|
||||
{
|
||||
if( fee_asset->get_id() != asset_id_type() )
|
||||
{
|
||||
db().modify(*fee_asset_dyn_data, [this](asset_dynamic_data_object& d) {
|
||||
d.accumulated_fees += fee_from_account.amount;
|
||||
d.fee_pool -= core_fee_paid;
|
||||
});
|
||||
if( !trx_state->skip_fee ) {
|
||||
if( fee_asset->get_id() != asset_id_type() )
|
||||
{
|
||||
db().modify(*fee_asset_dyn_data, [this](asset_dynamic_data_object& d) {
|
||||
d.accumulated_fees += fee_from_account.amount;
|
||||
d.fee_pool -= core_fee_paid;
|
||||
});
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void generic_evaluator::pay_fee()
|
||||
{ try {
|
||||
database& d = db();
|
||||
/// TODO: db().pay_fee( account_id, core_fee );
|
||||
d.modify(*fee_paying_account_statistics, [&](account_statistics_object& s)
|
||||
{
|
||||
s.pay_fee( core_fee_paid, d.get_global_properties().parameters.cashback_vesting_threshold );
|
||||
});
|
||||
if( !trx_state->skip_fee ) {
|
||||
database& d = db();
|
||||
/// TODO: db().pay_fee( account_id, core_fee );
|
||||
d.modify(*fee_paying_account_statistics, [&](account_statistics_object& s)
|
||||
{
|
||||
s.pay_fee( core_fee_paid, d.get_global_properties().parameters.cashback_vesting_threshold );
|
||||
});
|
||||
}
|
||||
} FC_CAPTURE_AND_RETHROW() }
|
||||
|
||||
} }
|
||||
|
|
|
|||
|
|
@ -23,6 +23,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 {
|
||||
|
|
@ -227,10 +228,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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,5 +45,7 @@ namespace graphene { namespace chain {
|
|||
const signed_transaction* _trx = nullptr;
|
||||
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