-
-
Notifications
You must be signed in to change notification settings - Fork 479
feat: implement should_apply_proposer_boost for gloas #9233
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
base: unstable
Are you sure you want to change the base?
Changes from all commits
9bc6eb6
2d7f37c
57594ee
8aafc5e
09174a2
d2bb968
e9d11c0
28e0fbc
6b87bda
90677ef
545a190
148a1c5
cc95ae3
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 {DataAvailabilityStatus} from "@lodestar/state-transition"; | ||
| import {Epoch, RootHex, Slot, UintNum64} from "@lodestar/types"; | ||
| import {Epoch, RootHex, Slot, UintNum64, ValidatorIndex} from "@lodestar/types"; | ||
|
|
||
| // RootHex is a root as a hex string | ||
| // Used for lightweight and easy comparison | ||
|
|
@@ -144,6 +144,13 @@ export type ProtoBlock = BlockExtraMeta & { | |
| // Indicate whether block arrives in a timely manner ie. before the 4 second mark | ||
| timeliness: boolean; | ||
|
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. we may want to use a single
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. Is there a real benefit to this? Using bits impact readability, and we are only saving one boolean field per |
||
|
|
||
| // Indicate whether block arrives before the PTC deadline | ||
| // Spec: gloas/fork-choice.md#modified-record_block_timeliness (block_timeliness[PTC_TIMELINESS_INDEX]) | ||
| ptcTimeliness: boolean; | ||
|
|
||
| // The index of the block proposer. Used by should_apply_proposer_boost to detect proposer equivocations | ||
| proposerIndex: ValidatorIndex; | ||
|
|
||
| /** Payload status for this node (Gloas fork). Always FULL in pre-gloas */ | ||
| payloadStatus: PayloadStatus; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||||||||||
| import {BitArray} from "@chainsafe/ssz"; | ||||||||||||
| import {EFFECTIVE_BALANCE_INCREMENT, GENESIS_EPOCH, GENESIS_SLOT, PTC_SIZE} from "@lodestar/params"; | ||||||||||||
| import {DataAvailabilityStatus, computeEpochAtSlot, computeStartSlotAtEpoch} from "@lodestar/state-transition"; | ||||||||||||
| import {Epoch, RootHex, Slot} from "@lodestar/types"; | ||||||||||||
| import {Epoch, RootHex, Slot, ValidatorIndex} from "@lodestar/types"; | ||||||||||||
| import {bitCount, toRootHex} from "@lodestar/utils"; | ||||||||||||
| import {ForkChoiceError, ForkChoiceErrorCode} from "../forkChoice/errors.js"; | ||||||||||||
| import {LVHExecError, LVHExecErrorCode, ProtoArrayError, ProtoArrayErrorCode} from "./errors.js"; | ||||||||||||
|
|
@@ -2007,6 +2007,32 @@ export class ProtoArray { | |||||||||||
| return this.getNodeByIndex(nodeIndex); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Return true if a block other than `excludeRoot` at `slot` was proposed by `proposerIndex` and | ||||||||||||
| * is PTC-timely. Used by `should_apply_proposer_boost` to detect proposer equivocations. | ||||||||||||
| * | ||||||||||||
| * https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.14/specs/gloas/fork-choice.md#new-should_apply_proposer_boost | ||||||||||||
| * | ||||||||||||
| * Iterates unique block roots (via the canonical variant) since `slot`, `proposerIndex` and | ||||||||||||
| * `ptcTimeliness` are block-level properties identical across payload-status variants. | ||||||||||||
| */ | ||||||||||||
| hasEquivocatingBlock(proposerIndex: ValidatorIndex, slot: Slot, excludeRoot: RootHex): boolean { | ||||||||||||
| for (const root of this.indices.keys()) { | ||||||||||||
| if (root === excludeRoot) { | ||||||||||||
| continue; | ||||||||||||
| } | ||||||||||||
| const nodeIndex = this.getDefaultNodeIndex(root); | ||||||||||||
| if (nodeIndex === undefined) { | ||||||||||||
| continue; | ||||||||||||
| } | ||||||||||||
| const node = this.nodes[nodeIndex]; | ||||||||||||
| if (node !== undefined && node.slot === slot && node.proposerIndex === proposerIndex && node.ptcTimeliness) { | ||||||||||||
|
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. I am not sure this can happen right now, if we receive a equivocating block over gossip, we would just ignore it lodestar/packages/beacon-node/src/chain/validation/block.ts Lines 86 to 90 in 148a1c5
this is kinda related to #9757, need to see if we wanna use
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. the |
||||||||||||
| return true; | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
| return false; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Return MUTABLE ProtoBlock for blockRoot with explicit payload status | ||||||||||||
| * | ||||||||||||
|
|
||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
so this should only be relevant in case of proposer equivocation to make sure the next proposer can see it and can be aware of the equivocation in time?
so using the ptc timing seems pretty arbitrary to me but the purpose if I understand this correctly is to figure out if the it was an "early equivocation"
should this be renamed?
Edit: after thinking more about it, not sure the rename is better because it could suggest that the block is an equivocation
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.
Yea I like
isBlockPtcTimely