Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Redirect pallets weights generated by benchmarking in runtime (#195)
Browse files Browse the repository at this point in the history
[#180] Redirect pallets weights generated by benchmarking in runtime
  • Loading branch information
kalaninja authored Jun 13, 2023
1 parent 6756bf2 commit 3230c03
Show file tree
Hide file tree
Showing 29 changed files with 4,213 additions and 185 deletions.
17 changes: 7 additions & 10 deletions runtime/trappist/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@
// limitations under the License.

use crate::{
constants::currency::deposit, Balance, Balances, RandomnessCollectiveFlip, Runtime,
constants::currency::deposit, weights, Balance, Balances, RandomnessCollectiveFlip, Runtime,
RuntimeBlockWeights, RuntimeCall, RuntimeEvent, Timestamp,
};
use frame_support::{
parameter_types,
traits::{ConstBool, ConstU32, Nothing},
weights::Weight,
};
use pallet_contracts::{
weights::{SubstrateWeight, WeightInfo},
Config, DefaultAddressGenerator, Frame, Schedule,
};
use pallet_contracts::{weights::WeightInfo, Config, DefaultAddressGenerator, Frame, Schedule};
pub use parachains_common::AVERAGE_ON_INITIALIZE_RATIO;

// Prints debug output of the `contracts` pallet to stdout if the node is
Expand Down Expand Up @@ -62,15 +59,15 @@ impl Config for Runtime {
/// change because that would break already deployed contracts. The `Call` structure itself
/// is not allowed to change the indices of existing pallets, too.
type CallFilter = Nothing;
type DepositPerItem = DepositPerItem;
type DepositPerByte = DepositPerByte;
type WeightPrice = pallet_transaction_payment::Pallet<Self>;
type WeightInfo = SubstrateWeight<Self>;
type WeightInfo = weights::pallet_contracts::WeightInfo<Self>;
type ChainExtension = ();
type DeletionQueueDepth = DeletionQueueDepth;
type DeletionWeightLimit = DeletionWeightLimit;
type Schedule = MySchedule;
type CallStack = [Frame<Self>; 31];
type DeletionQueueDepth = DeletionQueueDepth;
type DeletionWeightLimit = DeletionWeightLimit;
type DepositPerByte = DepositPerByte;
type DepositPerItem = DepositPerItem;
type AddressGenerator = DefaultAddressGenerator;
type MaxCodeLen = ConstU32<{ 128 * 1024 }>;
type MaxStorageKeyLen = ConstU32<128>;
Expand Down
86 changes: 43 additions & 43 deletions runtime/trappist/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,24 +175,24 @@ impl frame_system::Config for Runtime {
type BaseCallFilter = LockdownMode;
type BlockWeights = RuntimeBlockWeights;
type BlockLength = RuntimeBlockLength;
type AccountId = AccountId;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Lookup = AccountIdLookup<AccountId, ()>;
type Index = Index;
type BlockNumber = BlockNumber;
type Hash = Hash;
type Hashing = BlakeTwo256;
type AccountId = AccountId;
type Lookup = AccountIdLookup<AccountId, ()>;
type Header = Header;
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
type BlockHashCount = BlockHashCount;
type DbWeight = RocksDbWeight;
type Version = Version;
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = ();
type AccountData = pallet_balances::AccountData<Balance>;
type SystemWeightInfo = frame_system::weights::SubstrateWeight<Runtime>;
type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
type SS58Prefix = ConstU16<42>;
type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
type MaxConsumers = ConstU32<16>;
Expand All @@ -203,7 +203,7 @@ impl pallet_timestamp::Config for Runtime {
type Moment = u64;
type OnTimestampSet = Aura;
type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;
type WeightInfo = pallet_timestamp::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
}

impl pallet_authorship::Config for Runtime {
Expand All @@ -214,15 +214,15 @@ impl pallet_authorship::Config for Runtime {
}

impl pallet_balances::Config for Runtime {
type MaxLocks = ConstU32<50>;
/// The type for recording an account's balance.
type Balance = Balance;
type DustRemoval = ();
/// The ubiquitous event type.
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ConstU128<EXISTENTIAL_DEPOSIT>;
type AccountStore = System;
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
type MaxLocks = ConstU32<50>;
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
}
Expand All @@ -236,11 +236,11 @@ impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction =
pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees<Runtime>>;
type OperationalFeeMultiplier = ConstU8<5>;
/// Relay Chain `TransactionByteFee` / 10
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
type OperationalFeeMultiplier = ConstU8<5>;
}

impl pallet_asset_tx_payment::Config for Runtime {
Expand All @@ -266,14 +266,14 @@ impl pallet_multisig::Config for Runtime {
type DepositBase = DepositBase;
type DepositFactor = DepositFactor;
type MaxSignatories = ConstU32<100>;
type WeightInfo = pallet_multisig::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
}

impl pallet_utility::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type PalletsOrigin = OriginCaller;
type WeightInfo = pallet_utility::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
}

parameter_types! {
Expand All @@ -285,9 +285,9 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnSystemEvent = ();
type SelfParaId = parachain_info::Pallet<Runtime>;
type OutboundXcmpMessageSource = XcmpQueue;
type DmpMessageHandler = LockdownMode;
type ReservedDmpWeight = ReservedDmpWeight;
type OutboundXcmpMessageSource = XcmpQueue;
type XcmpMessageHandler = XcmpQueue;
type ReservedXcmpWeight = ReservedXcmpWeight;
type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases;
Expand Down Expand Up @@ -315,13 +315,13 @@ impl pallet_session::Config for Runtime {
// Essentially just Aura, but lets be pedantic.
type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
type Keys = SessionKeys;
type WeightInfo = pallet_session::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
}

impl pallet_aura::Config for Runtime {
type AuthorityId = AuraId;
type DisabledValidators = ();
type MaxAuthorities = ConstU32<100_000>;
type DisabledValidators = ();
}

parameter_types! {
Expand All @@ -341,12 +341,12 @@ 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_sudo::Config for Runtime {
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
}

parameter_types! {
Expand All @@ -363,24 +363,24 @@ pub type AssetBalance = Balance;
impl pallet_assets::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = AssetBalance;
type RemoveItemsLimit = ConstU32<1000>;
type AssetId = AssetId;
type AssetIdParameter = parity_scale_codec::Compact<AssetId>;
type Currency = Balances;
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
type ForceOrigin = AssetsForceOrigin;
type AssetDeposit = ConstU128<{ UNITS }>;
type AssetAccountDeposit = ConstU128<{ UNITS }>;
type MetadataDepositBase = ConstU128<{ UNITS }>;
type MetadataDepositPerByte = ConstU128<{ 10 * CENTS }>;
type ApprovalDeposit = ConstU128<{ 10 * CENTS }>;
type StringLimit = ConstU32<50>;
type Freezer = ();
type Extra = ();
type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
type AssetAccountDeposit = ConstU128<{ UNITS }>;
type RemoveItemsLimit = ConstU32<1000>;
type CallbackHandle = ();
type WeightInfo = weights::pallet_assets::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
type CallbackHandle = ();
}

type CouncilCollective = pallet_collective::Instance1;
Expand All @@ -392,7 +392,7 @@ impl pallet_collective::Config<CouncilCollective> for Runtime {
type MaxProposals = ConstU32<100>;
type MaxMembers = ConstU32<100>;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_collective::WeightInfo<Runtime>;
}

type EnsureRootOrHalfCouncil = EitherOfDiverse<
Expand All @@ -418,7 +418,7 @@ impl pallet_identity::Config for Runtime {
type Slashed = ();
type ForceOrigin = EnsureRootOrHalfCouncil;
type RegistrarOrigin = EnsureRootOrHalfCouncil;
type WeightInfo = ();
type WeightInfo = weights::pallet_identity::WeightInfo<Runtime>;
}

parameter_types! {
Expand All @@ -438,6 +438,8 @@ impl pallet_uniques::Config for Runtime {
type ItemId = u32;
type Currency = Balances;
type ForceOrigin = frame_system::EnsureRoot<AccountId>;
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
type Locker = ();
type CollectionDeposit = CollectionDeposit;
type ItemDeposit = ItemDeposit;
type MetadataDepositBase = UniquesMetadataDepositBase;
Expand All @@ -446,11 +448,9 @@ impl pallet_uniques::Config for Runtime {
type StringLimit = StringLimit;
type KeyLimit = KeyLimit;
type ValueLimit = ValueLimit;
type WeightInfo = pallet_uniques::weights::SubstrateWeight<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type Helper = ();
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
type Locker = ();
type WeightInfo = weights::pallet_uniques::WeightInfo<Runtime>;
}

parameter_types! {
Expand All @@ -465,9 +465,9 @@ impl pallet_scheduler::Config for Runtime {
type RuntimeCall = RuntimeCall;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = frame_system::EnsureRoot<AccountId>;
type MaxScheduledPerBlock = ConstU32<512>;
type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>;
type OriginPrivilegeCmp = EqualPrivilegeOnly;
type MaxScheduledPerBlock = ConstU32<512>;
type WeightInfo = weights::pallet_scheduler::WeightInfo<Runtime>;
type Preimages = Preimage;
}

Expand All @@ -477,8 +477,8 @@ parameter_types! {
}

impl pallet_preimage::Config for Runtime {
type WeightInfo = pallet_preimage::weights::SubstrateWeight<Runtime>;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_preimage::WeightInfo<Runtime>;
type Currency = Balances;
type ManagerOrigin = EnsureRoot<AccountId>;
type BaseDeposit = PreimageBaseDeposit;
Expand All @@ -498,25 +498,24 @@ parameter_types! {
}

impl pallet_democracy::Config for Runtime {
type WeightInfo = pallet_democracy::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_democracy::WeightInfo<Runtime>;
type RuntimeEvent = RuntimeEvent;
type Scheduler = Scheduler;
type Preimages = Preimage;
type Currency = Balances;
type MinimumDeposit = MinimumDeposit;
type InstantAllowed = InstantAllowed;
type MaxVotes = MaxVotes;
type MaxProposals = MaxProposals;
type MaxDeposits = ConstU32<100>;
type MaxBlacklisted = ConstU32<100>;
type Slash = Treasury;
//Periods
type EnactmentPeriod = EnactmentPeriod;
type LaunchPeriod = LaunchPeriod;
type VotingPeriod = VotingPeriod;
type VoteLockingPeriod = EnactmentPeriod;
type MinimumDeposit = MinimumDeposit;
type InstantAllowed = InstantAllowed;
type FastTrackVotingPeriod = FastTrackVotingPeriod;
type CooloffPeriod = CooloffPeriod;
type MaxVotes = MaxVotes;
type MaxProposals = MaxProposals;
type MaxDeposits = ConstU32<100>;
type MaxBlacklisted = ConstU32<100>;
//Origins
//Council mayority can make proposal into referendum
type ExternalOrigin =
Expand All @@ -540,6 +539,7 @@ impl pallet_democracy::Config for Runtime {
>;
type VetoOrigin = pallet_collective::EnsureMember<AccountId, CouncilCollective>;
type PalletsOrigin = OriginCaller;
type Slash = Treasury;
}

parameter_types! {
Expand All @@ -556,7 +556,7 @@ impl pallet_dex::Config for Runtime {
type AssetId = AssetId;
type Assets = Assets;
type AssetRegistry = Assets;
type WeightInfo = pallet_dex::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_dex::WeightInfo<Runtime>;
type ProviderFeeNumerator = ConstU128<3>;
type ProviderFeeDenominator = ConstU128<1000>;
type MinDeposit = ConstU128<{ UNITS }>;
Expand All @@ -583,7 +583,7 @@ impl pallet_asset_registry::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type ReserveAssetModifierOrigin = frame_system::EnsureRoot<Self::AccountId>;
type Assets = Assets;
type WeightInfo = pallet_asset_registry::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_asset_registry::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = AssetRegistryBenchmarkHelper;
}
Expand Down Expand Up @@ -612,7 +612,6 @@ parameter_types! {
}

impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryPalletId;
type Currency = Balances;
type ApproveOrigin = TreasuryApproveCancelOrigin;
type RejectOrigin = TreasuryApproveCancelOrigin;
Expand All @@ -623,10 +622,11 @@ impl pallet_treasury::Config for Runtime {
type ProposalBondMaximum = ProposalBondMaximum;
type SpendPeriod = SpendPeriod;
type Burn = ();
type PalletId = TreasuryPalletId;
type BurnDestination = ();
type MaxApprovals = MaxApprovals;
type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
type SpendFunds = ();
type MaxApprovals = MaxApprovals;
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>;
}

Expand All @@ -636,7 +636,7 @@ impl pallet_lockdown_mode::Config for Runtime {
type BlackListedCalls = RuntimeBlackListedCalls;
type LockdownDmpHandler = LockdownDmpHandler;
type XcmExecutorManager = XcmExecutionManager;
type WeightInfo = pallet_lockdown_mode::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_lockdown_mode::WeightInfo<Runtime>;
}

// Create the runtime by composing the FRAME pallets that were previously configured.
Expand Down
Loading

0 comments on commit 3230c03

Please sign in to comment.