From 47296c8af438765ead8c9a73974c13717d0eb575 Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Wed, 21 Oct 2026 10:46:01 +0200 Subject: [PATCH] Build the rollback delta while the merkle update runs Co-Authored-By: Claude Opus 5.5 (1M context) --- nomt/src/lib.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/nomt/src/lib.rs b/nomt/src/lib.rs index 1ef815c193..3f543f78ca 100644 --- a/nomt/src/lib.rs +++ b/nomt/src/lib.rs @@ -580,11 +580,6 @@ impl Session { ); } } - let rollback_delta = self - .rollback_delta - .take() - .map(|delta_builder| delta_builder.finalize(&actuals)); - let mut compact_actuals = Vec::with_capacity(actuals.len()); for (path, read_write) in &actuals { compact_actuals.push((path.clone(), read_write.to_compact::())); @@ -594,6 +589,13 @@ impl Session { .merkle_updater .update_and_prove::(compact_actuals, self.witness_mode.0)?; + // Built while the merkle update runs: both only read the store, which is not modified + // until the finished session is committed. + let rollback_delta = self + .rollback_delta + .take() + .map(|delta_builder| delta_builder.finalize(&actuals)); + let mut tx = self.store.new_value_tx(); for (path, read_write) in actuals { if let KeyReadWrite::Write(value) | KeyReadWrite::ReadThenWrite(_, value) = read_write {