-
-
Notifications
You must be signed in to change notification settings - Fork 427
feat: implement ePBS gossip topics #8616
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
Open
ensi321
wants to merge
25
commits into
unstable
Choose a base branch
from
nc/epbs-p2p
base: unstable
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
9069fc9
validateAggregateAndProof
ensi321 5fdb2fd
Update attestation validation
ensi321 4e34cff
Gossip payload envelope
ensi321 cb326a6
Gossip payload attestation
ensi321 4f5da97
Gossip bid
ensi321 999e940
Update gossip block validation
ensi321 9c928a7
Merge branch 'unstable' into nc/epbs-p2p
ensi321 ad623b1
Add payload attestation pool
ensi321 8459c88
Add payload att seen cache. Finish gossip validation for payload att
ensi321 1b54928
Gossip validator for bids
ensi321 6821c48
Handle gossip payload attestation
ensi321 a5d469a
Boilerplate stuff
ensi321 d3b7901
Lint
ensi321 fa64a52
Address comments
ensi321 ef17b17
Update packages/beacon-node/src/chain/opPools/payloadAttestationPool.ts
ensi321 664f988
Execution payload validation
ensi321 3bbfbff
Add seen cache for payload
ensi321 4d9d27e
Add bid pool
ensi321 c219e8c
lint
ensi321 3ad1368
Add bid seen cache
ensi321 97e6678
Polish
ensi321 479ea21
Merge branch 'unstable' into nc/epbs-p2p
ensi321 43f2a3d
Address comments
ensi321 6b57579
Resolve merge conflicts
nflaig b8492bf
chore: review epbs gossip topic changes (#8715)
nflaig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/beacon-node/src/chain/errors/executionPayloadBid.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import {RootHex, Slot, ValidatorIndex} from "@lodestar/types"; | ||
| import {GossipActionError} from "./gossipValidation.ts"; | ||
|
|
||
| export enum ExecutionPayloadBidErrorCode { | ||
| BUILDER_NOT_ELIGIBLE = "EXECUTION_PAYLOAD_BID_ERROR_BUILDER_NOT_ELIGIBLE", | ||
| BUILDER_BAD_CREDENTIALS = "EXECUTION_PAYLOAD_BID_ERROR_BUILDER_BAD_CREDENTIALS", | ||
| NON_ZERO_EXECUTION_PAYMENT = "EXECUTION_PAYLOAD_BID_ERROR_NON_ZERO_EXECUTION_PAYMENT", | ||
| BID_ALREADY_KNOWN = "EXECUTION_PAYLOAD_BID_ERROR_BID_ALREADY_KNOWN", | ||
| BID_TOO_LOW = "EXECUTION_PAYLOAD_BID_ERROR_BID_TOO_LOW", | ||
| BID_TOO_HIGH = "EXECUTION_PAYLOAD_BID_ERROR_BID_TOO_HIGH", | ||
| UNKNOWN_PARENT_BLOCK_HASH = "EXECUTION_PAYLOAD_BID_ERROR_UNKNOWN_PARENT_BLOCK_HASH", | ||
| UNKNOWN_BLOCK_ROOT = "EXECUTION_PAYLOAD_BID_ERROR_UNKNOWN_BLOCK_ROOT", | ||
| INVALID_SLOT = "EXECUTION_PAYLOAD_BID_ERROR_INVALID_SLOT", | ||
| INVALID_SIGNATURE = "EXECUTION_PAYLOAD_BID_ERROR_INVALID_SIGNATURE", | ||
| } | ||
|
|
||
| export type ExecutionPayloadBidErrorType = | ||
| | {code: ExecutionPayloadBidErrorCode.BUILDER_NOT_ELIGIBLE; builderIndex: ValidatorIndex} | ||
| | {code: ExecutionPayloadBidErrorCode.BUILDER_BAD_CREDENTIALS; builderIndex: ValidatorIndex} | ||
| | { | ||
| code: ExecutionPayloadBidErrorCode.NON_ZERO_EXECUTION_PAYMENT; | ||
| builderIndex: ValidatorIndex; | ||
| executionPayment: number; | ||
| } | ||
| | { | ||
| code: ExecutionPayloadBidErrorCode.BID_ALREADY_KNOWN; | ||
| builderIndex: ValidatorIndex; | ||
| slot: Slot; | ||
| parentBlockRoot: RootHex; | ||
| parentBlockHash: RootHex; | ||
| } | ||
| | {code: ExecutionPayloadBidErrorCode.BID_TOO_LOW; bidValue: number; currentHighestBid: number} | ||
| | {code: ExecutionPayloadBidErrorCode.BID_TOO_HIGH; bidValue: number; builderBalance: number} | ||
| | {code: ExecutionPayloadBidErrorCode.UNKNOWN_PARENT_BLOCK_HASH; parentBlockHash: RootHex} | ||
| | {code: ExecutionPayloadBidErrorCode.UNKNOWN_BLOCK_ROOT; parentBlockRoot: RootHex} | ||
| | {code: ExecutionPayloadBidErrorCode.INVALID_SLOT; builderIndex: ValidatorIndex; slot: Slot} | ||
| | {code: ExecutionPayloadBidErrorCode.INVALID_SIGNATURE; builderIndex: ValidatorIndex; slot: Slot}; | ||
|
|
||
| export class ExecutionPayloadBidError extends GossipActionError<ExecutionPayloadBidErrorType> {} | ||
35 changes: 35 additions & 0 deletions
35
packages/beacon-node/src/chain/errors/executionPayloadEnvelope.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import {RootHex, Slot, ValidatorIndex} from "@lodestar/types"; | ||
| import {GossipActionError} from "./gossipValidation.js"; | ||
|
|
||
| export enum ExecutionPayloadEnvelopeErrorCode { | ||
| BELONG_TO_FINALIZED_BLOCK = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_BELONG_TO_FINALIZED_BLOCK", | ||
| BLOCK_ROOT_UNKNOWN = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_BLOCK_ROOT_UNKNOWN", | ||
| ENVELOPE_ALREADY_KNOWN = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_ALREADY_KNOWN", | ||
| INVALID_BLOCK = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_INVALID_BLOCK", | ||
| SLOT_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_SLOT_MISMATCH", | ||
| BUILDER_INDEX_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_BUILDER_INDEX_MISMATCH", | ||
| BLOCK_HASH_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_BLOCK_HASH_MISMATCH", | ||
| INVALID_SIGNATURE = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_INVALID_SIGNATURE", | ||
| CACHE_FAIL = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_CACHE_FAIL", | ||
| } | ||
| export type ExecutionPayloadEnvelopeErrorType = | ||
| | {code: ExecutionPayloadEnvelopeErrorCode.BELONG_TO_FINALIZED_BLOCK; envelopeSlot: Slot; finalizedSlot: Slot} | ||
| | {code: ExecutionPayloadEnvelopeErrorCode.BLOCK_ROOT_UNKNOWN; blockRoot: RootHex} | ||
| | { | ||
| code: ExecutionPayloadEnvelopeErrorCode.ENVELOPE_ALREADY_KNOWN; | ||
| blockRoot: RootHex; | ||
| slot: Slot; | ||
| builderIndex: ValidatorIndex; | ||
| } | ||
| | {code: ExecutionPayloadEnvelopeErrorCode.INVALID_BLOCK; blockRoot: RootHex} | ||
| | {code: ExecutionPayloadEnvelopeErrorCode.SLOT_MISMATCH; envelopeSlot: Slot; blockSlot: Slot} | ||
| | { | ||
| code: ExecutionPayloadEnvelopeErrorCode.BUILDER_INDEX_MISMATCH; | ||
| envelopeBuilderIndex: ValidatorIndex; | ||
| bidBuilderIndex: ValidatorIndex; | ||
| } | ||
| | {code: ExecutionPayloadEnvelopeErrorCode.BLOCK_HASH_MISMATCH; envelopeBlockHash: RootHex; bidBlockHash: RootHex} | ||
| | {code: ExecutionPayloadEnvelopeErrorCode.INVALID_SIGNATURE} | ||
| | {code: ExecutionPayloadEnvelopeErrorCode.CACHE_FAIL; blockRoot: RootHex}; | ||
|
|
||
| export class ExecutionPayloadEnvelopeError extends GossipActionError<ExecutionPayloadEnvelopeErrorType> {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/beacon-node/src/chain/errors/payloadAttestation.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import {RootHex, Slot, ValidatorIndex} from "@lodestar/types"; | ||
| import {GossipActionError} from "./gossipValidation.ts"; | ||
|
|
||
| export enum PayloadAttestationErrorCode { | ||
| NOT_CURRENT_SLOT = "PAYLOAD_ATTESTATION_ERROR_NOT_CURRENT_SLOT", | ||
| PAYLOAD_ATTESTATION_ALREADY_KNOWN = "PAYLOAD_ATTESTATION_ERROR_PAYLOAD_ATTESTATION_ALREADY_KNOWN", | ||
| UNKNOWN_BLOCK_ROOT = "PAYLOAD_ATTESTATION_ERROR_UNKNOWN_BLOCK_ROOT", | ||
| INVALID_BLOCK = "PAYLOAD_ATTESTATION_ERROR_INVALID_BLOCK", | ||
| INVALID_ATTESTER = "PAYLOAD_ATTESTATION_ERROR_INVALID_ATTESTER", | ||
| INVALID_SIGNATURE = "PAYLOAD_ATTESTATION_ERROR_INVALID_SIGNATURE", | ||
| } | ||
| export type PayloadAttestationErrorType = | ||
| | {code: PayloadAttestationErrorCode.NOT_CURRENT_SLOT; currentSlot: Slot; slot: Slot} | ||
| | { | ||
| code: PayloadAttestationErrorCode.PAYLOAD_ATTESTATION_ALREADY_KNOWN; | ||
| validatorIndex: ValidatorIndex; | ||
| slot: Slot; | ||
| blockRoot: RootHex; | ||
| } | ||
| | {code: PayloadAttestationErrorCode.UNKNOWN_BLOCK_ROOT; blockRoot: RootHex} | ||
| | {code: PayloadAttestationErrorCode.INVALID_BLOCK; blockRoot: RootHex} | ||
| | {code: PayloadAttestationErrorCode.INVALID_ATTESTER; attesterIndex: ValidatorIndex} | ||
| | {code: PayloadAttestationErrorCode.INVALID_SIGNATURE}; | ||
|
|
||
| export class PayloadAttestationError extends GossipActionError<PayloadAttestationErrorType> {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
packages/beacon-node/src/chain/opPools/executionPayloadBidPool.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import {Slot, gloas} from "@lodestar/types"; | ||
| import {MapDef, toRootHex} from "@lodestar/utils"; | ||
| import {InsertOutcome} from "./types.js"; | ||
| import {pruneBySlot} from "./utils.js"; | ||
|
|
||
| const SLOTS_RETAINED = 2; | ||
|
|
||
| type BlockRootHex = string; | ||
| type BlockHashHex = string; | ||
|
|
||
| /** | ||
| * Store the best execution payload bid per slot / (parent block root, parent block hash). | ||
| */ | ||
| export class ExecutionPayloadBidPool { | ||
| private readonly bidByParentHashByParentRootBySlot = new MapDef< | ||
| Slot, | ||
| MapDef<BlockRootHex, Map<BlockHashHex, gloas.ExecutionPayloadBid>> | ||
| >(() => new MapDef<BlockRootHex, Map<BlockHashHex, gloas.ExecutionPayloadBid>>(() => new Map())); | ||
| private lowestPermissibleSlot = 0; | ||
|
|
||
| add(bid: gloas.ExecutionPayloadBid): InsertOutcome { | ||
| const {slot, parentBlockRoot, parentBlockHash, value} = bid; | ||
| const lowestPermissibleSlot = this.lowestPermissibleSlot; | ||
|
|
||
| if (slot < lowestPermissibleSlot) { | ||
| return InsertOutcome.Old; | ||
| } | ||
|
|
||
| const parentRootHex = toRootHex(parentBlockRoot); | ||
| const parentHashHex = toRootHex(parentBlockHash); | ||
| const bidByParentHash = this.bidByParentHashByParentRootBySlot.getOrDefault(slot).getOrDefault(parentRootHex); | ||
| const existing = bidByParentHash.get(parentHashHex); | ||
|
|
||
| if (existing) { | ||
| const existingValue = existing.value; | ||
| const newValue = value; | ||
| if (newValue > existingValue) { | ||
| bidByParentHash.set(parentHashHex, bid); | ||
| return InsertOutcome.NewData; | ||
| } | ||
| return newValue === existingValue ? InsertOutcome.AlreadyKnown : InsertOutcome.NotBetterThan; | ||
| } | ||
|
|
||
| bidByParentHash.set(parentHashHex, bid); | ||
| return InsertOutcome.NewData; | ||
| } | ||
|
|
||
| /** | ||
| * Return the highest-value bid matching slot, parent block root, and parent block hash. | ||
| * Used for gossip validation and block production. | ||
| */ | ||
| getBestBid( | ||
| parentBlockRoot: BlockRootHex, | ||
| parentBlockHash: BlockHashHex, | ||
| slot: Slot | ||
| ): gloas.ExecutionPayloadBid | null { | ||
| const bidByParentHash = this.bidByParentHashByParentRootBySlot.get(slot)?.get(parentBlockRoot); | ||
| return bidByParentHash?.get(parentBlockHash) ?? null; | ||
| } | ||
|
|
||
| prune(clockSlot: Slot): void { | ||
| this.lowestPermissibleSlot = pruneBySlot(this.bidByParentHashByParentRootBySlot, clockSlot, SLOTS_RETAINED); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| export {AggregatedAttestationPool} from "./aggregatedAttestationPool.js"; | ||
| export {AttestationPool} from "./attestationPool.js"; | ||
| export {ExecutionPayloadBidPool} from "./executionPayloadBidPool.js"; | ||
| export {OpPool} from "./opPool.js"; | ||
| export {PayloadAttestationPool} from "./payloadAttestationPool.js"; | ||
| export {SyncCommitteeMessagePool} from "./syncCommitteeMessagePool.js"; | ||
| export {SyncContributionAndProofPool} from "./syncContributionAndProofPool.js"; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
a lot of these
builderIndex: ValidatorIndexwe will need to change once builders are no longer validators