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

hive: engine-cancun: fix return error code and bit of refactoring #9307

Closed
wants to merge 1 commit into from

Conversation

racytech
Copy link
Contributor

@racytech racytech commented Jan 25, 2024

In general it is a bad practice to keep 2 or more separate code parts that do the same thing. So in this PR I removed errors in engine_helpers and created a function in rpc that creates an error based on error code. Additionally I am thinking to remove all errors in rpc.errors except methodNotFoundError and subscriptionNotFoundError since they seem to have constant return message.

@racytech racytech marked this pull request as ready for review January 25, 2024 00:59
if version >= clparams.DenebVersion && payloadAttributes.ParentBeaconBlockRoot == nil {
return nil, &engine_helpers.InvalidPayloadAttributesErr // Beacon Root missing
if version >= clparams.DenebVersion && payloadAttributes.ParentBeaconBlockRoot == nil { // Beacon Root missing
return nil, &rpc.InvalidParamsError{Message: "Beacon Root missing"}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is returning -32602? I think this should still be -38003 with the message

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

As per https://github.com/ethereum/execution-apis/blob/main/src/engine/cancun.md#specification-1 if the payloadAttributes structure has issues it should return -38003. Maybe we need to check with Hive team

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, I also had this in my mind.

Copy link
Contributor Author

@racytech racytech Jan 25, 2024

Choose a reason for hiding this comment

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

Or there might be a place we did not implemented yet or something?

Copy link
Member

Choose a reason for hiding this comment

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

I think the Hive tests need to be updated. See #8982 & ethereum/execution-apis#498

TOO_LARGE_REQUEST = -38004
UNSUPPORTED_FORK_ERROR = -38005
)

Copy link
Contributor

Choose a reason for hiding this comment

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

The engine API specific errors are meant for CL <> EL API-play. I think this should be kept with other engineapi code

Copy link
Contributor Author

@racytech racytech Jan 25, 2024

Choose a reason for hiding this comment

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

Right, but I am just not a fan of code duplicating thing. It just doesn't lead to a good... but let's not merge this for now

Copy link
Contributor

Choose a reason for hiding this comment

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

I see it as compartmentalization not duplicating

Copy link
Contributor Author

@racytech racytech Jan 25, 2024

Choose a reason for hiding this comment

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

I think you are partially right, I understand what you mean, but I think it's batter to keep error related thing in one place, it's just how I would do it. You can call it design choice :). Anyway this is not a huge performance boost, so we can leave it as is

Copy link
Contributor

Choose a reason for hiding this comment

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

These aren't errors per se, but certain specific return values - the way it woks with engine api. rpc encompasses a lot more

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see them as error codes. If any error code in the future will change you will have to go all over the code to change them manually instead of changing a value in a single place. It probably makes sense to extract errors from rpc as well in the future in case we will do major refactoring, but not now. we are leaving it as is, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

One way to go about it, yes. Maybe calling upon @yperbasis to settle the tie

@racytech racytech closed this Jan 25, 2024
@VBulikov VBulikov mentioned this pull request Feb 5, 2025
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.

4 participants