Skip to content
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

Engine API: return error if forkchoice state is inconsistent #213

Merged
merged 5 commits into from
May 10, 2022

Conversation

mkalinin
Copy link
Collaborator

@mkalinin mkalinin commented Apr 29, 2022

There could be the case (likely if CL is buggy) when headBlock does exist while either finalizedBlock or safeBlock does not.

This PR proposes to have an explicit check in engine_forkchoiceUpdated processing flow and the corresponding error message in response to the call if forkchoiceState is found inconsistent.

Should be rebased with #211

Copy link
Contributor

@djrtwo djrtwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally fine with this but I suggest we consider defining it as an error if inconsistent rather than just "does not exist"

@@ -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** return `-32003: Invalid forkchoice state` error if the payload referenced by `forkchoiceState.headBlockHash` is `VALID` and a payload referenced by either `forkchoiceState.finalizedBlockHash` or `forkchoiceState.safeBlockHash` does not exist.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not exist? or is not in the chain defined by headBlockHash -- aka is inconsistent (which covers DNE as well)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EL will have to traverse the blockchain to check if safeBlock and finalizedBlock do belong to the same chain as a headBlock does. This kind of check is expensive to be run per each fcU call. I agree that proving existence doesn't necessarily prove the consistency (I would call it a weak consistency check), but it looks like a reasonable trade-off in this case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is actually expensive?
The existence check is cheap because they just maintain some sort of hash map for all blocks? But not for a given chain?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, I have overestimated EL implementation complexity. Most of EL clients are fine with full consistency check. I've made the corresponding adjustment to the spec. Also, I have swapped codes for payload attributes and forkchoice state inconsistency errors to make codes respect the order they appear in the spec.

@djrtwo djrtwo merged commit f6b1aa2 into ethereum:main May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants