From c55e74f8db5af38a0dce3fed8a73c31a54ff78dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Enrique=20Mu=C3=B1oz=20Mart=C3=ADn?= Date: Sun, 18 Aug 2024 22:58:33 +0200 Subject: [PATCH] Clean: Remove unused gateway origin (#1976) * remove unused gateway origin * fix: reanchor submodule to 6e8f1a29dff0d7cf5ff74285cfffadae8a8b303f --------- Co-authored-by: William Freudenberger --- pallets/liquidity-pools-gateway/src/lib.rs | 20 +--------- pallets/liquidity-pools-gateway/src/mock.rs | 4 +- pallets/liquidity-pools-gateway/src/origin.rs | 37 ------------------- runtime/altair/src/lib.rs | 4 +- runtime/centrifuge/src/lib.rs | 4 +- runtime/development/src/lib.rs | 4 +- runtime/integration-tests/src/config.rs | 3 +- .../submodules/liquidity-pools | 2 +- 8 files changed, 8 insertions(+), 70 deletions(-) delete mode 100644 pallets/liquidity-pools-gateway/src/origin.rs diff --git a/pallets/liquidity-pools-gateway/src/lib.rs b/pallets/liquidity-pools-gateway/src/lib.rs index 5cb0b47712..2af042d319 100644 --- a/pallets/liquidity-pools-gateway/src/lib.rs +++ b/pallets/liquidity-pools-gateway/src/lib.rs @@ -50,17 +50,15 @@ use crate::{ weights::WeightInfo, }; -mod origin; -pub use origin::*; - pub mod message; pub mod weights; +mod message_processing; + #[cfg(test)] mod mock; -mod message_processing; #[cfg(test)] mod tests; @@ -74,25 +72,11 @@ pub mod pallet { #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); - #[pallet::origin] - pub type Origin = GatewayOrigin; - #[pallet::config] pub trait Config: frame_system::Config { - /// The origin type. - type RuntimeOrigin: Into::RuntimeOrigin>> - + From; - /// The event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; - /// The LocalOrigin ensures that some calls can only be performed from a - /// local context i.e. a different pallet. - type LocalEVMOrigin: EnsureOrigin< - ::RuntimeOrigin, - Success = GatewayOrigin, - >; - /// The AdminOrigin ensures that some calls can only be performed by /// admins. type AdminOrigin: EnsureOrigin<::RuntimeOrigin>; diff --git a/pallets/liquidity-pools-gateway/src/mock.rs b/pallets/liquidity-pools-gateway/src/mock.rs index d082646f37..910e2a6545 100644 --- a/pallets/liquidity-pools-gateway/src/mock.rs +++ b/pallets/liquidity-pools-gateway/src/mock.rs @@ -16,7 +16,7 @@ use scale_info::TypeInfo; use sp_core::{crypto::AccountId32, H160}; use sp_runtime::{traits::IdentityLookup, DispatchError, DispatchResult}; -use crate::{pallet as pallet_liquidity_pools_gateway, EnsureLocal, GatewayMessage}; +use crate::{pallet as pallet_liquidity_pools_gateway, GatewayMessage}; pub const TEST_SESSION_ID: u32 = 1; pub const TEST_EVM_CHAIN: EVMChainId = 1; @@ -202,7 +202,6 @@ frame_support::parameter_types! { impl pallet_liquidity_pools_gateway::Config for Runtime { type AdminOrigin = EnsureRoot; type InboundMessageHandler = MockLiquidityPools; - type LocalEVMOrigin = EnsureLocal; type MaxIncomingMessageSize = MaxIncomingMessageSize; type MaxRouterCount = MaxRouterCount; type Message = Message; @@ -211,7 +210,6 @@ impl pallet_liquidity_pools_gateway::Config for Runtime { type RouterId = RouterId; type RouterProvider = TestRouterProvider; type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; type Sender = Sender; type SessionId = u32; type WeightInfo = (); diff --git a/pallets/liquidity-pools-gateway/src/origin.rs b/pallets/liquidity-pools-gateway/src/origin.rs deleted file mode 100644 index a09675b699..0000000000 --- a/pallets/liquidity-pools-gateway/src/origin.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2023 Centrifuge Foundation (centrifuge.io). -// -// This file is part of the Centrifuge chain project. -// Centrifuge is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version (see http://www.gnu.org/licenses). -// Centrifuge is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -use cfg_types::domain_address::DomainAddress; -use frame_support::traits::EnsureOrigin; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use scale_info::TypeInfo; -use sp_runtime::RuntimeDebug; - -#[derive(Clone, Eq, PartialEq, RuntimeDebug, Encode, Decode, MaxEncodedLen, TypeInfo)] -pub enum GatewayOrigin { - Domain(DomainAddress), -} - -pub struct EnsureLocal; - -impl> + From> EnsureOrigin for EnsureLocal { - type Success = GatewayOrigin; - - fn try_origin(o: O) -> Result { - o.into() - } - - #[cfg(feature = "runtime-benchmarks")] - fn try_successful_origin() -> Result { - unimplemented!() - } -} diff --git a/runtime/altair/src/lib.rs b/runtime/altair/src/lib.rs index 88056e59c9..cee137b4fb 100644 --- a/runtime/altair/src/lib.rs +++ b/runtime/altair/src/lib.rs @@ -1775,7 +1775,6 @@ parameter_types! { impl pallet_liquidity_pools_gateway::Config for Runtime { type AdminOrigin = EnsureRoot; type InboundMessageHandler = LiquidityPools; - type LocalEVMOrigin = pallet_liquidity_pools_gateway::EnsureLocal; type MaxIncomingMessageSize = MaxIncomingMessageSize; type MaxRouterCount = MaxRouterCount; type Message = pallet_liquidity_pools::Message; @@ -1784,7 +1783,6 @@ impl pallet_liquidity_pools_gateway::Config for Runtime { type RouterId = RouterId; type RouterProvider = LPGatewayRouterProvider; type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; type Sender = Sender; type SessionId = LPGatewaySessionId; type WeightInfo = (); @@ -2096,7 +2094,7 @@ construct_runtime!( BlockRewards: pallet_block_rewards::{Pallet, Call, Storage, Event, Config} = 105, Keystore: pallet_keystore::{Pallet, Call, Storage, Event} = 106, LiquidityPools: pallet_liquidity_pools::{Pallet, Call, Storage, Event} = 108, - LiquidityPoolsGateway: pallet_liquidity_pools_gateway::{Pallet, Call, Storage, Event, Origin } = 109, + LiquidityPoolsGateway: pallet_liquidity_pools_gateway::{Pallet, Call, Storage, Event } = 109, LiquidityRewardsBase: pallet_rewards::::{Pallet, Storage, Event, Config} = 110, LiquidityRewards: pallet_liquidity_rewards::{Pallet, Call, Storage, Event} = 111, GapRewardMechanism: pallet_rewards::mechanism::gap = 112, diff --git a/runtime/centrifuge/src/lib.rs b/runtime/centrifuge/src/lib.rs index 5d76da74fc..20823f2da4 100644 --- a/runtime/centrifuge/src/lib.rs +++ b/runtime/centrifuge/src/lib.rs @@ -1874,7 +1874,6 @@ parameter_types! { impl pallet_liquidity_pools_gateway::Config for Runtime { type AdminOrigin = EnsureAccountOrRootOr; type InboundMessageHandler = LiquidityPools; - type LocalEVMOrigin = pallet_liquidity_pools_gateway::EnsureLocal; type MaxIncomingMessageSize = MaxIncomingMessageSize; type MaxRouterCount = MaxRouterCount; type Message = pallet_liquidity_pools::Message; @@ -1883,7 +1882,6 @@ impl pallet_liquidity_pools_gateway::Config for Runtime { type RouterId = RouterId; type RouterProvider = LPGatewayRouterProvider; type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; type Sender = Sender; type SessionId = LPGatewaySessionId; type WeightInfo = (); @@ -2099,7 +2097,7 @@ construct_runtime!( LiquidityRewardsBase: pallet_rewards::::{Pallet, Storage, Event, Config} = 104, LiquidityRewards: pallet_liquidity_rewards::{Pallet, Call, Storage, Event} = 105, GapRewardMechanism: pallet_rewards::mechanism::gap = 106, - LiquidityPoolsGateway: pallet_liquidity_pools_gateway::{Pallet, Call, Storage, Event, Origin } = 107, + LiquidityPoolsGateway: pallet_liquidity_pools_gateway::{Pallet, Call, Storage, Event } = 107, OrderBook: pallet_order_book::{Pallet, Call, Storage, Event} = 108, ForeignInvestments: pallet_foreign_investments::{Pallet, Storage, Event} = 109, TransferAllowList: pallet_transfer_allowlist::{Pallet, Call, Storage, Event, HoldReason} = 110, diff --git a/runtime/development/src/lib.rs b/runtime/development/src/lib.rs index 2727b103b9..3aaf571e1c 100644 --- a/runtime/development/src/lib.rs +++ b/runtime/development/src/lib.rs @@ -1880,7 +1880,6 @@ parameter_types! { impl pallet_liquidity_pools_gateway::Config for Runtime { type AdminOrigin = EnsureRootOr; type InboundMessageHandler = LiquidityPools; - type LocalEVMOrigin = pallet_liquidity_pools_gateway::EnsureLocal; type MaxIncomingMessageSize = MaxIncomingMessageSize; type MaxRouterCount = MaxRouterCount; type Message = pallet_liquidity_pools::Message; @@ -1889,7 +1888,6 @@ impl pallet_liquidity_pools_gateway::Config for Runtime { type RouterId = RouterId; type RouterProvider = LPGatewayRouterProvider; type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; type Sender = Sender; type SessionId = LPGatewaySessionId; type WeightInfo = (); @@ -2207,7 +2205,7 @@ construct_runtime!( BlockRewards: pallet_block_rewards::{Pallet, Call, Storage, Event, Config} = 111, TransferAllowList: pallet_transfer_allowlist::{Pallet, Call, Storage, Event, HoldReason} = 112, GapRewardMechanism: pallet_rewards::mechanism::gap = 114, - LiquidityPoolsGateway: pallet_liquidity_pools_gateway::{Pallet, Call, Storage, Event, Origin } = 115, + LiquidityPoolsGateway: pallet_liquidity_pools_gateway::{Pallet, Call, Storage, Event } = 115, OrderBook: pallet_order_book::{Pallet, Call, Storage, Event} = 116, ForeignInvestments: pallet_foreign_investments::{Pallet, Storage, Event} = 117, OraclePriceFeed: pallet_oracle_feed::{Pallet, Call, Storage, Event} = 118, diff --git a/runtime/integration-tests/src/config.rs b/runtime/integration-tests/src/config.rs index 70e94cbacc..2898b6e1ef 100644 --- a/runtime/integration-tests/src/config.rs +++ b/runtime/integration-tests/src/config.rs @@ -277,8 +277,7 @@ pub trait Runtime: + Clone + OriginTrait::RuntimeCall, AccountId = AccountId> + From - + Into::RuntimeOrigin>> - + From; + + Into::RuntimeOrigin>>; /// Block used by the runtime type BlockExt: Block< diff --git a/runtime/integration-tests/submodules/liquidity-pools b/runtime/integration-tests/submodules/liquidity-pools index 4301885b9a..6e8f1a29df 160000 --- a/runtime/integration-tests/submodules/liquidity-pools +++ b/runtime/integration-tests/submodules/liquidity-pools @@ -1 +1 @@ -Subproject commit 4301885b9a3b8ec36f3bda4b789daa5b115c006a +Subproject commit 6e8f1a29dff0d7cf5ff74285cfffadae8a8b303f