-
-
Notifications
You must be signed in to change notification settings - Fork 464
feat: add dependent root check when giving out proposer boost #9565
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import {ChainForkConfig} from "@lodestar/config"; | ||
| import {SLOTS_PER_EPOCH} from "@lodestar/params"; | ||
| import {MIN_SEED_LOOKAHEAD, SLOTS_PER_EPOCH} from "@lodestar/params"; | ||
| import { | ||
| DataAvailabilityStatus, | ||
| EffectiveBalanceIncrements, | ||
|
|
@@ -707,7 +707,8 @@ export class ForkChoice implements IForkChoice { | |
| // only boost the first block we see | ||
| this.proposerBoostRoot === null && | ||
| expectedProposerIndex !== null && | ||
| block.proposerIndex === expectedProposerIndex | ||
| block.proposerIndex === expectedProposerIndex && | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| this.isProposerBoostSameDependentRoot(this.head.blockRoot, parentRootHex) | ||
| ) { | ||
| this.proposerBoostRoot = blockRootHex; | ||
| } | ||
|
|
@@ -1494,6 +1495,34 @@ export class ForkChoice implements IForkChoice { | |
| throw Error(`Not found dependent root for block slot ${block.slot}, epoch difference ${epochDifference}`); | ||
| } | ||
|
|
||
| /** | ||
| * Spec: phase0/fork-choice.md#update_proposer_boost_root (`is_same_dependent_root` condition, | ||
| * consensus-specs #5306). Proposer boost is only granted when the imported block shares the same | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| * proposer-shuffling dependent root for the current epoch as the canonical head computed before | ||
| * the block was imported. This withholds the boost from a block built on a different shuffling | ||
| * branch than the head. | ||
| * | ||
| * The block is not yet in the proto-array when this runs, so its dependent root is traced from | ||
| * its parent | ||
| */ | ||
| private isProposerBoostSameDependentRoot(headRootHex: RootHex, blockParentRootHex: RootHex): boolean { | ||
| const epoch = computeEpochAtSlot(this.fcStore.currentSlot); | ||
| // Genesis block parent | ||
| if (epoch <= MIN_SEED_LOOKAHEAD) { | ||
| return true; | ||
| } | ||
|
|
||
| const dependentSlot = computeStartSlotAtEpoch(epoch - MIN_SEED_LOOKAHEAD) - 1; | ||
| const headDependentRoot = this.protoArray.getAncestorOrNull(headRootHex, dependentSlot)?.blockRoot; | ||
| const blockDependentRoot = this.protoArray.getAncestorOrNull(blockParentRootHex, dependentSlot)?.blockRoot; | ||
| // On lookup failure, we lean on the conservative side and withold the boost | ||
| if (headDependentRoot === undefined || blockDependentRoot === undefined) { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this happens only when the ancestor gets pruned. Not sure if we return true or false in this case. I think either is fine. Any thought? @twoeths |
||
| return false; | ||
| } | ||
|
ensi321 marked this conversation as resolved.
|
||
|
|
||
| return headDependentRoot === blockDependentRoot; | ||
| } | ||
|
|
||
| /** | ||
| * Return true if the block is timely for the current slot. | ||
| * Child class can overwrite this for testing purpose. | ||
|
|
||
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.
@ensi321 do you know what's missing to pass the remaining tests?