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

Execution API: execution requests serialization #14498

Closed
wants to merge 2 commits into from

Conversation

james-prysm
Copy link
Contributor

@james-prysm james-prysm commented Oct 2, 2024

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 in engine_getPayloadV4

prerequisite for #14492

Which issues(s) does this PR fix?

part of ethereum/consensus-specs#3818

Other notes for review

Acknowledgements

  • I have read CONTRIBUTING.md.
  • I have made an appropriate entry to CHANGELOG.md.
  • I have added a description to this PR with sufficient context for reviewers to understand this PR.

@james-prysm james-prysm added the Electra electra hardfork label Oct 2, 2024
@james-prysm james-prysm requested a review from a team as a code owner October 2, 2024 22:36
@james-prysm james-prysm requested review from potuz, rkapka and nisdas October 2, 2024 22:36
return er, nil
}

func verifyExecutionRequests(er *ExecutionRequests) error {
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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?

Copy link
Contributor

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 {
Copy link
Contributor

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 {
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Comment on lines +21 to +22
er := &ExecutionRequests{}
if err := processRequestBytes(eb.ExecutionRequests, er); err != nil {
Copy link
Contributor

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)
Copy link
Contributor

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) {
Copy link
Contributor

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

@potuz
Copy link
Contributor

potuz commented Oct 3, 2024

Closing this because of the spec changes @james-prysm feel free to reopen if you reuse the branch

@potuz potuz closed this Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Electra electra hardfork
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants