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

feat: don't include hashes of preimages in execution witness #14503

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

meyer9
Copy link
Contributor

@meyer9 meyer9 commented Feb 14, 2025

Switch execution witness to return vectors instead of hashes. There's no reason to include the hash of the preimage in the response, potentially allowing callers to trust the EL client unnecessarily. No other clients implement this RPC and the only usage currently is in optimism and kona. I'll update these usages once this is merged.

Request from geth team here: ethereum/go-ethereum#30613 (comment)

Once this is complete, I can start implementing debug_executePayload method in geth and execution-apis.

Edit: this is blocked by #14503

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

I believe we can't guarantee a specific ordering here

but maybe this is okay, wdyt @rkrasiuk

do we want to change the provider fns as well or should those keep returning maps

@meyer9 meyer9 marked this pull request as ready for review February 14, 2025 19:51
@emhane emhane added the A-rpc Related to the RPC implementation label Feb 16, 2025
Copy link
Member

@emhane emhane left a comment

Choose a reason for hiding this comment

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

usually it's best practice to ket the caller do any cloning

fn witness(&self, input: TrieInput, target: HashedPostState) -> ProviderResult<Vec<Bytes>> {
TrieWitness::overlay_witness(self.tx(), input, target)
.map_err(ProviderError::from)
.map(|hm| hm.values().cloned().collect())
Copy link
Member

Choose a reason for hiding this comment

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

now we have an extra clone here, not sure that's desired due to perf impact. additionally, usually its best practice to let the caller do the cloning instead of hiding costly ops under the hood (can also be written in docs though that this method clones). is it possible instead to return an iterator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

its best practice to let the caller do the cloning instead of hiding costly ops under the hood

Good callout and good to know for future reference! I tried returning a Box<dyn Iterator<Item = Bytes>>, but there's a macro called delegate_impls_to_as_ref which doesn't correctly handle iterator lifetimes, so I wasn't able to return an iterator here. Other functions in this trait return vecs like proof and multiproof, so I think it's OK for now, although I'd be interested to learn how this can be implemented more efficiently.

Let me know if you have any suggestions on how to make this work!

@@ -655,7 +655,7 @@ where
let state = state_provider
.witness(Default::default(), hashed_state)
.map_err(EthApiError::from)?;
Ok(ExecutionWitness { state: state.into_iter().collect(), codes, keys })
Ok(ExecutionWitness { state: state.clone(), codes, keys })
Copy link
Member

Choose a reason for hiding this comment

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

now we also have this extra clone, same here not sure if we want that. can it be avoided?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good callout!

@mattsse mattsse added this to the release 1.2.1 milestone Feb 17, 2025
@mattsse mattsse added the S-blocked This cannot more forward until something else changes label Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Related to the RPC implementation S-blocked This cannot more forward until something else changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants