-
-
Notifications
You must be signed in to change notification settings - Fork 318
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
Review importBlock order of operations #4976
Conversation
@@ -309,7 +309,7 @@ export class ForkChoice implements IForkChoice { | |||
blockDelaySec: number, | |||
currentSlot: Slot, | |||
executionStatus: MaybeValidExecutionStatus | |||
): void { | |||
): ProtoBlock { |
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.
Make onBlock return the blockSummary to prevent having to consider in the forkchoice that the new block is not found in the fork-choice
import {REPROCESS_MIN_TIME_TO_NEXT_SLOT_SEC} from "../reprocess.js"; | ||
import {RegenCaller} from "../regen/interface.js"; | ||
import type {BeaconChain} from "../chain.js"; | ||
import {BlockInputType, FullyVerifiedBlock, ImportBlockOpts, AttestationImportOpt} from "./types.js"; | ||
import {PendingEvents} from "./utils/pendingEvents.js"; |
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.
- From Remove all intermediary ChainEvents #4973 all remaining events are safe to be emitted in the order of this PR
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 may be safe from a logic perspective, but we may want to keep this to avoid a future footgun?
Now we will be adding additional work, running all event handlers, interspersed with importBlock, which we want to finish ASAP.
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's safe because none of those events trigger side effects, unlike they did before. They are solely consumed by API eventsream clients
fb549ae
to
84b4cdb
Compare
Performance Report✔️ no performance regression detected Full benchmark results
|
The only If there are not awaits it's more of a question of what is allowed to throw before what. Regarding the head state keep in mind there's a possibility the head state is not available, so it triggers regen and will be null for a while. |
84b4cdb
to
a565018
Compare
Closing + re-opening to trigger CI, somehow it got stuck |
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.
looks good! reviewing post merge 👍
Motivation
We noted with @g11tech that the import order of importBlock is not safe since it can import a block into the fork-choice without it being available in the DB. That can cause the node to get stuck if it ever needs to regen, and other potential undefined behavior.
Description
ImportBlock order of operations must guarantee that BeaconNode does not end in an unknown state:
in the DB. Otherwise the beacon node may end up in an unrecoverable state. If a block is persisted in the hot
db but is unknown by the fork-choice, then it will just use some extra disk space. On restart is will be
pruned regardless.
write happens latter requires the ability to roll back a fork-choice head change if disk write fails