Skip to content

Support multiple stateless trie implementations#10

Merged
mattsse merged 7 commits into
paradigmxyz:mainfrom
jsign:jsign/new-stateless-trie
Mar 3, 2026
Merged

Support multiple stateless trie implementations#10
mattsse merged 7 commits into
paradigmxyz:mainfrom
jsign:jsign/new-stateless-trie

Conversation

@jsign
Copy link
Copy Markdown
Contributor

@jsign jsign commented Feb 18, 2026

This PR generalizes trie support for stateless validation by separating trie implementations into a dedicated crate and adding a second implementation backed by zeth-mpt.

  • Extracted trie abstractions from stateless into new crates/tries:
    • moved existing sparse trie to tries::default::StatelessSparseTrie
    • moved trie/db error types into tries
  • Added new tries::zeth::SparseState implementation backed by vendored crates/zeth-mpt
  • Updated stateless and ef-tests to consume trie implementations from tries
  • Updated EF test selection to support both tries:
    • scripts/run_ef_tests.sh now requires an explicit arg: default|zeth
    • EF tests read EF_TEST_TRIE and dispatch to the selected trie
  • Updated CI to run EF tests in parallel for both triesor`
  • Default behavior remains the existing reth sparse trie path (tries::default).

I didn't want to touch much the zeth-mpt implementation -- but I think we might want to iterate on it further to remove some panic cases or similars. Kept the Reth trie still be the default one.

Close #9

Comment thread .github/workflows/ci.yml
run: cargo clippy --workspace --all-targets --all-features -- -D warnings

ef-tests:
name: Ethereum Foundation tests
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Run CI for both tries (or more in the future if supported).
Mechanism is basically passing a mandatory arg to ruf_ef_tests.sh which will proxy through env var for test runner.

It is mostly plumbing since stateless_validation already has support for generic trie via generics.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Mainly renamed & moved file, and move StatelessTrie in lib.rs of new crate.

Comment thread crates/tries/src/zeth.rs
@@ -0,0 +1,220 @@
//! Provides a zeth-backed sparse MPT implementation for the stateless validator guest program.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@@ -0,0 +1,195 @@
// Copyright 2025 RISC Zero, Inc.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

path::{Path, PathBuf},
sync::Arc,
};
use tries::{StatelessTrie, default::StatelessSparseTrie, zeth::SparseState};
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here until end is mainly the mentioned plumbing for testing with different tries.

Comment thread crates/zeth-mpt/Cargo.toml Outdated
workspace = true

[dependencies]
alloy-trie = { version = "0.8.0", default-features = false }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Important note: zeth trie depends on 0.8.0. We can't use workspace 0.9.0 since this version removed a critical feature that this other trie relies on.

Signed-off-by: jsign <jsign.uy@gmail.com>
@jsign jsign marked this pull request as ready for review February 18, 2026 19:42
@mattsse mattsse merged commit ed189a5 into paradigmxyz:main Mar 3, 2026
4 checks passed
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.

Migrate efficient MPT implementation into this repo

2 participants