diff --git a/.changelog/v2.0.4/bug-fixes/200-remove-migration-to-v2.0.1.md b/.changelog/v2.0.4/bug-fixes/200-remove-migration-to-v2.0.1.md new file mode 100644 index 00000000..9ab6dd7f --- /dev/null +++ b/.changelog/v2.0.4/bug-fixes/200-remove-migration-to-v2.0.1.md @@ -0,0 +1,2 @@ +- Remove contracts migration code from version v1.1.x to version v2.0.2 and bump contracts version to v2.0.4. + ([\#200](https://github.com/informalsystems/hydro/pull/200)) diff --git a/.changelog/v2.0.4/summary.md b/.changelog/v2.0.4/summary.md new file mode 100644 index 00000000..6456b777 --- /dev/null +++ b/.changelog/v2.0.4/summary.md @@ -0,0 +1 @@ +Date: December 9th, 2024 diff --git a/CHANGELOG b/CHANGELOG index d782d01e..2c7067a6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,14 @@ # CHANGELOG +## v2.0.4 + +Date: December 9th, 2024 + +### BUG FIXES + +- Remove contracts migration code from version v1.1.x to version v2.0.2 and bump contracts version to v2.0.4. + ([\#200](https://github.com/informalsystems/hydro/pull/200)) + ## v2.0.3 Date: December 9th, 2024 diff --git a/Cargo.lock b/Cargo.lock index 4a800d3b..aa723604 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1660,7 +1660,7 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hydro" -version = "2.0.2" +version = "2.0.4" dependencies = [ "bech32 0.9.1", "cosmos-sdk-proto 0.20.0", @@ -3728,7 +3728,7 @@ dependencies = [ [[package]] name = "tribute" -version = "2.0.2" +version = "2.0.4" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/artifacts/checksums.txt b/artifacts/checksums.txt index 73c47fcf..96f51aa0 100644 --- a/artifacts/checksums.txt +++ b/artifacts/checksums.txt @@ -1,2 +1,2 @@ -984fa9abc8f2b8463b19a1a58efdb0deb2934e9b36d0036c5f47331a978156f3 hydro.wasm -03b0d7c99f9e3e53f86fdc3ab42e230ff113e41d007e06be54c74b0b799d376b tribute.wasm +a6776a5163a701a20bd789f331e781d013755ebfc985aabf9b0306dcc106cd65 hydro.wasm +c6766be58bfc7bd482e5c9e8fbdac3dfa29ee8eeebedd782e4ed49bb3f26a4ff tribute.wasm diff --git a/artifacts/hydro.wasm b/artifacts/hydro.wasm index 1e61f19a..6a00b1d2 100644 Binary files a/artifacts/hydro.wasm and b/artifacts/hydro.wasm differ diff --git a/artifacts/tribute.wasm b/artifacts/tribute.wasm index 9be34b39..d1956959 100644 Binary files a/artifacts/tribute.wasm and b/artifacts/tribute.wasm differ diff --git a/contracts/hydro/Cargo.toml b/contracts/hydro/Cargo.toml index 505615ef..05a99236 100644 --- a/contracts/hydro/Cargo.toml +++ b/contracts/hydro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydro" -version = "2.0.2" +version = "2.0.4" authors = ["Jehan Tremback", "Philip Offtermatt", "Dusan Maksimovic"] edition = "2018" diff --git a/contracts/hydro/src/migration/migrate.rs b/contracts/hydro/src/migration/migrate.rs index 052cfb98..e75e0bc8 100644 --- a/contracts/hydro/src/migration/migrate.rs +++ b/contracts/hydro/src/migration/migrate.rs @@ -7,7 +7,7 @@ use cw2::{get_contract_version, set_contract_version}; use neutron_sdk::bindings::msg::NeutronMsg; use neutron_sdk::bindings::query::NeutronQuery; -use super::v2_0_1::{migrate_v1_1_0_to_v2_0_1, MigrateMsgV2_0_1}; +use super::v2_0_4::MigrateMsgV2_0_4; pub const CONTRACT_VERSION_V1_1_0: &str = "1.1.0"; pub const CONTRACT_VERSION_V2_0_1: &str = "2.0.1"; @@ -15,9 +15,9 @@ pub const CONTRACT_VERSION_V2_0_2: &str = "2.0.2"; #[cfg_attr(not(feature = "library"), entry_point)] pub fn migrate( - mut deps: DepsMut, + deps: DepsMut, _env: Env, - msg: MigrateMsgV2_0_1, + _msg: MigrateMsgV2_0_4, ) -> Result, ContractError> { let contract_version = get_contract_version(deps.storage)?; @@ -27,10 +27,6 @@ pub fn migrate( ))); } - if contract_version.version == CONTRACT_VERSION_V1_1_0 { - migrate_v1_1_0_to_v2_0_1(&mut deps, msg)?; - } - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; Ok(Response::default()) diff --git a/contracts/hydro/src/migration/mod.rs b/contracts/hydro/src/migration/mod.rs index d5f748f5..0952d5b8 100644 --- a/contracts/hydro/src/migration/mod.rs +++ b/contracts/hydro/src/migration/mod.rs @@ -1,6 +1,2 @@ pub mod migrate; -pub mod v1_1_0; -pub mod v2_0_1; - -#[cfg(test)] -mod testing_v1_1_0_to_v2_0_1; +pub mod v2_0_4; diff --git a/contracts/hydro/src/migration/testing_v1_1_0_to_v2_0_1.rs b/contracts/hydro/src/migration/testing_v1_1_0_to_v2_0_1.rs deleted file mode 100644 index 2fd937f5..00000000 --- a/contracts/hydro/src/migration/testing_v1_1_0_to_v2_0_1.rs +++ /dev/null @@ -1,559 +0,0 @@ -use std::collections::HashMap; - -use cosmwasm_std::{testing::mock_env, Addr, Coin, Decimal, Timestamp, Uint128}; -use cw2::{get_contract_version, set_contract_version}; -use cw_storage_plus::{Item, Map}; - -use crate::{ - contract::{instantiate, CONTRACT_NAME}, - migration::{ - migrate::{migrate, CONTRACT_VERSION_V1_1_0, CONTRACT_VERSION_V2_0_2}, - v1_1_0::{ConstantsV1_1_0, ProposalV1_1_0, VoteV1_1_0}, - v2_0_1::{ConstantsV2_0_1, MigrateMsgV2_0_1, ProposalV2_0_1, VoteV2_0_1}, - }, - state::{LockEntry, LOCKS_MAP}, - testing::{ - get_default_instantiate_msg, get_message_info, IBC_DENOM_1, IBC_DENOM_2, IBC_DENOM_3, - VALIDATOR_1, VALIDATOR_1_LST_DENOM_1, VALIDATOR_2, VALIDATOR_2_LST_DENOM_1, - VALIDATOR_3_LST_DENOM_1, - }, - testing_lsm_integration::set_validator_infos_for_round, - testing_mocks::{denom_trace_grpc_query_mock, mock_dependencies, no_op_grpc_query_mock}, -}; - -struct LockToInsert { - pub voter: Addr, - pub lock: LockEntry, -} - -struct ExpectedUserVote { - pub round_id: u64, - pub tranche_id: u64, - pub voter: Addr, - pub lock_id: u64, - pub proposal_id: Option, - pub time_weighted_shares: Option<(String, Decimal)>, -} - -#[test] -fn test_constants_and_proposals_migration() { - let (mut deps, env) = (mock_dependencies(no_op_grpc_query_mock()), mock_env()); - - let user_addr = "addr0000"; - let info = get_message_info(&deps.api, user_addr, &[]); - - // Instantiate the contract - let instantiate_msg = get_default_instantiate_msg(&deps.api); - instantiate(deps.as_mut(), env.clone(), info.clone(), instantiate_msg).unwrap(); - - // Override contract version so that we can run the migration - let res = set_contract_version(&mut deps.storage, CONTRACT_NAME, CONTRACT_VERSION_V1_1_0); - assert!( - res.is_ok(), - "failed to set contract version before running the migration" - ); - - const OLD_CONSTANTS: Item = Item::new("constants"); - const NEW_CONSTANTS: Item = Item::new("constants"); - - const OLD_PROPOSAL_MAP: Map<(u64, u64, u64), ProposalV1_1_0> = Map::new("prop_map"); - const NEW_PROPOSAL_MAP: Map<(u64, u64, u64), ProposalV2_0_1> = Map::new("prop_map"); - - // Override the constants so that they have old data structure stored before running the migration - let old_constants = ConstantsV1_1_0 { - round_length: 2628000000000000, - lock_epoch_length: 2628000000000000, - first_round_start: Timestamp::from_nanos(1730851140000000000), - max_locked_tokens: 20000000000, - max_validator_shares_participating: 500, - hub_connection_id: "connection-0".to_string(), - hub_transfer_channel_id: "channel-1".to_string(), - icq_update_period: 109000, - paused: false, - is_in_pilot_mode: true, - }; - - let res = OLD_CONSTANTS.save(&mut deps.storage, &old_constants); - assert!( - res.is_ok(), - "failed to save old constants before running the migration" - ); - - let old_proposals = vec![ - ProposalV1_1_0 { - round_id: 0, - tranche_id: 1, - proposal_id: 0, - power: Uint128::new(250), - percentage: Uint128::zero(), - title: "proposal 1 title".to_string(), - description: "proposal 1 description".to_string(), - }, - ProposalV1_1_0 { - round_id: 0, - tranche_id: 1, - proposal_id: 1, - power: Uint128::new(750), - percentage: Uint128::zero(), - title: "proposal 2 title".to_string(), - description: "proposal 2 description".to_string(), - }, - ProposalV1_1_0 { - round_id: 1, - tranche_id: 1, - proposal_id: 2, - power: Uint128::new(10000), - percentage: Uint128::zero(), - title: "proposal 3 title".to_string(), - description: "proposal 3 description".to_string(), - }, - ]; - - for old_proposal in &old_proposals { - let res = OLD_PROPOSAL_MAP.save( - &mut deps.storage, - ( - old_proposal.round_id, - old_proposal.tranche_id, - old_proposal.proposal_id, - ), - old_proposal, - ); - assert!( - res.is_ok(), - "failed to save old proposals before running the migration" - ) - } - - // Run the migration - let migrate_msg = MigrateMsgV2_0_1 { - max_deployment_duration: 12, - }; - let res = migrate(deps.as_mut(), env.clone(), migrate_msg.clone()); - assert!(res.is_ok(), "migration failed!"); - - // Verify that the Constants got migrated properly - let expected_new_constants = ConstantsV2_0_1 { - round_length: old_constants.round_length, - lock_epoch_length: old_constants.lock_epoch_length, - first_round_start: old_constants.first_round_start, - max_locked_tokens: old_constants.max_locked_tokens, - max_validator_shares_participating: old_constants.max_validator_shares_participating, - hub_connection_id: old_constants.hub_connection_id, - hub_transfer_channel_id: old_constants.hub_transfer_channel_id, - icq_update_period: old_constants.icq_update_period, - paused: old_constants.paused, - is_in_pilot_mode: old_constants.is_in_pilot_mode, - max_deployment_duration: migrate_msg.max_deployment_duration, - }; - let res = NEW_CONSTANTS.load(&deps.storage); - assert!( - res.is_ok(), - "failed to load new constants after running the migration" - ); - let new_constants = res.unwrap(); - assert_eq!( - new_constants, expected_new_constants, - "migrated constants not equal to expected ones" - ); - - // Verify that the proposals got migrated properly - for old_proposal in old_proposals { - let res = NEW_PROPOSAL_MAP.load( - &deps.storage, - ( - old_proposal.round_id, - old_proposal.tranche_id, - old_proposal.proposal_id, - ), - ); - assert!( - res.is_ok(), - "failed to load proposal from store after running the migration" - ); - let new_proposal = res.unwrap(); - - let expected_new_proposal = ProposalV2_0_1 { - round_id: old_proposal.round_id, - tranche_id: old_proposal.tranche_id, - proposal_id: old_proposal.proposal_id, - power: old_proposal.power, - percentage: old_proposal.percentage, - title: old_proposal.title, - description: old_proposal.description, - deployment_duration: 1, - minimum_atom_liquidity_request: Uint128::zero(), - }; - assert_eq!( - new_proposal, expected_new_proposal, - "migrated proposal not equal to expected one" - ); - } - - // Verify the contract version after running the migration - let res = get_contract_version(&deps.storage); - assert_eq!(res.unwrap().version, CONTRACT_VERSION_V2_0_2.to_string()); -} - -#[test] -fn test_votes_migration() { - let grpc_query = denom_trace_grpc_query_mock( - "transfer/channel-1".to_string(), - HashMap::from([ - (IBC_DENOM_1.to_string(), VALIDATOR_1_LST_DENOM_1.to_string()), - (IBC_DENOM_2.to_string(), VALIDATOR_2_LST_DENOM_1.to_string()), - (IBC_DENOM_3.to_string(), VALIDATOR_3_LST_DENOM_1.to_string()), - ]), - ); - - let (mut deps, env) = (mock_dependencies(grpc_query), mock_env()); - - let round_id = 0; - let tranche_id = 1; - - // Set top N validator info - let result = set_validator_infos_for_round( - &mut deps.storage, - round_id, - vec![VALIDATOR_1.to_string(), VALIDATOR_2.to_string()], - ); - assert!(result.is_ok()); - - let instantiate_addr = "addr0000"; - let info = get_message_info(&deps.api, instantiate_addr, &[]); - - // Instantiate the contract - let instantiate_msg = get_default_instantiate_msg(&deps.api); - instantiate(deps.as_mut(), env.clone(), info.clone(), instantiate_msg).unwrap(); - - // Override contract version so that the migration can be run - let res = set_contract_version(&mut deps.storage, CONTRACT_NAME, CONTRACT_VERSION_V1_1_0); - assert!( - res.is_ok(), - "failed to set contract version before running the migration" - ); - - // Override the constants so that they have old data structure stored before running the migration - let first_round_start = 1730851140000000000; - let lock_epoch_length = 2628000000000000; - - let old_constants = ConstantsV1_1_0 { - round_length: lock_epoch_length, - lock_epoch_length, - first_round_start: Timestamp::from_nanos(first_round_start), - max_locked_tokens: 20000000000, - max_validator_shares_participating: 500, - hub_connection_id: "connection-0".to_string(), - hub_transfer_channel_id: "channel-1".to_string(), - icq_update_period: 109000, - paused: false, - is_in_pilot_mode: true, - }; - - const OLD_CONSTANTS: Item = Item::new("constants"); - let res = OLD_CONSTANTS.save(&mut deps.storage, &old_constants); - assert!( - res.is_ok(), - "failed to save old constants before running the migration" - ); - - let user1_address = deps.api.addr_make("addr0001"); - let user2_address = deps.api.addr_make("addr0002"); - - let user_lockups = vec![ - // lockup that gives 1x power - LockToInsert { - voter: user1_address.clone(), - lock: LockEntry { - lock_id: 0, - funds: Coin::new(11u128, IBC_DENOM_1), - lock_start: Timestamp::from_nanos(first_round_start + 10000), - lock_end: Timestamp::from_nanos(first_round_start + 10000 + lock_epoch_length), - }, - }, - // lockup that gives 1x power - LockToInsert { - voter: user1_address.clone(), - lock: LockEntry { - lock_id: 1, - funds: Coin::new(32u128, IBC_DENOM_1), - lock_start: Timestamp::from_nanos(first_round_start + 20000), - lock_end: Timestamp::from_nanos(first_round_start + 20000 + lock_epoch_length), - }, - }, - // lockup that gives 1x power - LockToInsert { - voter: user1_address.clone(), - lock: LockEntry { - lock_id: 2, - funds: Coin::new(53u128, IBC_DENOM_2), - lock_start: Timestamp::from_nanos(first_round_start + 30000), - lock_end: Timestamp::from_nanos(first_round_start + 30000 + lock_epoch_length), - }, - }, - // simulates an expired lockup, even though we will not have such lockups in the first round - LockToInsert { - voter: user1_address.clone(), - lock: LockEntry { - lock_id: 3, - funds: Coin::new(74u128, IBC_DENOM_2), - lock_start: Timestamp::from_nanos(first_round_start - 40000), - lock_end: Timestamp::from_nanos(first_round_start - 40000 + lock_epoch_length), - }, - }, - // lockup that gives 1x power - LockToInsert { - voter: user2_address.clone(), - lock: LockEntry { - lock_id: 4, - funds: Coin::new(1u128, IBC_DENOM_1), - lock_start: Timestamp::from_nanos(first_round_start + 10000), - lock_end: Timestamp::from_nanos(first_round_start + 10000 + lock_epoch_length), - }, - }, - // lockup that gives 1x power - LockToInsert { - voter: user2_address.clone(), - lock: LockEntry { - lock_id: 5, - funds: Coin::new(2u128, IBC_DENOM_1), - lock_start: Timestamp::from_nanos(first_round_start + 20000), - lock_end: Timestamp::from_nanos(first_round_start + 20000 + lock_epoch_length), - }, - }, - // lockup that gives 1x power - LockToInsert { - voter: user2_address.clone(), - lock: LockEntry { - lock_id: 6, - funds: Coin::new(3u128, IBC_DENOM_2), - lock_start: Timestamp::from_nanos(first_round_start + 30000), - lock_end: Timestamp::from_nanos(first_round_start + 30000 + lock_epoch_length), - }, - }, - // simulates an expired lockup, even though we will not have such lockups in the first round - LockToInsert { - voter: user2_address.clone(), - lock: LockEntry { - lock_id: 7, - funds: Coin::new(4u128, IBC_DENOM_2), - lock_start: Timestamp::from_nanos(first_round_start - 40000), - lock_end: Timestamp::from_nanos(first_round_start - 40000 + lock_epoch_length), - }, - }, - ]; - - for user_lockup in &user_lockups { - let res = LOCKS_MAP.save( - &mut deps.storage, - (user_lockup.voter.clone(), user_lockup.lock.lock_id), - &user_lockup.lock, - ); - assert!( - res.is_ok(), - "failed to save lockup into the store before running the migration" - ); - } - - // Create user votes for arbitrary proposals and with the scaled voting power summed up from all user lockups - let user1_validator1_voting_power = - user_lockups[0].lock.funds.amount + user_lockups[1].lock.funds.amount; - let user1_validator2_voting_power = user_lockups[2].lock.funds.amount; - - let user2_validator1_voting_power = - user_lockups[4].lock.funds.amount + user_lockups[5].lock.funds.amount; - let user2_validator2_voting_power = user_lockups[6].lock.funds.amount; - - let user1_voted_proposal = 3; - let user2_voted_proposal = 7; - - let old_user_votes = vec![ - ( - user1_address.clone(), - VoteV1_1_0 { - prop_id: user1_voted_proposal, - time_weighted_shares: HashMap::from([ - ( - VALIDATOR_1.to_string(), - Decimal::from_ratio(user1_validator1_voting_power, Uint128::one()), - ), - ( - VALIDATOR_2.to_string(), - Decimal::from_ratio(user1_validator2_voting_power, Uint128::one()), - ), - ]), - }, - ), - ( - user2_address.clone(), - VoteV1_1_0 { - prop_id: user2_voted_proposal, - time_weighted_shares: HashMap::from([ - ( - VALIDATOR_1.to_string(), - Decimal::from_ratio(user2_validator1_voting_power, Uint128::one()), - ), - ( - VALIDATOR_2.to_string(), - Decimal::from_ratio(user2_validator2_voting_power, Uint128::one()), - ), - ]), - }, - ), - ]; - - const OLD_VOTE_MAP: Map<(u64, u64, Addr), VoteV1_1_0> = Map::new("vote_map"); - const NEW_VOTE_MAP: Map<((u64, u64), Addr, u64), VoteV2_0_1> = Map::new("vote_map"); - - for user_vote in &old_user_votes { - let res = OLD_VOTE_MAP.save( - &mut deps.storage, - (round_id, tranche_id, user_vote.0.clone()), - &user_vote.1, - ); - assert!( - res.is_ok(), - "failed to save user vote into the store before running the migration" - ); - } - - // Run the migration - let migrate_msg = MigrateMsgV2_0_1 { - max_deployment_duration: 12, - }; - let res = migrate(deps.as_mut(), env.clone(), migrate_msg); - assert!(res.is_ok(), "migration failed!"); - - let expected_votes = vec![ - ExpectedUserVote { - round_id, - tranche_id, - voter: user1_address.clone(), - lock_id: 0, - proposal_id: Some(user1_voted_proposal), - time_weighted_shares: Some(( - VALIDATOR_1.to_string(), - Decimal::from_ratio(user_lockups[0].lock.funds.amount, Uint128::one()), - )), - }, - ExpectedUserVote { - round_id, - tranche_id, - voter: user1_address.clone(), - lock_id: 1, - proposal_id: Some(user1_voted_proposal), - time_weighted_shares: Some(( - VALIDATOR_1.to_string(), - Decimal::from_ratio(user_lockups[1].lock.funds.amount, Uint128::one()), - )), - }, - ExpectedUserVote { - round_id, - tranche_id, - voter: user1_address.clone(), - lock_id: 2, - proposal_id: Some(user1_voted_proposal), - time_weighted_shares: Some(( - VALIDATOR_2.to_string(), - Decimal::from_ratio(user_lockups[2].lock.funds.amount, Uint128::one()), - )), - }, - ExpectedUserVote { - round_id, - tranche_id, - voter: user1_address.clone(), - lock_id: 3, - proposal_id: None, - time_weighted_shares: None, - }, - ExpectedUserVote { - round_id, - tranche_id, - voter: user2_address.clone(), - lock_id: 4, - proposal_id: Some(user2_voted_proposal), - time_weighted_shares: Some(( - VALIDATOR_1.to_string(), - Decimal::from_ratio(user_lockups[4].lock.funds.amount, Uint128::one()), - )), - }, - ExpectedUserVote { - round_id, - tranche_id, - voter: user2_address.clone(), - lock_id: 5, - proposal_id: Some(user2_voted_proposal), - time_weighted_shares: Some(( - VALIDATOR_1.to_string(), - Decimal::from_ratio(user_lockups[5].lock.funds.amount, Uint128::one()), - )), - }, - ExpectedUserVote { - round_id, - tranche_id, - voter: user2_address.clone(), - lock_id: 6, - proposal_id: Some(user2_voted_proposal), - time_weighted_shares: Some(( - VALIDATOR_2.to_string(), - Decimal::from_ratio(user_lockups[6].lock.funds.amount, Uint128::one()), - )), - }, - ExpectedUserVote { - round_id, - tranche_id, - voter: user2_address.clone(), - lock_id: 7, - proposal_id: None, - time_weighted_shares: None, - }, - ]; - - for expected_vote in expected_votes { - let res = NEW_VOTE_MAP.load( - &deps.storage, - ( - (expected_vote.round_id, expected_vote.tranche_id), - expected_vote.voter, - expected_vote.lock_id, - ), - ); - - match expected_vote.proposal_id { - Some(expected_proposal_id) => { - assert!( - res.is_ok(), - "failed to load expected user vote after running the migration" - ); - - let new_vote = res.unwrap(); - let expected_time_weighted_shares = expected_vote.time_weighted_shares.unwrap(); - - assert_eq!(new_vote.prop_id, expected_proposal_id); - assert_eq!( - new_vote.time_weighted_shares.0, - expected_time_weighted_shares.0 - ); - assert_eq!( - new_vote.time_weighted_shares.1, - expected_time_weighted_shares.1 - ); - } - None => { - assert!( - res.is_err(), - "loaded user vote that shouldn't exist after running the migration" - ); - } - } - } - - // Verify that old votes are removed - for user_vote in old_user_votes { - let res = OLD_VOTE_MAP.load(&deps.storage, (round_id, tranche_id, user_vote.0)); - assert!( - res.unwrap_err().to_string().contains("not found"), - "loaded old user vote from the store after running the migration" - ); - } -} diff --git a/contracts/hydro/src/migration/v1_1_0.rs b/contracts/hydro/src/migration/v1_1_0.rs deleted file mode 100644 index feb54560..00000000 --- a/contracts/hydro/src/migration/v1_1_0.rs +++ /dev/null @@ -1,42 +0,0 @@ -use std::collections::HashMap; - -use cosmwasm_schema::cw_serde; -use cosmwasm_std::{Decimal, Timestamp, Uint128}; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct MigrateMsgV1_1_0 { - pub new_first_round_start: Timestamp, -} - -#[cw_serde] -pub struct ConstantsV1_1_0 { - pub round_length: u64, - pub lock_epoch_length: u64, - pub first_round_start: Timestamp, - pub max_locked_tokens: u128, - pub max_validator_shares_participating: u64, - pub hub_connection_id: String, - pub hub_transfer_channel_id: String, - pub icq_update_period: u64, - pub paused: bool, - pub is_in_pilot_mode: bool, -} - -#[cw_serde] -pub struct ProposalV1_1_0 { - pub round_id: u64, - pub tranche_id: u64, - pub proposal_id: u64, - pub title: String, - pub description: String, - pub power: Uint128, - pub percentage: Uint128, -} - -#[cw_serde] -pub struct VoteV1_1_0 { - pub prop_id: u64, - pub time_weighted_shares: HashMap, -} diff --git a/contracts/hydro/src/migration/v2_0_1.rs b/contracts/hydro/src/migration/v2_0_1.rs deleted file mode 100644 index 0626fbac..00000000 --- a/contracts/hydro/src/migration/v2_0_1.rs +++ /dev/null @@ -1,256 +0,0 @@ -use cosmwasm_schema::cw_serde; -use cosmwasm_std::{Addr, Decimal, DepsMut, Order, Storage, Timestamp, Uint128}; -use cw_storage_plus::{Item, Map}; -use neutron_sdk::bindings::query::NeutronQuery; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use crate::contract::{compute_round_end, get_lock_time_weighted_shares}; -use crate::error::ContractError; - -use crate::lsm_integration::resolve_validator_from_denom; -use crate::migration::v1_1_0::{ConstantsV1_1_0, ProposalV1_1_0, VoteV1_1_0}; -use crate::state::{CONSTANTS, LOCKS_MAP}; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct MigrateMsgV2_0_1 { - pub max_deployment_duration: u64, -} - -#[cw_serde] -pub struct ConstantsV2_0_1 { - pub round_length: u64, - pub lock_epoch_length: u64, - pub first_round_start: Timestamp, - pub max_locked_tokens: u128, - pub max_validator_shares_participating: u64, - pub hub_connection_id: String, - pub hub_transfer_channel_id: String, - pub icq_update_period: u64, - pub paused: bool, - pub is_in_pilot_mode: bool, - pub max_deployment_duration: u64, -} - -impl ConstantsV2_0_1 { - pub fn from(old_constants: ConstantsV1_1_0, max_deployment_duration: u64) -> Self { - Self { - round_length: old_constants.round_length, - lock_epoch_length: old_constants.lock_epoch_length, - first_round_start: old_constants.first_round_start, - max_locked_tokens: old_constants.max_locked_tokens, - max_validator_shares_participating: old_constants.max_validator_shares_participating, - hub_connection_id: old_constants.hub_connection_id, - hub_transfer_channel_id: old_constants.hub_transfer_channel_id, - icq_update_period: old_constants.icq_update_period, - paused: old_constants.paused, - is_in_pilot_mode: old_constants.is_in_pilot_mode, - // Set max_deployment_duration to the value specified in the migrate message - max_deployment_duration, - } - } -} - -#[cw_serde] -pub struct ProposalV2_0_1 { - pub round_id: u64, - pub tranche_id: u64, - pub proposal_id: u64, - pub title: String, - pub description: String, - pub power: Uint128, - pub percentage: Uint128, - pub deployment_duration: u64, - pub minimum_atom_liquidity_request: Uint128, -} - -impl ProposalV2_0_1 { - pub fn from(old_proposal: ProposalV1_1_0) -> Self { - Self { - round_id: old_proposal.round_id, - tranche_id: old_proposal.tranche_id, - proposal_id: old_proposal.proposal_id, - power: old_proposal.power, - percentage: old_proposal.percentage, - title: old_proposal.title, - description: old_proposal.description, - // Existing proposals are getting the liquidity deployed for only one round - deployment_duration: 1, - minimum_atom_liquidity_request: Uint128::zero(), - } - } -} - -#[cw_serde] -pub struct VoteV2_0_1 { - pub prop_id: u64, - pub time_weighted_shares: (String, Decimal), -} - -struct OldVoteInfo { - pub round_id: u64, - pub tranche_id: u64, - pub voter: Addr, -} - -struct NewVoteInfo { - pub round_id: u64, - pub tranche_id: u64, - pub voter: Addr, - pub lock_id: u64, - pub vote: VoteV2_0_1, -} - -// Migrating from 1.1.0 to 2.0.1 will: -// - Migrate the existing Constants to add "max_deployment_duration" field -// - Migrate the existing Proposals to add "deployment_duration" and "minimum_atom_liquidity_request" fields -// - Migrate each Vote from first round to a new format where the key will also include lock_id, and the value -// will no longer contain HashMap but only (String, Decimal), since each vote refers to -// a single lock entry, and therefore has only one LSM token denom associated with it. To construct new votes, -// we iterate over all lock entries that belong to a user and create a vote for each lock entry. -// All votes saved under the old keys are removed from the store, and the replacing votes are added -// under the new keys. -pub fn migrate_v1_1_0_to_v2_0_1( - deps: &mut DepsMut, - msg: MigrateMsgV2_0_1, -) -> Result<(), ContractError> { - migrate_constants(deps.storage, msg)?; - migrate_proposals(deps.storage)?; - migrate_votes(deps)?; - - Ok(()) -} - -fn migrate_constants( - storage: &mut dyn Storage, - migrate_msg: MigrateMsgV2_0_1, -) -> Result<(), ContractError> { - const OLD_CONSTANTS: Item = Item::new("constants"); - const NEW_CONSTANTS: Item = Item::new("constants"); - - let old_constants = OLD_CONSTANTS.load(storage)?; - let new_constants = ConstantsV2_0_1::from(old_constants, migrate_msg.max_deployment_duration); - NEW_CONSTANTS.save(storage, &new_constants)?; - - Ok(()) -} - -fn migrate_proposals(storage: &mut dyn Storage) -> Result<(), ContractError> { - const OLD_PROPOSAL_MAP: Map<(u64, u64, u64), ProposalV1_1_0> = Map::new("prop_map"); - const NEW_PROPOSAL_MAP: Map<(u64, u64, u64), ProposalV2_0_1> = Map::new("prop_map"); - - let old_proposals = OLD_PROPOSAL_MAP.range(storage, None, None, Order::Descending); - let mut new_proposals = vec![]; - - for old_proposal in old_proposals { - let ((_, _, _), old_proposal) = old_proposal?; - new_proposals.push(ProposalV2_0_1::from(old_proposal)); - } - - for new_proposal in new_proposals { - NEW_PROPOSAL_MAP.save( - storage, - ( - new_proposal.round_id, - new_proposal.tranche_id, - new_proposal.proposal_id, - ), - &new_proposal, - )?; - } - - Ok(()) -} - -fn migrate_votes(deps: &mut DepsMut) -> Result<(), ContractError> { - const OLD_VOTE_MAP: Map<(u64, u64, Addr), VoteV1_1_0> = Map::new("vote_map"); - const NEW_VOTE_MAP: Map<((u64, u64), Addr, u64), VoteV2_0_1> = Map::new("vote_map"); - - let mut old_votes = vec![]; - let mut new_votes = vec![]; - - // Here we rely on CONSTANTS being already migrated, and therefore we can use - // the new struct and helper functions from the latest code. - let constants = CONSTANTS.load(deps.storage)?; - let lock_epoch_length = constants.lock_epoch_length; - - for old_vote in OLD_VOTE_MAP.range(deps.storage, None, None, Order::Descending) { - let ((round_id, tranche_id, voter), old_vote) = old_vote?; - let round_end = compute_round_end(&constants, round_id)?; - - old_votes.push(OldVoteInfo { - round_id, - tranche_id, - voter: voter.clone(), - }); - - // We use LOCKS_MAP from the latest code since this storage hasn't changed. - // This is needed in order to use get_lock_time_weighted_shares() helper function. - for lock_entry in - LOCKS_MAP - .prefix(voter.clone()) - .range(deps.storage, None, None, Order::Ascending) - { - let (_, lock_entry) = lock_entry?; - let validator = match resolve_validator_from_denom( - &deps.as_ref(), - &constants, - lock_entry.clone().funds.denom, - ) { - Ok(validator) => validator, - Err(_) => { - continue; - } - }; - - // We do not check if the validator is active at the moment we run the migration, since this can change - // afterwards. Instead, we will create a vote for each lock that user has. The reasoning is as follows: - // if user voted, most likely they voted with all their locks. If they first voted and then locked more - // tokens, this would add the new lock to their vote. If user voted with tokens from validator that later - // dropped out from the top N, this lock's power would remain in user's vote, which is the same we do in - // this migration. Votes with tokens from dropped-out validators will be filtered out in query_votes(). - let scaled_shares = Decimal::from_ratio( - get_lock_time_weighted_shares(round_end, lock_entry.clone(), lock_epoch_length), - Uint128::one(), - ); - - if scaled_shares.is_zero() { - continue; - } - - let new_vote = NewVoteInfo { - round_id, - tranche_id, - voter: voter.clone(), - lock_id: lock_entry.lock_id, - vote: VoteV2_0_1 { - prop_id: old_vote.prop_id, - time_weighted_shares: (validator, scaled_shares), - }, - }; - - new_votes.push(new_vote); - } - } - - for old_vote in old_votes { - OLD_VOTE_MAP.remove( - deps.storage, - (old_vote.round_id, old_vote.tranche_id, old_vote.voter), - ); - } - - for new_vote in new_votes { - NEW_VOTE_MAP.save( - deps.storage, - ( - (new_vote.round_id, new_vote.tranche_id), - new_vote.voter, - new_vote.lock_id, - ), - &new_vote.vote, - )?; - } - - Ok(()) -} diff --git a/contracts/tribute/src/migration/v1_1_0.rs b/contracts/hydro/src/migration/v2_0_4.rs similarity index 53% rename from contracts/tribute/src/migration/v1_1_0.rs rename to contracts/hydro/src/migration/v2_0_4.rs index 00d0172e..fd6677a9 100644 --- a/contracts/tribute/src/migration/v1_1_0.rs +++ b/contracts/hydro/src/migration/v2_0_4.rs @@ -1,8 +1,6 @@ -use cosmwasm_std::Uint128; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +// Message to migrate the contract from v2.0.2 to v2.0.4 #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct MigrateMsgV1_1_0 { - pub min_prop_percent_for_claimable_tributes: Uint128, -} +pub struct MigrateMsgV2_0_4 {} diff --git a/contracts/tribute/Cargo.toml b/contracts/tribute/Cargo.toml index 6fb79e80..60ace0e2 100644 --- a/contracts/tribute/Cargo.toml +++ b/contracts/tribute/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tribute" -version = "2.0.2" +version = "2.0.4" edition = "2018" authors = ["Jehan Tremback", "Philip Offtermatt", "Dusan Maksimovic"] diff --git a/contracts/tribute/src/migration/migrate.rs b/contracts/tribute/src/migration/migrate.rs index b4a1ac50..9ad477ac 100644 --- a/contracts/tribute/src/migration/migrate.rs +++ b/contracts/tribute/src/migration/migrate.rs @@ -4,18 +4,19 @@ use cw2::{get_contract_version, set_contract_version}; use crate::{ contract::{CONTRACT_NAME, CONTRACT_VERSION}, error::ContractError, - migration::v2_0_1::{migrate_v1_1_1_to_v2_0_1, MigrateMsgV2_0_1}, }; +use super::v2_0_4::MigrateMsgV2_0_4; + pub const CONTRACT_VERSION_V1_1_1: &str = "1.1.1"; pub const CONTRACT_VERSION_V2_0_1: &str = "2.0.1"; pub const CONTRACT_VERSION_V2_0_2: &str = "2.0.2"; #[cfg_attr(not(feature = "library"), entry_point)] pub fn migrate( - mut deps: DepsMut, + deps: DepsMut, _env: Env, - _msg: MigrateMsgV2_0_1, + _msg: MigrateMsgV2_0_4, ) -> Result { let contract_version = get_contract_version(deps.storage)?; @@ -25,10 +26,6 @@ pub fn migrate( ))); } - if contract_version.version == CONTRACT_VERSION_V1_1_1 { - migrate_v1_1_1_to_v2_0_1(&mut deps)?; - } - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; Ok(Response::default()) diff --git a/contracts/tribute/src/migration/mod.rs b/contracts/tribute/src/migration/mod.rs index 6eaf9415..0952d5b8 100644 --- a/contracts/tribute/src/migration/mod.rs +++ b/contracts/tribute/src/migration/mod.rs @@ -1,7 +1,2 @@ pub mod migrate; -pub mod v1_1_0; -pub mod v1_1_1; -pub mod v2_0_1; - -#[cfg(test)] -mod testing_v1_1_1_to_v2_0_1; +pub mod v2_0_4; diff --git a/contracts/tribute/src/migration/testing_v1_1_1_to_v2_0_1.rs b/contracts/tribute/src/migration/testing_v1_1_1_to_v2_0_1.rs deleted file mode 100644 index e320601a..00000000 --- a/contracts/tribute/src/migration/testing_v1_1_1_to_v2_0_1.rs +++ /dev/null @@ -1,169 +0,0 @@ -use cosmwasm_std::{ - testing::{mock_dependencies, mock_env}, - Coin, Timestamp, Uint128, -}; -use cw2::{get_contract_version, set_contract_version}; -use cw_storage_plus::{Item, Map}; -use hydro::state::Constants; - -use crate::{ - contract::{instantiate, CONTRACT_NAME}, - migration::{ - migrate::{migrate, CONTRACT_VERSION_V1_1_1, CONTRACT_VERSION_V2_0_2}, - v1_1_1::{ConfigV1_1_1, TributeV1_1_1}, - v2_0_1::{ConfigV2_0_1, MigrateMsgV2_0_1, TributeV2_0_1}, - }, - testing::{get_instantiate_msg, get_message_info, MockWasmQuerier}, -}; - -#[test] -fn test_migrate() { - let (mut deps, env) = (mock_dependencies(), mock_env()); - - let round_id = 0; - let tranche_id = 1; - - let user_addr = "addr0000"; - let hydro_addr = "addr0001"; - - let hydro_contract_address = deps.api.addr_make(hydro_addr); - let user_address = deps.api.addr_make(user_addr); - let info = get_message_info(&deps.api, user_addr, &[]); - - let first_round_start = 1730851140000000000; - let lock_epoch_length = 2628000000000000; - - let constants_mock = Constants { - round_length: lock_epoch_length, - lock_epoch_length, - first_round_start: Timestamp::from_nanos(first_round_start), - max_locked_tokens: 20000000000, - max_validator_shares_participating: 500, - hub_connection_id: "connection-0".to_string(), - hub_transfer_channel_id: "channel-1".to_string(), - icq_update_period: 109000, - paused: false, - is_in_pilot_mode: true, - max_deployment_duration: 12, - }; - - let mock_querier = MockWasmQuerier::new( - hydro_contract_address.to_string(), - round_id, - vec![], - vec![], - vec![], - Some(constants_mock.clone()), - ); - deps.querier.update_wasm(move |q| mock_querier.handler(q)); - - let msg = get_instantiate_msg(hydro_contract_address.to_string()); - let res = instantiate(deps.as_mut(), env.clone(), info.clone(), msg.clone()); - assert!(res.is_ok()); - - // Override contract version so that we can run the migration - let res = set_contract_version(&mut deps.storage, CONTRACT_NAME, CONTRACT_VERSION_V1_1_1); - assert!( - res.is_ok(), - "failed to set contract version before running the migration" - ); - - const OLD_CONFIG: Item = Item::new("config"); - const NEW_CONFIG: Item = Item::new("config"); - - const OLD_ID_TO_TRIBUTE_MAP: Map = Map::new("id_to_tribute_map"); - const NEW_ID_TO_TRIBUTE_MAP: Map = Map::new("id_to_tribute_map"); - - // Override the config so it has the old data structure stored before running the migration - let old_config = ConfigV1_1_1 { - hydro_contract: hydro_contract_address.clone(), - top_n_props_count: 11, - min_prop_percent_for_claimable_tributes: Uint128::new(7), - }; - - let res = OLD_CONFIG.save(&mut deps.storage, &old_config); - assert!( - res.is_ok(), - "failed to save old config before running the migration" - ); - - let old_tributes = vec![ - TributeV1_1_1 { - round_id, - tranche_id, - proposal_id: 0, - tribute_id: 0, - depositor: user_address.clone(), - funds: Coin::new(100u128, "token1"), - refunded: false, - }, - TributeV1_1_1 { - round_id, - tranche_id, - proposal_id: 1, - tribute_id: 1, - depositor: user_address.clone(), - funds: Coin::new(200u128, "token2"), - refunded: false, - }, - TributeV1_1_1 { - round_id: round_id + 1, - tranche_id, - proposal_id: 2, - tribute_id: 2, - depositor: user_address.clone(), - funds: Coin::new(300u128, "token3"), - refunded: true, - }, - ]; - - for old_tribute in &old_tributes { - let res = - OLD_ID_TO_TRIBUTE_MAP.save(&mut deps.storage, old_tribute.tribute_id, old_tribute); - assert!( - res.is_ok(), - "failed to save old proposals before running the migration" - ) - } - - // Run the migration - let res = migrate(deps.as_mut(), env.clone(), MigrateMsgV2_0_1 {}); - assert!(res.is_ok(), "migration failed!"); - - // Verify that the Config got migrated properly - let res = NEW_CONFIG.load(&deps.storage); - assert!( - res.is_ok(), - "failed to load new config after running the migration!" - ); - assert_eq!(res.unwrap().hydro_contract, old_config.hydro_contract); - - // Verify that the tributes got migrated properly - for old_tribute in &old_tributes { - let res = NEW_ID_TO_TRIBUTE_MAP.load(&deps.storage, old_tribute.tribute_id); - assert!( - res.is_ok(), - "failed to load new tribute after running the migration!" - ); - - let new_tribute = res.unwrap(); - assert_eq!(new_tribute.round_id, old_tribute.round_id); - assert_eq!(new_tribute.tranche_id, old_tribute.tranche_id); - assert_eq!(new_tribute.proposal_id, old_tribute.proposal_id); - assert_eq!(new_tribute.tribute_id, old_tribute.tribute_id); - assert_eq!(new_tribute.depositor, old_tribute.depositor); - assert_eq!(new_tribute.funds, old_tribute.funds); - assert_eq!(new_tribute.refunded, old_tribute.refunded); - - assert_eq!(new_tribute.creation_round, old_tribute.round_id); - - let expected_creation_time = constants_mock - .first_round_start - .plus_nanos(new_tribute.round_id * constants_mock.lock_epoch_length); - assert_eq!(new_tribute.creation_time, expected_creation_time); - } - - // Verify the contract version after running the migration - let res = get_contract_version(&deps.storage); - assert_eq!(res.unwrap().version, CONTRACT_VERSION_V2_0_2.to_string()); -} diff --git a/contracts/tribute/src/migration/v1_1_1.rs b/contracts/tribute/src/migration/v1_1_1.rs deleted file mode 100644 index 91d1bf09..00000000 --- a/contracts/tribute/src/migration/v1_1_1.rs +++ /dev/null @@ -1,20 +0,0 @@ -use cosmwasm_schema::cw_serde; -use cosmwasm_std::{Addr, Coin, Uint128}; - -#[cw_serde] -pub struct ConfigV1_1_1 { - pub hydro_contract: Addr, - pub top_n_props_count: u64, - pub min_prop_percent_for_claimable_tributes: Uint128, -} - -#[cw_serde] -pub struct TributeV1_1_1 { - pub round_id: u64, - pub tranche_id: u64, - pub proposal_id: u64, - pub tribute_id: u64, - pub depositor: Addr, - pub funds: Coin, - pub refunded: bool, -} diff --git a/contracts/tribute/src/migration/v2_0_1.rs b/contracts/tribute/src/migration/v2_0_1.rs deleted file mode 100644 index 1169896c..00000000 --- a/contracts/tribute/src/migration/v2_0_1.rs +++ /dev/null @@ -1,106 +0,0 @@ -use cosmwasm_schema::cw_serde; -use cosmwasm_std::{Addr, Coin, DepsMut, Order, StdResult, Storage, Timestamp}; -use cw_storage_plus::{Item, Map}; -use hydro::{ - contract::compute_round_end, - query::{ConstantsResponse, QueryMsg as HydroQueryMsg}, - state::Constants, -}; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use crate::{ - error::ContractError, - migration::v1_1_1::{ConfigV1_1_1, TributeV1_1_1}, -}; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct MigrateMsgV2_0_1 {} - -#[cw_serde] -pub struct ConfigV2_0_1 { - pub hydro_contract: Addr, -} - -#[cw_serde] -pub struct TributeV2_0_1 { - pub round_id: u64, - pub tranche_id: u64, - pub proposal_id: u64, - pub tribute_id: u64, - pub depositor: Addr, - pub funds: Coin, - pub refunded: bool, - pub creation_time: Timestamp, - pub creation_round: u64, -} - -impl TributeV2_0_1 { - fn from(old_tribute: TributeV1_1_1, constants: &Constants) -> StdResult { - let round_start = - compute_round_end(constants, old_tribute.round_id)?.nanos() - constants.round_length; - - Ok(Self { - round_id: old_tribute.round_id, - tranche_id: old_tribute.tranche_id, - proposal_id: old_tribute.proposal_id, - tribute_id: old_tribute.tribute_id, - depositor: old_tribute.depositor, - funds: old_tribute.funds, - refunded: old_tribute.refunded, - // Set the tribute creation time to the start of the round in which the tribute was created - creation_time: Timestamp::from_nanos(round_start), - // In V1 tributes could only be added in current round - creation_round: old_tribute.round_id, - }) - } -} - -// Migrating from 1.1.1 to 2.0.1 will: -// - Migrate the existing Config to remove "top_n_props_count" and "min_prop_percent_for_claimable_tributes" fields. -// - Migrate the existing Tributes to add "creation_round" and "creation_time" fields. This fields will be populated -// with the round in which the tribute was created and with timestamp when the given round started. -pub fn migrate_v1_1_1_to_v2_0_1(deps: &mut DepsMut) -> Result<(), ContractError> { - let new_config = migrate_config(deps.storage)?; - migrate_tributes(deps, new_config)?; - - Ok(()) -} - -fn migrate_config(storage: &mut dyn Storage) -> Result { - const OLD_CONFIG: Item = Item::new("config"); - const NEW_CONFIG: Item = Item::new("config"); - - let old_config = OLD_CONFIG.load(storage)?; - let new_config = ConfigV2_0_1 { - hydro_contract: old_config.hydro_contract, - }; - - NEW_CONFIG.save(storage, &new_config)?; - - Ok(new_config) -} - -fn migrate_tributes(deps: &mut DepsMut, config: ConfigV2_0_1) -> Result<(), ContractError> { - const OLD_ID_TO_TRIBUTE_MAP: Map = Map::new("id_to_tribute_map"); - const NEW_ID_TO_TRIBUTE_MAP: Map = Map::new("id_to_tribute_map"); - - let constants_resp: ConstantsResponse = deps - .querier - .query_wasm_smart(config.hydro_contract, &HydroQueryMsg::Constants {})?; - - let mut new_tributes = vec![]; - - for old_tribute in OLD_ID_TO_TRIBUTE_MAP.range(deps.storage, None, None, Order::Ascending) { - let (_, old_tribute) = old_tribute?; - - let new_tribute = TributeV2_0_1::from(old_tribute, &constants_resp.constants)?; - new_tributes.push(new_tribute); - } - - for new_tribute in new_tributes { - NEW_ID_TO_TRIBUTE_MAP.save(deps.storage, new_tribute.tribute_id, &new_tribute)?; - } - - Ok(()) -} diff --git a/contracts/tribute/src/migration/v2_0_4.rs b/contracts/tribute/src/migration/v2_0_4.rs new file mode 100644 index 00000000..fd6677a9 --- /dev/null +++ b/contracts/tribute/src/migration/v2_0_4.rs @@ -0,0 +1,6 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +// Message to migrate the contract from v2.0.2 to v2.0.4 +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct MigrateMsgV2_0_4 {} diff --git a/packages/interface/src/hydro.rs b/packages/interface/src/hydro.rs index cdd8c768..b1e99855 100644 --- a/packages/interface/src/hydro.rs +++ b/packages/interface/src/hydro.rs @@ -1,12 +1,12 @@ use cw_orch::interface; -use hydro::migration::v2_0_1::MigrateMsgV2_0_1; +use hydro::migration::v2_0_4::MigrateMsgV2_0_4; pub use hydro::msg::{ExecuteMsg, InstantiateMsg}; pub use hydro::query::QueryMsg; pub const CONTRACT_ID: &str = "hydro_contract"; -#[interface(InstantiateMsg, ExecuteMsg, QueryMsg, MigrateMsgV2_0_1, id = CONTRACT_ID)] +#[interface(InstantiateMsg, ExecuteMsg, QueryMsg, MigrateMsgV2_0_4, id = CONTRACT_ID)] pub struct Hydro; #[cfg(not(target_arch = "wasm32"))] diff --git a/packages/interface/src/tribute.rs b/packages/interface/src/tribute.rs index c425e17b..0d31a717 100644 --- a/packages/interface/src/tribute.rs +++ b/packages/interface/src/tribute.rs @@ -1,12 +1,12 @@ use cw_orch::interface; -use tribute::migration::v2_0_1::MigrateMsgV2_0_1; +use tribute::migration::v2_0_4::MigrateMsgV2_0_4; pub use tribute::msg::{ExecuteMsg, InstantiateMsg}; pub use tribute::query::QueryMsg; pub const CONTRACT_ID: &str = "tribute_contract"; -#[interface(InstantiateMsg, ExecuteMsg, QueryMsg, MigrateMsgV2_0_1, id = CONTRACT_ID)] +#[interface(InstantiateMsg, ExecuteMsg, QueryMsg, MigrateMsgV2_0_4, id = CONTRACT_ID)] pub struct Tribute; #[cfg(not(target_arch = "wasm32"))]