Skip to content

Commit 10b4a28

Browse files
authored
chore: restore pending dkg contract state migration (#6116)
since it has not yet been run on mainnet
1 parent bbbb948 commit 10b4a28

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

contracts/coconut-dkg/src/contract.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,12 @@ pub fn query(deps: Deps<'_>, env: Env, msg: QueryMsg) -> Result<QueryResponse, C
255255
}
256256

257257
#[entry_point]
258-
pub fn migrate(deps: DepsMut<'_>, _env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
258+
pub fn migrate(deps: DepsMut<'_>, env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
259259
set_build_information!(deps.storage)?;
260260
cw2::ensure_from_older_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
261261

262+
crate::queued_migrations::introduce_historical_epochs(deps, env)?;
263+
262264
Ok(Response::new())
263265
}
264266

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
11
// Copyright 2025 - Nym Technologies SA <[email protected]>
22
// SPDX-License-Identifier: Apache-2.0
3+
4+
use crate::epoch_state::storage::HISTORICAL_EPOCH;
5+
use crate::error::ContractError;
6+
use cosmwasm_std::{DepsMut, Env};
7+
8+
pub fn introduce_historical_epochs(deps: DepsMut, env: Env) -> Result<(), ContractError> {
9+
if HISTORICAL_EPOCH.may_load(deps.storage)?.is_some() {
10+
return Err(ContractError::FailedMigration {
11+
comment: "this migration has already been run before".to_string(),
12+
});
13+
}
14+
15+
#[allow(deprecated)]
16+
let current = crate::epoch_state::storage::CURRENT_EPOCH.load(deps.storage)?;
17+
// we won't have information on intermediate states prior to now, but that's not the end of the world
18+
HISTORICAL_EPOCH.save(deps.storage, &current, env.block.height)?;
19+
20+
Ok(())
21+
}

0 commit comments

Comments
 (0)