Skip to content

Commit 8058687

Browse files
mkalininarnetheducklightclient
authored
Engine API: define payload bodies requests (#352)
* Engine API: define payload bodies requests * Apply suggestions from code review Co-authored-by: Jacek Sieka <[email protected]> * Update src/engine/shanghai.md Co-authored-by: lightclient <[email protected]> * Add handling pre-Shanghai bodies * More null values * Provide example responses for ByRange * Note that EL is expected to carry the full history Co-authored-by: Jacek Sieka <[email protected]> Co-authored-by: lightclient <[email protected]>
1 parent f28aa40 commit 8058687

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

src/engine/shanghai.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Engine API changes introduced in Shanghai.
1010
- [Structures](#structures)
1111
- [WithdrawalV1](#withdrawalv1)
1212
- [ExecutionPayloadV2](#executionpayloadv2)
13+
- [ExecutionPayloadBodyV1](#executionpayloadbodyv1)
1314
- [PayloadAttributesV2](#payloadattributesv2)
1415
- [Methods](#methods)
1516
- [engine_newPayloadV2](#engine_newpayloadv2)
@@ -24,6 +25,14 @@ Engine API changes introduced in Shanghai.
2425
- [Request](#request-2)
2526
- [Response](#response-2)
2627
- [Specification](#specification-2)
28+
- [engine_getPayloadBodiesByHashV1](#engine_getpayloadbodiesbyhashv1)
29+
- [Request](#request-3)
30+
- [Response](#response-3)
31+
- [Specification](#specification-3)
32+
- [engine_getPayloadBodiesByRangeV1](#engine_getpayloadbodiesbyrangev1)
33+
- [Request](#request-4)
34+
- [Response](#response-4)
35+
- [Specification](#specification-4)
2736

2837
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
2938

@@ -62,6 +71,11 @@ This structure has the syntax of `ExecutionPayloadV1` and appends a single field
6271
- `transactions`: `Array of DATA` - Array of transaction objects, each object is a byte list (`DATA`) representing `TransactionType || TransactionPayload` or `LegacyTransaction` as defined in [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718)
6372
- `withdrawals`: `Array of WithdrawalV1` - Array of withdrawals, each object is an `OBJECT` containing the fields of a `WithdrawalV1` structure.
6473

74+
### ExecutionPayloadBodyV1
75+
This structure contains a body of an execution payload. The fields are encoded as follows:
76+
- `transactions`: `Array of DATA` - Array of transaction objects, each object is a byte list (`DATA`) representing `TransactionType || TransactionPayload` or `LegacyTransaction` as defined in [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718)
77+
- `withdrawals`: `Array of WithdrawalV1` - Array of withdrawals, each object is an `OBJECT` containing the fields of a `WithdrawalV1` structure.
78+
6579
### PayloadAttributesV2
6680

6781
This structure has the syntax of `PayloadAttributesV1` and appends a single field: `withdrawals`.
@@ -146,3 +160,66 @@ This method follows the same specification as [`engine_forkchoiceUpdatedV1`](./p
146160
This method follows the same specification as [`engine_getPayloadV1`](./paris.md#engine_getpayloadv1) with the addition of the following:
147161

148162
1. Client software **SHOULD** use the sum of the block's priority fees or any other algorithm to determine `blockValue`.
163+
164+
### engine_getPayloadBodiesByHashV1
165+
166+
#### Request
167+
168+
* method: `engine_getPayloadBodiesByHashV1`
169+
* params:
170+
1. `Array of DATA`, 32 Bytes - Array of `block_hash` field values of the `ExecutionPayload` structure
171+
* timeout: 10s
172+
173+
#### Response
174+
175+
* result: `Array of ExecutionPayloadBodyV1` - Array of [`ExecutionPayloadBodyV1`](#ExecutionPayloadBodyV1) objects.
176+
* error: code and message set in case an exception happens while processing the method call.
177+
178+
#### Specification
179+
180+
1. Given array of block hashes client software **MUST** respond with array of `ExecutionPayloadBodyV1` objects with the corresponding hashes respecting the order of block hashes in the input array.
181+
182+
1. Client software **MUST** place responses in the order given in the request, using `null` for any missing blocks. For instance, if the request is `[A.block_hash, B.block_hash, C.block_hash]` and client software has data of payloads `A` and `C`, but doesn't have data of `B`, the response **MUST** be `[A.body, null, C.body]`.
183+
184+
1. Client software **MAY NOT** respond to requests for finalized blocks by hash.
185+
186+
1. Client software **MUST** set `withdrawals` field to `null` for bodies of pre-Shanghai blocks.
187+
188+
1. This request maps to [`BeaconBlocksByRoot`](https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/p2p-interface.md#beaconblocksbyroot) in the consensus layer `p2p` specification. Callers must be careful to use the execution block hash, instead of the beacon block root.
189+
190+
### engine_getPayloadBodiesByRangeV1
191+
192+
#### Request
193+
194+
* method: `engine_getPayloadBodiesByRangeV1`
195+
* params:
196+
1. `start`: `QUANTITY`, 64 bits - Starting block number
197+
1. `count`: `QUANITTY`, 64 bits - Number of blocks to return
198+
* timeout: 10s
199+
200+
#### Response
201+
202+
* result: `Array of ExecutionPayloadBodyV1` - Array of [`ExecutionPayloadBodyV1`](#ExecutionPayloadBodyV1) objects.
203+
* error: code and message set in case an exception happens while processing the method call.
204+
205+
#### Specification
206+
207+
1. Given a `start` and a `count`, the client software **MUST** respond with array of `ExecutionPayloadBodyV1` objects with the corresponding execution block number respecting the order of blocks in the canonical chain, as selected by the latest `engine_forkchoiceUpdated` call.
208+
209+
1. Client software **MUST** support `count` values of at least 32 blocks.
210+
211+
1. Client software **MUST** place `null` in the response array for unavailable blocks which numbers are lower than a number of the latest known block. Client software **MUST NOT** return trailing `null` values if the request extends past the current latest known block. Execution Layer client software is expected to download and carry the full block history until EIP-4444 or a similar proposal takes into effect. Consider the following response examples:
212+
* `[B1.body, B2.body, ..., Bn.body]` -- entire requested range is filled with block bodies,
213+
* `[null, null, B3.body, ..., Bn.body]` -- first two blocks are unavailable (either pruned or not yet downloaded),
214+
* `[null, null, ..., null]` -- requested range is behind the latest known block and all blocks are unavailable,
215+
* `[B1.body, B2.body, B3.body, B4.body]` -- `B4` is the latest known block and trailing `null` values are trimmed,
216+
* `[]` -- entire requested range is beyond the latest known block,
217+
* `[null, null, B3.body, B4.body]` -- first two blocks are unavailable, `B4` is the latest known block.
218+
219+
1. Client software **MUST** set `withdrawals` field to `null` for bodies of pre-Shanghai blocks.
220+
221+
1. This request maps to [`BeaconBlocksByRange`](https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/p2p-interface.md#beaconblocksbyrange) in the consensus layer `p2p` specification.
222+
223+
1. Callers must be careful to not confuse `start` with a slot number, instead mapping the slot to a block number. Callers must also be careful to request non-finalized blocks by hash in order to avoid race conditions around the current view of the canonical chain.
224+
225+
1. Callers must be careful to verify the hash of the received blocks when requesting non-finalized parts of the chain since the response is prone to being re-orged.

wordlist.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
apis
22
attributesv
3+
bodyv
4+
bodiesbyrangev
5+
bodiesbyhashv
36
bytecode
47
configurationv
58
crypto

0 commit comments

Comments
 (0)