From dd5b7708b4f3c22ba70b5f077250917f6dadb9d5 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Sun, 3 Jan 2016 20:40:21 -0500 Subject: [PATCH] potential fix for hung chain --- libraries/chain/db_block.cpp | 5 ++++- libraries/chain/db_update.cpp | 6 ++++++ libraries/chain/include/graphene/chain/database.hpp | 3 ++- .../chain/include/graphene/chain/protocol/asset_ops.hpp | 4 +++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index 770951b6..ceb9d4be 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -548,7 +548,10 @@ processed_transaction database::apply_transaction(const signed_transaction& trx, processed_transaction database::_apply_transaction(const signed_transaction& trx) { try { uint32_t skip = get_node_properties().skip_flags; - trx.validate(); + + if( !(skip&skip_validate) ) + trx.validate(); + auto& trx_idx = get_mutable_index_type(); const chain_id_type& chain_id = get_chain_id(); auto trx_id = trx.id(); diff --git a/libraries/chain/db_update.cpp b/libraries/chain/db_update.cpp index 2b6ba2e7..37c0a5de 100644 --- a/libraries/chain/db_update.cpp +++ b/libraries/chain/db_update.cpp @@ -348,6 +348,12 @@ void database::clear_expired_orders() assert(itr != call_index.end() && itr->debt_type() == mia_object.get_id()); asset max_settlement = max_settlement_volume - settled; + if( order.balance.amount == 0 ) + { + wlog( "0 settlement detected" ); + cancel_order( order ); + break; + } try { settled += match(*itr, order, settlement_price, max_settlement); } diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index c44e687d..9326004c 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -70,7 +70,8 @@ namespace graphene { namespace chain { skip_merkle_check = 1 << 7, ///< used while reindexing skip_assert_evaluation = 1 << 8, ///< used while reindexing skip_undo_history_check = 1 << 9, ///< used while reindexing - skip_witness_schedule_check = 1 << 10 ///< used whiel reindexing + skip_witness_schedule_check = 1 << 10, ///< used while reindexing + skip_validate = 1 << 11 ///< used prior to checkpoint, skips validate() call on transaction }; /** diff --git a/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp b/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp index 154c599d..13376053 100644 --- a/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp +++ b/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp @@ -225,7 +225,9 @@ namespace graphene { namespace chain { extensions_type extensions; account_id_type fee_payer()const { return account; } - void validate()const {} + void validate()const { + FC_ASSERT( amount.amount > 0, "Must settle at least 1 unit" ); + } share_type calculate_fee(const fee_parameters_type& params)const { return 0; }