#235 Updated benchmarks for the next release (#238)

Added benchmarking for EVM template.
Updated benchmarking for Generic Templates.
Fixed config for EVM template.
Added benchmarking utils.
This commit is contained in:
Nikita Khateev
2024-06-28 15:49:02 +04:00
committed by GitHub
parent 3c9696b982
commit be0abb6bf1
57 changed files with 5982 additions and 493 deletions
+50 -36
View File
@@ -7,7 +7,7 @@ pub mod xcm_config;
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
#[cfg(not(feature = "async-backing"))]
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use cumulus_primitives_core::{AggregateMessageOrigin, AssetId, ParaId};
use frame_support::{
derive_impl,
dispatch::DispatchClass,
@@ -43,11 +43,7 @@ use sp_std::marker::PhantomData;
use sp_version::RuntimeVersion;
// XCM Imports
use xcm::{
latest::{
prelude::{AssetId, BodyId},
InteriorLocation,
Junction::PalletInstance,
},
latest::{prelude::BodyId, InteriorLocation, Junction::PalletInstance},
VersionedLocation,
};
use xcm_builder::PayOverXcm;
@@ -55,6 +51,8 @@ use xcm_builder::PayOverXcm;
use xcm_builder::ProcessXcmMessage;
use xcm_config::{RelayLocation, XcmOriginToTransactDispatchOrigin};
#[cfg(feature = "runtime-benchmarks")]
use crate::benchmark::{OpenHrmpChannel, PayWithEnsure};
use crate::{
constants::{
currency::{deposit, CENTS, EXISTENTIAL_DEPOSIT, MICROCENTS},
@@ -66,7 +64,7 @@ use crate::{
AccountId, Balance, Block, BlockNumber, CollatorSelectionUpdateOrigin, ConsensusHook, Hash,
Nonce, PriceForSiblingParachainDelivery,
},
weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
weights::{self, BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
Aura, Balances, BaseFee, CollatorSelection, EVMChainId, MessageQueue, OpenZeppelinPrecompiles,
OriginCaller, PalletInfo, ParachainSystem, Preimage, Runtime, RuntimeCall, RuntimeEvent,
RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask, Session, SessionKeys,
@@ -183,7 +181,7 @@ impl pallet_scheduler::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
type ScheduleOrigin = EnsureRoot<AccountId>;
type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_scheduler::WeightInfo<Runtime>;
}
parameter_types! {
@@ -206,7 +204,7 @@ impl pallet_preimage::Config for Runtime {
type Currency = Balances;
type ManagerOrigin = EnsureRoot<AccountId>;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = pallet_preimage::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_preimage::WeightInfo<Runtime>;
}
impl pallet_timestamp::Config for Runtime {
@@ -217,7 +215,7 @@ impl pallet_timestamp::Config for Runtime {
/// A timestamp: milliseconds since the unix epoch.
type Moment = u64;
type OnTimestampSet = Aura;
type WeightInfo = pallet_timestamp::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
}
impl pallet_authorship::Config for Runtime {
@@ -291,7 +289,7 @@ impl pallet_proxy::Config for Runtime {
type ProxyType = ProxyType;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = pallet_proxy::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_proxy::WeightInfo<Runtime>;
}
parameter_types! {
@@ -316,7 +314,7 @@ impl pallet_balances::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeFreezeReason = RuntimeFreezeReason;
type RuntimeHoldReason = RuntimeHoldReason;
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
}
parameter_types! {
@@ -337,7 +335,7 @@ impl pallet_transaction_payment::Config for Runtime {
impl pallet_sudo::Config for Runtime {
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = pallet_sudo::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_sudo::WeightInfo<Runtime>;
}
parameter_types! {
@@ -359,7 +357,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type ReservedXcmpWeight = ReservedXcmpWeight;
type RuntimeEvent = RuntimeEvent;
type SelfParaId = parachain_info::Pallet<Runtime>;
type WeightInfo = cumulus_pallet_parachain_system::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
type XcmpMessageHandler = XcmpQueue;
}
@@ -391,7 +389,7 @@ impl pallet_message_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type ServiceWeight = MessageQueueServiceWeight;
type Size = u32;
type WeightInfo = pallet_message_queue::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>;
}
impl cumulus_pallet_aura_ext::Config for Runtime {}
@@ -412,7 +410,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type PriceForSiblingDelivery = PriceForSiblingParachainDelivery;
type RuntimeEvent = RuntimeEvent;
type VersionWrapper = ();
type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
// Enqueue XCMP messages from siblings for later processing.
type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
}
@@ -432,7 +430,7 @@ impl pallet_multisig::Config for Runtime {
type MaxSignatories = MaxSignatories;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = pallet_multisig::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
}
parameter_types! {
@@ -455,7 +453,7 @@ impl pallet_session::Config for Runtime {
type ValidatorId = <Self as frame_system::Config>::AccountId;
// we don't have stash and controller, thus we don't need the convert as well.
type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
type WeightInfo = pallet_session::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
}
#[cfg(not(feature = "async-backing"))]
@@ -504,14 +502,14 @@ impl pallet_collator_selection::Config for Runtime {
type ValidatorId = <Self as frame_system::Config>::AccountId;
type ValidatorIdOf = pallet_collator_selection::IdentityCollator;
type ValidatorRegistration = Session;
type WeightInfo = pallet_collator_selection::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_collator_selection::WeightInfo<Runtime>;
}
impl pallet_utility::Config for Runtime {
type PalletsOrigin = OriginCaller;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = pallet_utility::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
}
parameter_types! {
@@ -529,13 +527,36 @@ parameter_types! {
pub TreasuryAccount: AccountId = Treasury::account_id();
}
#[cfg(feature = "runtime-benchmarks")]
parameter_types! {
pub LocationParents: u8 = 1;
pub BenchmarkParaId: u8 = 0;
}
type Beneficiary = VersionedLocation;
type AssetKind = VersionedLocatableAsset;
pub type TreasuryPaymaster = PayOverXcm<
TreasuryInteriorLocation,
xcm_config::XcmRouter,
crate::PolkadotXcm,
ConstU32<{ 6 * HOURS }>,
Beneficiary,
AssetKind,
LocatableAssetConverter,
VersionedLocationConverter,
>;
impl pallet_treasury::Config for Runtime {
type ApproveOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type AssetKind = VersionedLocatableAsset;
type AssetKind = AssetKind;
type BalanceConverter = frame_support::traits::tokens::UnityAssetBalanceConversion;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::TreasuryArguments;
type Beneficiary = VersionedLocation;
type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::TreasuryArguments<
LocationParents,
BenchmarkParaId,
>;
type Beneficiary = Beneficiary;
type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
type Burn = ();
type BurnDestination = ();
@@ -543,16 +564,10 @@ impl pallet_treasury::Config for Runtime {
type MaxApprovals = MaxApprovals;
type OnSlash = Treasury;
type PalletId = TreasuryPalletId;
type Paymaster = PayOverXcm<
TreasuryInteriorLocation,
xcm_config::XcmRouter,
crate::PolkadotXcm,
ConstU32<{ 6 * HOURS }>,
Self::Beneficiary,
Self::AssetKind,
LocatableAssetConverter,
VersionedLocationConverter,
>;
#[cfg(feature = "runtime-benchmarks")]
type Paymaster = PayWithEnsure<TreasuryPaymaster, OpenHrmpChannel<BenchmarkParaId>>;
#[cfg(not(feature = "runtime-benchmarks"))]
type Paymaster = TreasuryPaymaster;
type PayoutPeriod = PayoutSpendPeriod;
type ProposalBond = ProposalBond;
type ProposalBondMaximum = ProposalBondMaximum;
@@ -562,7 +577,7 @@ impl pallet_treasury::Config for Runtime {
type SpendFunds = ();
type SpendOrigin = TreasurySpender;
type SpendPeriod = SpendPeriod;
type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
}
parameter_types! {
@@ -603,8 +618,7 @@ impl pallet_evm::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type SuicideQuickClearLimit = SuicideQuickClearLimit;
type Timestamp = Timestamp;
// FIXME: run the benchmarks
type WeightInfo = pallet_evm::weights::SubstrateWeight<Self>;
type WeightInfo = weights::pallet_evm::WeightInfo<Self>;
type WeightPerGas = WeightPerGas;
type WithdrawOrigin = EnsureAccountId20;
}