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: clarify payloadAttributes checks and fcu v3 processing flow #498

Merged
merged 2 commits into from
Dec 13, 2023

Conversation

mkalinin
Copy link
Collaborator

@mkalinin mkalinin commented Dec 1, 2023

This PR incorporates changes proposed by #476, #479 and results from the conversations happening in-person during the DevConnect and in the Discord after the event.

The list of proposed changes:

  1. Update fcu v1 spec to explicitly state that payloadAttributes validations and build process can only be run after forkchoiceState is processed and only if the head is VALID implying that if a client is SYNCING no payloadAttributes validations are run.
  2. State that forkchoiceState fields must be validated before any processing starts with the corresponding error on failure.
  3. Define a new sequence of payloadAttributes checks that must be run after applying the fork choice state.
    The first step of this sequence is to verify that payloadAttributes matches the expected fields and return -38003: Invalid payload attributes on failure. This step is what can cause additional engineering efforts on EL side. The problem here is that EL clients define PayloadAttributesV1 fields as required and if any of them is missed then the method will return with an error before processing the forkchoiceState, this behaviour would contradict the proposed change. cc @jflo @lightclient @MarekM25 @yperbasis

Hive test scenarios covering forkchoiceState and payloadAttributes checks should be validated when this PR gets merged. cc @marioevz

Supersedes #476 #479

src/engine/cancun.md Outdated Show resolved Hide resolved
Copy link
Member

@lightclient lightclient left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@jflo jflo left a comment

Choose a reason for hiding this comment

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

adding -38003 here helps a lot

Copy link
Contributor

@g11tech g11tech left a comment

Choose a reason for hiding this comment

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

lgtm

@marioevz
Copy link
Member

LGTM!

Just as a heads up, this change will result in adding hive tests where we send malformed payload attributes to syncing clients, which very likely will result in new failures. We will tag all EL devs on the hive PR that implements these tests.

@mkalinin
Copy link
Collaborator Author

mkalinin commented Dec 12, 2023

LGTM!

Just as a heads up, this change will result in adding hive tests where we send malformed payload attributes to syncing clients, which very likely will result in new failures. We will tag all EL devs on the hive PR that implements these tests.

@marioevz note that this change also includes the following statement to the fcU V1 that is inherently applicable to all further versions:

  1. Client software MUST process provided payloadAttributes after successfully applying the forkchoiceState and only if the payload referenced by forkchoiceState.headBlockHash is VALID. The processing flow is as follows:

One of the intentions of that statement is skipping payloadAttributes validation and processing if the response is supposed to be SYNCING. If that intention isn’t clear from the change then I think it should be clarified additionally.

@mkalinin mkalinin merged commit a0d0308 into ethereum:main Dec 13, 2023
3 checks passed
yperbasis added a commit to erigontech/erigon that referenced this pull request Dec 14, 2023

2. Extend point (7) of the `engine_forkchoiceUpdatedV1` [specification](./paris.md#specification-1) by defining the following sequence of checks that **MUST** be run over `payloadAttributes`:

1. `payloadAttributes` matches the [`PayloadAttributesV3`](#payloadattributesv3) structure, return `-38003: Invalid payload attributes` on failure.
Copy link
Contributor

@flcl42 flcl42 Mar 21, 2024

Choose a reason for hiding this comment

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

It's not clear how we extend point 7 of Paris fork. Might be better just to add this rules to Paris also in expected order

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

One of this rules is in Paris which is checking the timestamp wrt parent block’s timestamp. Other two are introduced in Cancun, so they aren’t relevant for Paris. The point (7) in Cancun has an extended list of checks wrt to Paris

Choose a reason for hiding this comment

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

I also had some confusion wrt to this. We have an engine api test:

ForkchoiceUpdatedV2 To Request Shanghai Payload, Non-Null Beacon Root

where we essentially fcuV2 before Cancun, with a Shanghai timestamp and a non null parentBeaconBlockRoot (incorrect Payload Attributes structure).

As we are before Cancun my assumption would be that the extended points to (7) are not yet applied. Most clients return -38003: Invalid payload attributes for this case. The addition to Paris only validates the Payload Attributes based on the timestamp. So to my understanding we don't explicitly state what to return in this case.

So I agree with @flcl42 that we could add the Payload Attributes structure check to Paris. Apologies if I am missing something here

Choose a reason for hiding this comment

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

Ahh, I just noticed that this check would be covered by: https://github.com/ethereum/execution-apis/blob/main/src/engine/shanghai.md#engine_forkchoiceupdatedv2. And the appropraite response should be -32602: Invalid params.

As most clients return -38003: Invalid payload attributes would it make sense to change it here. Similarly, I personally found this tricky to determine based on the current spec regarding the Payload Attributes structure check (but I could be the stupid odd one out).

I added a potential change for the latter here: main...spencer-tb:execution-apis:src/engine/payload-attributes-updates

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

why should the parent.timestamp check be removed from cancun?
Also, i am hesitant to change the previous versions of any methods in the spec unless the change is coherent with the behavior of the majority of EL clients

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do EL clients check payloadAttributes structure in case of V1? If we remove a check from V3 then it is not clear in which order they are applied which may result in the return error message to be different on the same payloadAttributes in different client implementations

Copy link

@spencer-tb spencer-tb Mar 28, 2024

Choose a reason for hiding this comment

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

why should the parent.timestamp check be removed from cancun?

My fault - it should be kept, I wasn't taking into consideration the order of the checks!

I'd like to double check our tests for the payloadAttributes structure in case of V1. Will get back to you :)

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.

9 participants