From 232ec78522359fa1276dc58baf568c3f0e1a6a31 Mon Sep 17 00:00:00 2001 From: lemunozm Date: Fri, 20 Dec 2024 10:35:31 +0100 Subject: [PATCH 01/12] basics --- .../src/migrations/liquidity_pools_v2.rs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/runtime/common/src/migrations/liquidity_pools_v2.rs b/runtime/common/src/migrations/liquidity_pools_v2.rs index b33ba9d73e..bbdd7fec49 100644 --- a/runtime/common/src/migrations/liquidity_pools_v2.rs +++ b/runtime/common/src/migrations/liquidity_pools_v2.rs @@ -540,10 +540,13 @@ pub mod init_axelar_router { chain_id: EVMChainId, domain: &Domain, ) -> DispatchResult { + // Read v0::gateway::AllowList storage => addr1 + // Read v0::axelar-gateway-precompile::GatewayContract => addr 2 + pallet_axelar_router::Pallet::::set_config( T::RuntimeOrigin::root(), router.evm_chain.clone(), - Box::new(router.migrate_to_domain_config(chain_id)), + Box::new(router.migrate_to_domain_config(chain_id /* , addr1, addr2 */)), ) .map_err(|e| { log::error!( @@ -773,18 +776,17 @@ mod types { From + Into>>, { pub(crate) fn migrate_to_domain_config(&self, chain_id: EVMChainId) -> AxelarConfig { - todo!() - /* AxelarConfig { - liquidity_pools_contract_address: self.liquidity_pools_contract_address, + app_contract_address: todo!("previous value in gateway::AllowList storage"), + inbound_contract_address: todo!( + "previous axelar-gateway-precompile::GatewayContract storage", + ), + outbound_contract_address: self.liquidity_pools_contract_address, domain: DomainConfig::Evm(EvmConfig { - chain_id, - target_contract_address: self.router.evm_domain.target_contract_address, - target_contract_hash: self.router.evm_domain.target_contract_hash, - fee_values: self.router.evm_domain.fee_values.clone(), + chain_id: chain_id, + outbound_fee_values: self.router.evm_domain.fee_values.clone(), }), - } - */ + }; } } From 3ebac85291674df87e003a94a4e4c0f09f4575ff Mon Sep 17 00:00:00 2001 From: lemunozm Date: Fri, 20 Dec 2024 11:16:32 +0100 Subject: [PATCH 02/12] add previous storages --- .../common/src/migrations/liquidity_pools_v2.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/runtime/common/src/migrations/liquidity_pools_v2.rs b/runtime/common/src/migrations/liquidity_pools_v2.rs index bbdd7fec49..7c30c51bb2 100644 --- a/runtime/common/src/migrations/liquidity_pools_v2.rs +++ b/runtime/common/src/migrations/liquidity_pools_v2.rs @@ -757,6 +757,20 @@ mod types { AxelarXCM(AxelarXCMRouter), } + #[storage_alias] + pub type GatewayContract = + StorageValue, H160, ValueQuery>; + + #[storage_alias] + pub type Allowlist = StorageDoubleMap< + pallet_liquidity_pools_gateway::Pallet, + Blake2_128Concat, + Domain, + Blake2_128Concat, + DomainAddress, + (), + >; + #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] pub struct AxelarEVMRouter where From 263da203d00f851c8b0e8b58718e79b140b2c18b Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Fri, 10 Jan 2025 07:52:26 +0100 Subject: [PATCH 03/12] fix: rm forwarder from Cfg runtime --- Cargo.lock | 1 - runtime/centrifuge/Cargo.toml | 4 ---- runtime/centrifuge/src/lib.rs | 14 ++------------ 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 525ea3542b..fa681fe005 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1503,7 +1503,6 @@ dependencies = [ "pallet-investments", "pallet-keystore", "pallet-liquidity-pools", - "pallet-liquidity-pools-forwarder", "pallet-liquidity-pools-gateway", "pallet-liquidity-pools-gateway-queue", "pallet-liquidity-rewards", diff --git a/runtime/centrifuge/Cargo.toml b/runtime/centrifuge/Cargo.toml index 4fb42616de..0a4f83b50f 100644 --- a/runtime/centrifuge/Cargo.toml +++ b/runtime/centrifuge/Cargo.toml @@ -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 } @@ -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", @@ -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", @@ -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", diff --git a/runtime/centrifuge/src/lib.rs b/runtime/centrifuge/src/lib.rs index eb1683262e..55213a18da 100644 --- a/runtime/centrifuge/src/lib.rs +++ b/runtime/centrifuge/src/lib.rs @@ -1843,15 +1843,6 @@ parameter_types! { pub const MaxRouterCount: u32 = 8; } -impl pallet_liquidity_pools_forwarder::Config for Runtime { - type AdminOrigin = EnsureAccountOrRootOr; - type Message = pallet_liquidity_pools::Message; - type MessageReceiver = LiquidityPoolsGateway; - type MessageSender = MessageSerializer, 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 @@ -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, ()>; type RouterId = RouterId; type RouterProvider = LPGatewayRouterProvider; type RuntimeEvent = RuntimeEvent; @@ -1998,7 +1989,7 @@ impl pallet_ethereum_transaction::Config for Runtime {} impl pallet_axelar_router::Config for Runtime { type AdminOrigin = EnsureAccountOrRootOr; type Middleware = RouterId; - type Receiver = MessageSerializer, LiquidityPoolsForwarder>; + type Receiver = MessageSerializer<(), LiquidityPoolsGateway>; type RuntimeEvent = RuntimeEvent; type Transactor = EthereumTransaction; } @@ -2102,7 +2093,6 @@ construct_runtime!( Remarks: pallet_remarks::{Pallet, Call, Event} = 113, PoolFees: pallet_pool_fees::{Pallet, Call, Storage, Event} = 114, LiquidityPoolsGatewayQueue: pallet_liquidity_pools_gateway_queue::{Pallet, Call, Storage, Event} = 115, - LiquidityPoolsForwarder: pallet_liquidity_pools_forwarder::{Pallet, Call, Storage, Event} = 116, // XCM XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event} = 120, From 978d4d19dff53c1ea4d25c859163c21ff6c5a8bb Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Fri, 10 Jan 2025 08:01:17 +0100 Subject: [PATCH 04/12] chore: rm wip comment --- runtime/common/src/migrations/liquidity_pools_v2.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/runtime/common/src/migrations/liquidity_pools_v2.rs b/runtime/common/src/migrations/liquidity_pools_v2.rs index 690800df5a..544ac79386 100644 --- a/runtime/common/src/migrations/liquidity_pools_v2.rs +++ b/runtime/common/src/migrations/liquidity_pools_v2.rs @@ -142,10 +142,6 @@ pub mod v2_update_message_queue { fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { assert!( v2::MessageQueue::::iter_values().all(|message| match message { - // TODO: Investigate whether current GatewayMessage should contain domain - // instead (newer commit than on public) - // Ref public: https://github.com/centrifuge/centrifuge-chain/blame/main/pallets/liquidity-pools-gateway/src/message.rs#L8 - // Ref internal: https://github.com/centrifuge/centrifuge-chain-internal/blame/main/pallets/liquidity-pools-gateway/src/message.rs#L8 v2::GatewayMessage::::Inbound { domain_address, .. } => maybe_router_id(domain_address.domain()).is_some(), @@ -157,7 +153,6 @@ pub mod v2_update_message_queue { assert!(v2::FailedMessageQueue::::iter_values() .into_iter() .all(|(message, _)| match message { - // TODO: See above v2::GatewayMessage::::Inbound { domain_address, .. } => maybe_router_id(domain_address.domain()).is_some(), From 74e095f48a1042ac7046f5711bd10202cc1ae718 Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Mon, 13 Jan 2025 15:50:04 +0100 Subject: [PATCH 05/12] feat: add allowlist removal --- runtime/centrifuge/src/migrations.rs | 6 +- .../src/migrations/liquidity_pools_v2.rs | 57 +++++++++++++++++++ runtime/development/src/migrations.rs | 7 ++- 3 files changed, 66 insertions(+), 4 deletions(-) diff --git a/runtime/centrifuge/src/migrations.rs b/runtime/centrifuge/src/migrations.rs index 36f6728690..98ccc69e2a 100644 --- a/runtime/centrifuge/src/migrations.rs +++ b/runtime/centrifuge/src/migrations.rs @@ -17,7 +17,7 @@ use crate::Runtime; /// 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, // Clear OutboundMessageNonceStore and migrate outbound storage to LP queue runtime_common::migrations::liquidity_pools_v2::v0_init_message_queue::Migration, @@ -29,8 +29,8 @@ pub type UpgradeCentrifuge1403 = ( pallet_liquidity_pools_gateway::Pallet, ::DbWeight, >, - // Remove deprecated RelayerList storage - runtime_common::migrations::liquidity_pools_v2::kill_relayer_list::Migration, + // Remove deprecated LiquidityPoolsGateway::{v0, v1, v2}::Allowlist storage + runtime_common::migrations::liquidity_pools_v2::kill_allowlist::Migration, // Remove undecodable ForeignInvestmentInfo v0 entries runtime_common::migrations::foreign_investments_v2::Migration, // Bump to v1 diff --git a/runtime/common/src/migrations/liquidity_pools_v2.rs b/runtime/common/src/migrations/liquidity_pools_v2.rs index 71991db724..1bb5a7b247 100644 --- a/runtime/common/src/migrations/liquidity_pools_v2.rs +++ b/runtime/common/src/migrations/liquidity_pools_v2.rs @@ -97,6 +97,63 @@ pub mod kill_relayer_list { } } +pub mod kill_allowlist { + use frame_support::traits::OnRuntimeUpgrade; + #[cfg(feature = "try-runtime")] + use frame_support::{dispatch::DispatchResult, storage::with_storage_layer}; + #[cfg(feature = "try-runtime")] + use sp_arithmetic::traits::Zero; + #[cfg(feature = "try-runtime")] + use sp_std::vec; + + use super::{types::v0, *}; + use crate::migrations::nuke::storage_clean_res_log; + + const LOG_PREFIX: &str = "ClearAllowlist"; + + pub struct Migration(PhantomData); + + impl OnRuntimeUpgrade for Migration + where + T: pallet_liquidity_pools_gateway::Config, + { + fn on_runtime_upgrade() -> Weight { + let res = v0::Allowlist::::clear(REMOVAL_ITEM_LIMIT, None); + storage_clean_res_log(&res, "Allowlist", LOG_PREFIX); + + log::info!("{LOG_PREFIX}: Migration done!"); + + T::DbWeight::get().reads_writes(res.loops.into(), res.unique.into()) + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + let mut cleared: bool = false; + + // Need to rollback in order to be NOOP + let _ = with_storage_layer(|| -> DispatchResult { + cleared = v0::Allowlist::::clear(REMOVAL_ITEM_LIMIT, None) + .maybe_cursor + .is_none(); + Err(DispatchError::Other("Reverting on purpose")) + }); + assert!(cleared); + + log::info!("{LOG_PREFIX}: Pre checks done!"); + + Ok(vec![]) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(_: Vec) -> Result<(), sp_runtime::TryRuntimeError> { + assert!(v0::Allowlist::::iter_keys().count().is_zero()); + log::info!("{LOG_PREFIX}: Post checks done!"); + + Ok(()) + } + } +} + pub mod v2_update_message_queue { use pallet_liquidity_pools::Message; use pallet_liquidity_pools_gateway::message::GatewayMessage; diff --git a/runtime/development/src/migrations.rs b/runtime/development/src/migrations.rs index 19ec695e22..a080639708 100644 --- a/runtime/development/src/migrations.rs +++ b/runtime/development/src/migrations.rs @@ -15,8 +15,9 @@ use frame_support::migrations::VersionedMigration; use crate::Runtime; pub type UpgradeDevelopment1403 = ( - runtime_common::migrations::liquidity_pools_v2::kill_relayer_list::Migration, + // Clear OutboundMessageNonceStore and migrate outbound storage to LP queue runtime_common::migrations::liquidity_pools_v2::v2_update_message_queue::Migration, + // Remove deprecated DomainRouters entries and migrate relevant ones to Axelar Router Config VersionedMigration< 2, 3, @@ -24,4 +25,8 @@ pub type UpgradeDevelopment1403 = ( pallet_liquidity_pools_gateway::Pallet, ::DbWeight, >, + // Remove deprecated LiquidityPoolsGateway::{v0, v1, v2}::RelayerList storage + runtime_common::migrations::liquidity_pools_v2::kill_relayer_list::Migration, + // Remove deprecated LiquidityPoolsGateway::{v0, v1, v2}::Allowlist storage + runtime_common::migrations::liquidity_pools_v2::kill_allowlist::Migration, ); From e3020783275f538071fee33e5336e99a85cd515b Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Mon, 13 Jan 2025 16:57:26 +0100 Subject: [PATCH 06/12] chore: add storage version to axelar router --- pallets/axelar-router/src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pallets/axelar-router/src/lib.rs b/pallets/axelar-router/src/lib.rs index 5f9ffd3009..de789ef8fd 100644 --- a/pallets/axelar-router/src/lib.rs +++ b/pallets/axelar-router/src/lib.rs @@ -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(_); #[pallet::config] From 07b2afc33bf44ffd202fd725379a946a730d5165 Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Mon, 13 Jan 2025 17:29:38 +0100 Subject: [PATCH 07/12] feat: clear deprecated LiquidityPoolsAxelarGateway pallet --- runtime/centrifuge/src/lib.rs | 3 ++- runtime/centrifuge/src/migrations.rs | 10 ++++++++++ runtime/development/src/migrations.rs | 12 +++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/runtime/centrifuge/src/lib.rs b/runtime/centrifuge/src/lib.rs index 55213a18da..503d9c02a7 100644 --- a/runtime/centrifuge/src/lib.rs +++ b/runtime/centrifuge/src/lib.rs @@ -2116,7 +2116,8 @@ construct_runtime!( BaseFee: pallet_base_fee::{Pallet, Call, Config, Storage, Event} = 162, Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 163, EthereumTransaction: pallet_ethereum_transaction::{Pallet, Storage} = 164, - AxelarRouter: pallet_axelar_router::{Pallet, Call, Storage, Event} = 165, + // Removed: LiquidityPoolsAxelarGateway = 165 + AxelarRouter: pallet_axelar_router::{Pallet, Call, Storage, Event} = 166, // Synced pallets across all runtimes - Range: 180-240 // WHY: * integrations like fireblocks will need to know the index in the enum diff --git a/runtime/centrifuge/src/migrations.rs b/runtime/centrifuge/src/migrations.rs index 98ccc69e2a..78ff224746 100644 --- a/runtime/centrifuge/src/migrations.rs +++ b/runtime/centrifuge/src/migrations.rs @@ -11,9 +11,14 @@ // 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 = ( @@ -51,4 +56,9 @@ pub type UpgradeCentrifuge1403 = ( pallet_permissions::Pallet, ::DbWeight, >, + // Remove deprecated LiquidityPoolsAxelarGateway + runtime_common::migrations::nuke::KillPallet< + PalletLiquidityPoolsAxelarGateway, + ::DbWeight, + >, ); diff --git a/runtime/development/src/migrations.rs b/runtime/development/src/migrations.rs index a080639708..4c4c59f8ce 100644 --- a/runtime/development/src/migrations.rs +++ b/runtime/development/src/migrations.rs @@ -11,9 +11,14 @@ // 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"; +} + pub type UpgradeDevelopment1403 = ( // Clear OutboundMessageNonceStore and migrate outbound storage to LP queue runtime_common::migrations::liquidity_pools_v2::v2_update_message_queue::Migration, @@ -25,8 +30,13 @@ pub type UpgradeDevelopment1403 = ( pallet_liquidity_pools_gateway::Pallet, ::DbWeight, >, - // Remove deprecated LiquidityPoolsGateway::{v0, v1, v2}::RelayerList storage + // Remove deprecated LiquidityPoolsGateway::{v0, v1, v2}::RelayerList storag runtime_common::migrations::liquidity_pools_v2::kill_relayer_list::Migration, // Remove deprecated LiquidityPoolsGateway::{v0, v1, v2}::Allowlist storage runtime_common::migrations::liquidity_pools_v2::kill_allowlist::Migration, + // Remove deprecated LiquidityPoolsAxelarGateway + runtime_common::migrations::nuke::KillPallet< + PalletLiquidityPoolsAxelarGateway, + ::DbWeight, + >, ); From dea1cbed500480cf072a511009629df07abd2f4a Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Mon, 13 Jan 2025 17:29:57 +0100 Subject: [PATCH 08/12] chore: remove forwarder from dev runtime --- Cargo.lock | 1 - runtime/development/Cargo.toml | 4 ---- runtime/development/src/lib.rs | 14 ++------------ 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fa681fe005..f15381b496 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3116,7 +3116,6 @@ dependencies = [ "pallet-investments", "pallet-keystore", "pallet-liquidity-pools", - "pallet-liquidity-pools-forwarder", "pallet-liquidity-pools-gateway", "pallet-liquidity-pools-gateway-queue", "pallet-liquidity-rewards", diff --git a/runtime/development/Cargo.toml b/runtime/development/Cargo.toml index 8391926851..ac92c94e31 100644 --- a/runtime/development/Cargo.toml +++ b/runtime/development/Cargo.toml @@ -106,7 +106,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 } @@ -237,7 +236,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", @@ -325,7 +323,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", @@ -413,7 +410,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", diff --git a/runtime/development/src/lib.rs b/runtime/development/src/lib.rs index 4c8ee882b8..2b157632df 100644 --- a/runtime/development/src/lib.rs +++ b/runtime/development/src/lib.rs @@ -1859,15 +1859,6 @@ impl pallet_liquidity_pools::Config for Runtime { type WeightInfo = (); } -impl pallet_liquidity_pools_forwarder::Config for Runtime { - type AdminOrigin = EnsureRootOr; - type Message = pallet_liquidity_pools::Message; - type MessageReceiver = LiquidityPoolsGateway; - type MessageSender = MessageSerializer, LiquidityPoolsForwarder>; - type RouterId = RouterId; - type RuntimeEvent = RuntimeEvent; -} - parameter_types! { pub Sender: DomainAddress = gateway::get_gateway_domain_address::(); pub const MaxIncomingMessageSize: u32 = 1024; @@ -1881,7 +1872,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, ()>; type RouterId = RouterId; type RouterProvider = LPGatewayRouterProvider; type RuntimeEvent = RuntimeEvent; @@ -2005,7 +1996,7 @@ impl pallet_ethereum_transaction::Config for Runtime {} impl pallet_axelar_router::Config for Runtime { type AdminOrigin = EnsureRoot; type Middleware = RouterId; - type Receiver = MessageSerializer, LiquidityPoolsForwarder>; + type Receiver = MessageSerializer<(), LiquidityPoolsGateway>; type RuntimeEvent = RuntimeEvent; type Transactor = EthereumTransaction; } @@ -2210,7 +2201,6 @@ construct_runtime!( // our pallets part 2 AnchorsV2: pallet_anchors_v2::{Pallet, Call, Storage, Event} = 130, LiquidityPoolsGatewayQueue: pallet_liquidity_pools_gateway_queue::{Pallet, Call, Storage, Event} = 131, - LiquidityPoolsForwarder: pallet_liquidity_pools_forwarder::{Pallet, Call, Storage, Event} = 132, // XCM XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event} = 120, From 02f8f62cdf26fc6cd6650ea4b80c5678685f6a59 Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Mon, 13 Jan 2025 17:37:43 +0100 Subject: [PATCH 09/12] chore: remove forwarder from altair runtime --- Cargo.lock | 1 - runtime/altair/Cargo.toml | 4 ---- runtime/altair/src/lib.rs | 14 ++------------ 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f15381b496..6f8e3a8859 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -180,7 +180,6 @@ dependencies = [ "pallet-investments", "pallet-keystore", "pallet-liquidity-pools", - "pallet-liquidity-pools-forwarder", "pallet-liquidity-pools-gateway", "pallet-liquidity-pools-gateway-queue", "pallet-liquidity-rewards", diff --git a/runtime/altair/Cargo.toml b/runtime/altair/Cargo.toml index 9393852b18..ea5009dd4e 100644 --- a/runtime/altair/Cargo.toml +++ b/runtime/altair/Cargo.toml @@ -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 } @@ -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", @@ -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", @@ -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", diff --git a/runtime/altair/src/lib.rs b/runtime/altair/src/lib.rs index 549f6756df..b4265f14f7 100644 --- a/runtime/altair/src/lib.rs +++ b/runtime/altair/src/lib.rs @@ -1755,15 +1755,6 @@ impl pallet_liquidity_pools::Config for Runtime { type WeightInfo = (); } -impl pallet_liquidity_pools_forwarder::Config for Runtime { - type AdminOrigin = EnsureRootOr; - type Message = pallet_liquidity_pools::Message; - type MessageReceiver = LiquidityPoolsGateway; - type MessageSender = MessageSerializer, LiquidityPoolsForwarder>; - type RouterId = RouterId; - type RuntimeEvent = RuntimeEvent; -} - parameter_types! { pub Sender: DomainAddress = gateway::get_gateway_domain_address::(); pub const MaxIncomingMessageSize: u32 = 1024; @@ -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, ()>; type RouterId = RouterId; type RouterProvider = LPGatewayRouterProvider; type RuntimeEvent = RuntimeEvent; @@ -1900,7 +1891,7 @@ impl pallet_ethereum_transaction::Config for Runtime {} impl pallet_axelar_router::Config for Runtime { type AdminOrigin = EnsureRoot; type Middleware = RouterId; - type Receiver = MessageSerializer, LiquidityPoolsForwarder>; + type Receiver = MessageSerializer<(), LiquidityPoolsGateway>; type RuntimeEvent = RuntimeEvent; type Transactor = EthereumTransaction; } @@ -2131,7 +2122,6 @@ construct_runtime!( // Removed: Swaps = 200 TokenMux: pallet_token_mux::{Pallet, Call, Storage, Event} = 201, LiquidityPoolsGatewayQueue: pallet_liquidity_pools_gateway_queue::{Pallet, Call, Storage, Event} = 202, - LiquidityPoolsForwarder: pallet_liquidity_pools_forwarder::{Pallet, Call, Storage, Event} = 203, } ); From ffbd2dbf04d6109539d5b9b2f91c4bc71665a5b1 Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Mon, 13 Jan 2025 17:38:06 +0100 Subject: [PATCH 10/12] fix: clippy --- runtime/common/src/migrations/liquidity_pools_v2.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/runtime/common/src/migrations/liquidity_pools_v2.rs b/runtime/common/src/migrations/liquidity_pools_v2.rs index 1bb5a7b247..dc9d69fd3f 100644 --- a/runtime/common/src/migrations/liquidity_pools_v2.rs +++ b/runtime/common/src/migrations/liquidity_pools_v2.rs @@ -425,11 +425,10 @@ pub mod v0_init_message_queue { pub mod init_axelar_router { use cfg_types::{domain_address::DomainAddress, EVMChainId}; #[cfg(feature = "try-runtime")] + use frame_support::dispatch::DispatchResult; + #[cfg(feature = "try-runtime")] use frame_support::storage::transactional; - use frame_support::{ - dispatch::DispatchResult, - traits::{GetStorageVersion, OriginTrait, StorageVersion}, - }; + use frame_support::traits::{GetStorageVersion, OriginTrait, StorageVersion}; use frame_system::pallet_prelude::OriginFor; #[cfg(feature = "try-runtime")] use sp_arithmetic::traits::SaturatedConversion; From e5370b35cdc292da5e1d08340bb59d5a0dd0e731 Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Mon, 13 Jan 2025 22:26:15 +0100 Subject: [PATCH 11/12] chore: add migration to altair --- runtime/altair/src/migrations.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/runtime/altair/src/migrations.rs b/runtime/altair/src/migrations.rs index 2b08b593c2..7afdd9df0c 100644 --- a/runtime/altair/src/migrations.rs +++ b/runtime/altair/src/migrations.rs @@ -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, // Clear OutboundMessageNonceStore and migrate outbound storage to LP queue runtime_common::migrations::liquidity_pools_v2::v0_init_message_queue::Migration, @@ -49,4 +54,9 @@ pub type UpgradeAltair1403 = ( pallet_permissions::Pallet, ::DbWeight, >, + // Remove deprecated LiquidityPoolsAxelarGateway + runtime_common::migrations::nuke::KillPallet< + PalletLiquidityPoolsAxelarGateway, + ::DbWeight, + >, ); From 05b77d6ed23e9e0a60441dc80f582f40fa4a22f9 Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Mon, 13 Jan 2025 22:27:29 +0100 Subject: [PATCH 12/12] chore: remove forwarder integration tests --- runtime/integration-tests/src/cases.rs | 1 - .../integration-tests/src/cases/forwarder.rs | 45 ------------------- runtime/integration-tests/src/config.rs | 1 - 3 files changed, 47 deletions(-) delete mode 100644 runtime/integration-tests/src/cases/forwarder.rs diff --git a/runtime/integration-tests/src/cases.rs b/runtime/integration-tests/src/cases.rs index 5804e2b963..6a79cd5c84 100644 --- a/runtime/integration-tests/src/cases.rs +++ b/runtime/integration-tests/src/cases.rs @@ -5,7 +5,6 @@ mod currency_conversions; mod ethereum_transaction; mod example; mod foreign_investments; -mod forwarder; mod investments; mod loans; mod lp; diff --git a/runtime/integration-tests/src/cases/forwarder.rs b/runtime/integration-tests/src/cases/forwarder.rs deleted file mode 100644 index fc9b2a1967..0000000000 --- a/runtime/integration-tests/src/cases/forwarder.rs +++ /dev/null @@ -1,45 +0,0 @@ -use cfg_traits::liquidity_pools::MessageProcessor; -use cfg_types::{domain_address::Domain, EVMChainId}; -use frame_support::{assert_err, assert_ok, dispatch::RawOrigin, BoundedVec}; -use pallet_liquidity_pools::Message; -use pallet_liquidity_pools_gateway::message::GatewayMessage; -use runtime_common::routing::{AxelarId, RouterId}; -use sp_core::H160; - -use crate::{config::Runtime, env::Env, envs::runtime_env::RuntimeEnv}; - -const CHAIN_ID: EVMChainId = 1; -const FORWARDED_CONTRACT: H160 = H160::repeat_byte(1); -const ROUTER_ID: RouterId = RouterId::Axelar(AxelarId::Evm(CHAIN_ID)); - -#[test_runtimes(all)] -fn send() { - let mut env = RuntimeEnv::::default(); - - env.parachain_state_mut(|| { - assert_ok!(pallet_liquidity_pools_gateway::Pallet::::set_routers( - RawOrigin::Root.into(), - BoundedVec::try_from(vec![ROUTER_ID]).unwrap(), - )); - - assert_ok!( - pallet_liquidity_pools_forwarder::Pallet::::set_forwarder( - RawOrigin::Root.into(), - ROUTER_ID, - Domain::Centrifuge, // NOTE: this parameter will be removed - FORWARDED_CONTRACT, - ) - ); - - let gateway_message = GatewayMessage::Outbound { - router_id: ROUTER_ID, - message: Message::Invalid, - }; - - // If the message reach the router, it worked - assert_err!( - pallet_liquidity_pools_gateway::Pallet::::process(gateway_message).0, - pallet_axelar_router::Error::::RouterConfigurationNotFound - ); - }); -} diff --git a/runtime/integration-tests/src/config.rs b/runtime/integration-tests/src/config.rs index e68dcbef93..2898b6e1ef 100644 --- a/runtime/integration-tests/src/config.rs +++ b/runtime/integration-tests/src/config.rs @@ -183,7 +183,6 @@ pub trait Runtime: Balance = Balance, Rewards = pallet_rewards::Pallet, > + pallet_axelar_router::Config - + pallet_liquidity_pools_forwarder::Config + pallet_token_mux::Config< BalanceIn = Balance, BalanceOut = Balance,