Newer
Older
// 5 Days = 72000 Blocks @ 6 sec per block
pub const EndingPeriod: BlockNumber = 5 * DAYS;
// ~ 1000 samples per day -> ~ 20 blocks per sample -> 2 minute samples
pub const SampleLength: BlockNumber = 2 * MINUTES;
}
impl auctions::Config for Runtime {
type Event = Event;
type Leaser = Slots;
type Registrar = Registrar;
type EndingPeriod = EndingPeriod;
type SampleLength = SampleLength;
type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
type InitiateOrigin = EnsureRoot<AccountId>;
type WeightInfo = weights::runtime_common_auctions::WeightInfo<Runtime>;
}
pub struct BalanceToU256;
impl sp_runtime::traits::Convert<Balance, sp_core::U256> for BalanceToU256 {
fn convert(n: Balance) -> sp_core::U256 {
n.into()
}
}
pub struct U256ToBalance;
impl sp_runtime::traits::Convert<sp_core::U256, Balance> for U256ToBalance {
fn convert(n: sp_core::U256) -> Balance {
use frame_support::traits::Defensive;
n.try_into().defensive_unwrap_or(Balance::MAX)
}
}
parameter_types! {
pub const PoolsPalletId: PalletId = PalletId(*b"py/nopls");
pub const MaxPointsToBalance: u8 = 10;
}
impl pallet_nomination_pools::Config for Runtime {
type Event = Event;
type WeightInfo = weights::pallet_nomination_pools::WeightInfo<Self>;
type Currency = Balances;
type CurrencyBalance = Balance;
type RewardCounter = FixedU128;
type BalanceToU256 = BalanceToU256;
type U256ToBalance = U256ToBalance;
type StakingInterface = Staking;
type PostUnbondingPoolsWindow = ConstU32<4>;
type MaxMetadataLen = ConstU32<256>;
// we use the same number of allowed unlocking chunks as with staking.
type MaxUnbonding = <Self as pallet_staking::Config>::MaxUnlockingChunks;
type PalletId = PoolsPalletId;
type MaxPointsToBalance = MaxPointsToBalance;
construct_runtime! {
pub enum Runtime where
Block = Block,
NodeBlock = primitives::v2::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
// Basic stuff; balances is uncallable initially.
Shaun Wang
committed
System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 0,
Shaun Wang
committed
Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned} = 1,
Shaun Wang
committed
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 2,
Indices: pallet_indices::{Pallet, Call, Storage, Config<T>, Event<T>} = 3,
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 4,
TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event<T>} = 26,
// Authorship must be before session in order to note author in the correct session and era
// for im-online and staking.
Shaun Wang
committed
Authorship: pallet_authorship::{Pallet, Call, Storage} = 5,
Staking: pallet_staking::{Pallet, Call, Storage, Config<T>, Event<T>} = 6,
Offences: pallet_offences::{Pallet, Storage, Event} = 7,
Shaun Wang
committed
Historical: session_historical::{Pallet} = 27,
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>} = 8,
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned} = 10,
ImOnline: pallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>} = 11,
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config} = 12,
Shaun Wang
committed
Utility: pallet_utility::{Pallet, Call, Event} = 16,
Shaun Wang
committed
Identity: pallet_identity::{Pallet, Call, Storage, Event<T>} = 17,
Shaun Wang
committed
Recovery: pallet_recovery::{Pallet, Call, Storage, Event<T>} = 18,
// Vesting. Usable initially, but removed once all vesting is finished.
Shaun Wang
committed
Vesting: pallet_vesting::{Pallet, Call, Storage, Event<T>, Config<T>} = 19,
Shaun Wang
committed
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 20,
// Preimage registrar.
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 28,
Shaun Wang
committed
Sudo: pallet_sudo::{Pallet, Call, Storage, Event<T>, Config<T>} = 21,
// Proxy module. Late addition.
Shaun Wang
committed
Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>} = 22,
// Multisig module. Late addition.
Shaun Wang
committed
Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>} = 23,
// Election pallet. Only works with staking, but placed here to maintain indices.
Shaun Wang
committed
ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event<T>, ValidateUnsigned} = 24,
Peter Goodspeed-Niklaus
committed
// Provides a semi-sorted list of nominators for staking.
VoterList: pallet_bags_list::{Pallet, Call, Storage, Event<T>} = 25,
Peter Goodspeed-Niklaus
committed
// Nomination pools for staking.
NominationPools: pallet_nomination_pools::{Pallet, Call, Storage, Event<T>, Config<T>} = 29,
// Parachains pallets. Start indices at 40 to leave room.
ParachainsOrigin: parachains_origin::{Pallet, Origin} = 41,
Configuration: parachains_configuration::{Pallet, Call, Storage, Config<T>} = 42,
ParasShared: parachains_shared::{Pallet, Call, Storage} = 43,
ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event<T>} = 44,
ParaInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent} = 45,
ParaScheduler: parachains_scheduler::{Pallet, Storage} = 46,
Paras: parachains_paras::{Pallet, Call, Storage, Event, Config} = 47,
Initializer: parachains_initializer::{Pallet, Call, Storage} = 48,
Dmp: parachains_dmp::{Pallet, Call, Storage} = 49,
Ump: parachains_ump::{Pallet, Call, Storage, Event} = 50,
Hrmp: parachains_hrmp::{Pallet, Call, Storage, Event<T>, Config} = 51,
ParaSessionInfo: parachains_session_info::{Pallet, Storage} = 52,
ParasDisputes: parachains_disputes::{Pallet, Call, Storage, Event<T>} = 53,
// Parachain Onboarding Pallets. Start indices at 60 to leave room.
Registrar: paras_registrar::{Pallet, Call, Storage, Event<T>, Config} = 60,
Slots: slots::{Pallet, Call, Storage, Event<T>} = 61,
ParasSudoWrapper: paras_sudo_wrapper::{Pallet, Call} = 62,
Auctions: auctions::{Pallet, Call, Storage, Event<T>} = 63,
Crowdloan: crowdloan::{Pallet, Call, Storage, Event<T>} = 64,
AssignedSlots: assigned_slots::{Pallet, Call, Storage, Event<T>} = 65,
// Pallet for sending XCM.
XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin, Config} = 99,
}
}
/// The address format for describing accounts.
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// Block type as expected by this runtime.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// A Block signed with a Justification
pub type SignedBlock = generic::SignedBlock<Block>;
/// `BlockId` type as expected by this runtime.
/// The `SignedExtension` to the basic transaction logic.
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
frame_system::CheckMortality<Runtime>,
frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Runtime,
Block,
frame_system::ChainContext<Runtime>,
Runtime,
(
pallet_nomination_pools::migration::v2::MigrateToV2<Runtime>,
pallet_staking::migrations::v10::MigrateToV10<Runtime>,
),
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;
#[cfg(feature = "runtime-benchmarks")]
mod benches {
define_benchmarks!(
// Polkadot
// NOTE: Make sure to prefix these with `runtime_common::` so
// the that path resolves correctly in the generated file.
[runtime_common::auctions, Auctions]
[runtime_common::crowdloan, Crowdloan]
[runtime_common::paras_registrar, Registrar]
[runtime_common::slots, Slots]
[runtime_parachains::configuration, Configuration]
[runtime_parachains::disputes, ParasDisputes]
[runtime_parachains::hrmp, Hrmp]
[runtime_parachains::initializer, Initializer]
[runtime_parachains::paras, Paras]
[runtime_parachains::paras_inherent, ParaInherent]
[runtime_parachains::ump, Ump]
[pallet_bags_list, VoterList]
[pallet_balances, Balances]
[pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
Georges
committed
[frame_election_provider_support, ElectionProviderBench::<Runtime>]
[pallet_identity, Identity]
[pallet_im_online, ImOnline]
[pallet_indices, Indices]
[pallet_multisig, Multisig]
[pallet_nomination_pools, NominationPoolsBench::<Runtime>]
[pallet_offences, OffencesBench::<Runtime>]
[pallet_preimage, Preimage]
[pallet_proxy, Proxy]
[pallet_recovery, Recovery]
[pallet_scheduler, Scheduler]
[pallet_session, SessionBench::<Runtime>]
[pallet_staking, Staking]
[frame_system, SystemBench::<Runtime>]
[pallet_timestamp, Timestamp]
[pallet_utility, Utility]
[pallet_vesting, Vesting]
// XCM
// NOTE: Make sure you point to the individual modules below.
[pallet_xcm_benchmarks::fungible, XcmBalances]
[pallet_xcm_benchmarks::generic, XcmGeneric]
);
}
#[cfg(not(feature = "disable-runtime-api"))]
sp_api::impl_runtime_apis! {
impl sp_api::Core<Block> for Runtime {
fn version() -> RuntimeVersion {
VERSION
}
fn execute_block(block: Block) {
Executive::execute_block(block);
}
fn initialize_block(header: &<Block as BlockT>::Header) {
Executive::initialize_block(header)
}
}
impl sp_api::Metadata<Block> for Runtime {
fn metadata() -> OpaqueMetadata {
OpaqueMetadata::new(Runtime::metadata().into())
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
}
}
impl block_builder_api::BlockBuilder<Block> for Runtime {
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
Executive::apply_extrinsic(extrinsic)
}
fn finalize_block() -> <Block as BlockT>::Header {
Executive::finalize_block()
}
fn inherent_extrinsics(data: inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
data.create_extrinsics()
}
fn check_inherents(
block: Block,
data: inherents::InherentData,
) -> inherents::CheckInherentsResult {
data.check_extrinsics(&block)
}
}
impl tx_pool_api::runtime_api::TaggedTransactionQueue<Block> for Runtime {
fn validate_transaction(
source: TransactionSource,
tx: <Block as BlockT>::Extrinsic,
block_hash: <Block as BlockT>::Hash,
Executive::validate_transaction(source, tx, block_hash)
}
}
impl offchain_primitives::OffchainWorkerApi<Block> for Runtime {
fn offchain_worker(header: &<Block as BlockT>::Header) {
Executive::offchain_worker(header)
}
}
impl primitives::runtime_api::ParachainHost<Block, Hash, BlockNumber> for Runtime {
fn validators() -> Vec<ValidatorId> {
parachains_runtime_api_impl::validators::<Runtime>()
fn validator_groups() -> (Vec<Vec<ValidatorIndex>>, GroupRotationInfo<BlockNumber>) {
parachains_runtime_api_impl::validator_groups::<Runtime>()
fn availability_cores() -> Vec<CoreState<Hash, BlockNumber>> {
parachains_runtime_api_impl::availability_cores::<Runtime>()
fn persisted_validation_data(para_id: ParaId, assumption: OccupiedCoreAssumption)
-> Option<PersistedValidationData<Hash, BlockNumber>> {
parachains_runtime_api_impl::persisted_validation_data::<Runtime>(para_id, assumption)
fn assumed_validation_data(
para_id: ParaId,
expected_persisted_validation_data_hash: Hash,
) -> Option<(PersistedValidationData<Hash, BlockNumber>, ValidationCodeHash)> {
parachains_runtime_api_impl::assumed_validation_data::<Runtime>(
para_id,
expected_persisted_validation_data_hash,
)
}
fn check_validation_outputs(
para_id: ParaId,
outputs: primitives::v2::CandidateCommitments,
parachains_runtime_api_impl::check_validation_outputs::<Runtime>(para_id, outputs)
fn session_index_for_child() -> SessionIndex {
parachains_runtime_api_impl::session_index_for_child::<Runtime>()
fn validation_code(para_id: ParaId, assumption: OccupiedCoreAssumption)
-> Option<ValidationCode> {
parachains_runtime_api_impl::validation_code::<Runtime>(para_id, assumption)
fn candidate_pending_availability(para_id: ParaId) -> Option<CommittedCandidateReceipt<Hash>> {
parachains_runtime_api_impl::candidate_pending_availability::<Runtime>(para_id)
fn candidate_events() -> Vec<CandidateEvent<Hash>> {
parachains_runtime_api_impl::candidate_events::<Runtime, _>(|ev| {
match ev {
Event::ParaInclusion(ev) => {
Some(ev)
}
_ => None,
}
})
}
fn session_info(index: SessionIndex) -> Option<SessionInfo> {
parachains_runtime_api_impl::session_info::<Runtime>(index)
fn dmq_contents(recipient: ParaId) -> Vec<InboundDownwardMessage<BlockNumber>> {
parachains_runtime_api_impl::dmq_contents::<Runtime>(recipient)
recipient: ParaId
) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>> {
parachains_runtime_api_impl::inbound_hrmp_channels_contents::<Runtime>(recipient)
fn validation_code_by_hash(hash: ValidationCodeHash) -> Option<ValidationCode> {
parachains_runtime_api_impl::validation_code_by_hash::<Runtime>(hash)
fn on_chain_votes() -> Option<ScrapedOnChainVotes<Hash>> {
parachains_runtime_api_impl::on_chain_votes::<Runtime>()
}
fn submit_pvf_check_statement(
Dan Shields
committed
stmt: PvfCheckStatement,
signature: ValidatorSignature,
) {
parachains_runtime_api_impl::submit_pvf_check_statement::<Runtime>(stmt, signature)
}
fn pvfs_require_precheck() -> Vec<ValidationCodeHash> {
parachains_runtime_api_impl::pvfs_require_precheck::<Runtime>()
}
fn validation_code_hash(para_id: ParaId, assumption: OccupiedCoreAssumption)
-> Option<ValidationCodeHash>
{
parachains_runtime_api_impl::validation_code_hash::<Runtime>(para_id, assumption)
}
fn staging_get_disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)> {
runtime_parachains::runtime_api_impl::vstaging::get_session_disputes::<Runtime>()
}
impl beefy_primitives::BeefyApi<Block> for Runtime {
fn validator_set() -> Option<beefy_primitives::ValidatorSet<BeefyId>> {
// dummy implementation due to lack of BEEFY pallet.
Adrian Catangiu
committed
impl mmr::MmrApi<Block, Hash> for Runtime {
fn generate_proof(_leaf_index: u64)
-> Result<(mmr::EncodableOpaqueLeaf, mmr::Proof<Hash>), mmr::Error>
{
Err(mmr::Error::PalletNotIncluded)
fn verify_proof(_leaf: mmr::EncodableOpaqueLeaf, _proof: mmr::Proof<Hash>)
-> Result<(), mmr::Error>
{
Err(mmr::Error::PalletNotIncluded)
}
fn verify_proof_stateless(
_root: Hash,
_leaf: mmr::EncodableOpaqueLeaf,
_proof: mmr::Proof<Hash>
) -> Result<(), mmr::Error> {
Err(mmr::Error::PalletNotIncluded)
Adrian Catangiu
committed
fn mmr_root() -> Result<Hash, mmr::Error> {
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
Err(mmr::Error::PalletNotIncluded)
}
fn generate_batch_proof(_leaf_indices: Vec<u64>)
-> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::BatchProof<Hash>), mmr::Error>
{
Err(mmr::Error::PalletNotIncluded)
}
fn verify_batch_proof(_leaves: Vec<mmr::EncodableOpaqueLeaf>, _proof: mmr::BatchProof<Hash>)
-> Result<(), mmr::Error>
{
Err(mmr::Error::PalletNotIncluded)
}
fn verify_batch_proof_stateless(
_root: Hash,
_leaves: Vec<mmr::EncodableOpaqueLeaf>,
_proof: mmr::BatchProof<Hash>
) -> Result<(), mmr::Error> {
Err(mmr::Error::PalletNotIncluded)
Adrian Catangiu
committed
}
impl fg_primitives::GrandpaApi<Block> for Runtime {
fn grandpa_authorities() -> Vec<(GrandpaId, u64)> {
Grandpa::grandpa_authorities()
}
fn current_set_id() -> fg_primitives::SetId {
Grandpa::current_set_id()
}
fn submit_report_equivocation_unsigned_extrinsic(
equivocation_proof: fg_primitives::EquivocationProof<
<Block as BlockT>::Hash,
sp_runtime::traits::NumberFor<Block>,
>,
key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,
) -> Option<()> {
let key_owner_proof = key_owner_proof.decode()?;
Grandpa::submit_unsigned_equivocation_report(
equivocation_proof,
key_owner_proof,
)
}
fn generate_key_ownership_proof(
_set_id: fg_primitives::SetId,
authority_id: fg_primitives::AuthorityId,
) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {
Historical::prove((fg_primitives::KEY_TYPE, authority_id))
.map(|p| p.encode())
.map(fg_primitives::OpaqueKeyOwnershipProof::new)
}
}
impl babe_primitives::BabeApi<Block> for Runtime {
fn configuration() -> babe_primitives::BabeGenesisConfiguration {
// The choice of `c` parameter (where `1 - c` represents the
// probability of a slot being empty), is done in accordance to the
// slot duration and expected target block time, for safely
// resisting network delays of maximum two seconds.
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
babe_primitives::BabeGenesisConfiguration {
slot_duration: Babe::slot_duration(),
epoch_length: EpochDuration::get(),
c: BABE_GENESIS_EPOCH_CONFIG.c,
genesis_authorities: Babe::authorities().to_vec(),
allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots,
fn current_epoch_start() -> babe_primitives::Slot {
fn current_epoch() -> babe_primitives::Epoch {
Babe::current_epoch()
}
fn next_epoch() -> babe_primitives::Epoch {
Babe::next_epoch()
}
fn generate_key_ownership_proof(
authority_id: babe_primitives::AuthorityId,
) -> Option<babe_primitives::OpaqueKeyOwnershipProof> {
Historical::prove((babe_primitives::KEY_TYPE, authority_id))
.map(|p| p.encode())
.map(babe_primitives::OpaqueKeyOwnershipProof::new)
}
fn submit_report_equivocation_unsigned_extrinsic(
equivocation_proof: babe_primitives::EquivocationProof<<Block as BlockT>::Header>,
key_owner_proof: babe_primitives::OpaqueKeyOwnershipProof,
) -> Option<()> {
let key_owner_proof = key_owner_proof.decode()?;
Babe::submit_unsigned_equivocation_report(
equivocation_proof,
key_owner_proof,
)
}
}
impl authority_discovery_primitives::AuthorityDiscoveryApi<Block> for Runtime {
fn authorities() -> Vec<AuthorityDiscoveryId> {
parachains_runtime_api_impl::relevant_authority_ids::<Runtime>()
}
}
impl sp_session::SessionKeys<Block> for Runtime {
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
SessionKeys::generate(seed)
}
fn decode_session_keys(
encoded: Vec<u8>,
) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
SessionKeys::decode_into_raw_public_keys(&encoded)
}
}
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
fn account_nonce(account: AccountId) -> Nonce {
System::account_nonce(account)
}
}
impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {
TransactionPayment::query_fee_details(uxt, len)
}
#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
Dan Shields
committed
fn on_runtime_upgrade() -> (frame_support::weights::Weight, frame_support::weights::Weight) {
log::info!("try-runtime::on_runtime_upgrade westend.");
let weight = Executive::try_runtime_upgrade().unwrap();
(weight, BlockWeights::get().max_block)
}
Dan Shields
committed
fn execute_block_no_check(block: Block) -> frame_support::weights::Weight {
Executive::execute_block_no_check(block)
#[cfg(feature = "runtime-benchmarks")]
impl frame_benchmarking::Benchmark<Block> for Runtime {
fn benchmark_metadata(extra: bool) -> (
Vec<frame_benchmarking::BenchmarkList>,
Vec<frame_support::traits::StorageInfo>,
) {
use frame_benchmarking::{Benchmarking, BenchmarkList};
use frame_support::traits::StorageInfoTrait;
use pallet_session_benchmarking::Pallet as SessionBench;
use pallet_offences_benchmarking::Pallet as OffencesBench;
Georges
committed
use pallet_election_provider_support_benchmarking::Pallet as ElectionProviderBench;
use frame_system_benchmarking::Pallet as SystemBench;
use pallet_nomination_pools_benchmarking::Pallet as NominationPoolsBench;
type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
let mut list = Vec::<BenchmarkList>::new();
let storage_info = AllPalletsWithSystem::storage_info();
return (list, storage_info)
}
Shawn Tabrizi
committed
config: frame_benchmarking::BenchmarkConfig,
Vec<frame_benchmarking::BenchmarkBatch>,
sp_runtime::RuntimeString,
> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, BenchmarkError};
// Trying to add benchmarks directly to some pallets caused cyclic dependency issues.
// To get around that, we separated the benchmarks into its own crate.
Shaun Wang
committed
use pallet_session_benchmarking::Pallet as SessionBench;
use pallet_offences_benchmarking::Pallet as OffencesBench;
Georges
committed
use pallet_election_provider_support_benchmarking::Pallet as ElectionProviderBench;
Shaun Wang
committed
use frame_system_benchmarking::Pallet as SystemBench;
use pallet_nomination_pools_benchmarking::Pallet as NominationPoolsBench;
impl pallet_session_benchmarking::Config for Runtime {}
impl pallet_offences_benchmarking::Config for Runtime {}
Georges
committed
impl pallet_election_provider_support_benchmarking::Config for Runtime {}
impl frame_system_benchmarking::Config for Runtime {}
impl pallet_nomination_pools_benchmarking::Config for Runtime {}
use xcm::latest::{
AssetId::*, Fungibility::*, Junctions::*, MultiAsset, MultiAssets, MultiLocation,
Response,
};
use xcm_config::{Westmint, WndLocation};
impl pallet_xcm_benchmarks::Config for Runtime {
type XcmConfig = xcm_config::XcmConfig;
type AccountIdConverter = xcm_config::LocationConverter;
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
Ok(Westmint::get())
}
fn worst_case_holding() -> MultiAssets {
// Westend only knows about WND.
vec![MultiAsset{
id: Concrete(WndLocation::get()),
fun: Fungible(1_000_000 * UNITS),
}].into()
}
}
parameter_types! {
pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some((
Westmint::get(),
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(WndLocation::get()) },
));
pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some((
Westmint::get(),
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(WndLocation::get()) },
));
}
impl pallet_xcm_benchmarks::fungible::Config for Runtime {
type TransactAsset = Balances;
type CheckedAccount = xcm_config::CheckAccount;
type TrustedTeleporter = TrustedTeleporter;
type TrustedReserve = TrustedReserve;
fn get_multi_asset() -> MultiAsset {
MultiAsset {
id: Concrete(WndLocation::get()),
fun: Fungible(1 * UNITS),
}
}
}
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
impl pallet_xcm_benchmarks::generic::Config for Runtime {
type Call = Call;
fn worst_case_response() -> (u64, Response) {
(0u64, Response::Version(Default::default()))
}
fn transact_origin() -> Result<MultiLocation, BenchmarkError> {
Ok(Westmint::get())
}
fn subscribe_origin() -> Result<MultiLocation, BenchmarkError> {
Ok(Westmint::get())
}
fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> {
let origin = Westmint::get();
let assets: MultiAssets = (Concrete(WndLocation::get()), 1_000 * UNITS).into();
let ticket = MultiLocation { parents: 0, interior: Here };
Ok((origin, ticket, assets))
}
}
type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;
let whitelist: Vec<TrackedStorageKey> = vec![
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
// Execution Phase
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
// Treasury Account
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da95ecffd7b6c0f78751baa9d281e0bfa3a6d6f646c70792f74727372790000000000000000000000000000000000000000").to_vec().into(),
// Dmp DownwardMessageQueueHeads
hex_literal::hex!("63f78c98723ddc9073523ef3beefda0c4d7fefc408aac59dbfe80a72ac8e3ce5").to_vec().into(),
// Dmp DownwardMessageQueues
hex_literal::hex!("63f78c98723ddc9073523ef3beefda0ca95dac46c07a40d91506e7637ec4ba57").to_vec().into(),
// Configuration ActiveConfig
hex_literal::hex!("06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385").to_vec().into(),
// The transactional storage limit.
hex_literal::hex!("3a7472616e73616374696f6e5f6c6576656c3a").to_vec().into(),
Shawn Tabrizi
committed
let params = (&config, &whitelist);
Ok(batches)