From b2061fa712e2b7190719c10bc05890cf78e0c19f Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Sat, 2 Nov 2019 18:13:39 -0500 Subject: [PATCH 1/2] Always call next() since net_plugin needs callback for tracking transactions in progress --- .../eosio/chain/unapplied_transaction_queue.hpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libraries/chain/include/eosio/chain/unapplied_transaction_queue.hpp b/libraries/chain/include/eosio/chain/unapplied_transaction_queue.hpp index da90ba3abd2..dfe7783ed2b 100644 --- a/libraries/chain/include/eosio/chain/unapplied_transaction_queue.hpp +++ b/libraries/chain/include/eosio/chain/unapplied_transaction_queue.hpp @@ -130,7 +130,7 @@ class unapplied_transaction_queue { ("bt", pending_block_time) ) ) ) ); } - removed( itr ); + removed( itr, false ); persisted_by_expiry.erase( itr ); } return true; @@ -221,8 +221,9 @@ class unapplied_transaction_queue { iterator incoming_begin() { return queue.get().lower_bound( trx_enum_type::incoming_persisted ); } iterator incoming_end() { return queue.get().end(); } // if changed to upper_bound, verify usage performance + /// callers responsibilty to call next() if applicable iterator erase( iterator itr ) { - removed( itr ); + removed( itr, false ); return queue.get().erase( itr ); } @@ -242,10 +243,15 @@ class unapplied_transaction_queue { } template - void removed( Itr itr ) { + void removed( Itr itr, bool call_next = true ) { if( itr->trx_type == trx_enum_type::incoming || itr->trx_type == trx_enum_type::incoming_persisted ) { --incoming_count; } + if( call_next && itr->next ) { + transaction_trace_ptr trace = std::make_shared(); + trace->id = itr->trx_meta->id(); + itr->next( trace ); + } size_in_bytes -= calc_size( itr->trx_meta ); } From 96f328917638fc4b444a6726f247a60375100841 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 5 Nov 2019 15:06:34 -0500 Subject: [PATCH 2/2] Guarantee that invariant of next function is called. Indicate duplicate trx instead of partial trace. --- .../chain/unapplied_transaction_queue.hpp | 18 ++++++++---------- plugins/producer_plugin/producer_plugin.cpp | 2 ++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libraries/chain/include/eosio/chain/unapplied_transaction_queue.hpp b/libraries/chain/include/eosio/chain/unapplied_transaction_queue.hpp index dfe7783ed2b..2ebe4f8a889 100644 --- a/libraries/chain/include/eosio/chain/unapplied_transaction_queue.hpp +++ b/libraries/chain/include/eosio/chain/unapplied_transaction_queue.hpp @@ -129,8 +129,7 @@ class unapplied_transaction_queue { ("id", itr->id())("e", itr->trx_meta->packed_trx()->expiration()) ("bt", pending_block_time) ) ) ) ); } - - removed( itr, false ); + removed( itr ); persisted_by_expiry.erase( itr ); } return true; @@ -146,6 +145,10 @@ class unapplied_transaction_queue { if( itr != queue.get().end() ) { if( itr->trx_type != trx_enum_type::persisted && itr->trx_type != trx_enum_type::incoming_persisted ) { + if( itr->next ) { + itr->next( std::static_pointer_cast( std::make_shared( + FC_LOG_MESSAGE( info, "duplicate transaction ${id}", ("id", itr->trx_meta->id()))))); + } removed( itr ); idx.erase( itr ); } @@ -221,9 +224,9 @@ class unapplied_transaction_queue { iterator incoming_begin() { return queue.get().lower_bound( trx_enum_type::incoming_persisted ); } iterator incoming_end() { return queue.get().end(); } // if changed to upper_bound, verify usage performance - /// callers responsibilty to call next() if applicable + /// caller's responsibilty to call next() if applicable iterator erase( iterator itr ) { - removed( itr, false ); + removed( itr ); return queue.get().erase( itr ); } @@ -243,15 +246,10 @@ class unapplied_transaction_queue { } template - void removed( Itr itr, bool call_next = true ) { + void removed( Itr itr ) { if( itr->trx_type == trx_enum_type::incoming || itr->trx_type == trx_enum_type::incoming_persisted ) { --incoming_count; } - if( call_next && itr->next ) { - transaction_trace_ptr trace = std::make_shared(); - trace->id = itr->trx_meta->id(); - itr->next( trace ); - } size_in_bytes -= calc_size( itr->trx_meta ); } diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index ecfc9d0840b..787945ab09a 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -1596,12 +1596,14 @@ bool producer_plugin_impl::process_unapplied_trxs( const fc::time_point& deadlin } else { // this failed our configured maximum transaction time, we don't want to replay it ++num_failed; + if( itr->next ) itr->next( trace ); itr = _unapplied_transactions.erase( itr ); continue; } } else { ++num_applied; if( itr->trx_type != trx_enum_type::persisted ) { + if( itr->next ) itr->next( trace ); itr = _unapplied_transactions.erase( itr ); continue; }