-
-
Notifications
You must be signed in to change notification settings - Fork 471
feat: add stateless path to publishExecutionPayloadEnvelope (gd5) #9506
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
Merged
ensi321
merged 7 commits into
glamsterdam-devnet-5
from
nc/publish-envelope-with-blobs-gd5
Jun 11, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9ca1bc7
feat: accept SignedExecutionPayloadEnvelopeContents on envelope publish
ensi321 697e867
fix: destructure broadcastValidation in publishExecutionPayloadEnvelope
ensi321 cc13d3b
fix: preserve header key type in publishExecutionPayloadEnvelope test
ensi321 43a3cc4
fix: validate supplied blobs against bid commitments and reject parti…
ensi321 726a2c0
refactor: discriminate ssz envelope wrapper by first offset and rejec…
ensi321 a12686b
fix: kzg-verify supplied blobs and proofs against bid commitments
ensi321 4fdfd81
chore: remove redundant comments around envelope publish wrapper
ensi321 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
123 changes: 123 additions & 0 deletions
123
packages/api/test/unit/beacon/publishExecutionPayloadEnvelope.test.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,123 @@ | ||
| import {describe, expect, it} from "vitest"; | ||
| import {createChainForkConfig, defaultChainConfig} from "@lodestar/config"; | ||
| import {ssz} from "@lodestar/types"; | ||
| import {BroadcastValidation, getDefinitions} from "../../../src/beacon/routes/beacon/block.js"; | ||
| import {WireFormat} from "../../../src/utils/wireFormat.js"; | ||
|
|
||
| function lowercaseKeys<T extends Record<string, string>>(headers: T): T { | ||
| return Object.fromEntries(Object.entries(headers).map(([k, v]) => [k.toLowerCase(), v])) as T; | ||
| } | ||
|
|
||
| describe("publishExecutionPayloadEnvelope route", () => { | ||
| const config = createChainForkConfig({...defaultChainConfig, GLOAS_FORK_EPOCH: 0}); | ||
| const definitions = getDefinitions(config); | ||
| const route = definitions.publishExecutionPayloadEnvelope; | ||
|
|
||
| const signedExecutionPayloadEnvelope = ssz.gloas.SignedExecutionPayloadEnvelope.defaultValue(); | ||
|
|
||
| describe("JSON wire format", () => { | ||
| it("round-trips a bare SignedExecutionPayloadEnvelope", () => { | ||
| const written = route.req.writeReqJson({signedExecutionPayloadEnvelope}); | ||
| expect(written.body).toHaveProperty("message"); | ||
| expect(written.body).toHaveProperty("signature"); | ||
| expect(written.body).not.toHaveProperty("signed_execution_payload_envelope"); | ||
|
|
||
| const parsed = route.req.parseReqJson({ | ||
| body: written.body, | ||
| headers: lowercaseKeys(written.headers), | ||
| query: written.query ?? {}, | ||
| }); | ||
| expect(parsed.signedExecutionPayloadEnvelope).toEqual(signedExecutionPayloadEnvelope); | ||
| expect(parsed.blobs).toBeUndefined(); | ||
| expect(parsed.kzgProofs).toBeUndefined(); | ||
| }); | ||
|
|
||
| it("round-trips a SignedExecutionPayloadEnvelopeContents wrapper when blobs are supplied", () => { | ||
| const blobs = [ssz.deneb.Blob.defaultValue()]; | ||
| const kzgProofs = Array.from({length: 128}, () => ssz.deneb.KZGProof.defaultValue()); | ||
|
|
||
| const written = route.req.writeReqJson({ | ||
| signedExecutionPayloadEnvelope, | ||
| blobs, | ||
| kzgProofs, | ||
| broadcastValidation: BroadcastValidation.consensus, | ||
| }); | ||
| expect(written.body).toHaveProperty("signed_execution_payload_envelope"); | ||
| expect(written.body).toHaveProperty("kzg_proofs"); | ||
| expect(written.body).toHaveProperty("blobs"); | ||
| expect(written.query?.broadcast_validation).toBe(BroadcastValidation.consensus); | ||
|
|
||
| const parsed = route.req.parseReqJson({ | ||
| body: written.body, | ||
| headers: lowercaseKeys(written.headers), | ||
| query: written.query ?? {}, | ||
| }); | ||
| expect(parsed.signedExecutionPayloadEnvelope).toEqual(signedExecutionPayloadEnvelope); | ||
| expect(parsed.blobs).toEqual(blobs); | ||
| expect(parsed.kzgProofs).toEqual(kzgProofs); | ||
| expect(parsed.broadcastValidation).toBe(BroadcastValidation.consensus); | ||
| }); | ||
| }); | ||
|
|
||
| describe("SSZ wire format", () => { | ||
| it("round-trips a bare SignedExecutionPayloadEnvelope", () => { | ||
| const written = route.req.writeReqSsz({signedExecutionPayloadEnvelope}); | ||
| const parsed = route.req.parseReqSsz({ | ||
| body: written.body, | ||
| headers: lowercaseKeys(written.headers), | ||
| query: written.query ?? {}, | ||
| }); | ||
| expect(parsed.signedExecutionPayloadEnvelope).toEqual(signedExecutionPayloadEnvelope); | ||
| expect(parsed.blobs).toBeUndefined(); | ||
| expect(parsed.kzgProofs).toBeUndefined(); | ||
| }); | ||
|
|
||
| it("round-trips a SignedExecutionPayloadEnvelopeContents wrapper", () => { | ||
| const blobs = [ssz.deneb.Blob.defaultValue()]; | ||
| const kzgProofs = Array.from({length: 128}, () => ssz.deneb.KZGProof.defaultValue()); | ||
|
|
||
| const written = route.req.writeReqSsz({signedExecutionPayloadEnvelope, blobs, kzgProofs}); | ||
| const parsed = route.req.parseReqSsz({ | ||
| body: written.body, | ||
| headers: lowercaseKeys(written.headers), | ||
| query: written.query ?? {}, | ||
| }); | ||
| expect(parsed.signedExecutionPayloadEnvelope).toEqual(signedExecutionPayloadEnvelope); | ||
| expect(parsed.blobs).toEqual(blobs); | ||
| expect(parsed.kzgProofs).toEqual(kzgProofs); | ||
| }); | ||
| }); | ||
|
|
||
| it("uses SSZ as the default request wire format", () => { | ||
| expect(route.init?.requestWireFormat).toBe(WireFormat.ssz); | ||
| }); | ||
|
|
||
| describe("partial blobs/kzgProofs rejection", () => { | ||
| const blobs = [ssz.deneb.Blob.defaultValue()]; | ||
| const kzgProofs = Array.from({length: 128}, () => ssz.deneb.KZGProof.defaultValue()); | ||
|
|
||
| it("writeReqJson throws when only blobs are supplied", () => { | ||
| expect(() => route.req.writeReqJson({signedExecutionPayloadEnvelope, blobs})).toThrow( | ||
| /blobs and kzgProofs must both be supplied/ | ||
| ); | ||
| }); | ||
|
|
||
| it("writeReqJson throws when only kzgProofs are supplied", () => { | ||
| expect(() => route.req.writeReqJson({signedExecutionPayloadEnvelope, kzgProofs})).toThrow( | ||
| /blobs and kzgProofs must both be supplied/ | ||
| ); | ||
| }); | ||
|
|
||
| it("writeReqSsz throws when only blobs are supplied", () => { | ||
| expect(() => route.req.writeReqSsz({signedExecutionPayloadEnvelope, blobs})).toThrow( | ||
| /blobs and kzgProofs must both be supplied/ | ||
| ); | ||
| }); | ||
|
|
||
| it("writeReqSsz throws when only kzgProofs are supplied", () => { | ||
| expect(() => route.req.writeReqSsz({signedExecutionPayloadEnvelope, kzgProofs})).toThrow( | ||
| /blobs and kzgProofs must both be supplied/ | ||
| ); | ||
| }); | ||
| }); | ||
| }); |
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
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
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.
If
publishExecutionPayloadEnvelopeis called multiple times for the same block (which is common in redundant/fallback setups or due to client retries), callingpayloadInput.addPayloadEnvelopewill throw an unhandledError: Payload envelope already set for block ...and result in a 500 Internal Server Error.To prevent this, we should check if the payload envelope is already set using
payloadInput.hasPayloadEnvelope()and return early (benign duplicate publish).