Skip to content

feat: block gossip validation for parent payload (consensus-specs#4923)#11

Open
lodekeeper wants to merge 2 commits intounstablefrom
feat/block-gossip-parent-payload
Open

feat: block gossip validation for parent payload (consensus-specs#4923)#11
lodekeeper wants to merge 2 commits intounstablefrom
feat/block-gossip-parent-payload

Conversation

@lodekeeper
Copy link
Owner

Motivation

Implement gossip validation for parent execution payload per ethereum/consensus-specs#4923.

Changes

  • IGNORE block if parent execution payload (bid.parent_block_hash) has not been seen
  • Add PARENT_PAYLOAD_UNKNOWN block error code
  • Add hasExecutionPayload() method to fork-choice and proto-array
  • O(n) linear scan for now (TODO: secondary index for O(1) lookups)

Split from alpha.3 upgrade PR #6.

- IGNORE block if parent execution payload has not been seen
- Add PARENT_PAYLOAD_UNKNOWN block error code
- Add hasExecutionPayload() method to fork-choice and proto-array
- Linear scan for now (TODO: secondary index for O(1) lookups)
* Looks through all nodes with FULL variant status for a matching executionPayloadBlockHash.
* Used for Gloas gossip validation: parent execution payload must have been seen.
*
* TODO GLOAS: Add secondary index (Set<RootHex> by executionPayloadBlockHash) for O(1) lookups.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you check ChainSafe@e275112 it has some optimization for this

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied in 0ac2422 — same approach as e275112:

  • private executionPayloadBlockHashes = new Set<RootHex>()
  • Maintained in onBlock() (pre-Gloas) and onExecutionPayload() (Gloas)
  • Pruned in maybePrune() alongside indices/ptcVotes
  • hasExecutionPayload() → single Set.has() call, O(1)

Thanks for the pointer!

Add Set<RootHex> secondary index for executionPayloadBlockHash
lookups. Maintained in onBlock() (pre-Gloas) and onExecutionPayload()
(Gloas), pruned in maybePrune(). Replaces O(n) linear scan.

Reference: ChainSafe/lodestar@e275112

Co-authored-by: lodekeeper <258435968+lodekeeper@users.noreply.github.com>
AI-assisted: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants