-
Notifications
You must be signed in to change notification settings - Fork 239
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
Backfiller #3263
Backfiller #3263
Conversation
Trusted node sync, aka checkpoint sync, allows syncing tyhe chain from a trusted node instead of relying on a full sync from genesis. Features include: * sync from any slot, including the latest finalized slot * backfill blocks either from the REST api (default) or p2p (#3263) Future improvements: * top up blocks between head in database and some other node - this makes for an efficient backup tool * recreate historical state to enable historical queries
Trusted node sync, aka checkpoint sync, allows syncing tyhe chain from a trusted node instead of relying on a full sync from genesis. Features include: * sync from any slot, including the latest finalized slot * backfill blocks either from the REST api (default) or p2p (#3263) Future improvements: * top up blocks between head in database and some other node - this makes for an efficient backup tool * recreate historical state to enable historical queries
Trusted node sync, aka checkpoint sync, allows syncing tyhe chain from a trusted node instead of relying on a full sync from genesis. Features include: * sync from any slot, including the latest finalized slot * backfill blocks either from the REST api (default) or p2p (#3263) Future improvements: * top up blocks between head in database and some other node - this makes for an efficient backup tool * recreate historical state to enable historical queries
Trusted node sync, aka checkpoint sync, allows syncing tyhe chain from a trusted node instead of relying on a full sync from genesis. Features include: * sync from any slot, including the latest finalized slot * backfill blocks either from the REST api (default) or p2p (#3263) Future improvements: * top up blocks between head in database and some other node - this makes for an efficient backup tool * recreate historical state to enable historical queries
* Trusted node sync Trusted node sync, aka checkpoint sync, allows syncing tyhe chain from a trusted node instead of relying on a full sync from genesis. Features include: * sync from any slot, including the latest finalized slot * backfill blocks either from the REST api (default) or p2p (#3263) Future improvements: * top up blocks between head in database and some other node - this makes for an efficient backup tool * recreate historical state to enable historical queries * fixes * load genesis from network metadata * check checkpoint block root against state * fix invalid block root in rest json decoding * odds and ends * retry looking for epoch-boundary checkpoint blocks
except CancelledError: | ||
if not(isNil(peer)): | ||
man.pool.release(peer) | ||
true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not simple.. break here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just because I do not want to investigate one more for/while+exception+break
issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it wouldn't be bad to add tests for this in chronos - basically, a few simple for/while/finally etc sanity tests
let forked = | ||
res.map() do (blcks: seq[phase0.SignedBeaconBlock]) -> auto: | ||
blcks.mapIt(ForkedSignedBeaconBlock.init(it)) | ||
return forked |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a template is worth it, so many wasted lines/mindspace
template debugLog(msg: string): untyped {.dirty.} =
debug msg,
peer = peer, slot = req.slot, count = req.count,
step = req.step, peer_speed = peer.netKbps(),
direction = man.direction, error = $res.error(),
topics = "syncman"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typically, this is solved with logScope
, but logscope is unfortunately unreliable (cc @zah can we do anything about that?)
beacon_chain/sync/sync_manager.nim
Outdated
@@ -303,10 +341,6 @@ proc syncStep[A, B](man: SyncManager[A, B], index: int, peer: A) {.async.} = | |||
peer_speed = peer.netKbps(), index = index, | |||
direction = man.direction, topics = "syncman" | |||
peer.updateScore(PeerScoreUseless) | |||
|
|||
# Give the peer time to do some syncing | |||
await sleepAsync(StatusExpirationTime div 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we avoid dos-ing peers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you think we DOS-ing peers? We descored peer which is not useful for us and we return it back to the PeerPool. So it is not supposed to be returned for next step.
peer = peer, index = index, | ||
peer_score = peer.getScore(), peer_speed = peer.netKbps(), | ||
errName = exc.name, errMsg = exc.msg, direction = man.direction, | ||
topics = "syncman" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the sync_manager needs a debugLog template to avoid littering the codebase with those. (though that might cause issue with filename:linenumber
logic from Chronicles?
Backfilling is the process of downloading historical blocks via P2P that are required to fulfill `GetBlocksByRange` duties - this happens during both trusted node and finalized checkpoint syncs. In particular, backfilling happens after syncing to head, such that attestation work can start as soon as possible.
Remove usage of `awaitne`. Add cancellation support. Remove unneeded `sleepAsync()` if peer's head is older than needed. Add `direction` field to all logs. Fix syncmanager wedge issue. Add proper resource cleaning procedure on backward sync finish.
24bde37
to
df72fec
Compare
When initializing backfill sync, the implementation intends to start at the first unknown slot (`1` before tail). However, an incorrect variable is passed, and backfill sync actually starts at the tail slot instead. This patch corrects this by passing the intended variable. The problem was introduced with the original backfill implementation at status-im#3263.
When initializing backfill sync, the implementation intends to start at the first unknown slot (`1` before tail). However, an incorrect variable is passed, and backfill sync actually starts at the tail slot instead. This patch corrects this by passing the intended variable. The problem was introduced with the original backfill implementation at #3263.
Backfilling is the process of downloading historical blocks via P2P that
are required to fulfill
GetBlocksByRange
duties - this happens duringboth trusted node and finalized checkpoint syncs.
In particular, backfilling happens after syncing to head, such that
attestation work can start as soon as possible.
This PR is captures the part of #3209 that still needs more work.