From f0cbe6f2b33c76f71faaa10ee057a5ac259163fb Mon Sep 17 00:00:00 2001
From: Rodrigo Quelhas <22591718+RomarQ@users.noreply.github.com>
Date: Thu, 22 Aug 2024 10:34:00 +0100
Subject: [PATCH 1/4] Add missing benchmarks (#2909)
* Add benchmarks for pallet-message-queue
* Add benchmarks for cumulus_pallet_parachain_system
* update MessageQueueHeapSize
* Use proper (2^n) value in MessageQueueHeapSize
---
Cargo.lock | 1 +
file_header.txt | 2 +-
runtime/common/Cargo.toml | 9 +-
.../cumulus_pallet_parachain_system.rs | 72 +++++++
runtime/common/src/weights/mod.rs | 2 +
.../src/weights/pallet_message_queue.rs | 184 ++++++++++++++++++
runtime/moonbase/src/lib.rs | 4 +-
runtime/moonbase/src/xcm_config.rs | 4 +-
runtime/moonbeam/src/lib.rs | 4 +-
runtime/moonbeam/src/xcm_config.rs | 4 +-
runtime/moonriver/src/lib.rs | 4 +-
runtime/moonriver/src/xcm_config.rs | 4 +-
12 files changed, 283 insertions(+), 11 deletions(-)
create mode 100644 runtime/common/src/weights/cumulus_pallet_parachain_system.rs
create mode 100644 runtime/common/src/weights/pallet_message_queue.rs
diff --git a/Cargo.lock b/Cargo.lock
index 10263419eb..effe0f2a34 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6978,6 +6978,7 @@ dependencies = [
"pallet-evm",
"pallet-evm-chain-id",
"pallet-identity",
+ "pallet-message-queue",
"pallet-migrations",
"pallet-moonbeam-foreign-assets",
"pallet-moonbeam-lazy-migrations",
diff --git a/file_header.txt b/file_header.txt
index 489cdef772..2f0941eac8 100644
--- a/file_header.txt
+++ b/file_header.txt
@@ -1,4 +1,4 @@
-// Copyright 2019-2022 PureStake Inc.
+// Copyright 2024 Moonbeam foundation
// This file is part of Moonbeam.
// Moonbeam is free software: you can redistribute it and/or modify
diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml
index 292ba44bbc..b94bbbc4ca 100644
--- a/runtime/common/Cargo.toml
+++ b/runtime/common/Cargo.toml
@@ -32,6 +32,7 @@ xcm-primitives = { workspace = true }
# Substrate
cumulus-pallet-parachain-system = { workspace = true }
cumulus-pallet-xcmp-queue = { workspace = true }
+pallet-message-queue = { workspace = true }
frame-benchmarking = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
@@ -105,6 +106,7 @@ std = [
"pallet-xcm-transactor/std",
"pallet-moonbeam-lazy-migrations/std",
"pallet-identity/std",
+ "pallet-message-queue/std",
"parity-scale-codec/std",
"precompile-utils/std",
"sp-consensus-slots/std",
@@ -120,6 +122,7 @@ std = [
runtime-benchmarks = [
"cumulus-pallet-parachain-system/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
+ "pallet-message-queue/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"pallet-asset-manager/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
@@ -151,4 +154,8 @@ runtime-benchmarks = [
"pallet-moonbeam-lazy-migrations/runtime-benchmarks",
"moonbeam-xcm-benchmarks/runtime-benchmarks",
]
-try-runtime = ["cumulus-pallet-parachain-system/try-runtime", "frame-support/try-runtime", "pallet-migrations/try-runtime"]
+try-runtime = [
+ "cumulus-pallet-parachain-system/try-runtime",
+ "frame-support/try-runtime",
+ "pallet-migrations/try-runtime",
+]
diff --git a/runtime/common/src/weights/cumulus_pallet_parachain_system.rs b/runtime/common/src/weights/cumulus_pallet_parachain_system.rs
new file mode 100644
index 0000000000..a60c09b775
--- /dev/null
+++ b/runtime/common/src/weights/cumulus_pallet_parachain_system.rs
@@ -0,0 +1,72 @@
+// Copyright 2024 Moonbeam foundation
+// This file is part of Moonbeam.
+
+// Moonbeam is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Moonbeam is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Moonbeam. If not, see .
+
+//! Autogenerated weights for `cumulus_pallet_parachain_system`
+//!
+//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
+//! DATE: 2024-08-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! WORST CASE MAP SIZE: `1000000`
+//! HOSTNAME: `MacBook-Pro-de-romarq.local`, CPU: ``
+//! WASM-EXECUTION: Compiled, CHAIN: Some("moonbase-dev"), DB CACHE: 1024
+
+// Executed Command:
+// ./target/release/moonbeam
+// benchmark
+// pallet
+// --chain=moonbase-dev
+// --steps=50
+// --repeat=20
+// --pallet=cumulus_pallet_parachain_system
+// --extrinsic=*
+// --wasm-execution=compiled
+// --header=./file_header.txt
+// --template=./benchmarking/frame-weight-template.hbs
+// --output=./runtime/common/src/weights/
+
+#![cfg_attr(rustfmt, rustfmt_skip)]
+#![allow(unused_parens)]
+#![allow(unused_imports)]
+
+use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
+use sp_std::marker::PhantomData;
+
+/// Weights for `cumulus_pallet_parachain_system`.
+pub struct WeightInfo(PhantomData);
+impl cumulus_pallet_parachain_system::WeightInfo for WeightInfo {
+ /// Storage: `ParachainSystem::LastDmqMqcHead` (r:1 w:1)
+ /// Proof: `ParachainSystem::LastDmqMqcHead` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
+ /// Storage: `MessageQueue::BookStateFor` (r:1 w:1)
+ /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
+ /// Storage: `MessageQueue::ServiceHead` (r:1 w:1)
+ /// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`)
+ /// Storage: `ParachainSystem::ProcessedDownwardMessages` (r:0 w:1)
+ /// Proof: `ParachainSystem::ProcessedDownwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
+ /// Storage: `MessageQueue::Pages` (r:0 w:1000)
+ /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(107993), added: 110468, mode: `MaxEncodedLen`)
+ /// The range of component `n` is `[0, 1000]`.
+ fn enqueue_inbound_downward_messages(n: u32, ) -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `82`
+ // Estimated: `3517`
+ // Minimum execution time: 2_000_000 picoseconds.
+ Weight::from_parts(2_000_000, 3517)
+ // Standard Error: 914_274
+ .saturating_add(Weight::from_parts(213_425_397, 0).saturating_mul(n.into()))
+ .saturating_add(T::DbWeight::get().reads(3_u64))
+ .saturating_add(T::DbWeight::get().writes(4_u64))
+ .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into())))
+ }
+}
diff --git a/runtime/common/src/weights/mod.rs b/runtime/common/src/weights/mod.rs
index 314d5e30c4..6108d9c228 100644
--- a/runtime/common/src/weights/mod.rs
+++ b/runtime/common/src/weights/mod.rs
@@ -16,6 +16,7 @@
//! Moonbeam common weights.
+pub mod cumulus_pallet_parachain_system;
pub mod cumulus_pallet_xcmp_queue;
pub mod db;
pub mod pallet_asset_manager;
@@ -29,6 +30,7 @@ pub mod pallet_conviction_voting;
pub mod pallet_crowdloan_rewards;
pub mod pallet_evm;
pub mod pallet_identity;
+pub mod pallet_message_queue;
pub mod pallet_moonbeam_foreign_assets;
pub mod pallet_moonbeam_lazy_migrations;
pub mod pallet_moonbeam_orbiters;
diff --git a/runtime/common/src/weights/pallet_message_queue.rs b/runtime/common/src/weights/pallet_message_queue.rs
new file mode 100644
index 0000000000..2e91ea15df
--- /dev/null
+++ b/runtime/common/src/weights/pallet_message_queue.rs
@@ -0,0 +1,184 @@
+// Copyright 2024 Moonbeam foundation
+// This file is part of Moonbeam.
+
+// Moonbeam is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Moonbeam is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Moonbeam. If not, see .
+
+//! Autogenerated weights for `pallet_message_queue`
+//!
+//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
+//! DATE: 2024-08-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! WORST CASE MAP SIZE: `1000000`
+//! HOSTNAME: `MacBook-Pro-de-romarq.local`, CPU: ``
+//! WASM-EXECUTION: Compiled, CHAIN: Some("moonbase-dev"), DB CACHE: 1024
+
+// Executed Command:
+// ./target/release/moonbeam
+// benchmark
+// pallet
+// --chain=moonbase-dev
+// --steps=50
+// --repeat=20
+// --pallet=pallet_message_queue
+// --extrinsic=*
+// --wasm-execution=compiled
+// --header=./file_header.txt
+// --template=./benchmarking/frame-weight-template.hbs
+// --output=./runtime/common/src/weights/
+
+#![cfg_attr(rustfmt, rustfmt_skip)]
+#![allow(unused_parens)]
+#![allow(unused_imports)]
+
+use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
+use sp_std::marker::PhantomData;
+
+/// Weights for `pallet_message_queue`.
+pub struct WeightInfo(PhantomData);
+impl pallet_message_queue::WeightInfo for WeightInfo {
+ /// Storage: `MessageQueue::ServiceHead` (r:1 w:0)
+ /// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`)
+ /// Storage: `MessageQueue::BookStateFor` (r:2 w:2)
+ /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
+ fn ready_ring_knit() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `223`
+ // Estimated: `6044`
+ // Minimum execution time: 10_000_000 picoseconds.
+ Weight::from_parts(11_000_000, 6044)
+ .saturating_add(T::DbWeight::get().reads(3_u64))
+ .saturating_add(T::DbWeight::get().writes(2_u64))
+ }
+ /// Storage: `MessageQueue::BookStateFor` (r:2 w:2)
+ /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
+ /// Storage: `MessageQueue::ServiceHead` (r:1 w:1)
+ /// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`)
+ fn ready_ring_unknit() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `218`
+ // Estimated: `6044`
+ // Minimum execution time: 9_000_000 picoseconds.
+ Weight::from_parts(10_000_000, 6044)
+ .saturating_add(T::DbWeight::get().reads(3_u64))
+ .saturating_add(T::DbWeight::get().writes(3_u64))
+ }
+ /// Storage: `MessageQueue::BookStateFor` (r:1 w:1)
+ /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
+ /// Storage: `EmergencyParaXcm::Mode` (r:1 w:0)
+ /// Proof: `EmergencyParaXcm::Mode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
+ /// Storage: `MaintenanceMode::MaintenanceMode` (r:1 w:0)
+ /// Proof: `MaintenanceMode::MaintenanceMode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
+ fn service_queue_base() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `190`
+ // Estimated: `3517`
+ // Minimum execution time: 7_000_000 picoseconds.
+ Weight::from_parts(7_000_000, 3517)
+ .saturating_add(T::DbWeight::get().reads(3_u64))
+ .saturating_add(T::DbWeight::get().writes(1_u64))
+ }
+ /// Storage: `MessageQueue::Pages` (r:1 w:1)
+ /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(134193), added: 136668, mode: `MaxEncodedLen`)
+ fn service_page_base_completion() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `72`
+ // Estimated: `137658`
+ // Minimum execution time: 5_000_000 picoseconds.
+ Weight::from_parts(6_000_000, 137658)
+ .saturating_add(T::DbWeight::get().reads(1_u64))
+ .saturating_add(T::DbWeight::get().writes(1_u64))
+ }
+ /// Storage: `MessageQueue::Pages` (r:1 w:1)
+ /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(134193), added: 136668, mode: `MaxEncodedLen`)
+ fn service_page_base_no_completion() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `72`
+ // Estimated: `137658`
+ // Minimum execution time: 5_000_000 picoseconds.
+ Weight::from_parts(6_000_000, 137658)
+ .saturating_add(T::DbWeight::get().reads(1_u64))
+ .saturating_add(T::DbWeight::get().writes(1_u64))
+ }
+ /// Storage: `MessageQueue::BookStateFor` (r:0 w:1)
+ /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
+ /// Storage: `MessageQueue::Pages` (r:0 w:1)
+ /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(134193), added: 136668, mode: `MaxEncodedLen`)
+ fn service_page_item() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `0`
+ // Estimated: `0`
+ // Minimum execution time: 155_000_000 picoseconds.
+ Weight::from_parts(156_000_000, 0)
+ .saturating_add(T::DbWeight::get().writes(2_u64))
+ }
+ /// Storage: `MessageQueue::ServiceHead` (r:1 w:1)
+ /// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `MaxEncodedLen`)
+ /// Storage: `MessageQueue::BookStateFor` (r:1 w:0)
+ /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
+ fn bump_service_head() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `171`
+ // Estimated: `3517`
+ // Minimum execution time: 5_000_000 picoseconds.
+ Weight::from_parts(6_000_000, 3517)
+ .saturating_add(T::DbWeight::get().reads(2_u64))
+ .saturating_add(T::DbWeight::get().writes(1_u64))
+ }
+ /// Storage: `MessageQueue::BookStateFor` (r:1 w:1)
+ /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
+ /// Storage: `MessageQueue::Pages` (r:1 w:1)
+ /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(134193), added: 136668, mode: `MaxEncodedLen`)
+ fn reap_page() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `134274`
+ // Estimated: `137658`
+ // Minimum execution time: 48_000_000 picoseconds.
+ Weight::from_parts(53_000_000, 137658)
+ .saturating_add(T::DbWeight::get().reads(2_u64))
+ .saturating_add(T::DbWeight::get().writes(2_u64))
+ }
+ /// Storage: `MessageQueue::BookStateFor` (r:1 w:1)
+ /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
+ /// Storage: `EmergencyParaXcm::Mode` (r:1 w:0)
+ /// Proof: `EmergencyParaXcm::Mode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
+ /// Storage: `MaintenanceMode::MaintenanceMode` (r:1 w:0)
+ /// Proof: `MaintenanceMode::MaintenanceMode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
+ /// Storage: `MessageQueue::Pages` (r:1 w:1)
+ /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(134193), added: 136668, mode: `MaxEncodedLen`)
+ fn execute_overweight_page_removed() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `134458`
+ // Estimated: `137658`
+ // Minimum execution time: 69_000_000 picoseconds.
+ Weight::from_parts(75_000_000, 137658)
+ .saturating_add(T::DbWeight::get().reads(4_u64))
+ .saturating_add(T::DbWeight::get().writes(2_u64))
+ }
+ /// Storage: `MessageQueue::BookStateFor` (r:1 w:1)
+ /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
+ /// Storage: `EmergencyParaXcm::Mode` (r:1 w:0)
+ /// Proof: `EmergencyParaXcm::Mode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
+ /// Storage: `MaintenanceMode::MaintenanceMode` (r:1 w:0)
+ /// Proof: `MaintenanceMode::MaintenanceMode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
+ /// Storage: `MessageQueue::Pages` (r:1 w:1)
+ /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(134193), added: 136668, mode: `MaxEncodedLen`)
+ fn execute_overweight_page_updated() -> Weight {
+ // Proof Size summary in bytes:
+ // Measured: `134458`
+ // Estimated: `137658`
+ // Minimum execution time: 82_000_000 picoseconds.
+ Weight::from_parts(88_000_000, 137658)
+ .saturating_add(T::DbWeight::get().reads(4_u64))
+ .saturating_add(T::DbWeight::get().writes(2_u64))
+ }
+}
diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs
index 395af492f3..6a591538cd 100644
--- a/runtime/moonbase/src/lib.rs
+++ b/runtime/moonbase/src/lib.rs
@@ -765,7 +765,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type CheckAssociatedRelayNumber = EmergencyParaXcm;
type ConsensusHook = ConsensusHookWrapperForRelayTimestamp;
type DmpQueue = frame_support::traits::EnqueueWithOrigin;
- type WeightInfo = cumulus_pallet_parachain_system::weights::SubstrateWeight;
+ type WeightInfo = moonbase_weights::cumulus_pallet_parachain_system::WeightInfo;
}
impl parachain_info::Config for Runtime {}
@@ -1501,7 +1501,9 @@ mod benches {
[pallet_author_mapping, AuthorMapping]
[pallet_proxy, Proxy]
[pallet_identity, Identity]
+ [cumulus_pallet_parachain_system, ParachainSystem]
[cumulus_pallet_xcmp_queue, XcmpQueue]
+ [pallet_message_queue, MessageQueue]
[pallet_xcm, PalletXcmExtrinsicsBenchmark::]
[pallet_asset_manager, AssetManager]
[pallet_xcm_transactor, XcmTransactor]
diff --git a/runtime/moonbase/src/xcm_config.rs b/runtime/moonbase/src/xcm_config.rs
index 4e44f607a4..2141cefdcb 100644
--- a/runtime/moonbase/src/xcm_config.rs
+++ b/runtime/moonbase/src/xcm_config.rs
@@ -434,7 +434,7 @@ parameter_types! {
/// A good value depends on the expected message sizes, their weights, the weight that is
/// available for processing them and the maximal needed message size. The maximal message
/// size is slightly lower than this as defined by [`MaxMessageLenOf`].
- pub const MessageQueueHeapSize: u32 = 128 * 1048;
+ pub const MessageQueueHeapSize: u32 = 103 * 1024;
}
impl pallet_message_queue::Config for Runtime {
@@ -455,7 +455,7 @@ impl pallet_message_queue::Config for Runtime {
type QueueChangeHandler = NarrowOriginToSibling;
// NarrowOriginToSibling calls XcmpQueue's is_paused if Origin is sibling. Allows all other origins
type QueuePausedQuery = EmergencyParaXcm;
- type WeightInfo = pallet_message_queue::weights::SubstrateWeight;
+ type WeightInfo = moonbase_weights::pallet_message_queue::WeightInfo;
type IdleMaxServiceWeight = MessageQueueServiceWeight;
}
diff --git a/runtime/moonbeam/src/lib.rs b/runtime/moonbeam/src/lib.rs
index e2b6b86108..551e4f965c 100644
--- a/runtime/moonbeam/src/lib.rs
+++ b/runtime/moonbeam/src/lib.rs
@@ -714,7 +714,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
type ConsensusHook = ConsensusHookWrapperForRelayTimestamp;
type DmpQueue = frame_support::traits::EnqueueWithOrigin;
- type WeightInfo = cumulus_pallet_parachain_system::weights::SubstrateWeight;
+ type WeightInfo = moonbeam_weights::cumulus_pallet_parachain_system::WeightInfo;
}
pub struct EthereumXcmEnsureProxy;
@@ -1489,7 +1489,9 @@ mod benches {
[pallet_author_mapping, AuthorMapping]
[pallet_proxy, Proxy]
[pallet_identity, Identity]
+ [cumulus_pallet_parachain_system, ParachainSystem]
[cumulus_pallet_xcmp_queue, XcmpQueue]
+ [pallet_message_queue, MessageQueue]
[pallet_xcm, PalletXcmExtrinsicsBenchmark::]
[pallet_asset_manager, AssetManager]
[pallet_xcm_transactor, XcmTransactor]
diff --git a/runtime/moonbeam/src/xcm_config.rs b/runtime/moonbeam/src/xcm_config.rs
index 6fa1210f8e..9e8ea4cd57 100644
--- a/runtime/moonbeam/src/xcm_config.rs
+++ b/runtime/moonbeam/src/xcm_config.rs
@@ -422,7 +422,7 @@ parameter_types! {
/// A good value depends on the expected message sizes, their weights, the weight that is
/// available for processing them and the maximal needed message size. The maximal message
/// size is slightly lower than this as defined by [`MaxMessageLenOf`].
- pub const MessageQueueHeapSize: u32 = 128 * 1048;
+ pub const MessageQueueHeapSize: u32 = 103 * 1024;
}
impl pallet_message_queue::Config for Runtime {
@@ -443,7 +443,7 @@ impl pallet_message_queue::Config for Runtime {
type QueueChangeHandler = NarrowOriginToSibling;
// NarrowOriginToSibling calls XcmpQueue's is_paused if Origin is sibling. Allows all other origins
type QueuePausedQuery = (MaintenanceMode, NarrowOriginToSibling);
- type WeightInfo = pallet_message_queue::weights::SubstrateWeight;
+ type WeightInfo = moonbeam_weights::pallet_message_queue::WeightInfo;
type IdleMaxServiceWeight = MessageQueueServiceWeight;
}
diff --git a/runtime/moonriver/src/lib.rs b/runtime/moonriver/src/lib.rs
index ba2b196098..f1975cbc68 100644
--- a/runtime/moonriver/src/lib.rs
+++ b/runtime/moonriver/src/lib.rs
@@ -750,7 +750,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
type ConsensusHook = ConsensusHookWrapperForRelayTimestamp;
type DmpQueue = frame_support::traits::EnqueueWithOrigin;
- type WeightInfo = cumulus_pallet_parachain_system::weights::SubstrateWeight;
+ type WeightInfo = moonriver_weights::cumulus_pallet_parachain_system::WeightInfo;
}
impl parachain_info::Config for Runtime {}
@@ -1490,7 +1490,9 @@ mod benches {
[pallet_author_mapping, AuthorMapping]
[pallet_proxy, Proxy]
[pallet_identity, Identity]
+ [cumulus_pallet_parachain_system, ParachainSystem]
[cumulus_pallet_xcmp_queue, XcmpQueue]
+ [pallet_message_queue, MessageQueue]
[pallet_xcm, PalletXcmExtrinsicsBenchmark::]
[pallet_asset_manager, AssetManager]
[pallet_xcm_transactor, XcmTransactor]
diff --git a/runtime/moonriver/src/xcm_config.rs b/runtime/moonriver/src/xcm_config.rs
index 38645915da..26f8d83eb2 100644
--- a/runtime/moonriver/src/xcm_config.rs
+++ b/runtime/moonriver/src/xcm_config.rs
@@ -430,7 +430,7 @@ parameter_types! {
/// A good value depends on the expected message sizes, their weights, the weight that is
/// available for processing them and the maximal needed message size. The maximal message
/// size is slightly lower than this as defined by [`MaxMessageLenOf`].
- pub const MessageQueueHeapSize: u32 = 128 * 1048;
+ pub const MessageQueueHeapSize: u32 = 103 * 1024;
}
impl pallet_message_queue::Config for Runtime {
@@ -451,7 +451,7 @@ impl pallet_message_queue::Config for Runtime {
type QueueChangeHandler = NarrowOriginToSibling;
// NarrowOriginToSibling calls XcmpQueue's is_paused if Origin is sibling. Allows all other origins
type QueuePausedQuery = (MaintenanceMode, NarrowOriginToSibling);
- type WeightInfo = pallet_message_queue::weights::SubstrateWeight;
+ type WeightInfo = moonriver_weights::pallet_message_queue::WeightInfo;
type IdleMaxServiceWeight = MessageQueueServiceWeight;
}
From 1682686be72f78f0bd79532695e0eed7fe32bfde Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?pablito=20=E3=83=86?=
Date: Thu, 22 Aug 2024 06:34:26 -0300
Subject: [PATCH 2/4] improve error & instructions to reproduce (#2910)
---
test/suites/smoke/test-polkadot-decoding.ts | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/test/suites/smoke/test-polkadot-decoding.ts b/test/suites/smoke/test-polkadot-decoding.ts
index d696c26af2..bcdb8b3061 100644
--- a/test/suites/smoke/test-polkadot-decoding.ts
+++ b/test/suites/smoke/test-polkadot-decoding.ts
@@ -5,6 +5,9 @@ import { ONE_HOURS } from "@moonwall/util";
import { ApiPromise } from "@polkadot/api";
import { fail } from "assert";
+// Change the following line to reproduce a particular case
+const STARTING_KEY_OVERRIDE = null;
+
const pageSize = (process.env.PAGE_SIZE && parseInt(process.env.PAGE_SIZE)) || 500;
const extractStorageKeyComponents = (storageKey: string) => {
@@ -104,11 +107,9 @@ describeSuite({
// 2. Extract the module, fn and params keys
const { moduleKey, fnKey, paramsKey } = extractStorageKeyComponents(storageKey);
- // 3. Generate a random startKey
- // Overwrite the PRNG seed to check particular cases by
- // uncommenting the following line
- // PRNG = new SeededPRNG(42);
+ // 3. Generate a random startKey, will be overridden if STARTING_KEY_OVERRIDE is set
currentStartKey = moduleKey + fnKey + randomHex(paramsKey.length);
+ currentStartKey = STARTING_KEY_OVERRIDE || currentStartKey;
// 4. Fetch the storage entries with the random startKey
// Trying to decode all storage entries may cause the node to timeout, decoding
@@ -129,9 +130,12 @@ describeSuite({
log(` - ${fn}: ${chalk.green(`✔`)}`);
} catch (e) {
const failMsg = `Failed to fetch storage at (${moduleName}::${fn}) `;
- const PRNGDetails = `using startKey "${currentStartKey} at block ${atBlockNumber}`;
- const msg = chalk.red(`${failMsg} ${PRNGDetails}`);
+ const RNGDetails = `using startKey "${currentStartKey} at block ${atBlockNumber}`;
+ const msg = chalk.red(`${failMsg} ${RNGDetails}`);
log(msg, e);
+ const reproducing = `To reproduce this failled case, set the STARTING_KEY_OVERRIDE
+ variable to "${currentStartKey}" at the top of the test file and run the test again.`;
+ log(chalk.red(reproducing));
fail(msg);
}
}
From 6553de5668b426b42aa088ac101f04ec4f4f5648 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89lo=C3=AFs?=
Date: Sat, 24 Aug 2024 12:43:08 +0200
Subject: [PATCH 3/4] mute hrmp channel moonriver - Litmus (#2914)
---
test/helpers/foreign-chains.ts | 1 +
1 file changed, 1 insertion(+)
diff --git a/test/helpers/foreign-chains.ts b/test/helpers/foreign-chains.ts
index b8822239cc..a72497f124 100644
--- a/test/helpers/foreign-chains.ts
+++ b/test/helpers/foreign-chains.ts
@@ -120,6 +120,7 @@ export const ForeignChainsEndpoints = [
{
name: "Litmus",
paraId: 2106,
+ mutedUntil: new Date("2024-10-01").getTime(),
},
{
name: "Mangata",
From 84bbe13628bd0f114149f15451f85f60c32c3fa2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?pablito=20=E3=83=86?=
Date: Tue, 27 Aug 2024 07:13:19 -0300
Subject: [PATCH 4/4] Add step to Build workflow to check for WASM runtime
sizes (#2888)
* add simple wasm size check
* only run on pull requests
* add Github token to env
* fix download dir name
* try comparing previous and current runtimes
* change master branch with dynamic target branch ref
* add comparison to latest release
* test with older release
* download from release instead of workflow artifact
* debug release tag not saved to env
* debug some more
* use gh cli to get releases instead of git tag
* use gh api instead of releases
* remove get build id & fix awk parsing
* build runtimes with _, releases with -
* add comment to PR and format msg
* use markdown report & replace comment
* cat report & fix comment formatting
* add twiggy diff reports as artifacts
* use upload v4 & create reports dir
* rm: deprecated ::set-output cmd
---
.github/workflows/build.yml | 164 ++++++++++++++++++++++++++++++++++++
1 file changed, 164 insertions(+)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 88df600092..be3739ebd7 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -320,6 +320,170 @@ jobs:
name: moonbeam
path: build
+ check-wasm-size:
+ name: "Check WASM runtimes with Twiggy"
+ runs-on: ubuntu-latest
+ if: github.event_name == 'pull_request'
+ needs: ["set-tags", "build"]
+ env:
+ GH_TOKEN: ${{ github.token }}
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ ref: ${{ needs.set-tags.outputs.git_ref }}
+ # With rustup's nice new toml format, we just need to run rustup show to install the toolchain
+ # https://github.com/actions-rs/toolchain/issues/126#issuecomment-782989659
+ - name: Setup Rust toolchain
+ run: |
+ rustup override unset
+ rustup show
+ - name: Download Twiggy
+ run: cargo install twiggy
+ - name: Lookup for latest target branch build
+ run: |
+ TARGET_BRANCH=${{ github.event.pull_request.base.ref }}
+ LATEST_TARGET_BRANCH_BUILD=$(gh run -R moonbeam-foundation/moonbeam list -w Build --limit=100 --json databaseId,url,headBranch,event,status,conclusion,createdAt --jq ".[] | select(.headBranch == \"$TARGET_BRANCH\" and .event == \"push\" and .status == \"completed\" and .conclusion == \"success\") | .databaseId" | head -n 1)
+ echo "LATEST_TARGET_BRANCH_BUILD=$LATEST_TARGET_BRANCH_BUILD" >> $GITHUB_OUTPUT
+ - name: Download latest target branch build artifacts
+ run: |
+ gh run download $LATEST_TARGET_BRANCH_BUILD -n uncompressed-runtimes --dir uncompressed-runtimes-target-branch
+ gh run download $LATEST_TARGET_BRANCH_BUILD -n runtimes --dir runtimes-target-branch
+ - name: Check Runtimes size for target branch
+ run: |
+ PREVIOUS_MOONBASE=$(du -k runtimes-target-branch/* | awk '/moonbase_runtime/ {print $1}')
+ PREVIOUS_MOONBEAM=$(du -k runtimes-target-branch/* | awk '/moonbeam_runtime/ {print $1}')
+ PREVIOUS_MOONRIVER=$(du -k runtimes-target-branch/* | awk '/moonriver_runtime/ {print $1}')
+ echo "PREVIOUS_MOONBASE=$PREVIOUS_MOONBASE" >> $GITHUB_ENV
+ echo "PREVIOUS_MOONBEAM=$PREVIOUS_MOONBEAM" >> $GITHUB_ENV
+ echo "PREVIOUS_MOONRIVER=$PREVIOUS_MOONRIVER" >> $GITHUB_ENV
+ - name: "Download branch built runtime"
+ uses: actions/download-artifact@v4
+ with:
+ name: runtimes
+ path: runtimes-current-branch
+ - name: "Download branch built uncompressed-runtimes"
+ uses: actions/download-artifact@v4
+ with:
+ name: uncompressed-runtimes
+ path: uncompressed-runtimes-current-branch
+ - name: Check Runtimes size for current branch
+ run: |
+ CURRENT_MOONBASE=$(du -k runtimes-current-branch/* | awk '/moonbase_runtime/ {print $1}')
+ CURRENT_MOONBEAM=$(du -k runtimes-current-branch/* | awk '/moonbeam_runtime/ {print $1}')
+ CURRENT_MOONRIVER=$(du -k runtimes-current-branch/* | awk '/moonriver_runtime/ {print $1}')
+ echo "CURRENT_MOONBASE=$CURRENT_MOONBASE" >> $GITHUB_ENV
+ echo "CURRENT_MOONBEAM=$CURRENT_MOONBEAM" >> $GITHUB_ENV
+ echo "CURRENT_MOONRIVER=$CURRENT_MOONRIVER" >> $GITHUB_ENV
+ - name: Fetch latest release tag
+ id: fetch_latest_release
+ run: |
+ LATEST_RELEASE_TAG=$(gh api repos/moonbeam-foundation/moonbeam/releases --paginate --jq '.[] | select(.tag_name | test("^runtime-\\d+$")) | .tag_name' | sort -V | tail -n 1)
+ echo "LATEST_RELEASE_TAG=$LATEST_RELEASE_TAG" >> $GITHUB_ENV
+ echo $LATEST_RELEASE_TAG
+ - name: Download latest release runtimes
+ run: |
+ gh release download $LATEST_RELEASE_TAG -R moonbeam-foundation/moonbeam -p "moonbeam-runtime-${LATEST_RELEASE_TAG#runtime-}.wasm" -p "moonbase-runtime-${LATEST_RELEASE_TAG#runtime-}.wasm" -p "moonriver-runtime-${LATEST_RELEASE_TAG#runtime-}.wasm" --dir runtimes-latest-release
+ - name: Check Runtimes size for latest release
+ run: |
+ LATEST_MOONBASE=$(du -k runtimes-latest-release/* | awk '/moonbase-runtime/ {print $1}')
+ LATEST_MOONBEAM=$(du -k runtimes-latest-release/* | awk '/moonbeam-runtime/ {print $1}')
+ LATEST_MOONRIVER=$(du -k runtimes-latest-release/* | awk '/moonriver-runtime/ {print $1}')
+ echo "LATEST_MOONBASE=$LATEST_MOONBASE" >> $GITHUB_ENV
+ echo "LATEST_MOONBEAM=$LATEST_MOONBEAM" >> $GITHUB_ENV
+ echo "LATEST_MOONRIVER=$LATEST_MOONRIVER" >> $GITHUB_ENV
+ - name: Create Twiggy diff reports
+ run: |
+ # Install Twiggy if not already installed
+ if ! command -v twiggy &> /dev/null; then
+ cargo install twiggy
+ fi
+
+ # Generate Twiggy diff reports in JSON format with top 100 entries
+ mkdir -p twiggy-diff-reports
+ twiggy diff -n 100 --format json uncompressed-runtimes-target-branch/moonbase_runtime.wasm uncompressed-runtimes-current-branch/moonbase_runtime.wasm > twiggy-diff-reports/twiggy_diff_moonbase.json
+ twiggy diff -n 100 --format json uncompressed-runtimes-target-branch/moonbeam_runtime.wasm uncompressed-runtimes-current-branch/moonbeam_runtime.wasm > twiggy-diff-reports/twiggy_diff_moonbeam.json
+ twiggy diff -n 100 --format json uncompressed-runtimes-target-branch/moonriver_runtime.wasm uncompressed-runtimes-current-branch/moonriver_runtime.wasm > twiggy-diff-reports/twiggy_diff_moonriver.json
+
+ - name: Upload Twiggy diff reports
+ uses: actions/upload-artifact@v4
+ with:
+ name: twiggy-diff-reports
+ path: twiggy-diff-reports
+ - name: Compare Runtimes sizes
+ run: |
+ # Create or truncate the file
+ echo "" > runtime_size_report.md
+
+ MOONBASE_DIFF=$((CURRENT_MOONBASE - PREVIOUS_MOONBASE))
+ MOONBEAM_DIFF=$((CURRENT_MOONBEAM - PREVIOUS_MOONBEAM))
+ MOONRIVER_DIFF=$((CURRENT_MOONRIVER - PREVIOUS_MOONRIVER))
+
+ LATEST_MOONBASE_DIFF=$((CURRENT_MOONBASE - LATEST_MOONBASE))
+ LATEST_MOONBEAM_DIFF=$((CURRENT_MOONBEAM - LATEST_MOONBEAM))
+ LATEST_MOONRIVER_DIFF=$((CURRENT_MOONRIVER - LATEST_MOONRIVER))
+
+ get_status_emoji() {
+ local size=$1
+ local diff=$2
+ if [ $size -gt 2400 ]; then
+ echo "🚨"
+ elif [ $diff -gt 0 ]; then
+ echo "⚠️"
+ else
+ echo "✅"
+ fi
+ }
+
+ MOONBASE_STATUS=$(get_status_emoji $CURRENT_MOONBASE $MOONBASE_DIFF)
+ MOONBEAM_STATUS=$(get_status_emoji $CURRENT_MOONBEAM $MOONBEAM_DIFF)
+ MOONRIVER_STATUS=$(get_status_emoji $CURRENT_MOONRIVER $MOONRIVER_DIFF)
+
+ LATEST_MOONBASE_STATUS=$(get_status_emoji $CURRENT_MOONBASE $LATEST_MOONBASE_DIFF)
+ LATEST_MOONBEAM_STATUS=$(get_status_emoji $CURRENT_MOONBEAM $LATEST_MOONBEAM_DIFF)
+ LATEST_MOONRIVER_STATUS=$(get_status_emoji $CURRENT_MOONRIVER $LATEST_MOONRIVER_DIFF)
+
+ MOONBASE_MSG="Moonbase runtime: ${CURRENT_MOONBASE} KB ($( [ $MOONBASE_DIFF -eq 0 ] && echo "no changes" || echo "$( [ $MOONBASE_DIFF -gt 0 ] && echo "+" )${MOONBASE_DIFF} KB")) ${MOONBASE_STATUS}"
+ MOONBEAM_MSG="Moonbeam runtime: ${CURRENT_MOONBEAM} KB ($( [ $MOONBEAM_DIFF -eq 0 ] && echo "no changes" || echo "$( [ $MOONBEAM_DIFF -gt 0 ] && echo "+" )${MOONBEAM_DIFF} KB")) ${MOONBEAM_STATUS}"
+ MOONRIVER_MSG="Moonriver runtime: ${CURRENT_MOONRIVER} KB ($( [ $MOONRIVER_DIFF -eq 0 ] && echo "no changes" || echo "$( [ $MOONRIVER_DIFF -gt 0 ] && echo "+" )${MOONRIVER_DIFF} KB")) ${MOONRIVER_STATUS}"
+
+ LATEST_MOONBASE_MSG="Moonbase runtime: ${CURRENT_MOONBASE} KB ($( [ $LATEST_MOONBASE_DIFF -eq 0 ] && echo "no changes" || echo "$( [ $LATEST_MOONBASE_DIFF -gt 0 ] && echo "+" )${LATEST_MOONBASE_DIFF} KB compared to latest release")) ${LATEST_MOONBASE_STATUS}"
+ LATEST_MOONBEAM_MSG="Moonbeam runtime: ${CURRENT_MOONBEAM} KB ($( [ $LATEST_MOONBEAM_DIFF -eq 0 ] && echo "no changes" || echo "$( [ $LATEST_MOONBEAM_DIFF -gt 0 ] && echo "+" )${LATEST_MOONBEAM_DIFF} KB compared to latest release")) ${LATEST_MOONBEAM_STATUS}"
+ LATEST_MOONRIVER_MSG="Moonriver runtime: ${CURRENT_MOONRIVER} KB ($( [ $LATEST_MOONRIVER_DIFF -eq 0 ] && echo "no changes" || echo "$( [ $LATEST_MOONRIVER_DIFF -gt 0 ] && echo "+" )${LATEST_MOONRIVER_DIFF} KB compared to latest release")) ${LATEST_MOONRIVER_STATUS}"
+
+ echo "### WASM runtime size check:" > runtime_size_report.md
+ echo "" >> runtime_size_report.md
+ echo "#### Compared to target branch" >> runtime_size_report.md
+ echo "" >> runtime_size_report.md
+ echo "$MOONBASE_MSG" >> runtime_size_report.md
+ echo "" >> runtime_size_report.md
+ echo "$MOONBEAM_MSG" >> runtime_size_report.md
+ echo "" >> runtime_size_report.md
+ echo "$MOONRIVER_MSG" >> runtime_size_report.md
+ echo "" >> runtime_size_report.md
+ echo "#### Compared to latest release (${LATEST_RELEASE_TAG})" >> runtime_size_report.md
+ echo "" >> runtime_size_report.md
+ echo "$LATEST_MOONBASE_MSG" >> runtime_size_report.md
+ echo "" >> runtime_size_report.md
+ echo "$LATEST_MOONBEAM_MSG" >> runtime_size_report.md
+ echo "" >> runtime_size_report.md
+ echo "$LATEST_MOONRIVER_MSG" >> runtime_size_report.md
+ cat runtime_size_report.md
+ - name: Find Comment
+ uses: peter-evans/find-comment@v3
+ id: fc
+ with:
+ issue-number: ${{ github.event.pull_request.number }}
+ comment-author: "github-actions[bot]"
+ body-includes: "WASM runtime size check"
+ - name: Create or update comment
+ uses: peter-evans/create-or-update-comment@v4
+ with:
+ comment-id: ${{ steps.fc.outputs.comment-id }}
+ issue-number: ${{ github.event.pull_request.number }}
+ body-path: runtime_size_report.md
+ edit-mode: replace
+
rust-test:
runs-on:
labels: bare-metal