feat: SSZ-REST Engine API transport#8994
feat: SSZ-REST Engine API transport#8994Giulio2002 wants to merge 4 commits intoChainSafe:unstablefrom
Conversation
Implement SSZ-REST transport for all Engine API methods: - new_payload (v3/v4/v5) - forkchoice_updated (v3) - get_payload (v3/v4/v5) - exchange_capabilities (v1) New CLI flag --execution.sszRestUrl enables SSZ-REST with automatic fallback to JSON-RPC on network errors. Includes proper fork-based version selection for Fulu (v5). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello, 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 introduces a significant upgrade to the execution layer communication by integrating the EIP-8161 SSZ-REST Engine API transport. This change allows for more efficient, binary-encoded interactions with the execution layer, enhancing performance and aligning with new Ethereum standards. The implementation includes a resilient fallback mechanism to JSON-RPC in case of network issues, ensuring continuous operation. It also provides a new configuration option for users to enable and specify the SSZ-REST endpoint. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
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.
Code Review
This pull request implements EIP-8161, adding SSZ-REST transport for the Engine API. The changes are well-structured, introducing a new SszRestClient, SSZ encoding/decoding logic, and integrating it into the existing ExecutionEngineHttp with a fallback to JSON-RPC. My review includes a few suggestions to improve code reuse and maintainability by replacing custom utility functions with existing ones from @lodestar/utils and refactoring duplicated logic.
| const version = | ||
| ForkSeq[fork] >= ForkSeq.fulu ? 5 : ForkSeq[fork] >= ForkSeq.electra ? 4 : ForkSeq[fork] >= ForkSeq.deneb ? 3 : ForkSeq[fork] >= ForkSeq.capella ? 2 : 1; |
There was a problem hiding this comment.
This version selection logic is duplicated in the getPayload method (lines 554-555). To improve maintainability and adhere to the DRY (Don't Repeat Yourself) principle, consider extracting this logic into a dedicated helper function. For example:
function getPayloadApiVersion(fork: ForkName): number {
const forkSeq = ForkSeq[fork];
if (forkSeq >= ForkSeq.fulu) return 5;
if (forkSeq >= ForkSeq.electra) return 4;
if (forkSeq >= ForkSeq.deneb) return 3;
if (forkSeq >= ForkSeq.capella) return 2;
return 1;
}You can then call this function here and in getPayload.
| constructor(opts: SszRestClientOpts) { | ||
| // Strip trailing slash for consistent path joining | ||
| this.baseUrl = opts.baseUrl.replace(/\/+$/, ""); | ||
| this.jwtSecret = opts.jwtSecretHex ? hexToBytes(opts.jwtSecretHex) : undefined; |
There was a problem hiding this comment.
For consistency and to leverage a more robust utility, please use the fromHex function from @lodestar/utils instead of the custom hexToBytes implementation. You'll need to add fromHex to your imports and can then remove the hexToBytes function (lines 139-146).
| this.jwtSecret = opts.jwtSecretHex ? hexToBytes(opts.jwtSecretHex) : undefined; | |
| this.jwtSecret = opts.jwtSecretHex ? fromHex(opts.jwtSecretHex) : undefined; |
| function hexToBytes20(hex: string): Uint8Array { | ||
| const stripped = hex.startsWith("0x") ? hex.slice(2) : hex; | ||
| if (stripped.length !== 40) { | ||
| throw Error(`Expected 20-byte hex address, got ${stripped.length / 2} bytes`); | ||
| } | ||
| const bytes = new Uint8Array(20); | ||
| for (let i = 0; i < 20; i++) { | ||
| bytes[i] = parseInt(stripped.substring(i * 2, i * 2 + 2), 16); | ||
| } | ||
| return bytes; | ||
| } |
There was a problem hiding this comment.
Instead of a custom hexToBytes20 implementation, you can use the existing fromHex utility from @lodestar/utils and add a length check. This promotes code reuse and consistency.
You will need to add import {fromHex} from "@lodestar/utils";.
function hexToBytes20(hex: string): Uint8Array {
const bytes = fromHex(hex);
if (bytes.length !== 20) {
throw Error(`Expected 20-byte hex address, got ${bytes.length} bytes`);
}
return bytes;
}…-REST
- new_payload → POST /engine/v{N}/payloads
- forkchoice_updated → POST /engine/v{N}/forkchoice
- get_payload → GET /engine/v{N}/payloads/{payload_id}
- get_blobs → POST /engine/v{N}/blobs
- Error responses now text/plain instead of JSON
- Added doGetRequest for GET support, Fulu version selection fix
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Per execution-apis PR ChainSafe#764 spec: - PayloadStatus.latest_valid_hash: List[Hash32, 1] - ForkchoiceUpdatedResponse.payload_id: List[Bytes8, 1] - ForkchoiceUpdatedRequest.payload_attributes: List[PayloadAttributes, 1] Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
is this different from #8993 which is based on @barnabasbusa ssz engine api spec? |
SSZ-REST URL is now derived from the first engine URL (same host:port). The EL serves SSZ-REST on the engine port under /engine/* paths. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
effectively the same |
|
Implements the SSZ-REST Engine API transport spec: ethereum/execution-apis#764 |
Summary
Implements SSZ-REST Engine API transport on the consensus layer (client side), as specified in ethereum/execution-apis#764.
--execution.sszRestUrlto configure SSZ-REST endpointnew_payload(v1-v5),forkchoice_updated(v1-v3),get_payload(v1-v5),exchange_capabilities