Skip to content

[on hold] Fix: NOMT verifier state root divergence#2739

Draft
citizen-stig wants to merge 17 commits intodevfrom
nikolai/nomt-verifier-state-root-divergence
Draft

[on hold] Fix: NOMT verifier state root divergence#2739
citizen-stig wants to merge 17 commits intodevfrom
nikolai/nomt-verifier-state-root-divergence

Conversation

@citizen-stig
Copy link
Copy Markdown
Member

@citizen-stig citizen-stig commented Apr 15, 2026

Description

Nomt::MultiProof produced different root hash in certain conditions.
NOMT PR with tests; thrumdev/nomt#931

This PR implements workaround by manually using Vec<PathProof> instead

  • I have updated CHANGELOG.md with a new entry if my PR makes any breaking changes or fixes a bug. If my PR removes a feature or changes its behavior, I provide help for users on how to migrate to the new behavior.
  • I have carefully reviewed all my Cargo.toml changes before opening the PRs. (Are all new dependencies necessary? Is any module dependency leaked into the full-node (hint: it shouldn't)?)

Linked Issues

Testing

New tests are added

Docs

No updates

bkolad and others added 8 commits April 14, 2026 13:42
TestCase::routing_bug_minimal reproduces the per-path routing bug fixed
by commits 1e0fefd, 306a31b, 5577902 in NomtVerifierStorage. It is
a two-round TestCase with two kernel writes per round (and zero user
writes), bisected from captured StateAccesses of the slow
demo-rollup test_mock_proof_public_data_matches_witnesses down to the
minimal input that still makes the pre-fix verifier's
verify_multi_proof_update diverge from session.finish().root().

Other additions:
- Four additional multi-write/multi-round TestCases for general coverage
  (multi_write_distinct_keys, multi_write_both_namespaces_distinct,
  mixed_reads_and_multi_writes, multi_round_multi_write). They don't
  trigger the routing bug on their own, but exercise code paths the
  single-write cases didn't.
- serde::Serialize / serde::Deserialize derives on StateAccesses and
  OrderedReadsAndWrites in sov-state::cache, gated behind the
  test-utils feature.
- dump_state_accesses_if_enabled in NomtProverStorage (gated behind
  test-utils + the SOV_DUMP_STATE_ACCESSES=<dir> env var) for capturing
  real STF state accesses as JSON. This is how routing_bug_minimal was
  derived.
- serde_json added as optional test-utils-only dep on sov-state.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Restores zk_storage.rs and prover_storage.rs to their origin/dev state,
undoing the aggregated effect of the three fix commits on these two
files. Other changes from those commits (outside these two files) are
not present in this branch's ancestry anyway.

The dump_state_accesses_if_enabled helper added in the previous commit
lived in prover_storage.rs and is wiped by this revert; that is
acceptable for this branch because the captures it produced are already
inlined into TestCase::routing_bug_minimal.

After this commit, running
  cargo nextest run -p sov-modules-api state_tests::compute_state_update
is expected to FAIL: test_roundtrip_nomt panics with a StorageRoot
mismatch on the kernel half of routing_bug_minimal, demonstrating the
per-path routing divergence between NomtProverStorage (NOMT
session.finish) and NomtVerifierStorage (verify_multi_proof_update on a
flat update list).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@citizen-stig citizen-stig changed the title Fix: NOMT verifier state root divergence [on hold] Fix: NOMT verifier state root divergence Apr 15, 2026
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

Comment thread crates/module-system/sov-state/src/nomt/zk_storage.rs Outdated
Comment thread crates/module-system/sov-state/src/nomt/zk_storage.rs Outdated
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.

2 participants