From 10b4a288c8386c5fa8a4743031c941f246454675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Wed, 15 Oct 2025 14:18:03 +0100 Subject: [PATCH] chore: restore pending dkg contract state migration (#6116) since it has not yet been run on mainnet --- contracts/coconut-dkg/src/contract.rs | 4 +++- .../coconut-dkg/src/queued_migrations.rs | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/contracts/coconut-dkg/src/contract.rs b/contracts/coconut-dkg/src/contract.rs index 6f3e331ed3..d5d525dd4c 100644 --- a/contracts/coconut-dkg/src/contract.rs +++ b/contracts/coconut-dkg/src/contract.rs @@ -255,10 +255,12 @@ pub fn query(deps: Deps<'_>, env: Env, msg: QueryMsg) -> Result, _env: Env, _msg: MigrateMsg) -> Result { +pub fn migrate(deps: DepsMut<'_>, env: Env, _msg: MigrateMsg) -> Result { set_build_information!(deps.storage)?; cw2::ensure_from_older_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; + crate::queued_migrations::introduce_historical_epochs(deps, env)?; + Ok(Response::new()) } diff --git a/contracts/coconut-dkg/src/queued_migrations.rs b/contracts/coconut-dkg/src/queued_migrations.rs index 7e1e3cacd6..54c149a518 100644 --- a/contracts/coconut-dkg/src/queued_migrations.rs +++ b/contracts/coconut-dkg/src/queued_migrations.rs @@ -1,2 +1,21 @@ // Copyright 2025 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 + +use crate::epoch_state::storage::HISTORICAL_EPOCH; +use crate::error::ContractError; +use cosmwasm_std::{DepsMut, Env}; + +pub fn introduce_historical_epochs(deps: DepsMut, env: Env) -> Result<(), ContractError> { + if HISTORICAL_EPOCH.may_load(deps.storage)?.is_some() { + return Err(ContractError::FailedMigration { + comment: "this migration has already been run before".to_string(), + }); + } + + #[allow(deprecated)] + let current = crate::epoch_state::storage::CURRENT_EPOCH.load(deps.storage)?; + // we won't have information on intermediate states prior to now, but that's not the end of the world + HISTORICAL_EPOCH.save(deps.storage, ¤t, env.block.height)?; + + Ok(()) +}