From 3eac840084b1d5e54190a0133bc306b8c7e47ae4 Mon Sep 17 00:00:00 2001 From: Dmytro Sydorchenko Date: Mon, 2 Aug 2021 16:29:36 -0400 Subject: [PATCH 1/4] net plugin bugfix for nodes getting out of sync --- plugins/net_plugin/net_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 32464cb8f95..701d5d2cdeb 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -1757,7 +1757,7 @@ namespace eosio { if( !is_sync_required( fork_head_block_num ) || target <= lib_num ) { fc_dlog( logger, "We are already caught up, my irr = ${b}, head = ${h}, target = ${t}", ("b", lib_num)( "h", fork_head_block_num )( "t", target ) ); - return; + send_handshakes(); } if( sync_state == in_sync ) { From e3d53b46c66037b715fee6d553d7596b5f1c5650 Mon Sep 17 00:00:00 2001 From: Dmytro Sydorchenko Date: Mon, 2 Aug 2021 22:37:30 -0400 Subject: [PATCH 2/4] PR #10590 concerns addressed --- plugins/net_plugin/net_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 701d5d2cdeb..d38d2496b5e 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -1757,7 +1757,7 @@ namespace eosio { if( !is_sync_required( fork_head_block_num ) || target <= lib_num ) { fc_dlog( logger, "We are already caught up, my irr = ${b}, head = ${h}, target = ${t}", ("b", lib_num)( "h", fork_head_block_num )( "t", target ) ); - send_handshakes(); + c->send_handshake(); } if( sync_state == in_sync ) { From fc3ba1a012efb3561702a9bf4387c66bd76f4c6d Mon Sep 17 00:00:00 2001 From: Dmytro Sydorchenko Date: Fri, 13 Aug 2021 22:38:14 -0400 Subject: [PATCH 3/4] back port of net plugin changes from #10390 --- plugins/net_plugin/net_plugin.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index d38d2496b5e..59feb5d59b7 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -1801,7 +1801,7 @@ namespace eosio { // sync need checks; (lib == last irreversible block) // // 0. my head block id == peer head id means we are all caught up block wise - // 1. my head block num < peer lib - start sync locally + // 1. my head block num < peer lib - send handshake (if not sent in handle_message) and wait for receipt of notice message to start syncing // 2. my lib > peer head num - send an last_irr_catch_up notice if not the first generation // // 3 my head block num < peer head block num - update sync state and send a catchup request @@ -1828,6 +1828,9 @@ namespace eosio { ("ep", c->peer_name())("lib", msg.last_irreversible_block_num)("head", msg.head_num) ("id", msg.head_id.str().substr(8,16)) ); c->syncing = false; + if (c->sent_handshake_count > 0) { + c->send_handshake(true); + } return; } if (lib_num > msg.head_num ) { From b77e32677ac6409f378989aa459f82d5513b9be0 Mon Sep 17 00:00:00 2001 From: Dmytro Sydorchenko Date: Fri, 13 Aug 2021 22:45:23 -0400 Subject: [PATCH 4/4] net plugin fix for node being stopped syncing --- plugins/net_plugin/net_plugin.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 59feb5d59b7..f3e1eb1b2bd 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -151,7 +151,7 @@ namespace eosio { public: explicit sync_manager( uint32_t span ); - static void send_handshakes(); + static void send_handshakes(bool force = false); bool syncing_with_peer() const { return sync_state == lib_catchup; } void sync_reset_lib_num( const connection_ptr& conn ); void sync_reassign_fetch( const connection_ptr& c, go_away_reason reason ); @@ -1725,10 +1725,10 @@ namespace eosio { } // static, thread safe - void sync_manager::send_handshakes() { - for_each_connection( []( auto& ci ) { + void sync_manager::send_handshakes(bool force) { + for_each_connection( [&]( auto& ci ) { if( ci->current() ) { - ci->send_handshake(); + ci->send_handshake(force); } return true; } ); @@ -2033,18 +2033,18 @@ namespace eosio { if( set_state_to_head_catchup ) { if( set_state( head_catchup ) ) { - send_handshakes(); + send_handshakes(true); } } else { set_state( in_sync ); - send_handshakes(); + send_handshakes(true); } } else if( state == lib_catchup ) { if( blk_num == sync_known_lib_num ) { fc_dlog( logger, "All caught up with last known last irreversible block resending handshake" ); set_state( in_sync ); g_sync.unlock(); - send_handshakes(); + send_handshakes(true); } else if( blk_num == sync_last_requested_num ) { request_next_chunk( std::move( g_sync) ); } else {