Skip to content

Commit

Permalink
check stable memory state
Browse files Browse the repository at this point in the history
  • Loading branch information
keplervital committed Sep 30, 2024
1 parent 129033b commit 901bf6f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions core/station/impl/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ impl MigrationHandler {
let stored_version = system_info.get_stable_memory_version();

if stored_version == STABLE_MEMORY_VERSION {
// Run the post-run checks that need to be run on every upgrade.
post_run();
return;
}

Expand All @@ -61,9 +63,23 @@ impl MigrationHandler {
// Update the stable memory version to the latest version.
system_info.set_stable_memory_version(STABLE_MEMORY_VERSION);
write_system_info(system_info);

// Run the post-run checks that need to be run on every upgrade.
post_run();
}
}

/// If there is a check that needs to be run on every upgrade, regardless if the memory version has changed,
/// it should be added here.
fn post_run() {
// Deserialization of the all requests to make sure an incompatible memory will panic and avoids
// putting the station in an inconsistent state.
//
// This is a temporary addition only for the next release since we've added a breaking change to
// the `ConfigureExternalCanisterSettingsInput` which was a new API not yet used in production.
REQUEST_REPOSITORY.rebuild();
}

/// The migration to apply to the station canister stable memory.
///
/// Please include the migration steps in the `apply_migration` function.
Expand Down

0 comments on commit 901bf6f

Please sign in to comment.