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(mpt): Copy-on-hash #1001

Merged
merged 1 commit into from
Feb 5, 2025
Merged

feat(mpt): Copy-on-hash #1001

merged 1 commit into from
Feb 5, 2025

Conversation

clabby
Copy link
Collaborator

@clabby clabby commented Feb 4, 2025

Overview

Adjusts the MPT crate to copy-on-hash rather than hash-in-place when computing the root hash of the trie.

This is less efficient, but is needed for completing execution of Optimistic blocks in the interop proof. Doing this enables for us to not rely solely on the L2AccountProof hint for output root computation, which depends on the block the proof is fetched within being canonical.

Benchmarks

The slowdown isn't crazy significant, but more keccak256 operations may not be amazing for users running kona on zkVMs. Native wallclock benchmarks don't directly translate to prover cost, but do give a rough indication on the hit (Benchmark: "Compute root, fully open trie - 65,536 nodes"):

Screenshot 2025-02-04 at 5 54 11 PM

Asterisc

Interestingly, doesn't really affect asterisc cycle count nor wallclock time (but note, we only ran one block, not a range proof):

main (61ed1419) - ~4610000000 cycles.
cl/mpt/copy-when-sealing (37c8dae) - ~4630000000 cycles.

If we care about this hit, we can look into adding some additional caching that preserves the full cache of the trie in-memory, but prevents re-hashing nodes whose cache has not been invalidated by a write.

Meta

closes #981

@clabby clabby added A-mpt Area: kona-mpt crate H-interop Hardfork: Interop related K-feature Kind: feature labels Feb 4, 2025
@clabby
Copy link
Collaborator Author

clabby commented Feb 4, 2025

📚 $\text{Stack Overview}$

Pulls submitted in this stack:

This comment was automatically generated by st.

@clabby clabby self-assigned this Feb 4, 2025
Copy link

codecov bot commented Feb 4, 2025

Codecov Report

Attention: Patch coverage is 93.93939% with 2 lines in your changes missing coverage. Please review.

Project coverage is 89.1%. Comparing base (f0a7bfe) to head (456dd2e).
Report is 2 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/executor/src/db/mod.rs 85.7% 1 Missing ⚠️
crates/executor/src/executor/mod.rs 0.0% 1 Missing ⚠️
Additional details and impacted files

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@refcell
Copy link
Collaborator

refcell commented Feb 4, 2025

IMO this hit is not significant enough to be a blocker for the interop workstream.

@clabby clabby marked this pull request as ready for review February 4, 2025 23:18
@clabby clabby requested review from refcell and emhane as code owners February 4, 2025 23:18
@clabby
Copy link
Collaborator Author

clabby commented Feb 4, 2025

IMO this hit is not significant enough to be a blocker for the interop workstream.

Yeah, agree. @ratankaliani & @hashcashier, please report back in the issues if the additional cache is needed for your usecases.

@clabby clabby force-pushed the cl/mpt/copy-when-sealing branch from 37c8dae to 456dd2e Compare February 5, 2025 02:16
@clabby clabby merged commit 8934111 into main Feb 5, 2025
16 checks passed
@clabby clabby deleted the cl/mpt/copy-when-sealing branch February 5, 2025 20:11
This was referenced Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mpt Area: kona-mpt crate H-interop Hardfork: Interop related K-feature Kind: feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(mpt): Don't seal MPT in place by default
2 participants