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

Unify Engine API failure responses #5154

Merged
merged 4 commits into from
Jan 18, 2023
Merged

Conversation

rubo
Copy link
Contributor

@rubo rubo commented Jan 17, 2023

Changes

Implemented ethereum/execution-apis#337 that unifies Engine API failure responses.

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a fix or a feature that would cause existing functionality not to work as expected)
  • Documentation update
  • Code style update (formatting, renaming)
  • Refactoring (no functional or API changes)
  • Build-related changes
  • Other: description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

Notes on testing

Withdrawals Hive tests passing.

@rubo rubo marked this pull request as ready for review January 17, 2023 13:11
@rubo rubo requested a review from MarekM25 January 17, 2023 13:11
Copy link
Member

@LukaszRozmej LukaszRozmej left a comment

Choose a reason for hiding this comment

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

Maybe we should do class hierarchy for ExecutionPayload?
Or at least a clear way of validating them, for example, extension methods like: IsValidV1, IsValidV2 or GetVersion.

@rubo
Copy link
Contributor Author

rubo commented Jan 17, 2023

Maybe we should do class hierarchy for ExecutionPayload?
Or at least a clear way of validating them, for example, extension methods like: IsValidV1, IsValidV2 or GetVersion.

That was exactly the way I went initially but it turned out to be a longer and more complicated approach. Class hierarchy won't work in this case either. The only way to distinguish versions, for now, is to check whether the Withdrawals property is null based on the timestamp and block number combination.
Given this check is only needed at the very beginning of this particular method, moving it to an extension method doesn't bring any value here. If we're going to reuse it somewhere else as well, then it would make sense, indeed.

Also, because this check is an input parameter validation, I'd like to have it before any other checks for FCU as well. However, the timestamp and block number logic are a bit complicated there, so I left it there.

Things may change with future version checks though.

@LukaszRozmej
Copy link
Member

Maybe we should do class hierarchy for ExecutionPayload?
Or at least a clear way of validating them, for example, extension methods like: IsValidV1, IsValidV2 or GetVersion.

That was exactly the way I went initially but it turned out to be a longer and more complicated approach. Class hierarchy won't work in this case either. The only way to distinguish versions, for now, is to check whether the Withdrawals property is null based on the timestamp and block number combination. Given this check is only needed at the very beginning of this particular method, moving it to an extension method doesn't bring any value here. If we're going to reuse it somewhere else as well, then it would make sense, indeed.

Also, because this check is an input parameter validation, I'd like to have it before any other checks for FCU as well. However, the timestamp and block number logic are a bit complicated there, so I left it there.

Things may change with future version checks though.

My whole point is on semantics and readability lets name it V1/V2 and make validation based on that. Will be easier to read and translate from specs, let me try to provide example

@rubo
Copy link
Contributor Author

rubo commented Jan 17, 2023

My whole point is on semantics and readability lets name it V1/V2 and make validation based on that. Will be easier to read and translate from specs, let me try to provide example

If we go with versions, then we will have engine_newPayloadV2(ExecutionPayloadV2). So, the JSON always will deserialize to V2. Then we need to check whether this V2 is really a V2 or a V1 based on timestamp and withdrawals presence. Thus, no difference.

@LukaszRozmej
Copy link
Member

created versioning PR: #5157

#5157)

* Simple versioning and simplified transparent message version validation

* remove redundant code

* fix

* fix v2

* fix searching for ReleaseSpec, prioritizing TImeStamp if not null

* More refactors

* revert change in ForkInfo

* revert changes

* fix

* Refactor

* Add comment
@rubo rubo marked this pull request as draft January 18, 2023 12:57
@rubo rubo force-pushed the feature/shanghai-engine-failure-unify branch from 18abe19 to f2b5bae Compare January 18, 2023 15:20
@rubo rubo marked this pull request as ready for review January 18, 2023 16:54
@rubo rubo merged commit 0508516 into master Jan 18, 2023
@rubo rubo deleted the feature/shanghai-engine-failure-unify branch January 18, 2023 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants