-
-
Notifications
You must be signed in to change notification settings - Fork 460
feat: add stateless path to publishExecutionPayloadEnvelope #9401
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
Draft
ensi321
wants to merge
7
commits into
unstable
Choose a base branch
from
nc/publish-envelope-with-blobs
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.
Draft
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
268607c
feat: accept SignedExecutionPayloadEnvelopeContents on envelope publish
ensi321 6d78f2f
fix: destructure broadcastValidation in publishExecutionPayloadEnvelope
ensi321 7b5460e
fix: preserve header key type in publishExecutionPayloadEnvelope test
ensi321 edb8c8d
fix: validate supplied blobs against bid commitments and reject parti…
ensi321 1f555b9
refactor: discriminate ssz envelope wrapper by first offset and rejec…
ensi321 5017b92
fix: kzg-verify supplied blobs and proofs against bid commitments
ensi321 fd38e7c
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
Some comments aren't visible on the classic Files Changed page.
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
94 changes: 94 additions & 0 deletions
94
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,94 @@ | ||
| 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): Record<string, string> { | ||
| return Object.fromEntries(Object.entries(headers).map(([k, v]) => [k.toLowerCase(), v])); | ||
| } | ||
|
|
||
| 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); | ||
| }); | ||
| }); |
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.
Uh oh!
There was an error while loading. Please reload this page.