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 1 commit
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
2 changes: 2 additions & 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ rewards = { version = "^1.2.0", path = "contracts/rewards" }
router = { version = "^1.1.0", path = "contracts/router" }
router-api = { version = "^1.0.0", path = "packages/router-api" }
schemars = "0.8.10"
semver = "1.0"
serde = { version = "1.0.145", default-features = false, features = ["derive"] }
serde_json = "1.0.89"
service-registry = { version = "^1.1.0", path = "contracts/service-registry" }
Expand Down
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
26 changes: 19 additions & 7 deletions contracts/coordinator/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
to_json_binary, Addr, Binary, Deps, DepsMut, Env, MessageInfo, Response, Storage,
to_json_binary, Addr, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, Storage
};
use error_stack::{report, ResultExt};

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

View workflow job for this annotation

GitHub Actions / Test Suite

unused import: `ResultExt`
cjcobb23 marked this conversation as resolved.
Show resolved Hide resolved
use itertools::Itertools;
use semver::{Version, VersionReq};

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 +24,11 @@
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)?;
let version_requirement = VersionReq::parse(">= 1.1.0, < 1.2.0")?;
assert!(version_requirement.matches(&old_version));
cjcobb23 marked this conversation as resolved.
Show resolved Hide resolved

// 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 +304,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);
}
}
1 change: 0 additions & 1 deletion contracts/coordinator/src/contract/migrations/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
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
1 change: 1 addition & 0 deletions packages/axelar-wasm-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ num-traits = { workspace = true }
regex = { version = "1.10.0", default-features = false, features = ["perf", "std"] }
report = { workspace = true }
schemars = "0.8.10"
semver = { workspace = true }
serde = { version = "1.0.145", default-features = false, features = ["derive"] }
serde_json = "1.0.89"
serde_with = { version = "3.11.0", features = ["macros"] }
Expand Down
8 changes: 8 additions & 0 deletions packages/axelar-wasm-std/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ impl From<cw2::VersionError> for ContractError {
}
}

impl From<semver::Error> for ContractError {
fn from(err: semver::Error) -> Self {
ContractError {
report: report!(err).change_context(Error::Report),
}
}
}

impl From<permission_control::Error> for ContractError {
fn from(err: permission_control::Error) -> Self {
ContractError {
Expand Down
Loading