From 745860fa240c0ca00fdd5f44eca78b34d0da8d23 Mon Sep 17 00:00:00 2001 From: Mikhail Kalinin Date: Thu, 28 Apr 2022 12:53:32 +0400 Subject: [PATCH 1/2] Engine API: respond with error if payload attributes are invalid --- src/engine/specification.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/engine/specification.md b/src/engine/specification.md index 9476acfed..6fb3d08e5 100644 --- a/src/engine/specification.md +++ b/src/engine/specification.md @@ -109,6 +109,7 @@ The list of error codes introduced by this specification can be found below. | -32603 | Internal error | Internal JSON-RPC error. | | -32000 | Server error | Generic client error while processing request. | | -32001 | Unknown payload | Payload does not exist / is not available. | +| -32002 | Invalid payload attributes | Payload attributes are invalid / inconsistent. | Each error returns a `null` `data` value, except `-32000` which returns the `data` object with a `err` member that explains the error encountered. @@ -301,16 +302,19 @@ The payload build process is specified as follows: * 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#block-validity) and **MUST** be processed according to the specification defined in the EIP * All updates to the forkchoice state resulting from this call **MUST** be made atomically. -6. Client software **MUST** begin a payload build process building on top of `forkchoiceState.headBlockHash` and identified via `buildProcessId` value if `payloadAttributes` is not `null` and the forkchoice state has been updated successfully. The build process is specified in the [Payload building](#payload-building) section. +6. Client software **MUST** ensure that `payloadAttributes.timestamp` is greater than `timestamp` of a block referenced by `forkchoiceState.headBlockHash`. If this condition isn't held client software **MUST** respond with `-32002: Invalid payload attributes` and **MUST NOT** begin a payload build process. In such an event, the `forkchoiceState` update **MUST NOT** be rolled back. -7. Client software **MUST** respond to this method call in the following way: +7. Client software **MUST** begin a payload build process building on top of `forkchoiceState.headBlockHash` and identified via `buildProcessId` value if `payloadAttributes` is not `null` and the forkchoice state has been updated successfully. The build process is specified in the [Payload building](#payload-building) section. + +8. Client software **MUST** respond to this method call in the following way: * `{payloadStatus: {status: SYNCING, latestValidHash: null, validationError: null}, payloadId: null}` if `forkchoiceState.headBlockHash` references an unknown payload or a payload that can't be validated because requisite data for the validation is missing * `{payloadStatus: {status: INVALID, latestValidHash: validHash, validationError: errorMessage | null}, payloadId: null}` obtained from the [Payload validation](#payload-validation) process if the payload is deemed `INVALID` * `{payloadStatus: {status: INVALID_TERMINAL_BLOCK, latestValidHash: null, validationError: errorMessage | null}, payloadId: null}` obtained either from the [Payload validation](#payload-validation) process or as a result of validating a PoW block referenced by `forkchoiceState.headBlockHash` * `{payloadStatus: {status: VALID, latestValidHash: forkchoiceState.headBlockHash, validationError: null}, payloadId: null}` if the payload is deemed `VALID` and a build process hasn't been started - * `{payloadStatus: {status: VALID, latestValidHash: forkchoiceState.headBlockHash, validationError: null}, payloadId: buildProcessId}` if the payload is deemed `VALID` and the build process has begun. + * `{payloadStatus: {status: VALID, latestValidHash: forkchoiceState.headBlockHash, validationError: null}, payloadId: buildProcessId}` if the payload is deemed `VALID` and the build process has begun + * `{error: {code: -32002, message: "Invalid payload attributes"}}` if the payload is deemed `VALID` and `forkchoiceState` has been applied successfully, but no build process has been started due to invalid `payloadAttributes`. -8. If any of the above fails due to errors unrelated to the normal processing flow of the method, client software **MUST** respond with an error object. +9. If any of the above fails due to errors unrelated to the normal processing flow of the method, client software **MUST** respond with an error object. ### engine_getPayloadV1 From 1e545638c0f58c925323f0defdff10744ace3e13 Mon Sep 17 00:00:00 2001 From: Mikhail Kalinin Date: Tue, 3 May 2022 12:00:48 +0400 Subject: [PATCH 2/2] Adjust error code with JSON-RPC spec --- src/engine/specification.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/specification.md b/src/engine/specification.md index 6fb3d08e5..f730a8de6 100644 --- a/src/engine/specification.md +++ b/src/engine/specification.md @@ -109,7 +109,7 @@ The list of error codes introduced by this specification can be found below. | -32603 | Internal error | Internal JSON-RPC error. | | -32000 | Server error | Generic client error while processing request. | | -32001 | Unknown payload | Payload does not exist / is not available. | -| -32002 | Invalid payload attributes | Payload attributes are invalid / inconsistent. | +| -31002 | Invalid payload attributes | Payload attributes are invalid / inconsistent. | Each error returns a `null` `data` value, except `-32000` which returns the `data` object with a `err` member that explains the error encountered. @@ -302,7 +302,7 @@ The payload build process is specified as follows: * 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#block-validity) and **MUST** be processed according to the specification defined in the EIP * All updates to the forkchoice state resulting from this call **MUST** be made atomically. -6. Client software **MUST** ensure that `payloadAttributes.timestamp` is greater than `timestamp` of a block referenced by `forkchoiceState.headBlockHash`. If this condition isn't held client software **MUST** respond with `-32002: Invalid payload attributes` and **MUST NOT** begin a payload build process. In such an event, the `forkchoiceState` update **MUST NOT** be rolled back. +6. Client software **MUST** ensure that `payloadAttributes.timestamp` is greater than `timestamp` of a block referenced by `forkchoiceState.headBlockHash`. If this condition isn't held client software **MUST** respond with `-31002: Invalid payload attributes` and **MUST NOT** begin a payload build process. In such an event, the `forkchoiceState` update **MUST NOT** be rolled back. 7. Client software **MUST** begin a payload build process building on top of `forkchoiceState.headBlockHash` and identified via `buildProcessId` value if `payloadAttributes` is not `null` and the forkchoice state has been updated successfully. The build process is specified in the [Payload building](#payload-building) section. @@ -312,7 +312,7 @@ The payload build process is specified as follows: * `{payloadStatus: {status: INVALID_TERMINAL_BLOCK, latestValidHash: null, validationError: errorMessage | null}, payloadId: null}` obtained either from the [Payload validation](#payload-validation) process or as a result of validating a PoW block referenced by `forkchoiceState.headBlockHash` * `{payloadStatus: {status: VALID, latestValidHash: forkchoiceState.headBlockHash, validationError: null}, payloadId: null}` if the payload is deemed `VALID` and a build process hasn't been started * `{payloadStatus: {status: VALID, latestValidHash: forkchoiceState.headBlockHash, validationError: null}, payloadId: buildProcessId}` if the payload is deemed `VALID` and the build process has begun - * `{error: {code: -32002, message: "Invalid payload attributes"}}` if the payload is deemed `VALID` and `forkchoiceState` has been applied successfully, but no build process has been started due to invalid `payloadAttributes`. + * `{error: {code: -31002, message: "Invalid payload attributes"}}` if the payload is deemed `VALID` and `forkchoiceState` has been applied successfully, but no build process has been started due to invalid `payloadAttributes`. 9. If any of the above fails due to errors unrelated to the normal processing flow of the method, client software **MUST** respond with an error object.