Skip to content

Commit a7ceb4a

Browse files
authored
Merge branch 'master' into multi_phase_default_snapshot_as_fallback
2 parents 63a0b03 + e8e8d6e commit a7ceb4a

107 files changed

Lines changed: 3811 additions & 2736 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 1 addition & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bridges/snowbridge/pallets/outbound-queue-v2/src/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use alloy_core::primitives::FixedBytes;
55
use codec::Encode;
66
use frame_support::{
77
assert_err, assert_ok,
8-
traits::{Hooks, ProcessMessage, ProcessMessageError},
8+
traits::{Hooks, ProcessMessage, ProcessMessageError, QueueFootprintQuery},
99
weights::WeightMeter,
1010
BoundedVec,
1111
};

bridges/snowbridge/pallets/outbound-queue/src/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{mock::*, *};
44

55
use frame_support::{
66
assert_err, assert_noop, assert_ok,
7-
traits::{Hooks, ProcessMessage, ProcessMessageError},
7+
traits::{Hooks, ProcessMessage, ProcessMessageError, QueueFootprintQuery},
88
weights::WeightMeter,
99
};
1010

bridges/snowbridge/primitives/inbound-queue/src/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use sp_runtime::{
66
};
77
use xcm::{latest::WESTEND_GENESIS_HASH, prelude::*};
88

9-
pub const CHAIN_ID: u64 = 11155111;
10-
pub const NETWORK: NetworkId = Ethereum { chain_id: CHAIN_ID };
9+
pub const SEPOLIA_ID: u64 = 11155111;
10+
pub const NETWORK: NetworkId = Ethereum { chain_id: SEPOLIA_ID };
1111

1212
parameter_types! {
1313
pub EthereumNetwork: NetworkId = NETWORK;

bridges/snowbridge/primitives/inbound-queue/src/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn test_convert_send_token_with_weth() {
9595
const FEE: u128 = 1_000;
9696
const ACCOUNT_ID: [u8; 32] = [0xBA; 32];
9797
const MESSAGE: VersionedMessage = VersionedMessage::V1(MessageV1 {
98-
chain_id: CHAIN_ID,
98+
chain_id: SEPOLIA_ID,
9999
command: Command::SendToken {
100100
token: WETH,
101101
destination: Destination::AccountId32 { id: ACCOUNT_ID },
@@ -132,7 +132,7 @@ fn test_convert_send_token_with_eth() {
132132
const FEE: u128 = 1_000;
133133
const ACCOUNT_ID: [u8; 32] = [0xBA; 32];
134134
const MESSAGE: VersionedMessage = VersionedMessage::V1(MessageV1 {
135-
chain_id: CHAIN_ID,
135+
chain_id: SEPOLIA_ID,
136136
command: Command::SendToken {
137137
token: ETH,
138138
destination: Destination::AccountId32 { id: ACCOUNT_ID },

cumulus/pallets/dmp-queue/src/mock.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717

1818
#![cfg(test)]
1919

20-
use frame_support::{
21-
derive_impl, parameter_types,
22-
traits::{HandleMessage, QueueFootprint},
23-
};
20+
use frame_support::{derive_impl, parameter_types, traits::HandleMessage};
2421
use sp_core::{bounded_vec::BoundedSlice, ConstU32};
2522
use sp_runtime::traits::IdentityLookup;
2623

@@ -72,10 +69,6 @@ impl HandleMessage for RecordingDmpSink {
7269
fn sweep_queue() {
7370
unimplemented!()
7471
}
75-
76-
fn footprint() -> QueueFootprint {
77-
unimplemented!()
78-
}
7972
}
8073

8174
pub fn new_test_ext() -> sp_io::TestExternalities {

cumulus/pallets/xcmp-queue/src/benchmarking.rs

Lines changed: 108 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,43 +45,138 @@ mod benchmarks {
4545
/// The message will be added on a new page and also, the `BookState` will be added
4646
/// to the ready ring.
4747
#[benchmark]
48-
fn enqueue_n_bytes_xcmp_message(n: Linear<1, { MaxXcmpMessageLenOf::<T>::get() }>) {
48+
fn enqueue_n_bytes_xcmp_message(n: Linear<0, { MaxXcmpMessageLenOf::<T>::get() }>) {
4949
#[cfg(test)]
5050
{
5151
mock::EnqueuedMessages::set(vec![]);
5252
}
5353

54-
let msg = BoundedVec::<u8, MaxXcmpMessageLenOf<T>>::try_from(vec![0; n as usize]).unwrap();
54+
let msg = BoundedVec::try_from(vec![0; n as usize]).unwrap();
55+
56+
#[cfg(not(test))]
5557
let fp_before = T::XcmpQueue::footprint(0.into());
5658
#[block]
5759
{
58-
assert_ok!(Pallet::<T>::enqueue_xcmp_message(0.into(), msg));
60+
assert_ok!(Pallet::<T>::enqueue_xcmp_messages(
61+
0.into(),
62+
&[msg],
63+
&mut WeightMeter::new()
64+
));
65+
}
66+
#[cfg(not(test))]
67+
{
68+
let fp_after = T::XcmpQueue::footprint(0.into());
69+
assert_eq!(fp_after.ready_pages, fp_before.ready_pages + 1);
5970
}
60-
let fp_after = T::XcmpQueue::footprint(0.into());
61-
assert_eq!(fp_after.ready_pages, fp_before.ready_pages + 1);
6271
}
6372

64-
/// Add 2 XCMP message of 0 bytes to the message queue.
73+
/// Add `n` XCMP message of 0 bytes to the message queue.
6574
///
6675
/// Only for the first message a new page will be created and the `BookState` will be added
6776
/// to the ready ring.
6877
#[benchmark]
69-
fn enqueue_2_empty_xcmp_messages() {
78+
fn enqueue_n_empty_xcmp_messages(n: Linear<0, 1000>) {
79+
#[cfg(test)]
80+
{
81+
mock::EnqueuedMessages::set(vec![]);
82+
<QueueConfig<T>>::set(QueueConfigData {
83+
suspend_threshold: 1100,
84+
drop_threshold: 1100,
85+
resume_threshold: 1100,
86+
});
87+
}
88+
89+
let msgs = vec![Default::default(); n as usize];
90+
91+
#[cfg(not(test))]
92+
let fp_before = T::XcmpQueue::footprint(0.into());
93+
#[block]
94+
{
95+
assert_ok!(Pallet::<T>::enqueue_xcmp_messages(
96+
0.into(),
97+
&msgs,
98+
&mut WeightMeter::new()
99+
));
100+
}
101+
#[cfg(not(test))]
102+
{
103+
let fp_after = T::XcmpQueue::footprint(0.into());
104+
if !msgs.is_empty() {
105+
assert_eq!(fp_after.ready_pages, fp_before.ready_pages + 1);
106+
}
107+
}
108+
}
109+
110+
/// Add `n` pages to the message queue.
111+
///
112+
/// We add one page by enqueueing a maximal size message which fills it.
113+
#[benchmark]
114+
fn enqueue_n_full_pages(n: Linear<0, 100>) {
70115
#[cfg(test)]
71116
{
72117
mock::EnqueuedMessages::set(vec![]);
73118
}
119+
<QueueConfig<T>>::set(QueueConfigData {
120+
suspend_threshold: 200,
121+
drop_threshold: 200,
122+
resume_threshold: 200,
123+
});
74124

75-
let msg_1 = BoundedVec::<u8, MaxXcmpMessageLenOf<T>>::default();
76-
let msg_2 = BoundedVec::<u8, MaxXcmpMessageLenOf<T>>::default();
125+
let max_msg_len = MaxXcmpMessageLenOf::<T>::get() as usize;
126+
let mut msgs = vec![];
127+
for _i in 0..n {
128+
let msg = BoundedVec::try_from(vec![0; max_msg_len]).unwrap();
129+
msgs.push(msg);
130+
}
131+
132+
#[cfg(not(test))]
77133
let fp_before = T::XcmpQueue::footprint(0.into());
78134
#[block]
79135
{
80-
assert_ok!(Pallet::<T>::enqueue_xcmp_message(0.into(), msg_1));
81-
assert_ok!(Pallet::<T>::enqueue_xcmp_message(0.into(), msg_2));
136+
assert_ok!(Pallet::<T>::enqueue_xcmp_messages(
137+
0.into(),
138+
&msgs,
139+
&mut WeightMeter::new()
140+
));
141+
}
142+
#[cfg(not(test))]
143+
{
144+
let fp_after = T::XcmpQueue::footprint(0.into());
145+
assert_eq!(fp_after.ready_pages, fp_before.ready_pages + n);
146+
}
147+
}
148+
149+
#[benchmark]
150+
fn enqueue_1000_small_xcmp_messages() {
151+
#[cfg(test)]
152+
{
153+
<QueueConfig<T>>::set(QueueConfigData {
154+
suspend_threshold: 1100,
155+
drop_threshold: 1100,
156+
resume_threshold: 1100,
157+
});
158+
}
159+
160+
let mut msgs = vec![];
161+
for _i in 0..1000 {
162+
msgs.push(BoundedVec::try_from(vec![0; 3]).unwrap());
163+
}
164+
165+
#[cfg(not(test))]
166+
let fp_before = T::XcmpQueue::footprint(0.into());
167+
#[block]
168+
{
169+
assert_ok!(Pallet::<T>::enqueue_xcmp_messages(
170+
0.into(),
171+
&msgs,
172+
&mut WeightMeter::new()
173+
));
174+
}
175+
#[cfg(not(test))]
176+
{
177+
let fp_after = T::XcmpQueue::footprint(0.into());
178+
assert_eq!(fp_after.ready_pages, fp_before.ready_pages + 1);
82179
}
83-
let fp_after = T::XcmpQueue::footprint(0.into());
84-
assert_eq!(fp_after.ready_pages, fp_before.ready_pages + 1);
85180
}
86181

87182
#[benchmark]

0 commit comments

Comments
 (0)