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 {