Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(coordinator): remove old migration #712

Merged
merged 5 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contracts/coordinator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ msgs-derive = { workspace = true }
multisig = { workspace = true, features = ["library"] }
report = { workspace = true }
router-api = { workspace = true }
semver = { workspace = true }
service-registry-api = { workspace = true }
thiserror = { workspace = true }

Expand Down
34 changes: 26 additions & 8 deletions contracts/coordinator/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
to_json_binary, Addr, Binary, Deps, DepsMut, Env, MessageInfo, Response, Storage,
ensure, to_json_binary, Addr, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, Storage,
};
use error_stack::{report, ResultExt};
use cw2::VersionError;
use error_stack::report;
use itertools::Itertools;
use semver::Version;

use crate::error::ContractError;
use crate::msg::{ExecuteMsg, InstantiateMsg, MigrationMsg, QueryMsg};
use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use crate::state::{is_prover_registered, Config, CONFIG};

pub const CONTRACT_NAME: &str = env!("CARGO_PKG_NAME");
Expand All @@ -23,12 +25,16 @@
pub fn migrate(
deps: DepsMut,
_env: Env,
msg: MigrationMsg,
_msg: Empty,
) -> Result<Response, axelar_wasm_std::error::ContractError> {
let service_registry = validate_cosmwasm_address(deps.api, &msg.service_registry)?;

migrations::v1_0_0::migrate(deps.storage, service_registry)
.change_context(ContractError::Migration)?;
let old_version = Version::parse(&cw2::get_contract_version(deps.storage)?.version)?;
ensure!(
old_version.major == 1 && old_version.minor == 1,
report!(VersionError::WrongVersion {
expected: "1.1.x".into(),
found: old_version.to_string()
})

Check warning on line 36 in contracts/coordinator/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/coordinator/src/contract.rs#L33-L36

Added lines #L33 - L36 were not covered by tests
);

// this needs to be the last thing to do during migration,
// because previous migration steps should check the old version
Expand Down Expand Up @@ -304,4 +310,16 @@
.to_string()
));
}

#[test]
fn migrate_sets_contract_version() {
let governance = "governance_for_coordinator";
let mut test_setup = setup(governance);

migrate(test_setup.deps.as_mut(), mock_env(), Empty {}).unwrap();

let contract_version = cw2::get_contract_version(test_setup.deps.as_mut().storage).unwrap();
assert_eq!(contract_version.contract, CONTRACT_NAME);
assert_eq!(contract_version.version, CONTRACT_VERSION);
}
}
2 changes: 1 addition & 1 deletion contracts/coordinator/src/contract/migrations/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub mod v1_0_0;

115 changes: 0 additions & 115 deletions contracts/coordinator/src/contract/migrations/v1_0_0.rs

This file was deleted.

5 changes: 0 additions & 5 deletions contracts/coordinator/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ use msgs_derive::EnsurePermissions;
use router_api::ChainName;
use service_registry_api::Verifier;

#[cw_serde]
pub struct MigrationMsg {
pub service_registry: String,
}

#[cw_serde]
pub struct InstantiateMsg {
pub governance_address: String,
Expand Down
Loading