From 0eae52c8202baafc758c462ef59b0cd816cc30d6 Mon Sep 17 00:00:00 2001 From: Rusty Fleming Date: Fri, 29 Jan 2021 15:47:27 -0600 Subject: [PATCH] EPE-389 nodeos_irreversible_mode_lr_test fails to progress This fix handles situations where a node is in head_catchup state and recieves the sync_last_requested_num and then does a sync_update_expected for the next block. And the next block has already been received by the node. In this instance, the block will not receive the next block and will be effectively hung. --- plugins/net_plugin/net_plugin.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index ee335cad1bb..302a46748b6 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -148,7 +148,7 @@ namespace eosio { private: constexpr static auto stage_str( stages s ); - void set_state( stages s ); + bool set_state( stages s ); bool is_sync_required( uint32_t fork_head_block_num ); void request_next_chunk( std::unique_lock g_sync, const connection_ptr& conn = connection_ptr() ); void start_sync( const connection_ptr& c, uint32_t target ); @@ -1532,12 +1532,13 @@ namespace eosio { } } - void sync_manager::set_state(stages newstate) { + bool sync_manager::set_state(stages newstate) { if( sync_state == newstate ) { - return; + return false; } fc_ilog( logger, "old state ${os} becoming ${ns}", ("os", stage_str( sync_state ))( "ns", stage_str( newstate ) ) ); sync_state = newstate; + return true; } void sync_manager::sync_reset_lib_num(const connection_ptr& c) { @@ -1964,7 +1965,9 @@ namespace eosio { } ); if( set_state_to_head_catchup ) { - set_state( head_catchup ); + if( set_state( head_catchup ) ) { + send_handshakes(); + } } else { set_state( in_sync ); send_handshakes();