fix: unknown list should get header from headermap and db #3702
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Thanks to @eval-exec for pointing out these problems
ref: #3668
unknown list bug
unknown_list
is the key to enabling multi-node parallel download in ibd phase. Its implementation is the get locator algorithm:ckb/sync/src/types/mod.rs
Lines 2032 to 2035 in 1ce2b34
Note this line in the algorithm, all results are added to the genesis hash again at the end
If
insert_peer_unknown_header_list
can find the corresponding value at the beginning of a new connection, this node can be used as one of the download sources:ckb/sync/src/types/mod.rs
Lines 1875 to 1889 in 1ce2b34
Otherwise,
try_update_best_known_with_unknown_header_list
will get stuck in a dead loop on the genesis hash and the node will not be able to become a download source again in the connected state:ckb/sync/src/types/mod.rs
Lines 1891 to 1903 in 1ce2b34
Finally, the
try_update_best_known_with_unknown_header_list
function is removed andget_header_view
is used instead of just looking from the headermap.Because if the block is inserted into the DB and the header map is cleaned up, the unknown list may get stuck in this situation where the hash cannot be found, resulting in reduce the download of the source.
eviction bug
In the ibd process, a node can only request headers data from one peer at a time. For headers, multiple data sources will result in duplicate downloads.
When synchronization starts, the headers_sync_controller of the node will be initialized to the normal state:
ckb/sync/src/synchronizer/mod.rs
Lines 370 to 380 in 1ce2b34
eviction
's remaining judgments will likely result in simultaneous requests for headers to multiple data sources, which is unnecessary in the ibd phase and should be disabledCheck List
Tests
Release note