Skip to content

Commit

Permalink
Merge pull request #66 from centrifuge/lpv2-migration-upgrade
Browse files Browse the repository at this point in the history
Required to LPv2 Migration to pass from internal to public repo (WIP)
  • Loading branch information
wischli authored Jan 14, 2025
2 parents bbc9d36 + 185fe2c commit 4d69a7e
Show file tree
Hide file tree
Showing 15 changed files with 194 additions and 145 deletions.
3 changes: 0 additions & 3 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions pallets/axelar-router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ pub struct FeeValues {
pub mod pallet {
use super::*;

const STORAGE_VERSION: StorageVersion = StorageVersion::new(0);

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);

#[pallet::config]
Expand Down
4 changes: 0 additions & 4 deletions runtime/altair/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ pallet-interest-accrual = { workspace = true }
pallet-investments = { workspace = true }
pallet-keystore = { workspace = true }
pallet-liquidity-pools = { workspace = true }
pallet-liquidity-pools-forwarder = { workspace = true }
pallet-liquidity-pools-gateway = { workspace = true }
pallet-liquidity-pools-gateway-queue = { workspace = true }
pallet-liquidity-rewards = { workspace = true }
Expand Down Expand Up @@ -235,7 +234,6 @@ std = [
"pallet-investments/std",
"pallet-keystore/std",
"pallet-liquidity-pools/std",
"pallet-liquidity-pools-forwarder/std",
"pallet-liquidity-pools-gateway/std",
"pallet-liquidity-rewards/std",
"pallet-loans/std",
Expand Down Expand Up @@ -323,7 +321,6 @@ runtime-benchmarks = [
"pallet-investments/runtime-benchmarks",
"pallet-keystore/runtime-benchmarks",
"pallet-liquidity-pools/runtime-benchmarks",
"pallet-liquidity-pools-forwarder/runtime-benchmarks",
"pallet-liquidity-pools-gateway/runtime-benchmarks",
"pallet-liquidity-rewards/runtime-benchmarks",
"pallet-loans/runtime-benchmarks",
Expand Down Expand Up @@ -410,7 +407,6 @@ try-runtime = [
"pallet-investments/try-runtime",
"pallet-keystore/try-runtime",
"pallet-liquidity-pools/try-runtime",
"pallet-liquidity-pools-forwarder/try-runtime",
"pallet-liquidity-pools-gateway/try-runtime",
"pallet-liquidity-rewards/try-runtime",
"pallet-loans/try-runtime",
Expand Down
14 changes: 2 additions & 12 deletions runtime/altair/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1755,15 +1755,6 @@ impl pallet_liquidity_pools::Config for Runtime {
type WeightInfo = ();
}

impl pallet_liquidity_pools_forwarder::Config for Runtime {
type AdminOrigin = EnsureRootOr<HalfOfCouncil>;
type Message = pallet_liquidity_pools::Message;
type MessageReceiver = LiquidityPoolsGateway;
type MessageSender = MessageSerializer<RouterDispatcher<Runtime>, LiquidityPoolsForwarder>;
type RouterId = RouterId;
type RuntimeEvent = RuntimeEvent;
}

parameter_types! {
pub Sender: DomainAddress = gateway::get_gateway_domain_address::<Runtime>();
pub const MaxIncomingMessageSize: u32 = 1024;
Expand All @@ -1777,7 +1768,7 @@ impl pallet_liquidity_pools_gateway::Config for Runtime {
type MaxRouterCount = MaxRouterCount;
type Message = pallet_liquidity_pools::Message;
type MessageQueue = LiquidityPoolsGatewayQueue;
type MessageSender = LiquidityPoolsForwarder;
type MessageSender = MessageSerializer<RouterDispatcher<Runtime>, ()>;
type RouterId = RouterId;
type RouterProvider = LPGatewayRouterProvider;
type RuntimeEvent = RuntimeEvent;
Expand Down Expand Up @@ -1900,7 +1891,7 @@ impl pallet_ethereum_transaction::Config for Runtime {}
impl pallet_axelar_router::Config for Runtime {
type AdminOrigin = EnsureRoot<AccountId>;
type Middleware = RouterId;
type Receiver = MessageSerializer<RouterDispatcher<Runtime>, LiquidityPoolsForwarder>;
type Receiver = MessageSerializer<(), LiquidityPoolsGateway>;
type RuntimeEvent = RuntimeEvent;
type Transactor = EthereumTransaction;
}
Expand Down Expand Up @@ -2131,7 +2122,6 @@ construct_runtime!(
// Removed: Swaps = 200
TokenMux: pallet_token_mux::{Pallet, Call, Storage, Event<T>} = 201,
LiquidityPoolsGatewayQueue: pallet_liquidity_pools_gateway_queue::{Pallet, Call, Storage, Event<T>} = 202,
LiquidityPoolsForwarder: pallet_liquidity_pools_forwarder::{Pallet, Call, Storage, Event<T>} = 203,
}
);

Expand Down
12 changes: 11 additions & 1 deletion runtime/altair/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@
// GNU General Public License for more details.

use frame_support::migrations::VersionedMigration;
use sp_core::parameter_types;

use crate::Runtime;

parameter_types! {
pub PalletLiquidityPoolsAxelarGateway: &'static str = "LiquidityPoolsAxelarGateway";
}

/// The migration set for Altair @ Kusama.
/// It includes all the migrations that have to be applied on that chain.
pub type UpgradeAltair1403 = (
// Clear v0 RelayerList storage
// Remove deprecated LiquidityPoolsGateway::{v0, v1, v2}::RelayerList storage
runtime_common::migrations::liquidity_pools_v2::kill_relayer_list::Migration<Runtime>,
// Clear OutboundMessageNonceStore and migrate outbound storage to LP queue
runtime_common::migrations::liquidity_pools_v2::v0_init_message_queue::Migration<Runtime>,
Expand Down Expand Up @@ -49,4 +54,9 @@ pub type UpgradeAltair1403 = (
pallet_permissions::Pallet<Runtime>,
<Runtime as frame_system::Config>::DbWeight,
>,
// Remove deprecated LiquidityPoolsAxelarGateway
runtime_common::migrations::nuke::KillPallet<
PalletLiquidityPoolsAxelarGateway,
<Runtime as frame_system::Config>::DbWeight,
>,
);
4 changes: 0 additions & 4 deletions runtime/centrifuge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ pallet-interest-accrual = { workspace = true }
pallet-investments = { workspace = true }
pallet-keystore = { workspace = true }
pallet-liquidity-pools = { workspace = true }
pallet-liquidity-pools-forwarder = { workspace = true }
pallet-liquidity-pools-gateway = { workspace = true }
pallet-liquidity-pools-gateway-queue = { workspace = true }
pallet-liquidity-rewards = { workspace = true }
Expand Down Expand Up @@ -227,7 +226,6 @@ std = [
"pallet-investments/std",
"pallet-keystore/std",
"pallet-liquidity-pools/std",
"pallet-liquidity-pools-forwarder/std",
"pallet-liquidity-pools-gateway/std",
"pallet-liquidity-rewards/std",
"pallet-loans/std",
Expand Down Expand Up @@ -311,7 +309,6 @@ runtime-benchmarks = [
"pallet-investments/runtime-benchmarks",
"pallet-keystore/runtime-benchmarks",
"pallet-liquidity-pools/runtime-benchmarks",
"pallet-liquidity-pools-forwarder/runtime-benchmarks",
"pallet-liquidity-pools-gateway/runtime-benchmarks",
"pallet-liquidity-rewards/runtime-benchmarks",
"pallet-loans/runtime-benchmarks",
Expand Down Expand Up @@ -394,7 +391,6 @@ try-runtime = [
"pallet-investments/try-runtime",
"pallet-keystore/try-runtime",
"pallet-liquidity-pools/try-runtime",
"pallet-liquidity-pools-forwarder/try-runtime",
"pallet-liquidity-pools-gateway/try-runtime",
"pallet-liquidity-rewards/try-runtime",
"pallet-loans/try-runtime",
Expand Down
17 changes: 4 additions & 13 deletions runtime/centrifuge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1843,15 +1843,6 @@ parameter_types! {
pub const MaxRouterCount: u32 = 8;
}

impl pallet_liquidity_pools_forwarder::Config for Runtime {
type AdminOrigin = EnsureAccountOrRootOr<LpAdminAccount, TwoThirdOfCouncil>;
type Message = pallet_liquidity_pools::Message;
type MessageReceiver = LiquidityPoolsGateway;
type MessageSender = MessageSerializer<RouterDispatcher<Runtime>, LiquidityPoolsForwarder>;
type RouterId = RouterId;
type RuntimeEvent = RuntimeEvent;
}

parameter_types! {
// A temporary admin account for the LP logic
// This is a multi-sig controlled pure proxy on mainnet
Expand All @@ -1875,7 +1866,7 @@ impl pallet_liquidity_pools_gateway::Config for Runtime {
type MaxRouterCount = MaxRouterCount;
type Message = pallet_liquidity_pools::Message;
type MessageQueue = LiquidityPoolsGatewayQueue;
type MessageSender = LiquidityPoolsForwarder;
type MessageSender = MessageSerializer<RouterDispatcher<Runtime>, ()>;
type RouterId = RouterId;
type RouterProvider = LPGatewayRouterProvider;
type RuntimeEvent = RuntimeEvent;
Expand Down Expand Up @@ -1998,7 +1989,7 @@ impl pallet_ethereum_transaction::Config for Runtime {}
impl pallet_axelar_router::Config for Runtime {
type AdminOrigin = EnsureAccountOrRootOr<LpAdminAccount, TwoThirdOfCouncil>;
type Middleware = RouterId;
type Receiver = MessageSerializer<RouterDispatcher<Runtime>, LiquidityPoolsForwarder>;
type Receiver = MessageSerializer<(), LiquidityPoolsGateway>;
type RuntimeEvent = RuntimeEvent;
type Transactor = EthereumTransaction;
}
Expand Down Expand Up @@ -2102,7 +2093,6 @@ construct_runtime!(
Remarks: pallet_remarks::{Pallet, Call, Event<T>} = 113,
PoolFees: pallet_pool_fees::{Pallet, Call, Storage, Event<T>} = 114,
LiquidityPoolsGatewayQueue: pallet_liquidity_pools_gateway_queue::{Pallet, Call, Storage, Event<T>} = 115,
LiquidityPoolsForwarder: pallet_liquidity_pools_forwarder::{Pallet, Call, Storage, Event<T>} = 116,

// XCM
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 120,
Expand All @@ -2126,7 +2116,8 @@ construct_runtime!(
BaseFee: pallet_base_fee::{Pallet, Call, Config<T>, Storage, Event} = 162,
Ethereum: pallet_ethereum::{Pallet, Config<T>, Call, Storage, Event, Origin} = 163,
EthereumTransaction: pallet_ethereum_transaction::{Pallet, Storage} = 164,
AxelarRouter: pallet_axelar_router::{Pallet, Call, Storage, Event<T>} = 165,
// Removed: LiquidityPoolsAxelarGateway = 165
AxelarRouter: pallet_axelar_router::{Pallet, Call, Storage, Event<T>} = 166,

// Synced pallets across all runtimes - Range: 180-240
// WHY: * integrations like fireblocks will need to know the index in the enum
Expand Down
16 changes: 13 additions & 3 deletions runtime/centrifuge/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@
// GNU General Public License for more details.

use frame_support::migrations::VersionedMigration;
use sp_core::parameter_types;

use crate::Runtime;

parameter_types! {
pub PalletLiquidityPoolsAxelarGateway: &'static str = "LiquidityPoolsAxelarGateway";
}

/// The migration set for Centrifuge @ Polkadot.
/// It includes all the migrations that have to be applied on that chain.
pub type UpgradeCentrifuge1403 = (
// Clear v0 RelayerList storage
// Remove deprecated LiquidityPoolsGateway::{v0, v1, v2}::RelayerList storage
runtime_common::migrations::liquidity_pools_v2::kill_relayer_list::Migration<Runtime>,
// Clear OutboundMessageNonceStore and migrate outbound storage to LP queue
runtime_common::migrations::liquidity_pools_v2::v0_init_message_queue::Migration<Runtime>,
Expand All @@ -29,8 +34,8 @@ pub type UpgradeCentrifuge1403 = (
pallet_liquidity_pools_gateway::Pallet<Runtime>,
<Runtime as frame_system::Config>::DbWeight,
>,
// Remove deprecated RelayerList storage
runtime_common::migrations::liquidity_pools_v2::kill_relayer_list::Migration<Runtime>,
// Remove deprecated LiquidityPoolsGateway::{v0, v1, v2}::Allowlist storage
runtime_common::migrations::liquidity_pools_v2::kill_allowlist::Migration<Runtime, 20>,
// Remove undecodable ForeignInvestmentInfo v0 entries
runtime_common::migrations::foreign_investments_v2::Migration<Runtime>,
// Bump to v1
Expand All @@ -51,4 +56,9 @@ pub type UpgradeCentrifuge1403 = (
pallet_permissions::Pallet<Runtime>,
<Runtime as frame_system::Config>::DbWeight,
>,
// Remove deprecated LiquidityPoolsAxelarGateway
runtime_common::migrations::nuke::KillPallet<
PalletLiquidityPoolsAxelarGateway,
<Runtime as frame_system::Config>::DbWeight,
>,
);
Loading

0 comments on commit 4d69a7e

Please sign in to comment.