diff --git a/parachain/pallets/outbound-queue/src/lib.rs b/parachain/pallets/outbound-queue/src/lib.rs index 0b42224b27..3406759b31 100644 --- a/parachain/pallets/outbound-queue/src/lib.rs +++ b/parachain/pallets/outbound-queue/src/lib.rs @@ -94,12 +94,12 @@ use bridge_hub_common::{AggregateMessageOrigin, CustomDigestItem}; use codec::Decode; use frame_support::{ storage::StorageStreamIter, - traits::{tokens::Balance, Defensive, EnqueueMessage, Get, ProcessMessageError}, + traits::{tokens::Balance, Contains, Defensive, EnqueueMessage, Get, ProcessMessageError}, weights::{Weight, WeightToFee}, }; use snowbridge_core::{ outbound::{Fee, GasMeter, QueuedMessage, VersionedQueuedMessage, ETHER_DECIMALS}, - BasicOperatingMode, Channel, ChannelId, StaticLookup, + BasicOperatingMode, ChannelId, }; use snowbridge_outbound_queue_merkle_tree::merkle_root; pub use snowbridge_outbound_queue_merkle_tree::MerkleProof; @@ -150,8 +150,8 @@ pub mod pallet { #[pallet::constant] type MaxMessagesPerBlock: Get; - /// Lookup a channel descriptor - type ChannelLookup: StaticLookup; + /// Check whether a channel exists + type Channels: Contains; type PricingParameters: Get>; diff --git a/parachain/pallets/outbound-queue/src/mock.rs b/parachain/pallets/outbound-queue/src/mock.rs index 9b3e7b85ba..6c196e8e7a 100644 --- a/parachain/pallets/outbound-queue/src/mock.rs +++ b/parachain/pallets/outbound-queue/src/mock.rs @@ -4,16 +4,15 @@ use super::*; use frame_support::{ parameter_types, - traits::{Everything, Hooks}, + traits::{Contains, Everything, Hooks}, weights::IdentityFee, }; -use hex_literal::hex; use snowbridge_core::{ gwei, meth, outbound::*, pricing::{PricingParameters, Rewards}, - Channel, ParaId, StaticLookup, PRIMARY_GOVERNANCE_CHANNEL, + ParaId, PRIMARY_GOVERNANCE_CHANNEL, }; use sp_core::{ConstU32, ConstU8, H160, H256}; use sp_runtime::{ @@ -94,13 +93,10 @@ parameter_types! { pub const DOT: u128 = 10_000_000_000; -pub struct MockChannelLookup; -impl StaticLookup for MockChannelLookup { - type Source = ChannelId; - type Target = Channel; - - fn lookup(channel_id: Self::Source) -> Option { - Some(Channel { agent_id: H256::zero(), para_id: 0.into() }) +pub struct MockChannels; +impl Contains for MockChannels { + fn contains(_: &ChannelId) -> bool { + true } } @@ -114,7 +110,7 @@ impl crate::Config for Test { type GasMeter = ConstantGasMeter; type Balance = u128; type PricingParameters = Parameters; - type ChannelLookup = MockChannelLookup; + type Channels = MockChannels; type WeightToFee = IdentityFee; type WeightInfo = (); } diff --git a/parachain/pallets/outbound-queue/src/send_message_impl.rs b/parachain/pallets/outbound-queue/src/send_message_impl.rs index c3be64bcfc..a84e2c520e 100644 --- a/parachain/pallets/outbound-queue/src/send_message_impl.rs +++ b/parachain/pallets/outbound-queue/src/send_message_impl.rs @@ -49,7 +49,7 @@ where ); // Ensure there is a registered channel we can transmit this message on - ensure!(T::ChannelLookup::lookup(message.channel_id).is_some(), SendError::InvalidChannel); + ensure!(T::Channels::contains(&message.channel_id), SendError::InvalidChannel); // Generate a unique message id unless one is provided let message_id: H256 = message diff --git a/parachain/pallets/system/src/lib.rs b/parachain/pallets/system/src/lib.rs index 522699d49f..b6a29e5323 100644 --- a/parachain/pallets/system/src/lib.rs +++ b/parachain/pallets/system/src/lib.rs @@ -57,7 +57,7 @@ use frame_support::{ traits::{ fungible::{Inspect, Mutate}, tokens::Preservation, - EnsureOrigin, + Contains, EnsureOrigin, }, }; use frame_system::pallet_prelude::*; @@ -653,6 +653,12 @@ pub mod pallet { } } + impl Contains for Pallet { + fn contains(channel_id: &ChannelId) -> bool { + Channels::::get(channel_id).is_some() + } + } + impl Get> for Pallet { fn get() -> PricingParametersOf { PricingParameters::::get() diff --git a/parachain/pallets/system/src/mock.rs b/parachain/pallets/system/src/mock.rs index feba51c5dd..7fd43dd7c8 100644 --- a/parachain/pallets/system/src/mock.rs +++ b/parachain/pallets/system/src/mock.rs @@ -178,7 +178,7 @@ impl snowbridge_outbound_queue::Config for Test { type GasMeter = ConstantGasMeter; type Balance = u128; type PricingParameters = EthereumSystem; - type ChannelLookup = EthereumSystem; + type Channels = EthereumSystem; type WeightToFee = IdentityFee; type WeightInfo = (); } diff --git a/polkadot-sdk b/polkadot-sdk index 66e6c4ee7a..fd959244eb 160000 --- a/polkadot-sdk +++ b/polkadot-sdk @@ -1 +1 @@ -Subproject commit 66e6c4ee7aef533de142e117085a7cbe14cbaed1 +Subproject commit fd959244eb80186fa65bfdaa907f6f9ec5072ca5