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

eip7685: Pass execution_requests_hash to is_valid_block_hash #3950

Closed
wants to merge 10 commits into from

Conversation

mkalinin
Copy link
Collaborator

@mkalinin mkalinin commented Sep 30, 2024

Replaces execution_requests with the execution_requests_hash in the call to is_valid_block_hash. The hash is computed as it is defined by EIP-7685.

This changes is the part of EL triggered requests redesign, the corresponding Engine API change is in ethereum/execution-apis#591

specs/electra/beacon-chain.md Show resolved Hide resolved
specs/electra/beacon-chain.md Outdated Show resolved Hide resolved
Copy link
Member

@ralexstokes ralexstokes left a comment

Choose a reason for hiding this comment

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

I'm wondering what value this brings the CL?

instead we could simply not apply this PR and leave the CL as-is

the CL then sends over the full ExecutionRequests over the Engine API and the EL can do whatever it wants from there, i.e. check conformance with the execution_requests_hash -- which it will have to do anyway AFAICT.

it seems like this PR is just an optimization to save some bytes across the Engine API and I'd rather prioritize keeping the spec code simple

specs/electra/beacon-chain.md Outdated Show resolved Hide resolved
Co-authored-by: Alex Stokes <r.alex.stokes@gmail.com>
@mkalinin
Copy link
Collaborator Author

mkalinin commented Oct 1, 2024

the CL then sends over the full ExecutionRequests over the Engine API and the EL can do whatever it wants from there, i.e. check conformance with the execution_requests_hash -- which it will have to do anyway AFAICT.

According to the new design EL’s responsibility is get requests byte sequences from system smart contracts, order them by the first byte ascending and then concatenated in order to compute requestsHash. So, the CL needs to at least encode requests and then send them encoded to the EL, i.e. send [deposit_bytes, withdrawal_bytes, consolidation_bytes] — from that concatenating and computing the hash is an optimisation which is quite straightforward to do. Then EL would just need to incorporate the hash into the blockHash validation process.

@mkalinin
Copy link
Collaborator Author

mkalinin commented Oct 1, 2024

Updated the PR to modify is_valid_block_hash and revert changes made to notify_new_payload

@ppopth
Copy link
Member

ppopth commented Oct 2, 2024

I quite agree with @ralexstokes that the benefit is very minimal.


# [Modified in Electra:EIP7685]
if not self.is_valid_block_hash(
execution_payload,
parent_beacon_block_root,
execution_requests_hash):
execution_requests_list):
Copy link
Member

Choose a reason for hiding this comment

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

I would still prefer to pass execution_requests here, and if anything handle the serialization step in the engine API, rather than the consensus specs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It’s not about serialization, the exact encoding is currently a part of the protocol and would have to be done even if there was other communication channel than engine API. Serialization of this array to JSON is happening in the engine API client

Copy link
Contributor

@lucassaldanha lucassaldanha left a comment

Choose a reason for hiding this comment

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

LGTM

@mkalinin mkalinin changed the title eip7685: Pass execution_requests_hash to notify_new_payload eip7685: Pass execution_requests to notify_new_payload Oct 4, 2024
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

@potuz
Copy link
Contributor

potuz commented Oct 7, 2024

Please change the description of the PR as it's not passing the hash (which is what we should do given that the theoretical limit, disregarding block gas limit, is over 1.5 MB of data)

@jtraglia jtraglia changed the title eip7685: Pass execution_requests to notify_new_payload eip7685: Pass execution_requests_hash to notify_new_payload Oct 7, 2024
@jtraglia
Copy link
Member

jtraglia commented Oct 7, 2024

@mkalinin I've reverted the commit which changed this to a list of bytes. During the testing call, we decided to pass the hash. This is originally how you had it.

Copy link
Member

@ralexstokes ralexstokes left a comment

Choose a reason for hiding this comment

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

I still stand by what I said above that I think this unnecessarily complicates the CL side of things for not much gain

That being said, assuming we fix the hash computation to reflect the latest EIP specification then I'm fine merging to unblock devnet-4

specs/electra/beacon-chain.md Outdated Show resolved Hide resolved
@jtraglia jtraglia changed the title eip7685: Pass execution_requests_hash to notify_new_payload eip7685: Pass execution_requests_hash to is_valid_block_hash Oct 8, 2024
@jtraglia jtraglia mentioned this pull request Oct 8, 2024
5 tasks
The computation algorithm is defined by [EIP-7685](https://eips.ethereum.org/EIPS/eip-7685).

```python
def compute_execution_requests_hash(execution_requests: ExecutionRequests) -> Hash32:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Alternatively we can do:

def compute_execution_requests_hash(execution_requests: ExecutionRequests) -> Hash32:
    request_list = [execution_requests.deposits, execution_requests.withdrawals, execution_requests.consolidations]
    hash_list = []
    for index, requests in enumerate(requests_list):
        request_type = uint_to_bytes(uint8(index))
        hash_list.append(hash(request_type + serialize(requests)))

    return hash(b''.join(hash_list))

This allows to get rid of explicit type bytes in the spec and easy to extend in the future by adding requests to the flat list used for commitment computation

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we wanted to get rid of these custom one-off hashing schemes that are just a mess to maintain over time?

@jtraglia
Copy link
Member

jtraglia commented Oct 8, 2024

Closing. We have reached a consensus to send the full requests.

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