-
-
Notifications
You must be signed in to change notification settings - Fork 416
[WIP] feat: implement ePBS networking spec #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
base: unstable
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @ensi321, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request lays the groundwork for implementing the ePBS (enshrined Proposer-Builder Separation) networking specification, likely for an upcoming Ethereum fork referred to as "Gloas." It introduces new data structures and validation rules for execution payload bids, envelopes, and payload attestations, and integrates these new message types into the beacon node's gossip network for propagation and processing. This is a Work In Progress, building upon a previous PR. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces networking specifications for ePBS, including new gossip message types, error codes, and validation logic. The changes are extensive and touch upon core validation and networking components. My review has identified a critical logic error in attestation validation, several typos in new error codes that should be corrected for consistency, and some areas for code improvement regarding duplication and import consistency. Overall, the changes are a good step towards implementing the ePBS spec, but the identified issues, especially the critical one, should be addressed.
| if (block.slot === attSlot && attData.index === 0) { | ||
| throw new AttestationError(GossipAction.REJECT, {code: AttestationErrorCode.PREMATURELY_INDICATE_PAYLOAD_PRESENT}); | ||
| } |
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.
The validation logic here appears to be incorrect. The comment and the error code PREMATURELY_INDICATE_PAYLOAD_PRESENT suggest that an attestation for the current slot should not indicate that the payload is present. In gloas, an index of 1 means the payload is present, while 0 means it is not. Therefore, you should reject if attData.index === 1 (or attData.index !== 0 since valid values are 0 and 1). The current code rejects if attData.index === 0, which is the opposite of the intended logic.
| if (block.slot === attSlot && attData.index === 0) { | |
| throw new AttestationError(GossipAction.REJECT, {code: AttestationErrorCode.PREMATURELY_INDICATE_PAYLOAD_PRESENT}); | |
| } | |
| if (block.slot === attSlot && attData.index !== 0) { | |
| throw new AttestationError(GossipAction.REJECT, {code: AttestationErrorCode.PREMATURELY_INDICATE_PAYLOAD_PRESENT}); | |
| } |
| 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", | ||
| UNKNWON_BLOCK_ROOT = "EXECUTION_PAYLOAD_BID_ERROR_UNKNWON_BLOCK_ROOT", |
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.
| | {code: ExecutionPayloadBidErrorCode.BID_TOO_LOW; bidValue: bigint; currentHighestBid: bigint} | ||
| | {code: ExecutionPayloadBidErrorCode.BID_TOO_HIGH; bidValue: bigint; builderBalance: bigint} | ||
| | {code: ExecutionPayloadBidErrorCode.UNKNOWN_PARENT_BLOCK_HASH; parentBlockHash: RootHex} | ||
| | {code: ExecutionPayloadBidErrorCode.UNKNWON_BLOCK_ROOT; parentBlockRoot: RootHex} |
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.
| 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_MISTACH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_SLOT_MISTACH", |
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.
| | {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_MISTACH, envelopeSlot: Slot, blockSlot: Slot} |
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.
| 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.UNKNWON_BLOCK_ROOT; blockRoot: RootHex} |
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.
| // [REJECT] len(committee_indices) == 1, where committee_indices = get_committee_indices(aggregate) | ||
| attIndex = (aggregate as electra.Attestation).committeeBits.getSingleTrueBit(); | ||
| if (attIndex === null) { | ||
| throw new AttestationError(GossipAction.REJECT, {code: AttestationErrorCode.NOT_EXACTLY_ONE_COMMITTEE_BIT_SET}); | ||
| } |
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.
| @@ -0,0 +1,76 @@ | |||
| import {gloas} from "@lodestar/types"; | |||
| import {ExecutionPayloadBidError, ExecutionPayloadBidErrorCode, GossipAction, PayloadAttestationError, PayloadAttestationErrorCode} from "../errors/index.ts"; | |||
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.
The imports PayloadAttestationError and PayloadAttestationErrorCode are not used in this file and can be removed.
| import {ExecutionPayloadBidError, ExecutionPayloadBidErrorCode, GossipAction, PayloadAttestationError, PayloadAttestationErrorCode} from "../errors/index.ts"; | |
| import {ExecutionPayloadBidError, ExecutionPayloadBidErrorCode, GossipAction} from "../errors/index.ts"; |
| computeStartSlotAtEpoch, | ||
| } from "@lodestar/state-transition"; | ||
| import {gloas} from "@lodestar/types"; | ||
| import {ExecutionPayloadEnvelopeError, ExecutionPayloadEnvelopeErrorCode, GossipAction} from "../errors/index.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.
This file imports from ../errors/index.js with a .js extension, while other new files in this PR (e.g., executionPayloadBid.ts) import from .ts files. Please ensure consistency in import extensions across the project to avoid potential module resolution issues. It seems .ts is used in other new validation files.
| import {ExecutionPayloadEnvelopeError, ExecutionPayloadEnvelopeErrorCode, GossipAction} from "../errors/index.js"; | |
| import {ExecutionPayloadEnvelopeError, ExecutionPayloadEnvelopeErrorCode, GossipAction} from "../errors/index.ts"; |
|
|
||
| async function validateExecutionPayloadEnvelope( | ||
| chain: IBeaconChain, | ||
| exeuctionPayloadEnvelope: gloas.SignedExecutionPayloadEnvelope, |
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.
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
Depends on #8507