-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Execution API: execution requests serialization #14498
Conversation
return er, nil | ||
} | ||
|
||
func verifyExecutionRequests(er *ExecutionRequests) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did I miss any verifications?
// GetDecodedExecutionRequests decodes the byte array in ExecutionBundleElectra and returns a ExecutionRequests container object | ||
// based on specifications from EIP-7685 | ||
func (eb *ExecutionBundleElectra) GetDecodedExecutionRequests() (*ExecutionRequests, error) { | ||
if len(eb.ExecutionRequests) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this error out or return empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be the empty requests, we need to guarantee that the slice is not nil before though.
// GetDecodedExecutionRequests decodes the byte array in ExecutionBundleElectra and returns a ExecutionRequests container object | ||
// based on specifications from EIP-7685 | ||
func (eb *ExecutionBundleElectra) GetDecodedExecutionRequests() (*ExecutionRequests, error) { | ||
if len(eb.ExecutionRequests) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be the empty requests, we need to guarantee that the slice is not nil before though.
if uint64(len(er.Deposits)) > params.BeaconConfig().MaxDepositRequestsPerPayload { | ||
return fmt.Errorf("too many deposits requested: received %d, expected %d", len(er.Deposits), params.BeaconConfig().MaxDepositRequestsPerPayload) | ||
} | ||
if uint64(len(er.Withdrawals)) > params.BeaconConfig().MaxWithdrawalsPerPayload { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be withdrawals requests per payload, not withdrawals
return fmt.Errorf("too many deposits requested: received %d, expected %d", len(er.Deposits), params.BeaconConfig().MaxDepositRequestsPerPayload) | ||
} | ||
if uint64(len(er.Withdrawals)) > params.BeaconConfig().MaxWithdrawalsPerPayload { | ||
return fmt.Errorf("too many withdrawals requested: received %d, expected %d", len(er.Withdrawals), params.BeaconConfig().MaxWithdrawalRequestsPerPayload) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
er := &ExecutionRequests{} | ||
if err := processRequestBytes(eb.ExecutionRequests, er); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you are passing an empty request container here anyway, why not use the signature
func processRequestBytes([]byte); (*ExecutionRequests, error)
} | ||
|
||
// Recursive call with the remaining bytes | ||
return processRequestBytes(remainingBytes, requests) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a loop instead of a recursive algorithm is better here, the tail recursion elimination in this case is simple.
} | ||
|
||
// EncodeExecutionRequests is a helper function that takes a ExecutionRequests container and converts it into a hash used for `engine_NewPayloadV4` | ||
func EncodeExecutionRequests(eb *ExecutionRequests) (common.Hash, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pending questions here on whether ordering would matter to the EL. cc @fjl
Closing this because of the spec changes @james-prysm feel free to reopen if you reuse the branch |
What type of PR is this?
Other
What does this PR do? Why is it needed?
implements the serialization of common hash for use in
engine_NewPayloadV4
as well as decoding of the byte array inengine_getPayloadV4
prerequisite for #14492
Which issues(s) does this PR fix?
part of ethereum/consensus-specs#3818
Other notes for review
Acknowledgements