Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
EPE-389 net_plugin stall during head catchup
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rusty-block-one committed Feb 2, 2021
1 parent e1e8bc9 commit 4800c3f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,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<std::mutex> g_sync, const connection_ptr& conn = connection_ptr() );
void start_sync( const connection_ptr& c, uint32_t target );
Expand Down Expand Up @@ -1372,12 +1372,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) {
Expand Down Expand Up @@ -1808,7 +1809,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();
Expand Down

0 comments on commit 4800c3f

Please sign in to comment.