......@@ -16,9 +16,5 @@
use substrate_wasm_builder::WasmBuilder;
fn main() {
WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
WasmBuilder::build_using_defaults();
}
......@@ -30,8 +30,8 @@ use xcm_builder::{
parameter_types! {
pub const WestendLocation: Location = Location::parent();
pub const WestendNetwork: Option<NetworkId> = Some(NetworkId::Westend);
pub UniversalLocation: InteriorLocation = [Parachain(ParachainInfo::parachain_id().into())].into();
pub const WestendNetwork: NetworkId = NetworkId::Westend;
pub UniversalLocation: InteriorLocation = [GlobalConsensus(WestendNetwork::get()), Parachain(ParachainInfo::parachain_id().into())].into();
}
/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
......
......@@ -102,6 +102,7 @@ pub type UncheckedExtrinsic =
/// Migrations to apply on runtime upgrade.
pub type Migrations = (
pallet_collator_selection::migration::v2::MigrationToV2<Runtime>,
// permanent
pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
);
......
......@@ -17,9 +17,9 @@
//! Autogenerated weights for `pallet_xcm`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-03-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2024-02-20, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-h2rr8wx7-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! HOSTNAME: `runner-bn-ce5rx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("people-rococo-dev")`, DB CACHE: 1024
// Executed Command:
......@@ -62,28 +62,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `38`
// Estimated: `3503`
// Minimum execution time: 17_935_000 picoseconds.
Weight::from_parts(18_482_000, 0)
.saturating_add(Weight::from_parts(0, 3503))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0)
/// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1)
/// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0)
/// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0)
/// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1)
/// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn send_blob() -> Weight {
// Proof Size summary in bytes:
// Measured: `38`
// Estimated: `3503`
// Minimum execution time: 18_311_000 picoseconds.
Weight::from_parts(18_850_000, 0)
// Minimum execution time: 17_830_000 picoseconds.
Weight::from_parts(18_411_000, 0)
.saturating_add(Weight::from_parts(0, 3503))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
......@@ -104,8 +84,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `70`
// Estimated: `3535`
// Minimum execution time: 56_182_000 picoseconds.
Weight::from_parts(58_136_000, 0)
// Minimum execution time: 55_456_000 picoseconds.
Weight::from_parts(56_808_000, 0)
.saturating_add(Weight::from_parts(0, 3535))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
......@@ -140,24 +120,14 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
Weight::from_parts(18_446_744_073_709_551_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `Benchmark::Override` (r:0 w:0)
/// Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn execute_blob() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 18_446_744_073_709_551_000 picoseconds.
Weight::from_parts(18_446_744_073_709_551_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `PolkadotXcm::SupportedVersion` (r:0 w:1)
/// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn force_xcm_version() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 5_979_000 picoseconds.
Weight::from_parts(6_289_000, 0)
// Minimum execution time: 5_996_000 picoseconds.
Weight::from_parts(6_154_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
......@@ -167,8 +137,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_853_000 picoseconds.
Weight::from_parts(2_045_000, 0)
// Minimum execution time: 1_768_000 picoseconds.
Weight::from_parts(1_914_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
......@@ -192,8 +162,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `38`
// Estimated: `3503`
// Minimum execution time: 23_827_000 picoseconds.
Weight::from_parts(24_493_000, 0)
// Minimum execution time: 24_120_000 picoseconds.
Weight::from_parts(24_745_000, 0)
.saturating_add(Weight::from_parts(0, 3503))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(5))
......@@ -216,8 +186,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `255`
// Estimated: `3720`
// Minimum execution time: 26_755_000 picoseconds.
Weight::from_parts(27_125_000, 0)
// Minimum execution time: 26_630_000 picoseconds.
Weight::from_parts(27_289_000, 0)
.saturating_add(Weight::from_parts(0, 3720))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(4))
......@@ -228,8 +198,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_898_000 picoseconds.
Weight::from_parts(2_028_000, 0)
// Minimum execution time: 1_821_000 picoseconds.
Weight::from_parts(1_946_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
......@@ -239,8 +209,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `89`
// Estimated: `13454`
// Minimum execution time: 16_300_000 picoseconds.
Weight::from_parts(16_995_000, 0)
// Minimum execution time: 16_586_000 picoseconds.
Weight::from_parts(16_977_000, 0)
.saturating_add(Weight::from_parts(0, 13454))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
......@@ -251,8 +221,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `93`
// Estimated: `13458`
// Minimum execution time: 16_495_000 picoseconds.
Weight::from_parts(16_950_000, 0)
// Minimum execution time: 16_923_000 picoseconds.
Weight::from_parts(17_415_000, 0)
.saturating_add(Weight::from_parts(0, 13458))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
......@@ -263,8 +233,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `106`
// Estimated: `15946`
// Minimum execution time: 18_153_000 picoseconds.
Weight::from_parts(18_595_000, 0)
// Minimum execution time: 18_596_000 picoseconds.
Weight::from_parts(18_823_000, 0)
.saturating_add(Weight::from_parts(0, 15946))
.saturating_add(T::DbWeight::get().reads(6))
}
......@@ -284,8 +254,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `106`
// Estimated: `6046`
// Minimum execution time: 23_387_000 picoseconds.
Weight::from_parts(24_677_000, 0)
// Minimum execution time: 23_817_000 picoseconds.
Weight::from_parts(24_520_000, 0)
.saturating_add(Weight::from_parts(0, 6046))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
......@@ -296,8 +266,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `136`
// Estimated: `11026`
// Minimum execution time: 10_939_000 picoseconds.
Weight::from_parts(11_210_000, 0)
// Minimum execution time: 11_042_000 picoseconds.
Weight::from_parts(11_578_000, 0)
.saturating_add(Weight::from_parts(0, 11026))
.saturating_add(T::DbWeight::get().reads(4))
}
......@@ -307,8 +277,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `100`
// Estimated: `13465`
// Minimum execution time: 16_850_000 picoseconds.
Weight::from_parts(17_195_000, 0)
// Minimum execution time: 17_306_000 picoseconds.
Weight::from_parts(17_817_000, 0)
.saturating_add(Weight::from_parts(0, 13465))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
......@@ -329,8 +299,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `106`
// Estimated: `13471`
// Minimum execution time: 31_931_000 picoseconds.
Weight::from_parts(32_494_000, 0)
// Minimum execution time: 32_141_000 picoseconds.
Weight::from_parts(32_954_000, 0)
.saturating_add(Weight::from_parts(0, 13471))
.saturating_add(T::DbWeight::get().reads(10))
.saturating_add(T::DbWeight::get().writes(4))
......@@ -343,8 +313,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `32`
// Estimated: `1517`
// Minimum execution time: 3_514_000 picoseconds.
Weight::from_parts(3_709_000, 0)
// Minimum execution time: 3_410_000 picoseconds.
Weight::from_parts(3_556_000, 0)
.saturating_add(Weight::from_parts(0, 1517))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
......@@ -355,8 +325,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `7669`
// Estimated: `11134`
// Minimum execution time: 24_863_000 picoseconds.
Weight::from_parts(25_293_000, 0)
// Minimum execution time: 25_021_000 picoseconds.
Weight::from_parts(25_240_000, 0)
.saturating_add(Weight::from_parts(0, 11134))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
......@@ -367,8 +337,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `90`
// Estimated: `3555`
// Minimum execution time: 33_799_000 picoseconds.
Weight::from_parts(34_665_000, 0)
// Minimum execution time: 33_801_000 picoseconds.
Weight::from_parts(34_655_000, 0)
.saturating_add(Weight::from_parts(0, 3555))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
......
......@@ -36,16 +36,16 @@ use polkadot_parachain_primitives::primitives::Sibling;
use sp_runtime::traits::AccountIdConversion;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
DenyThenTry, DescribeTerminus, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter,
HashedDescription, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
DenyReserveTransferToRelayChain, DenyThenTry, DescribeTerminus, EnsureXcmOrigin,
FrameTransactionalProcessor, FungibleAdapter, HashedDescription, IsConcrete, ParentAsSuperuser,
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
XcmFeeManagerFromComponents, XcmFeeToAccount,
};
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
use xcm_executor::XcmExecutor;
parameter_types! {
pub const RootLocation: Location = Location::here();
......@@ -148,55 +148,6 @@ impl Contains<Location> for ParentOrParentsPlurality {
}
}
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
/// account for proof size weights.
///
/// Calls that are allowed through this filter must:
/// 1. Have a fixed weight;
/// 2. Cannot lead to another call being made;
/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters.
pub struct SafeCallFilter;
impl Contains<RuntimeCall> for SafeCallFilter {
fn contains(call: &RuntimeCall) -> bool {
#[cfg(feature = "runtime-benchmarks")]
{
if matches!(call, RuntimeCall::System(frame_system::Call::remark_with_event { .. })) {
return true
}
}
matches!(
call,
RuntimeCall::PolkadotXcm(
pallet_xcm::Call::force_xcm_version { .. } |
pallet_xcm::Call::force_default_xcm_version { .. }
) | RuntimeCall::System(
frame_system::Call::set_heap_pages { .. } |
frame_system::Call::set_code { .. } |
frame_system::Call::set_code_without_checks { .. } |
frame_system::Call::authorize_upgrade { .. } |
frame_system::Call::authorize_upgrade_without_checks { .. } |
frame_system::Call::kill_prefix { .. },
) | RuntimeCall::ParachainSystem(..) |
RuntimeCall::Timestamp(..) |
RuntimeCall::Balances(..) |
RuntimeCall::CollatorSelection(
pallet_collator_selection::Call::set_desired_candidates { .. } |
pallet_collator_selection::Call::set_candidacy_bond { .. } |
pallet_collator_selection::Call::register_as_candidate { .. } |
pallet_collator_selection::Call::leave_intent { .. } |
pallet_collator_selection::Call::set_invulnerables { .. } |
pallet_collator_selection::Call::add_invulnerable { .. } |
pallet_collator_selection::Call::remove_invulnerable { .. },
) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
RuntimeCall::XcmpQueue(..) |
RuntimeCall::MessageQueue(..) |
RuntimeCall::Identity(..) |
RuntimeCall::IdentityMigrator(..)
)
}
}
pub type Barrier = TrailingSetTopicAsId<
DenyThenTry<
DenyReserveTransferToRelayChain,
......@@ -214,6 +165,8 @@ pub type Barrier = TrailingSetTopicAsId<
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
// HRMP notifications from the relay chain are OK.
AllowHrmpNotificationsFromRelayChain,
),
UniversalLocation,
ConstU32<8>,
......@@ -270,8 +223,8 @@ impl xcm_executor::Config for XcmConfig {
>;
type MessageExporter = ();
type UniversalAliases = Nothing;
type CallDispatcher = WithOriginFilter<SafeCallFilter>;
type SafeCallFilter = SafeCallFilter;
type CallDispatcher = RuntimeCall;
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpNewChannelOpenRequestHandler = ();
......
......@@ -102,6 +102,7 @@ pub type UncheckedExtrinsic =
/// Migrations to apply on runtime upgrade.
pub type Migrations = (
pallet_collator_selection::migration::v2::MigrationToV2<Runtime>,
// permanent
pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
);
......
......@@ -17,9 +17,9 @@
//! Autogenerated weights for `pallet_xcm`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-03-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2024-02-20, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-h2rr8wx7-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! HOSTNAME: `runner-bn-ce5rx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("people-westend-dev")`, DB CACHE: 1024
// Executed Command:
......@@ -62,28 +62,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `38`
// Estimated: `3503`
// Minimum execution time: 17_450_000 picoseconds.
Weight::from_parts(17_913_000, 0)
.saturating_add(Weight::from_parts(0, 3503))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0)
/// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1)
/// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0)
/// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0)
/// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1)
/// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn send_blob() -> Weight {
// Proof Size summary in bytes:
// Measured: `38`
// Estimated: `3503`
// Minimum execution time: 18_082_000 picoseconds.
Weight::from_parts(18_293_000, 0)
// Minimum execution time: 17_856_000 picoseconds.
Weight::from_parts(18_473_000, 0)
.saturating_add(Weight::from_parts(0, 3503))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
......@@ -104,8 +84,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `70`
// Estimated: `3535`
// Minimum execution time: 54_939_000 picoseconds.
Weight::from_parts(55_721_000, 0)
// Minimum execution time: 56_112_000 picoseconds.
Weight::from_parts(57_287_000, 0)
.saturating_add(Weight::from_parts(0, 3535))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
......@@ -140,24 +120,14 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
Weight::from_parts(18_446_744_073_709_551_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `Benchmark::Override` (r:0 w:0)
/// Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn execute_blob() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 18_446_744_073_709_551_000 picoseconds.
Weight::from_parts(18_446_744_073_709_551_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `PolkadotXcm::SupportedVersion` (r:0 w:1)
/// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn force_xcm_version() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 5_789_000 picoseconds.
Weight::from_parts(5_995_000, 0)
// Minimum execution time: 6_186_000 picoseconds.
Weight::from_parts(6_420_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
......@@ -167,8 +137,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_795_000 picoseconds.
Weight::from_parts(1_924_000, 0)
// Minimum execution time: 1_824_000 picoseconds.
Weight::from_parts(1_999_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
......@@ -192,8 +162,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `38`
// Estimated: `3503`
// Minimum execution time: 23_445_000 picoseconds.
Weight::from_parts(23_906_000, 0)
// Minimum execution time: 23_833_000 picoseconds.
Weight::from_parts(24_636_000, 0)
.saturating_add(Weight::from_parts(0, 3503))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(5))
......@@ -216,8 +186,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `255`
// Estimated: `3720`
// Minimum execution time: 26_590_000 picoseconds.
Weight::from_parts(27_056_000, 0)
// Minimum execution time: 26_557_000 picoseconds.
Weight::from_parts(27_275_000, 0)
.saturating_add(Weight::from_parts(0, 3720))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(4))
......@@ -228,8 +198,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_889_000 picoseconds.
Weight::from_parts(1_962_000, 0)
// Minimum execution time: 1_921_000 picoseconds.
Weight::from_parts(2_040_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
......@@ -239,8 +209,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `89`
// Estimated: `13454`
// Minimum execution time: 16_408_000 picoseconds.
Weight::from_parts(16_877_000, 0)
// Minimum execution time: 16_832_000 picoseconds.
Weight::from_parts(17_312_000, 0)
.saturating_add(Weight::from_parts(0, 13454))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
......@@ -251,8 +221,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `93`
// Estimated: `13458`
// Minimum execution time: 16_791_000 picoseconds.
Weight::from_parts(17_111_000, 0)
// Minimum execution time: 16_687_000 picoseconds.
Weight::from_parts(17_123_000, 0)
.saturating_add(Weight::from_parts(0, 13458))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
......@@ -263,8 +233,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `106`
// Estimated: `15946`
// Minimum execution time: 18_355_000 picoseconds.
Weight::from_parts(19_110_000, 0)
// Minimum execution time: 18_164_000 picoseconds.
Weight::from_parts(18_580_000, 0)
.saturating_add(Weight::from_parts(0, 15946))
.saturating_add(T::DbWeight::get().reads(6))
}
......@@ -284,8 +254,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `106`
// Estimated: `6046`
// Minimum execution time: 23_354_000 picoseconds.
Weight::from_parts(23_999_000, 0)
// Minimum execution time: 23_577_000 picoseconds.
Weight::from_parts(24_324_000, 0)
.saturating_add(Weight::from_parts(0, 6046))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
......@@ -296,8 +266,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `136`
// Estimated: `11026`
// Minimum execution time: 11_065_000 picoseconds.
Weight::from_parts(11_302_000, 0)
// Minimum execution time: 11_014_000 picoseconds.
Weight::from_parts(11_223_000, 0)
.saturating_add(Weight::from_parts(0, 11026))
.saturating_add(T::DbWeight::get().reads(4))
}
......@@ -307,8 +277,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `100`
// Estimated: `13465`
// Minimum execution time: 16_998_000 picoseconds.
Weight::from_parts(17_509_000, 0)
// Minimum execution time: 16_887_000 picoseconds.
Weight::from_parts(17_361_000, 0)
.saturating_add(Weight::from_parts(0, 13465))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
......@@ -329,8 +299,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `106`
// Estimated: `13471`
// Minimum execution time: 31_068_000 picoseconds.
Weight::from_parts(31_978_000, 0)
// Minimum execution time: 31_705_000 picoseconds.
Weight::from_parts(32_166_000, 0)
.saturating_add(Weight::from_parts(0, 13471))
.saturating_add(T::DbWeight::get().reads(10))
.saturating_add(T::DbWeight::get().writes(4))
......@@ -343,8 +313,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `32`
// Estimated: `1517`
// Minimum execution time: 3_478_000 picoseconds.
Weight::from_parts(3_595_000, 0)
// Minimum execution time: 3_568_000 picoseconds.
Weight::from_parts(3_669_000, 0)
.saturating_add(Weight::from_parts(0, 1517))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
......@@ -355,8 +325,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `7669`
// Estimated: `11134`
// Minimum execution time: 24_962_000 picoseconds.
Weight::from_parts(25_404_000, 0)
// Minimum execution time: 24_823_000 picoseconds.
Weight::from_parts(25_344_000, 0)
.saturating_add(Weight::from_parts(0, 11134))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
......@@ -367,8 +337,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `90`
// Estimated: `3555`
// Minimum execution time: 32_685_000 picoseconds.
Weight::from_parts(33_592_000, 0)
// Minimum execution time: 34_516_000 picoseconds.
Weight::from_parts(35_478_000, 0)
.saturating_add(Weight::from_parts(0, 3555))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
......
......@@ -36,16 +36,16 @@ use polkadot_parachain_primitives::primitives::Sibling;
use sp_runtime::traits::AccountIdConversion;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
DenyThenTry, DescribeTerminus, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter,
HashedDescription, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
DenyReserveTransferToRelayChain, DenyThenTry, DescribeTerminus, EnsureXcmOrigin,
FrameTransactionalProcessor, FungibleAdapter, HashedDescription, IsConcrete, ParentAsSuperuser,
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
XcmFeeManagerFromComponents, XcmFeeToAccount,
};
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
use xcm_executor::XcmExecutor;
parameter_types! {
pub const RootLocation: Location = Location::here();
......@@ -155,55 +155,6 @@ impl Contains<Location> for FellowsPlurality {
}
}
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
/// account for proof size weights.
///
/// Calls that are allowed through this filter must:
/// 1. Have a fixed weight;
/// 2. Cannot lead to another call being made;
/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters.
pub struct SafeCallFilter;
impl Contains<RuntimeCall> for SafeCallFilter {
fn contains(call: &RuntimeCall) -> bool {
#[cfg(feature = "runtime-benchmarks")]
{
if matches!(call, RuntimeCall::System(frame_system::Call::remark_with_event { .. })) {
return true
}
}
matches!(
call,
RuntimeCall::PolkadotXcm(
pallet_xcm::Call::force_xcm_version { .. } |
pallet_xcm::Call::force_default_xcm_version { .. }
) | RuntimeCall::System(
frame_system::Call::set_heap_pages { .. } |
frame_system::Call::set_code { .. } |
frame_system::Call::set_code_without_checks { .. } |
frame_system::Call::authorize_upgrade { .. } |
frame_system::Call::authorize_upgrade_without_checks { .. } |
frame_system::Call::kill_prefix { .. },
) | RuntimeCall::ParachainSystem(..) |
RuntimeCall::Timestamp(..) |
RuntimeCall::Balances(..) |
RuntimeCall::CollatorSelection(
pallet_collator_selection::Call::set_desired_candidates { .. } |
pallet_collator_selection::Call::set_candidacy_bond { .. } |
pallet_collator_selection::Call::register_as_candidate { .. } |
pallet_collator_selection::Call::leave_intent { .. } |
pallet_collator_selection::Call::set_invulnerables { .. } |
pallet_collator_selection::Call::add_invulnerable { .. } |
pallet_collator_selection::Call::remove_invulnerable { .. },
) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
RuntimeCall::XcmpQueue(..) |
RuntimeCall::MessageQueue(..) |
RuntimeCall::Identity(..) |
RuntimeCall::IdentityMigrator(..)
)
}
}
pub type Barrier = TrailingSetTopicAsId<
DenyThenTry<
DenyReserveTransferToRelayChain,
......@@ -222,6 +173,8 @@ pub type Barrier = TrailingSetTopicAsId<
AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
// HRMP notifications from the relay chain are OK.
AllowHrmpNotificationsFromRelayChain,
),
UniversalLocation,
ConstU32<8>,
......@@ -278,8 +231,8 @@ impl xcm_executor::Config for XcmConfig {
>;
type MessageExporter = ();
type UniversalAliases = Nothing;
type CallDispatcher = WithOriginFilter<SafeCallFilter>;
type SafeCallFilter = SafeCallFilter;
type CallDispatcher = RuntimeCall;
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpNewChannelOpenRequestHandler = ();
......
......@@ -30,8 +30,8 @@ use xcm_builder::{
parameter_types! {
pub const RococoLocation: Location = Location::parent();
pub const RococoNetwork: Option<NetworkId> = Some(NetworkId::Rococo);
pub UniversalLocation: InteriorLocation = [Parachain(ParachainInfo::parachain_id().into())].into();
pub const RococoNetwork: NetworkId = NetworkId::Rococo;
pub UniversalLocation: InteriorLocation = [GlobalConsensus(RococoNetwork::get()), Parachain(ParachainInfo::parachain_id().into())].into();
}
/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
......
......@@ -16,11 +16,7 @@
#[cfg(feature = "std")]
fn main() {
substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
substrate_wasm_builder::WasmBuilder::build_using_defaults();
}
#[cfg(not(feature = "std"))]
......
......@@ -43,14 +43,15 @@ use polkadot_runtime_common::{impls::ToAuthor, xcm_sender::ExponentialPrice};
use sp_runtime::traits::{AccountIdConversion, ConvertInto, Identity, TryConvertInto};
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex, ConvertedConcreteId, EnsureXcmOrigin,
FixedWeightBounds, FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter, IsConcrete,
LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, StartsWith, TakeWeightCredit,
TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic,
XcmFeeManagerFromComponents, XcmFeeToAccount,
AccountId32Aliases, AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex,
ConvertedConcreteId, EnsureXcmOrigin, FixedWeightBounds, FrameTransactionalProcessor,
FungibleAdapter, FungiblesAdapter, IsConcrete, LocalMint, NativeAsset, NoChecking,
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, StartsWith, TakeWeightCredit, TrailingSetTopicAsId,
UsingComponents, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
XcmFeeToAccount,
};
use xcm_executor::{traits::JustTry, XcmExecutor};
......@@ -217,6 +218,8 @@ pub type Barrier = TrailingSetTopicAsId<(
AllowTopLevelPaidExecutionFrom<Everything>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
// HRMP notifications from the relay chain are OK.
AllowHrmpNotificationsFromRelayChain,
),
UniversalLocation,
ConstU32<8>,
......
......@@ -15,11 +15,7 @@
#[cfg(feature = "std")]
fn main() {
substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
substrate_wasm_builder::WasmBuilder::build_using_defaults();
}
#[cfg(not(feature = "std"))]
......
......@@ -74,9 +74,9 @@ use parachains_common::{
AccountId, AssetIdForTrustBackedAssets, Signature,
};
use xcm_builder::{
AllowKnownQueryResponses, AllowSubscriptionsFrom, AsPrefixedGeneralIndex, ConvertedConcreteId,
FrameTransactionalProcessor, FungiblesAdapter, LocalMint, TrailingSetTopicAsId,
WithUniqueTopic,
AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AsPrefixedGeneralIndex, ConvertedConcreteId, FrameTransactionalProcessor, FungiblesAdapter,
LocalMint, TrailingSetTopicAsId, WithUniqueTopic,
};
use xcm_executor::traits::JustTry;
......@@ -327,9 +327,9 @@ impl cumulus_pallet_aura_ext::Config for Runtime {}
parameter_types! {
pub const RocLocation: Location = Location::parent();
pub const RococoNetwork: Option<NetworkId> = Some(NetworkId::Rococo);
pub const RococoNetwork: NetworkId = NetworkId::Rococo;
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
pub UniversalLocation: InteriorLocation = [Parachain(ParachainInfo::parachain_id().into())].into();
pub UniversalLocation: InteriorLocation = [GlobalConsensus(RococoNetwork::get()), Parachain(ParachainInfo::parachain_id().into())].into();
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
}
......@@ -444,6 +444,8 @@ pub type Barrier = TrailingSetTopicAsId<(
AllowKnownQueryResponses<PolkadotXcm>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
// HRMP notifications from the relay chain are OK.
AllowHrmpNotificationsFromRelayChain,
)>;
parameter_types! {
......
......@@ -69,6 +69,9 @@ where
let price = P::price_for_delivery((), &xcm);
let versioned_xcm =
W::wrap_version(&d, xcm).map_err(|()| SendError::DestinationUnsupported)?;
versioned_xcm
.validate_xcm_nesting()
.map_err(|()| SendError::ExceedsMaxMessageSize)?;
let data = versioned_xcm.encode();
Ok((data, price))
......@@ -526,6 +529,8 @@ impl<
mod test_xcm_router {
use super::*;
use cumulus_primitives_core::UpwardMessage;
use frame_support::assert_ok;
use xcm::MAX_XCM_DECODE_DEPTH;
/// Validates [`validate`] for required Some(destination) and Some(message)
struct OkFixedXcmHashWithAssertingRequiredInputsSender;
......@@ -621,6 +626,29 @@ mod test_xcm_router {
)>(dest.into(), message)
);
}
#[test]
fn parent_as_ump_validate_nested_xcm_works() {
let dest = Parent;
type Router = ParentAsUmp<(), (), ()>;
// Message that is not too deeply nested:
let mut good = Xcm(vec![ClearOrigin]);
for _ in 0..MAX_XCM_DECODE_DEPTH - 1 {
good = Xcm(vec![SetAppendix(good)]);
}
// Check that the good message is validated:
assert_ok!(<Router as SendXcm>::validate(&mut Some(dest.into()), &mut Some(good.clone())));
// Nesting the message one more time should reject it:
let bad = Xcm(vec![SetAppendix(good)]);
assert_eq!(
Err(SendError::ExceedsMaxMessageSize),
<Router as SendXcm>::validate(&mut Some(dest.into()), &mut Some(bad))
);
}
}
#[cfg(test)]
mod test_trader {
......
......@@ -18,16 +18,10 @@
fn main() {
use substrate_wasm_builder::WasmBuilder;
WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build();
WasmBuilder::build_using_defaults();
WasmBuilder::new()
.with_current_project()
WasmBuilder::init_with_defaults()
.enable_feature("increment-spec-version")
.import_memory()
.set_file_name("wasm_binary_spec_version_incremented.rs")
.build();
}
......
# this image is built on top of existing Zombienet image
ARG ZOMBIENET_IMAGE
# this image uses substrate-relay image built elsewhere
ARG SUBSTRATE_RELAY_IMAGE=docker.io/paritytech/substrate-relay:v1.2.1
ARG SUBSTRATE_RELAY_IMAGE=docker.io/paritytech/substrate-relay:v1.5.0
# metadata
ARG VCS_REF
......
......@@ -131,6 +131,23 @@ pub struct RunCmd {
#[arg(long, value_name = "PATH")]
pub workers_path: Option<PathBuf>,
/// Override the maximum number of pvf execute workers.
///
/// **Dangerous!** Do not touch unless explicitly advised to.
#[arg(long)]
pub execute_workers_max_num: Option<usize>,
/// Override the maximum number of pvf workers that can be spawned in the pvf prepare
/// pool for tasks with the priority below critical.
///
/// **Dangerous!** Do not touch unless explicitly advised to.
#[arg(long)]
pub prepare_workers_soft_max_num: Option<usize>,
/// Override the absolute number of pvf workers that can be spawned in the pvf prepare pool.
///
/// **Dangerous!** Do not touch unless explicitly advised to.
#[arg(long)]
pub prepare_workers_hard_max_num: Option<usize>,
/// TESTING ONLY: disable the version check between nodes and workers.
#[arg(long, hide = true)]
pub disable_worker_version_check: bool,
......
......@@ -253,6 +253,9 @@ where
.overseer_channel_capacity_override,
malus_finality_delay: maybe_malus_finality_delay,
hwbench,
execute_workers_max_num: cli.run.execute_workers_max_num,
prepare_workers_hard_max_num: cli.run.prepare_workers_hard_max_num,
prepare_workers_soft_max_num: cli.run.prepare_workers_soft_max_num,
},
)
.map(|full| full.task_manager)?;
......
......@@ -53,3 +53,14 @@ kvdb-memorydb = "0.13.0"
test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" }
log = { workspace = true, default-features = true }
env_logger = "0.11"
polkadot-subsystem-bench = { path = "../../subsystem-bench" }
[[bench]]
name = "approval-voting-regression-bench"
path = "benches/approval-voting-regression-bench.rs"
harness = false
required-features = ["subsystem-benchmarks"]
[features]
subsystem-benchmarks = []
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot 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.
// Polkadot 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 Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! approval-voting throughput test
//!
//! Approval Voting benchmark based on Kusama parameters and scale.
//!
//! Subsystems involved:
//! - approval-distribution
//! - approval-voting
use polkadot_subsystem_bench::{
self,
approval::{bench_approvals, prepare_test, ApprovalsOptions},
configuration::TestConfiguration,
usage::BenchmarkUsage,
utils::save_to_file,
};
use std::io::Write;
const BENCH_COUNT: usize = 10;
fn main() -> Result<(), String> {
let mut messages = vec![];
let mut config = TestConfiguration::default();
config.n_cores = 100;
config.n_validators = 500;
config.num_blocks = 10;
config.peer_bandwidth = 524288000000;
config.bandwidth = 524288000000;
config.latency = None;
config.connectivity = 100;
config.generate_pov_sizes();
let options = ApprovalsOptions {
last_considered_tranche: 89,
coalesce_mean: 3.0,
coalesce_std_dev: 1.0,
coalesce_tranche_diff: 12,
enable_assignments_v2: true,
stop_when_approved: false,
workdir_prefix: "/tmp".to_string(),
num_no_shows_per_candidate: 0,
};
println!("Benchmarking...");
let usages: Vec<BenchmarkUsage> = (0..BENCH_COUNT)
.map(|n| {
print!("\r[{}{}]", "#".repeat(n), "_".repeat(BENCH_COUNT - n));
std::io::stdout().flush().unwrap();
let (mut env, state) = prepare_test(config.clone(), options.clone(), false);
env.runtime().block_on(bench_approvals("approvals_throughput", &mut env, state))
})
.collect();
println!("\rDone!{}", " ".repeat(BENCH_COUNT));
let average_usage = BenchmarkUsage::average(&usages);
save_to_file(
"charts/approval-voting-regression-bench.json",
average_usage.to_chart_json().map_err(|e| e.to_string())?,
)
.map_err(|e| e.to_string())?;
println!("{}", average_usage);
// We expect no variance for received and sent
// but use 0.001 because we operate with floats
messages.extend(average_usage.check_network_usage(&[
("Received from peers", 52942.4600, 0.001),
("Sent to peers", 63547.0330, 0.001),
]));
messages.extend(average_usage.check_cpu_usage(&[
("approval-distribution", 7.0317, 0.1),
("approval-voting", 9.5751, 0.1),
]));
if messages.is_empty() {
Ok(())
} else {
eprintln!("{}", messages.join("\n"));
Err("Regressions found".to_string())
}
}