Skip to content

feat: add stateless crate to expose stateless validation #15591

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

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

Conversation

kevaundray
Copy link
Contributor

@kevaundray kevaundray commented Apr 7, 2025

This PR adds a method to stateless verify a block, given the ExecutionWitness and ancestor headers.

@kevaundray kevaundray marked this pull request as ready for review April 11, 2025 19:23
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.

supportive,

some (pedantic) nits

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Reth Tracker Apr 12, 2025
Comment on lines +212 to +215
for rlp_encoded in &witness.codes {
let hash = keccak256(rlp_encoded);
bytecode.insert(hash, Bytecode::new_raw(rlp_encoded.clone()));
}
Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/paradigmxyz/reth/pull/15591/files#r2040307201

same can be said about the bytecodes. there is no validation that all the bytecodes have corresponding leaves in the witness

Comment on lines +229 to +232
Err(StatelessValidationError::PreStateRootMismatch {
got: computed_root,
expected: pre_state_root,
})
Copy link
Member

Choose a reason for hiding this comment

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

due to how reveal_witness works, i think this is a noop

@@ -0,0 +1,42 @@
[package]
Copy link
Member

Choose a reason for hiding this comment

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

you'd want to make this crate no-std compatible if it's intended to be run on risc v

Comment on lines +26 to +28
// TODO: use Vec instead -- ancestors should be contiguous
// TODO: so we can use the current_block_number and an offset to
// TODO: get the block number of a particular ancestor
Copy link
Member

Choose a reason for hiding this comment

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

would getting rid of extra key hashing matter to the prover?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it needs to be benchmarked first

trace!(target: "reth-stateless::evm", %address, %hashed_address, "retrieving account");
let Some(bytes) = self.trie.get_account_value(&hashed_address) else {
trace!(target: "reth-stateless::evm", %address, %hashed_address, "no account found");
return Ok(None)
Copy link
Member

Choose a reason for hiding this comment

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

here we should prove that the leaf is indeed not present in the trie. currently, this might lead to invalid execution due to partial witness

if let Some(value) = self.trie.get_storage_slot_value(&hashed_address, &hashed_slot) {
U256::decode(&mut value.as_slice())?
} else {
U256::ZERO
Copy link
Member

Choose a reason for hiding this comment

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

same here re non-existent leaf vs partial witness

@kevaundray kevaundray force-pushed the kw/stateless-experiment branch from b5871a1 to 5ed0fdf Compare April 16, 2025 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants