Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.0-beta1.2 -> main] P2P: Fix stuck in lib catchup #203

Merged
merged 3 commits into from
May 27, 2024
Merged
Changes from all 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
18 changes: 17 additions & 1 deletion plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2527,7 +2527,8 @@ namespace eosio {
} else {
if (!blk_applied) {
if (blk_num >= c->sync_last_requested_block) {
peer_dlog(c, "calling cancel_wait, block ${b}", ("b", blk_num));
peer_dlog(c, "calling cancel_wait, block ${b}, sync_last_requested_block ${lrb}",
("b", blk_num)("lrb", c->sync_last_requested_block));
c->cancel_wait();
} else {
peer_dlog(c, "calling sync_wait, block ${b}", ("b", blk_num));
Expand All @@ -2536,6 +2537,7 @@ namespace eosio {

if (sync_last_requested_num == 0) { // block was rejected
sync_next_expected_num = my_impl->get_chain_lib_num() + 1;
peer_dlog(c, "Reset sync_next_expected_num to ${n}", ("n", sync_next_expected_num));
} else {
if (blk_num == sync_next_expected_num) {
++sync_next_expected_num;
Expand All @@ -2544,6 +2546,8 @@ namespace eosio {
}
}
if (blk_num >= sync_known_lib_num) {
peer_dlog(c, "received non-applied block ${bn} > ${kn}, will send handshakes when caught up",
("bn", blk_num)("kn", sync_known_lib_num));
send_handshakes_when_synced = true;
}
}
Expand All @@ -2554,9 +2558,20 @@ namespace eosio {
fc_dlog(logger, "Requesting range ahead, head: ${h} blk_num: ${bn} sync_next_expected_num ${nen} sync_last_requested_num: ${lrn}",
("h", head)("bn", blk_num)("nen", sync_next_expected_num)("lrn", sync_last_requested_num));
request_next_chunk();
return;
}
}

if (!blk_applied && blk_num >= c->sync_last_requested_block) {
// block was not applied, possibly because we already have the block
// We didn't request the next chunk of blocks, request them anyway because we might need them to resolve a fork
fc_dlog(logger, "Requesting blocks, head: ${h} blk_num: ${bn} sync_next_expected_num ${nen} "
"sync_last_requested_num: ${lrn}, sync_last_requested_block: ${lrb}",
("h", head)("bn", blk_num)("nen", sync_next_expected_num)
("lrn", sync_last_requested_num)("lrb", c->sync_last_requested_block));
request_next_chunk();
}

}
} else {
send_handshakes_if_synced(blk_latency);
Expand All @@ -2566,6 +2581,7 @@ namespace eosio {
// thread safe
void sync_manager::send_handshakes_if_synced(const fc::microseconds& blk_latency) {
if (blk_latency.count() < config::block_interval_us && send_handshakes_when_synced) {
fc_dlog(logger, "Block latency within block interval, synced, sending handshakes");
send_handshakes();
send_handshakes_when_synced = false;
}
Expand Down
Loading