From 16edca21b04acdbae8d1d1de593e06d6b32cf341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Mon, 14 Oct 2024 11:41:36 +0100 Subject: [PATCH] allow to optionally skip state migration --- .../mixnet-contract/src/msg.rs | 1 + contracts/mixnet/src/contract.rs | 12 ++++++++---- .../testnet-manager/src/manager/network_init.rs | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/common/cosmwasm-smart-contracts/mixnet-contract/src/msg.rs b/common/cosmwasm-smart-contracts/mixnet-contract/src/msg.rs index 06caec5376..0e728aaf63 100644 --- a/common/cosmwasm-smart-contracts/mixnet-contract/src/msg.rs +++ b/common/cosmwasm-smart-contracts/mixnet-contract/src/msg.rs @@ -830,4 +830,5 @@ pub enum QueryMsg { #[cw_serde] pub struct MigrateMsg { pub vesting_contract_address: Option, + pub unsafe_skip_state_updates: Option, } diff --git a/contracts/mixnet/src/contract.rs b/contracts/mixnet/src/contract.rs index b3e3cc5df2..25bca25919 100644 --- a/contracts/mixnet/src/contract.rs +++ b/contracts/mixnet/src/contract.rs @@ -576,11 +576,15 @@ pub fn migrate( set_build_information!(deps.storage)?; cw2::ensure_from_older_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - // remove all family-related things - crate::queued_migrations::families_purge(deps.branch())?; + let skip_state_updates = msg.unsafe_skip_state_updates.unwrap_or(false); - // prepare the ground for using nym-nodes rather than standalone mixnodes/gateways - migrate_to_nym_nodes_usage(deps.branch(), &msg)?; + if !skip_state_updates { + // remove all family-related things + crate::queued_migrations::families_purge(deps.branch())?; + + // prepare the ground for using nym-nodes rather than standalone mixnodes/gateways + migrate_to_nym_nodes_usage(deps.branch(), &msg)?; + } // due to circular dependency on contract addresses (i.e. mixnet contract requiring vesting contract address // and vesting contract requiring the mixnet contract address), if we ever want to deploy any new fresh diff --git a/tools/internal/testnet-manager/src/manager/network_init.rs b/tools/internal/testnet-manager/src/manager/network_init.rs index bdbf39cf32..b298f9b981 100644 --- a/tools/internal/testnet-manager/src/manager/network_init.rs +++ b/tools/internal/testnet-manager/src/manager/network_init.rs @@ -109,6 +109,7 @@ impl NetworkManager { ) -> Result { Ok(nym_mixnet_contract_common::MigrateMsg { vesting_contract_address: Some(ctx.network.contracts.vesting.address()?.to_string()), + unsafe_skip_state_updates: Some(true), }) }