-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
base: main
Are you sure you want to change the base?
feat: don't include hashes of preimages in execution witness #14503
Conversation
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 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
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.
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()) |
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.
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?
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.
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!
crates/rpc/rpc/src/debug.rs
Outdated
@@ -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 }) |
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.
now we also have this extra clone, same here not sure if we want that. can it be avoided?
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.
good callout!
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