Skip to content

Commit a51c312

Browse files
authored
XCMP and DMP improvements (#8860)
Related to #489 This PR changes the parachain receiving logic for XCMP and DMP by adding some offchain processing before forwarding the messages to the parachain `set_validation_data` inherent. This enables us to relax the advancement rule.
1 parent 75deaab commit a51c312

15 files changed

Lines changed: 1200 additions & 245 deletions

File tree

cumulus/pallets/parachain-system/src/benchmarking.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
#![cfg(feature = "runtime-benchmarks")]
2121

2222
use super::*;
23-
use cumulus_primitives_core::relay_chain::Hash as RelayHash;
23+
use crate::parachain_inherent::InboundDownwardMessages;
24+
use cumulus_primitives_core::{relay_chain::Hash as RelayHash, InboundDownwardMessage};
2425
use frame_benchmarking::v2::*;
2526
use sp_runtime::traits::BlakeTwo256;
2627

@@ -43,7 +44,10 @@ mod benchmarks {
4344

4445
#[block]
4546
{
46-
Pallet::<T>::enqueue_inbound_downward_messages(head, msgs);
47+
Pallet::<T>::enqueue_inbound_downward_messages(
48+
head,
49+
InboundDownwardMessages::new(msgs).into_abridged(&mut usize::MAX.clone()),
50+
);
4751
}
4852

4953
assert_eq!(ProcessedDownwardMessages::<T>::get(), n);

cumulus/pallets/parachain-system/src/lib.rs

Lines changed: 157 additions & 143 deletions
Large diffs are not rendered by default.

cumulus/pallets/parachain-system/src/mock.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use frame_support::{
3737
},
3838
weights::{Weight, WeightMeter},
3939
};
40-
use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin};
40+
use frame_system::{limits::BlockWeights, pallet_prelude::BlockNumberFor, RawOrigin};
4141
use sp_core::ConstU32;
4242
use sp_runtime::{traits::BlakeTwo256, BuildStorage};
4343
use sp_version::RuntimeVersion;
@@ -67,13 +67,16 @@ parameter_types! {
6767
transaction_version: 1,
6868
system_version: 1,
6969
};
70+
pub RuntimeBlockWeights: BlockWeights =
71+
BlockWeights::simple_max(Weight::from_parts(1024, 6 * 1024 * 1024));
7072
pub const ParachainId: ParaId = ParaId::new(200);
7173
pub const ReservedXcmpWeight: Weight = Weight::zero();
7274
pub const ReservedDmpWeight: Weight = Weight::zero();
7375
}
7476

7577
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
7678
impl frame_system::Config for Test {
79+
type BlockWeights = RuntimeBlockWeights;
7780
type Block = Block;
7881
type Version = Version;
7982
type OnSetCode = ParachainSetCode<Self>;
@@ -226,12 +229,12 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
226229
}
227230

228231
#[allow(dead_code)]
229-
pub fn mk_dmp(sent_at: u32) -> InboundDownwardMessage {
230-
InboundDownwardMessage { sent_at, msg: format!("down{}", sent_at).into_bytes() }
232+
pub fn mk_dmp(sent_at: u8, size: usize) -> InboundDownwardMessage {
233+
InboundDownwardMessage { sent_at: sent_at as u32, msg: vec![sent_at; size] }
231234
}
232235

233-
pub fn mk_hrmp(sent_at: u32) -> InboundHrmpMessage {
234-
InboundHrmpMessage { sent_at, data: format!("{}", sent_at).into_bytes() }
236+
pub fn mk_hrmp(sent_at: u8, size: usize) -> InboundHrmpMessage {
237+
InboundHrmpMessage { sent_at: sent_at as u32, data: vec![sent_at; size] }
235238
}
236239

237240
pub struct ReadRuntimeVersion(pub Vec<u8>);

0 commit comments

Comments
 (0)