Skip to content

Commit 37c8852

Browse files
committed
Engine API: remove payloadId computation, refine forkchoiceUpdated
1 parent 0875361 commit 37c8852

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

src/engine/specification.md

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This document specifies the Engine API methods that the Consensus Layer uses to
2525
- [Request](#request-1)
2626
- [Response](#response-1)
2727
- [Specification](#specification-1)
28+
- [Payload build process](#payload-build-process)
2829
- [engine_getPayloadV1](#engine_getpayloadv1)
2930
- [Request](#request-2)
3031
- [Response](#response-2)
@@ -164,9 +165,9 @@ This structure contains the attributes required to initiate a payload build proc
164165

165166
* result: `object`
166167
- `status`: `enum` - `"VALID" | "INVALID" | "SYNCING"`
167-
- `latestValidHash`: `DATA|null`, 32 bytes - the hash of the most recent *valid* block in the branch defined by payload and its ancestors
168+
- `latestValidHash`: `DATA|null`, 32 Bytes - the hash of the most recent *valid* block in the branch defined by payload and its ancestors
168169
- `message`: `STRING|null` - the message providing additional details on the response to the method call if needed
169-
* error: code and message set in case an exception happens during showing a message.
170+
* error: code and message set in case an exception happens while executing the payload.
170171

171172
#### Specification
172173

@@ -191,46 +192,39 @@ This structure contains the attributes required to initiate a payload build proc
191192

192193
#### Response
193194

194-
* result: `enum`, `"SUCCESS" | "SYNCING"`
195-
* error: code and message set in case an exception happens while updating the forkchoice or preparing the payload.
195+
* result: `object`
196+
- `status`: `enum` - `"SUCCESS" | "SYNCING"`
197+
- `payloadId`: `QUANTITY|null`, 64 Bits - identifier of the payload build process or `null`
198+
* error: code and message set in case an exception happens while updating the forkchoice or initiating the payload build process.
196199

197200
#### Specification
198201

199202
1. The values `(forkchoiceState.headBlockHash, forkchoiceState.finalizedBlockHash)` of this method call map on the `POS_FORKCHOICE_UPDATED` event of [EIP-3675](https://eips.ethereum.org/EIPS/eip-3675#specification) and **MUST** be processed according to the specification defined in the EIP.
200203

201-
2. All updates to the forkchoice resulting from this call **MUST** be made atomically.
202-
203-
3. Client software **MUST** return `SYNCING` status if the payload identified by either the `forkchoiceState.headBlockHash` or the `forkchoiceState.finalizedBlockHash` is unknown or if the sync process is in progress. In the event that either the `forkchoiceState.headBlockHash` or the `forkchoiceState.finalizedBlockHash` is unknown, the client software **SHOULD** initiate the sync process.
204+
2. All updates to the forkchoice state resulting from this call **MUST** be made atomically.
204205

205-
4. Client software **MUST** begin a payload build process building on top of `forkchoiceState.headBlockHash` if `payloadAttributes` is not `null` and the client is not `SYNCING`. The build process is specified as:
206-
* The payload build process **MUST** be identified via `payloadId` where `payloadId` is defined as the hash of the block-production inputs, see [Hashing to `payloadId`](#hashing-to-payloadid).
207-
* Client software **MUST** set the payload field values according to the set of parameters passed into this method with exception of the `feeRecipient`. The prepared `ExecutionPayload` **MAY** deviate the `coinbase` field value from what is specified by the `feeRecipient` parameter.
208-
* Client software **SHOULD** build the initial version of the payload which has an empty transaction set.
209-
* Client software **SHOULD** start the process of updating the payload. The strategy of this process is implementation dependent. The default strategy is to keep the transaction set up-to-date with the state of local mempool.
210-
* Client software **SHOULD** stop the updating process when either a call to `engine_getPayload` with the build process's `payloadId` is made or [`SECONDS_PER_SLOT`](https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#time-parameters-1) (currently set to 12 in the Mainnet configuration) seconds have passed since the point in time identified by the `timestamp` parameter.
206+
3. Client software **MUST** return `{status: SUCCESS, payloadId: null}` if `payloadAttributes` is `null` and the client is not `SYNCING`.
211207

212-
5. If any of the above fails due to errors unrelated to the client software's normal `SYNCING` status, the client software **MUST** return an error.
208+
4. Client software **MUST** return `{status: SYNCING, payloadId: null}` if the payload identified by either the `forkchoiceState.headBlockHash` or the `forkchoiceState.finalizedBlockHash` is unknown or if the sync process is in progress. In the event that either the `forkchoiceState.headBlockHash` or the `forkchoiceState.finalizedBlockHash` is unknown, the client software **SHOULD** initiate the sync process.
213209

214-
##### Hashing to `payloadId`
210+
5. Client software **MUST** return `{status: SUCCESS, payloadId: buildProcessId}` if `payloadAttributes` is not `null` and the client is not `SYNCING`, and begin a payload build process building on top of `forkchoiceState.headBlockHash` and identified via `buildProcessId` value. The build process is specified in the [Payload build process](#payload-build-process) section.
215211

216-
The `payloadId` is the `sha256` hash of the concatenation of version byte and inputs:
217-
```python
218-
PAYLOAD_ID_VERSION_BYTE = b"\x00"
219-
sha256(PAYLOAD_ID_VERSION_BYTE + headBlockHash + payloadAttributes.timestamp.to_bytes(8, "big") + payloadAttributes.random + payloadAttributes.feeRecipient)
220-
```
221-
Note that the timestamp is encoded as big-endian and padded fully to 8 bytes.
212+
6. If any of the above fails due to errors unrelated to the client software's normal `SYNCING` status, the client software **MUST** return an error.
222213

223-
This ID-computation is versioned and may change over time, opaque to the engine API user, and **MUST** always be consistent between `engine_forkchoiceUpdated` and `engine_getPayload`.
224-
The `PAYLOAD_ID_VERSION_BYTE` **SHOULD** be updated if the intent or typing of the payload production inputs changes,
225-
such that a payload cache can be safely shared between current and later versions of `engine_forkchoiceUpdated`.
214+
##### Payload build process
215+
The payload build process is specified as follows:
216+
* Client software **MUST** set the payload field values according to the set of parameters passed into this method with exception of the `feeRecipient`. The built `ExecutionPayload` **MAY** deviate the `coinbase` field value from what is specified by the `feeRecipient` parameter.
217+
* Client software **SHOULD** build the initial version of the payload which has an empty transaction set.
218+
* Client software **SHOULD** start the process of updating the payload. The strategy of this process is implementation dependent. The default strategy is to keep the transaction set up-to-date with the state of local mempool.
219+
* Client software **SHOULD** stop the updating process when either a call to `engine_getPayload` with the build process's `payloadId` is made or [`SECONDS_PER_SLOT`](https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#time-parameters-1) (currently set to 12 in the Mainnet configuration) seconds have passed since the point in time identified by the `timestamp` parameter.
226220

227221
### engine_getPayloadV1
228222

229223
#### Request
230224

231225
* method: `engine_getPayloadV1`
232226
* params:
233-
1. `payloadId`: `DATA`, 32 bytes - Identifier of the payload build process
227+
1. `payloadId`: `QUANTITY`, 64 Bits - Identifier of the payload build process
234228

235229
#### Response
236230

0 commit comments

Comments
 (0)