Skip to content

Commit

Permalink
Merge pull request #2552 from dusk-network/issue-2551
Browse files Browse the repository at this point in the history
Suppress finalisation of a previous commit for loaded states
  • Loading branch information
miloszm authored Oct 1, 2024
2 parents 80db857 + a8fb04c commit 74e91ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions rusk-recovery/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down
10 changes: 8 additions & 2 deletions rusk-recovery/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}?;

Expand All @@ -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)?;
Expand Down

0 comments on commit 74e91ca

Please sign in to comment.