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

Always attempt to resync when receiving a block less than LIB. #10434

Merged
merged 3 commits into from
Jun 29, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ namespace eosio {
uint32_t max_nodes_per_host = 1;
bool p2p_accept_transactions = true;
bool p2p_reject_incomplete_blocks = true;
bool p2p_always_resync = false;

/// Peer clock may be no more than 1 second skewed from our clock, including network latency.
const std::chrono::system_clock::duration peer_authentication_interval{std::chrono::seconds{1}};
Expand Down Expand Up @@ -2918,9 +2919,18 @@ namespace eosio {
std::unique_lock<std::mutex> g( conn_mtx );
const auto last_sent_lib = last_handshake_sent.last_irreversible_block_num;
g.unlock();

if( blk_num < last_sent_lib ) {
fc_ilog( logger, "received block ${n} less than sent lib ${lib}", ("n", blk_num)("lib", last_sent_lib) );
close();
if(my_impl->p2p_always_resync) {
fc_ilog( logger, "attempting to resync with peer that is sending blocks less than sent lib ${lib}", ("lib", last_sent_lib) );
enqueue( (sync_request_message) {0, 0} );
send_handshake();
cancel_wait();
}
nksanthosh marked this conversation as resolved.
Show resolved Hide resolved
else {
close();
}
} else {
fc_ilog( logger, "received block ${n} less than lib ${lib}", ("n", blk_num)("lib", lib) );
enqueue( (sync_request_message) {0, 0} );
Expand Down Expand Up @@ -3971,6 +3981,7 @@ namespace eosio {
" _port \tremote port number of peer\n\n"
" _lip \tlocal IP address connected to peer\n\n"
" _lport \tlocal port number connected to peer\n\n")
( "p2p-always-resync", bpo::value<bool>()->default_value(false), "Always attempt to resync even when peer sends blocks earlier than this node's last irreversible block")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not add this new option and just make this the behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Option removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR name/description needs to be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

( "p2p-keepalive-interval-ms", bpo::value<int>()->default_value(def_keepalive_interval), "peer heartbeat keepalive message interval in milliseconds")
( "p2p-tls-security-group-ca-file", bpo::value<bfs::path>(), "Certificate Authority's certificate file used for verifying peers TLS connection when security groups feature enabled" )
( "p2p-tls-own-certificate-file", bpo::value<bfs::path>(), "Certificate file that will be used to authenticate running node if TLS is enabled")
Expand Down Expand Up @@ -3998,6 +4009,7 @@ namespace eosio {
my->max_nodes_per_host = options.at( "p2p-max-nodes-per-host" ).as<int>();
my->p2p_accept_transactions = options.at( "p2p-accept-transactions" ).as<bool>();
my->p2p_reject_incomplete_blocks = options.at("p2p-reject-incomplete-blocks").as<bool>();
my->p2p_always_resync = options.at( "p2p-always-resync" ).as<bool>();

my->use_socket_read_watermark = options.at( "use-socket-read-watermark" ).as<bool>();
my->keepalive_interval = std::chrono::milliseconds( options.at( "p2p-keepalive-interval-ms" ).as<int>() );
Expand Down