From a8fb04c94e56ded27fbcbb6935875e4965d53819 Mon Sep 17 00:00:00 2001 From: Milosz Muszynski Date: Tue, 1 Oct 2024 17:40:25 +0200 Subject: [PATCH] rusk-recovery: suppress finalisation of a previous commit for loaded state --- rusk-recovery/CHANGELOG.md | 2 ++ rusk-recovery/src/state.rs | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/rusk-recovery/CHANGELOG.md b/rusk-recovery/CHANGELOG.md index c851220b63..502b8644f9 100644 --- a/rusk-recovery/CHANGELOG.md +++ b/rusk-recovery/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Suppress finalisation of a previous commit for loaded states [#2551] - Ported to Piecrust 0.25.0 [#2536] - Removed 'phoenix-core' dependency [#1139] - Added closure argument to the 'deploy' method [#1630] @@ -21,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.6.0] - 2023-12-14 +[#2551]: https://github.com/dusk-network/rusk/issues/2551 [#2536]: https://github.com/dusk-network/rusk/issues/2536 [#1675]: https://github.com/dusk-network/rusk/issues/1675 [#1630]: https://github.com/dusk-network/rusk/issues/1630 diff --git a/rusk-recovery/src/state.rs b/rusk-recovery/src/state.rs index ad589136fd..b65f064f77 100644 --- a/rusk-recovery/src/state.rs +++ b/rusk-recovery/src/state.rs @@ -274,8 +274,12 @@ where let state_dir = state_dir.as_ref(); let state_id_path = rusk_profile::to_rusk_state_id_path(state_dir); + let mut loaded = false; let (vm, old_commit_id) = match snapshot.base_state() { - Some(state) => load_state(state_dir, state), + Some(state) => { + loaded = true; + load_state(state_dir, state) + } None => generate_empty_state(state_dir, snapshot), }?; @@ -296,7 +300,9 @@ where fs::write(state_id_path, commit_id)?; if old_commit_id != commit_id { - vm.finalize_commit(old_commit_id)?; + if !loaded { + vm.finalize_commit(old_commit_id)?; + } vm.delete_commit(old_commit_id)?; } vm.finalize_commit(commit_id)?;