From 57c62e89c8e8a78e44dee43cda99f239438c32e3 Mon Sep 17 00:00:00 2001 From: Rachit2323 Date: Sun, 16 Aug 2026 23:08:50 +0530 Subject: [PATCH 1/3] fix(sns-wasm): actually overwrite existing SNS-specific upgrade path entries --- rs/nns/sns-wasm/src/sns_wasm.rs | 44 ++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/rs/nns/sns-wasm/src/sns_wasm.rs b/rs/nns/sns-wasm/src/sns_wasm.rs index f5a021a3b546..5bc74084a09f 100644 --- a/rs/nns/sns-wasm/src/sns_wasm.rs +++ b/rs/nns/sns-wasm/src/sns_wasm.rs @@ -1940,7 +1940,7 @@ impl UpgradePath { .or_default() .entry(from) { - Entry::Occupied(occupied) => { + Entry::Occupied(mut occupied) => { println!( "Special Entry for {} from {:?} to {:?} is being overwritten with new value {:?}", sns_governance_canister_id, @@ -1948,6 +1948,7 @@ impl UpgradePath { occupied.get(), to ); + occupied.insert(to); } Entry::Vacant(vacant) => { vacant.insert(to); @@ -5646,4 +5647,45 @@ mod test { ); } } + + #[test] + fn test_insert_sns_specific_upgrade_path_entry_overwrites_existing_entry() { + let sns_governance_canister_id = CanisterId::from_u64(1000); + let from_version = SnsVersion { + governance_wasm_hash: vec![1], + ..Default::default() + }; + let first_to_version = SnsVersion { + governance_wasm_hash: vec![2], + ..Default::default() + }; + let second_to_version = SnsVersion { + governance_wasm_hash: vec![3], + ..Default::default() + }; + + let mut upgrade_path = UpgradePath::default(); + upgrade_path.insert_sns_specific_upgrade_path_entry( + from_version.clone(), + first_to_version.clone(), + sns_governance_canister_id, + ); + assert_eq!( + upgrade_path.get_next_version(from_version.clone(), sns_governance_canister_id.get()), + Some(first_to_version) + ); + + // Run code under test: reconfigure the same `from_version` entry with a new target. + upgrade_path.insert_sns_specific_upgrade_path_entry( + from_version.clone(), + second_to_version.clone(), + sns_governance_canister_id, + ); + + // The entry must reflect the new target, not the stale first one. + assert_eq!( + upgrade_path.get_next_version(from_version, sns_governance_canister_id.get()), + Some(second_to_version) + ); + } } From a87eaa5e3961886d711de53fa3511312c656f33f Mon Sep 17 00:00:00 2001 From: Rachit2323 Date: Tue, 18 Aug 2026 01:13:29 +0530 Subject: [PATCH 2/3] changelog: note the SNS-specific upgrade path overwrite fix --- rs/nns/sns-wasm/unreleased_changelog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rs/nns/sns-wasm/unreleased_changelog.md b/rs/nns/sns-wasm/unreleased_changelog.md index 94126a0ff421..0086401165e8 100644 --- a/rs/nns/sns-wasm/unreleased_changelog.md +++ b/rs/nns/sns-wasm/unreleased_changelog.md @@ -17,4 +17,9 @@ on the process that this file is part of, see ## Fixed +* `insert_upgrade_path_entries` now actually replaces an SNS-specific + emergency upgrade step when called again for the same SNS and starting + version, instead of silently keeping the old step while reporting + success. + ## Security From 06aec4fb194db2542582eb0f280287400aaae81e Mon Sep 17 00:00:00 2001 From: Rachit2323 Date: Tue, 18 Aug 2026 01:14:54 +0530 Subject: [PATCH 3/3] changelog: correct the function name in the SNS-specific upgrade path fix entry --- rs/nns/sns-wasm/unreleased_changelog.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rs/nns/sns-wasm/unreleased_changelog.md b/rs/nns/sns-wasm/unreleased_changelog.md index 0086401165e8..d0b3133a2f9a 100644 --- a/rs/nns/sns-wasm/unreleased_changelog.md +++ b/rs/nns/sns-wasm/unreleased_changelog.md @@ -17,9 +17,9 @@ on the process that this file is part of, see ## Fixed -* `insert_upgrade_path_entries` now actually replaces an SNS-specific - emergency upgrade step when called again for the same SNS and starting - version, instead of silently keeping the old step while reporting - success. +* `insert_sns_specific_upgrade_path_entry` now actually replaces an + SNS-specific emergency upgrade step when called again for the same SNS + and starting version, instead of silently keeping the old step while + reporting success. ## Security