Skip to content

Commit

Permalink
Merge branch 'main' into mraszyk/upgrader-stable-memory-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
mraszyk committed Jan 13, 2025
2 parents 30afad1 + 00d9700 commit 8a11cf3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions core/station/impl/src/models/request_operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ pub enum SystemUpgradeTarget {
pub struct WasmModuleExtraChunks {
pub store_canister: Principal,
pub extra_chunks_key: String,
#[serde(with = "serde_bytes")]
pub wasm_module_hash: Vec<u8>,
}

Expand All @@ -390,15 +391,19 @@ pub struct WasmModuleExtraChunks {
pub struct SystemUpgradeOperationInput {
pub target: SystemUpgradeTarget,
/// The module is only available while the operation is not finalized.
#[serde(with = "serde_bytes")]
pub module: Vec<u8>,
pub module_extra_chunks: Option<WasmModuleExtraChunks>,
#[serde(deserialize_with = "orbit_essentials::deserialize::deserialize_option_blob")]
pub arg: Option<Vec<u8>>,
}

#[storable]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SystemUpgradeOperation {
#[serde(with = "serde_bytes")]
pub module_checksum: Vec<u8>,
#[serde(deserialize_with = "orbit_essentials::deserialize::deserialize_option_blob")]
pub arg_checksum: Option<Vec<u8>>,
pub input: SystemUpgradeOperationInput,
}
Expand Down Expand Up @@ -450,15 +455,19 @@ pub struct SetDisasterRecoveryOperationInput {
pub struct ChangeExternalCanisterOperationInput {
pub canister_id: Principal,
pub mode: CanisterInstallMode,
#[serde(with = "serde_bytes")]
pub module: Vec<u8>,
pub module_extra_chunks: Option<WasmModuleExtraChunks>,
#[serde(deserialize_with = "orbit_essentials::deserialize::deserialize_option_blob")]
pub arg: Option<Vec<u8>>,
}

#[storable]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct ChangeExternalCanisterOperation {
#[serde(with = "serde_bytes")]
pub module_checksum: Vec<u8>,
#[serde(deserialize_with = "orbit_essentials::deserialize::deserialize_option_blob")]
pub arg_checksum: Option<Vec<u8>>,
pub input: ChangeExternalCanisterOperationInput,
}
Expand Down Expand Up @@ -761,6 +770,7 @@ impl ModelValidator<ValidationError> for CanisterMethod {
pub struct CallExternalCanisterOperationInput {
pub validation_method: Option<CanisterMethod>,
pub execution_method: CanisterMethod,
#[serde(deserialize_with = "orbit_essentials::deserialize::deserialize_option_blob")]
pub arg: Option<Vec<u8>>,
pub execution_method_cycles: Option<u64>,
}
Expand All @@ -769,22 +779,26 @@ pub struct CallExternalCanisterOperationInput {
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CallExternalCanisterOperation {
pub input: CallExternalCanisterOperationInput,
#[serde(deserialize_with = "orbit_essentials::deserialize::deserialize_option_blob")]
pub arg_checksum: Option<Vec<u8>>,
pub arg_rendering: Option<String>,
#[serde(deserialize_with = "orbit_essentials::deserialize::deserialize_option_blob")]
pub execution_method_reply: Option<Vec<u8>>,
}

#[storable]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SnapshotExternalCanisterOperationInput {
pub canister_id: Principal,
#[serde(deserialize_with = "orbit_essentials::deserialize::deserialize_option_blob")]
pub replace_snapshot: Option<Vec<u8>>,
pub force: bool,
}

#[storable]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SnapshotExternalCanisterOperation {
#[serde(deserialize_with = "orbit_essentials::deserialize::deserialize_option_blob")]
pub snapshot_id: Option<Vec<u8>>,
pub input: SnapshotExternalCanisterOperationInput,
}
Expand All @@ -793,6 +807,7 @@ pub struct SnapshotExternalCanisterOperation {
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct RestoreExternalCanisterOperationInput {
pub canister_id: Principal,
#[serde(with = "serde_bytes")]
pub snapshot_id: Vec<u8>,
}

Expand All @@ -805,6 +820,7 @@ pub struct RestoreExternalCanisterOperation {
#[storable]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum PruneExternalCanisterResource {
#[serde(with = "serde_bytes")]
Snapshot(Vec<u8>),
ChunkStore,
State,
Expand Down
1 change: 1 addition & 0 deletions core/station/impl/src/models/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub struct SystemInfo {
/// The upgrader canister id that is allowed to upgrade this canister.
upgrader_canister_id: Option<Principal>,
/// The upgrader canister wasm module.
#[serde(deserialize_with = "orbit_essentials::deserialize::deserialize_option_blob")]
upgrader_wasm_module: Option<Vec<u8>>,
/// The disaster recovery committee user group id.
disaster_recovery_committee: Option<DisasterRecoveryCommittee>,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/src/upgrader_migration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ where
test_data_generator.test_api();

// Submit a few more large disaster recovery requests to test that
// stable memory can grow with the new layout.
// stable memory can grow with the latest stable memory layout.
let committee =
get_disaster_recovery_committee(&env, upgrader_id, canister_ids.station).unwrap();
for (i, user) in committee.users.into_iter().take(20).enumerate() {
Expand Down

0 comments on commit 8a11cf3

Please sign in to comment.