Skip to content

Commit

Permalink
Check that channel exists when validating outbound message
Browse files Browse the repository at this point in the history
  • Loading branch information
vgeddes committed Dec 18, 2023
1 parent 5751529 commit 9f6d01d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion parachain/pallets/outbound-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ use frame_support::{
};
use snowbridge_core::{
outbound::{Fee, GasMeter, QueuedMessage, VersionedQueuedMessage, ETHER_DECIMALS},
BasicOperatingMode, ChannelId, StaticLookup,
BasicOperatingMode, Channel, ChannelId, StaticLookup,
};
use snowbridge_outbound_queue_merkle_tree::merkle_root;
pub use snowbridge_outbound_queue_merkle_tree::MerkleProof;
Expand Down
14 changes: 13 additions & 1 deletion parachain/pallets/outbound-queue/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ use frame_support::{
weights::IdentityFee,
};

use hex_literal::hex;
use snowbridge_core::{
gwei, meth,
outbound::*,
pricing::{PricingParameters, Rewards},
ParaId, PRIMARY_GOVERNANCE_CHANNEL,
Channel, ParaId, StaticLookup, PRIMARY_GOVERNANCE_CHANNEL,
};
use sp_core::{ConstU32, ConstU8, H160, H256};
use sp_runtime::{
Expand Down Expand Up @@ -93,6 +94,16 @@ 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<Self::Target> {
Some(Channel { agent_id: H256::zero(), para_id: 0.into() })
}
}

impl crate::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Hashing = Keccak256;
Expand All @@ -103,6 +114,7 @@ impl crate::Config for Test {
type GasMeter = ConstantGasMeter;
type Balance = u128;
type PricingParameters = Parameters;
type ChannelLookup = MockChannelLookup;
type WeightToFee = IdentityFee<u128>;
type WeightInfo = ();
}
Expand Down
1 change: 1 addition & 0 deletions parachain/pallets/system/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ impl snowbridge_outbound_queue::Config for Test {
type GasMeter = ConstantGasMeter;
type Balance = u128;
type PricingParameters = EthereumSystem;
type ChannelLookup = EthereumSystem;
type WeightToFee = IdentityFee<u128>;
type WeightInfo = ();
}
Expand Down
2 changes: 1 addition & 1 deletion polkadot-sdk

0 comments on commit 9f6d01d

Please sign in to comment.