referrerpolicy=no-referrer-when-downgrade

pallet_contracts_mock_network/mocks/
relay_message_queue.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Substrate.
3
4// Substrate is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Substrate is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Substrate.  If not, see <http://www.gnu.org/licenses/>.
16
17use frame_support::{parameter_types, weights::Weight};
18use xcm::latest::prelude::*;
19use xcm_simulator::{
20	AggregateMessageOrigin, ProcessMessage, ProcessMessageError, UmpQueueId, WeightMeter,
21};
22
23use crate::relay_chain::{RuntimeCall, XcmConfig};
24
25parameter_types! {
26	/// Amount of weight that can be spent per block to service messages.
27	pub MessageQueueServiceWeight: Weight = Weight::from_parts(1_000_000_000, 1_000_000);
28	pub const MessageQueueHeapSize: u32 = 65_536;
29	pub const MessageQueueMaxStale: u32 = 16;
30}
31
32/// Message processor to handle any messages that were enqueued into the `MessageQueue` pallet.
33pub struct MessageProcessor;
34impl ProcessMessage for MessageProcessor {
35	type Origin = AggregateMessageOrigin;
36
37	fn process_message(
38		message: &[u8],
39		origin: Self::Origin,
40		meter: &mut WeightMeter,
41		id: &mut [u8; 32],
42	) -> Result<bool, ProcessMessageError> {
43		let para = match origin {
44			AggregateMessageOrigin::Ump(UmpQueueId::Para(para)) => para,
45		};
46		xcm_builder::ProcessXcmMessage::<
47			Junction,
48			xcm_executor::XcmExecutor<XcmConfig>,
49			RuntimeCall,
50		>::process_message(message, Junction::Parachain(para.into()), meter, id)
51	}
52}