diff --git a/runtimes/eden/src/lib.rs b/runtimes/eden/src/lib.rs index a4b261c57ab..f7f6b561c9a 100644 --- a/runtimes/eden/src/lib.rs +++ b/runtimes/eden/src/lib.rs @@ -69,58 +69,58 @@ pub use version::native_version; pub use version::VERSION; construct_runtime! { - pub enum Runtime where - Block = Block, - NodeBlock = primitives::Block, - UncheckedExtrinsic = UncheckedExtrinsic - { - // System - System: frame_system = 0, - Timestamp: pallet_timestamp = 1, - Balances: pallet_balances = 2, - TransactionPayment: pallet_transaction_payment = 3, - RandomnessCollectiveFlip: pallet_randomness_collective_flip = 4, - - // Governance - Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 10, - CompanyReserve: pallet_reserve:: = 11, - InternationalReserve: pallet_reserve:: = 12, - UsaReserve: pallet_reserve:: = 13, - Vesting: pallet_grants = 14, - Mandate: pallet_mandate::{Pallet, Call, Storage, Event} = 15, - TechnicalCommittee: pallet_collective:: = 16, - TechnicalMembership: pallet_membership:: = 17, - - // Consensus - Authorship: pallet_authorship = 20, - ValidatorsSet: pallet_membership:: = 21, - Poa: pallet_poa = 22, - Session: pallet_session::{Pallet, Call, Storage, Event, Config} = 23, - Aura: pallet_aura::{Pallet, Config, Storage} = 24, - AuraExt: cumulus_pallet_aura_ext::{Pallet, Config, Storage} = 25, - - // Parachain - ParachainSystem: cumulus_pallet_parachain_system = 30, - ParachainInfo: parachain_info = 31, - CumulusXcm: cumulus_pallet_xcm = 32, - // XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event} = 33, - // DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event} = 34, - // PolkadotXcm: pallet_xcm::{Pallet, Call, Storage, Event, Origin, Config} = 35, - - // Neat things - Utility: pallet_utility = 40, - Multisig: pallet_multisig = 41, - Uniques: pallet_uniques = 42, - Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 43, - - // Nodle Stack - EmergencyShutdown: pallet_emergency_shutdown = 50, - Allocations: pallet_allocations = 51, - AllocationsOracles: pallet_membership:: = 52, - - // Temporary - Sudo: pallet_sudo = 60, - } + pub enum Runtime where + Block = Block, + NodeBlock = primitives::Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + // System + System: frame_system = 0, + Timestamp: pallet_timestamp = 1, + Balances: pallet_balances = 2, + TransactionPayment: pallet_transaction_payment = 3, + RandomnessCollectiveFlip: pallet_randomness_collective_flip = 4, + + // Governance + Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 10, + CompanyReserve: pallet_reserve:: = 11, + InternationalReserve: pallet_reserve:: = 12, + UsaReserve: pallet_reserve:: = 13, + Vesting: pallet_grants = 14, + Mandate: pallet_mandate::{Pallet, Call, Storage, Event} = 15, + TechnicalCommittee: pallet_collective:: = 16, + TechnicalMembership: pallet_membership:: = 17, + + // Consensus + Authorship: pallet_authorship = 20, + ValidatorsSet: pallet_membership:: = 21, + Poa: pallet_poa = 22, + Session: pallet_session::{Pallet, Call, Storage, Event, Config} = 23, + Aura: pallet_aura::{Pallet, Config, Storage} = 24, + AuraExt: cumulus_pallet_aura_ext::{Pallet, Config, Storage} = 25, + + // Parachain + ParachainSystem: cumulus_pallet_parachain_system = 30, + ParachainInfo: parachain_info = 31, + CumulusXcm: cumulus_pallet_xcm = 32, + // XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event} = 33, + // DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event} = 34, + // PolkadotXcm: pallet_xcm::{Pallet, Call, Storage, Event, Origin, Config} = 35, + + // Neat things + Utility: pallet_utility = 40, + Multisig: pallet_multisig = 41, + Uniques: pallet_uniques = 42, + Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 43, + + // Nodle Stack + EmergencyShutdown: pallet_emergency_shutdown = 50, + Allocations: pallet_allocations = 51, + AllocationsOracles: pallet_membership:: = 52, + + // Temporary + Sudo: pallet_sudo = 60, + } } /// The address format for describing accounts. @@ -154,194 +154,194 @@ pub type Executive = frame_executive::Executive, Runtime, AllPalletsWithSystem>; sp_api::impl_runtime_apis! { - impl sp_consensus_aura::AuraApi for Runtime { - fn slot_duration() -> sp_consensus_aura::SlotDuration { - sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration()) - } - - fn authorities() -> Vec { - Aura::authorities().into_inner() - } - } - - impl sp_session::SessionKeys for Runtime { - fn generate_session_keys(seed: Option>) -> Vec { - pallets_consensus::SessionKeys::generate(seed) - } - - fn decode_session_keys( - encoded: Vec, - ) -> Option, sp_core::crypto::KeyTypeId)>> { - pallets_consensus::SessionKeys::decode_into_raw_public_keys(&encoded) - } - } - - impl sp_api::Core for Runtime { - fn version() -> RuntimeVersion { - version::VERSION - } - - fn execute_block(block: Block) { - Executive::execute_block(block) - } - - fn initialize_block(header: &::Header) { - Executive::initialize_block(header) - } - } - - impl sp_api::Metadata for Runtime { - fn metadata() -> OpaqueMetadata { - OpaqueMetadata::new(Runtime::metadata().into()) - } - } - - impl sp_block_builder::BlockBuilder for Runtime { - fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { - Executive::apply_extrinsic(extrinsic) - } - - fn finalize_block() -> ::Header { - Executive::finalize_block() - } - - fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { - data.create_extrinsics() - } - - fn check_inherents( - block: Block, - data: sp_inherents::InherentData, - ) -> sp_inherents::CheckInherentsResult { - data.check_extrinsics(&block) - } - } - - impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { - fn validate_transaction( - source: TransactionSource, - tx: ::Extrinsic, - block_hash: ::Hash, - ) -> TransactionValidity { - Executive::validate_transaction(source, tx, block_hash) - } - } - - impl sp_offchain::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &::Header) { - Executive::offchain_worker(header) - } - } - - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Index { - System::account_nonce(account) - } - } - - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi< - Block, - Balance, - > for Runtime { - fn query_info(uxt: ::Extrinsic, len: u32) -> RuntimeDispatchInfo { - TransactionPayment::query_info(uxt, len) - } - - fn query_fee_details(uxt: ::Extrinsic, len: u32) -> FeeDetails { - TransactionPayment::query_fee_details(uxt, len) - } - } - - impl cumulus_primitives_core::CollectCollationInfo for Runtime { - fn collect_collation_info(header: &::Header) -> cumulus_primitives_core::CollationInfo { - ParachainSystem::collect_collation_info(header) - } - } - - #[cfg(feature = "runtime-benchmarks")] - impl frame_benchmarking::Benchmark for Runtime { - fn benchmark_metadata(extra: bool) -> ( - Vec, - Vec, - ) { - use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; - use frame_support::traits::StorageInfoTrait; - - // Trying to add benchmarks directly to the Session Pallet caused cyclic dependency - // issues. To get around that, we separated the Session benchmarks into its own crate, - // which is why we need these two lines below. - // use pallet_loans_benchmarking::Pallet as LoansBench; - use frame_system_benchmarking::Pallet as SystemBench; - - let mut list = Vec::::new(); - - list_benchmark!(list, extra, frame_system, SystemBench::); - list_benchmark!(list, extra, pallet_timestamp, Timestamp); - list_benchmark!(list, extra, pallet_balances, Balances); - list_benchmark!(list, extra, pallet_scheduler, Scheduler); - list_benchmark!(list, extra, pallet_preimage, Preimage); - list_benchmark!(list, extra, pallet_multisig, Multisig); - list_benchmark!(list, extra, pallet_reserve, CompanyReserve); - list_benchmark!(list, extra, pallet_grants, Vesting); - list_benchmark!(list, extra, pallet_uniques, Uniques); - list_benchmark!(list, extra, pallet_utility, Utility); - list_benchmark!(list, extra, pallet_emergency_shutdown, EmergencyShutdown); - list_benchmark!(list, extra, pallet_allocations, Allocations); - - let storage_info = AllPalletsWithSystem::storage_info(); - - (list, storage_info) - } - - fn dispatch_benchmark( - config: frame_benchmarking::BenchmarkConfig, - ) -> Result, sp_runtime::RuntimeString> { - // We did not include the offences and sessions benchmarks as they are parity - // specific and were causing some issues at compile time as they depend on the - // presence of the staking and elections pallets. - - use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, add_benchmark}; - - use frame_system_benchmarking::Pallet as SystemBench; - - impl frame_system_benchmarking::Config for Runtime {} - - let whitelist: Vec = vec![]; - let mut batches = Vec::::new(); - let params = (&config, &whitelist); - - add_benchmark!(params, batches, frame_system, SystemBench::); - add_benchmark!(params, batches, pallet_timestamp, Timestamp); - add_benchmark!(params, batches, pallet_balances, Balances); - add_benchmark!(params, batches, pallet_scheduler, Scheduler); - add_benchmark!(params, batches, pallet_preimage, Preimage); - add_benchmark!(params, batches, pallet_multisig, Multisig); - add_benchmark!(params, batches, pallet_reserve, CompanyReserve); - add_benchmark!(params, batches, pallet_grants, Vesting); - add_benchmark!(params, batches, pallet_uniques, Uniques); - add_benchmark!(params, batches, pallet_utility, Utility); - add_benchmark!(params, batches, pallet_emergency_shutdown, EmergencyShutdown); - add_benchmark!(params, batches, pallet_allocations, Allocations); - - if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } - Ok(batches) - } - } - - #[cfg(feature = "try-runtime")] - impl frame_try_runtime::TryRuntime for Runtime { - fn on_runtime_upgrade() -> (Weight, Weight) { - // NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to - // have a backtrace here. If any of the pre/post migration checks fail, we shall stop - // right here and right now. - let weight = Executive::try_runtime_upgrade().unwrap(); - (weight, constants::RuntimeBlockWeights::get().max_block) - } - - fn execute_block_no_check(block: Block) -> Weight { - Executive::execute_block_no_check(block) - } - } + impl sp_consensus_aura::AuraApi for Runtime { + fn slot_duration() -> sp_consensus_aura::SlotDuration { + sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration()) + } + + fn authorities() -> Vec { + Aura::authorities().into_inner() + } + } + + impl sp_session::SessionKeys for Runtime { + fn generate_session_keys(seed: Option>) -> Vec { + pallets_consensus::SessionKeys::generate(seed) + } + + fn decode_session_keys( + encoded: Vec, + ) -> Option, sp_core::crypto::KeyTypeId)>> { + pallets_consensus::SessionKeys::decode_into_raw_public_keys(&encoded) + } + } + + impl sp_api::Core for Runtime { + fn version() -> RuntimeVersion { + version::VERSION + } + + fn execute_block(block: Block) { + Executive::execute_block(block) + } + + fn initialize_block(header: &::Header) { + Executive::initialize_block(header) + } + } + + impl sp_api::Metadata for Runtime { + fn metadata() -> OpaqueMetadata { + OpaqueMetadata::new(Runtime::metadata().into()) + } + } + + impl sp_block_builder::BlockBuilder for Runtime { + fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { + Executive::apply_extrinsic(extrinsic) + } + + fn finalize_block() -> ::Header { + Executive::finalize_block() + } + + fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { + data.create_extrinsics() + } + + fn check_inherents( + block: Block, + data: sp_inherents::InherentData, + ) -> sp_inherents::CheckInherentsResult { + data.check_extrinsics(&block) + } + } + + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { + fn validate_transaction( + source: TransactionSource, + tx: ::Extrinsic, + block_hash: ::Hash, + ) -> TransactionValidity { + Executive::validate_transaction(source, tx, block_hash) + } + } + + impl sp_offchain::OffchainWorkerApi for Runtime { + fn offchain_worker(header: &::Header) { + Executive::offchain_worker(header) + } + } + + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(account: AccountId) -> Index { + System::account_nonce(account) + } + } + + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi< + Block, + Balance, + > for Runtime { + fn query_info(uxt: ::Extrinsic, len: u32) -> RuntimeDispatchInfo { + TransactionPayment::query_info(uxt, len) + } + + fn query_fee_details(uxt: ::Extrinsic, len: u32) -> FeeDetails { + TransactionPayment::query_fee_details(uxt, len) + } + } + + impl cumulus_primitives_core::CollectCollationInfo for Runtime { + fn collect_collation_info(header: &::Header) -> cumulus_primitives_core::CollationInfo { + ParachainSystem::collect_collation_info(header) + } + } + + #[cfg(feature = "runtime-benchmarks")] + impl frame_benchmarking::Benchmark for Runtime { + fn benchmark_metadata(extra: bool) -> ( + Vec, + Vec, + ) { + use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + use frame_support::traits::StorageInfoTrait; + + // Trying to add benchmarks directly to the Session Pallet caused cyclic dependency + // issues. To get around that, we separated the Session benchmarks into its own crate, + // which is why we need these two lines below. + // use pallet_loans_benchmarking::Pallet as LoansBench; + use frame_system_benchmarking::Pallet as SystemBench; + + let mut list = Vec::::new(); + + list_benchmark!(list, extra, frame_system, SystemBench::); + list_benchmark!(list, extra, pallet_timestamp, Timestamp); + list_benchmark!(list, extra, pallet_balances, Balances); + list_benchmark!(list, extra, pallet_scheduler, Scheduler); + list_benchmark!(list, extra, pallet_preimage, Preimage); + list_benchmark!(list, extra, pallet_multisig, Multisig); + list_benchmark!(list, extra, pallet_reserve, CompanyReserve); + list_benchmark!(list, extra, pallet_grants, Vesting); + list_benchmark!(list, extra, pallet_uniques, Uniques); + list_benchmark!(list, extra, pallet_utility, Utility); + list_benchmark!(list, extra, pallet_emergency_shutdown, EmergencyShutdown); + list_benchmark!(list, extra, pallet_allocations, Allocations); + + let storage_info = AllPalletsWithSystem::storage_info(); + + (list, storage_info) + } + + fn dispatch_benchmark( + config: frame_benchmarking::BenchmarkConfig, + ) -> Result, sp_runtime::RuntimeString> { + // We did not include the offences and sessions benchmarks as they are parity + // specific and were causing some issues at compile time as they depend on the + // presence of the staking and elections pallets. + + use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, add_benchmark}; + + use frame_system_benchmarking::Pallet as SystemBench; + + impl frame_system_benchmarking::Config for Runtime {} + + let whitelist: Vec = vec![]; + let mut batches = Vec::::new(); + let params = (&config, &whitelist); + + add_benchmark!(params, batches, frame_system, SystemBench::); + add_benchmark!(params, batches, pallet_timestamp, Timestamp); + add_benchmark!(params, batches, pallet_balances, Balances); + add_benchmark!(params, batches, pallet_scheduler, Scheduler); + add_benchmark!(params, batches, pallet_preimage, Preimage); + add_benchmark!(params, batches, pallet_multisig, Multisig); + add_benchmark!(params, batches, pallet_reserve, CompanyReserve); + add_benchmark!(params, batches, pallet_grants, Vesting); + add_benchmark!(params, batches, pallet_uniques, Uniques); + add_benchmark!(params, batches, pallet_utility, Utility); + add_benchmark!(params, batches, pallet_emergency_shutdown, EmergencyShutdown); + add_benchmark!(params, batches, pallet_allocations, Allocations); + + if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } + Ok(batches) + } + } + + #[cfg(feature = "try-runtime")] + impl frame_try_runtime::TryRuntime for Runtime { + fn on_runtime_upgrade() -> (Weight, Weight) { + // NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to + // have a backtrace here. If any of the pre/post migration checks fail, we shall stop + // right here and right now. + let weight = Executive::try_runtime_upgrade().unwrap(); + (weight, constants::RuntimeBlockWeights::get().max_block) + } + + fn execute_block_no_check(block: Block) -> Weight { + Executive::execute_block_no_check(block) + } + } } struct CheckInherents; diff --git a/runtimes/eden/src/pallets_util.rs b/runtimes/eden/src/pallets_util.rs index 9ab22364c26..0db969ae8c3 100644 --- a/runtimes/eden/src/pallets_util.rs +++ b/runtimes/eden/src/pallets_util.rs @@ -16,9 +16,8 @@ * along with this program. If not, see . */ use crate::{ - constants, implementations::RelayChainBlockNumberProvider, - pallets_governance::MoreThanHalfOfTechComm, Balances, Call, Event, Origin, OriginCaller, - Preimage, Runtime, + constants, implementations::RelayChainBlockNumberProvider, pallets_governance::MoreThanHalfOfTechComm, Balances, + Call, Event, Origin, OriginCaller, Preimage, Runtime, }; use frame_support::{ parameter_types, @@ -66,40 +65,40 @@ impl pallet_multisig::Config for Runtime { impl pallet_randomness_collective_flip::Config for Runtime {} parameter_types! { - pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * - constants::RuntimeBlockWeights::get().max_block; - pub const MaxScheduledPerBlock: u32 = 50; - pub const NoPreimagePostponement: Option = Some(10); + pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * + constants::RuntimeBlockWeights::get().max_block; + pub const MaxScheduledPerBlock: u32 = 50; + pub const NoPreimagePostponement: Option = Some(10); } impl pallet_scheduler::Config for Runtime { - type Event = Event; - type Origin = Origin; - type PalletsOrigin = OriginCaller; - type Call = Call; - type MaximumWeight = MaximumSchedulerWeight; - type ScheduleOrigin = frame_system::EnsureRoot; - type MaxScheduledPerBlock = MaxScheduledPerBlock; - type OriginPrivilegeCmp = EqualPrivilegeOnly; - type WeightInfo = pallet_scheduler::weights::SubstrateWeight; - type PreimageProvider = Preimage; - type NoPreimagePostponement = NoPreimagePostponement; + type Event = Event; + type Origin = Origin; + type PalletsOrigin = OriginCaller; + type Call = Call; + type MaximumWeight = MaximumSchedulerWeight; + type ScheduleOrigin = frame_system::EnsureRoot; + type MaxScheduledPerBlock = MaxScheduledPerBlock; + type OriginPrivilegeCmp = EqualPrivilegeOnly; + type WeightInfo = pallet_scheduler::weights::SubstrateWeight; + type PreimageProvider = Preimage; + type NoPreimagePostponement = NoPreimagePostponement; } parameter_types! { - pub const PreimageMaxSize: u32 = 4096 * 1024; - pub const PreimageBaseDeposit: Balance = constants::deposit(2, 64); - pub const PreimageByteDeposit: Balance = constants::deposit(0, 1); + pub const PreimageMaxSize: u32 = 4096 * 1024; + pub const PreimageBaseDeposit: Balance = constants::deposit(2, 64); + pub const PreimageByteDeposit: Balance = constants::deposit(0, 1); } impl pallet_preimage::Config for Runtime { - type WeightInfo = pallet_preimage::weights::SubstrateWeight; - type Event = Event; - type Currency = Balances; - type ManagerOrigin = EnsureRoot; - type MaxSize = PreimageMaxSize; - type BaseDeposit = PreimageBaseDeposit; - type ByteDeposit = PreimageByteDeposit; + type WeightInfo = pallet_preimage::weights::SubstrateWeight; + type Event = Event; + type Currency = Balances; + type ManagerOrigin = EnsureRoot; + type MaxSize = PreimageMaxSize; + type BaseDeposit = PreimageBaseDeposit; + type ByteDeposit = PreimageByteDeposit; } parameter_types! { diff --git a/runtimes/main/src/lib.rs b/runtimes/main/src/lib.rs index 62533bbef73..4feb310395c 100644 --- a/runtimes/main/src/lib.rs +++ b/runtimes/main/src/lib.rs @@ -72,59 +72,59 @@ pub use version::native_version; pub use version::VERSION; construct_runtime! { - pub enum Runtime where - Block = Block, - NodeBlock = primitives::Block, - UncheckedExtrinsic = UncheckedExtrinsic - { - // System - System: frame_system::{Pallet, Call, Storage, Config, Event} = 0, - Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 1, - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 2, - TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 3, - RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 4, - - // Consensus - Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned} = 5, - Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned} = 6, - Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent} = 7, - ImOnline: pallet_im_online::{Pallet, Call, Storage, Event, ValidateUnsigned, Config} = 8, - Offences: pallet_offences::{Pallet, Storage, Event} = 9, - ValidatorsSet: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 10, - Poa: pallet_poa::{Pallet, Storage} = 11, - Session: pallet_session::{Pallet, Call, Storage, Event, Config} = 12, - Historical: pallet_session_historical::{Pallet} = 13, - AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config} = 14, - - // Governance - TechnicalCommittee: pallet_collective::::{Pallet, Call, Storage, Origin, Event, Config} = 15, - TechnicalMembership: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 16, - FinancialCommittee: pallet_collective::::{Pallet, Call, Storage, Origin, Event, Config} = 17, - FinancialMembership: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 18, - RootCommittee: pallet_collective::::{Pallet, Call, Storage, Origin, Event, Config} = 19, - RootMembership: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 20, - Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 21, - Amendments: pallet_amendments::{Pallet, Call, Storage, Event} = 22, - Mandate: pallet_mandate::{Pallet, Call, Event} = 23, - CompanyReserve: pallet_reserve::::{Pallet, Call, Storage, Config, Event} = 24, - InternationalReserve: pallet_reserve::::{Pallet, Call, Storage, Config, Event} = 25, - UsaReserve: pallet_reserve::::{Pallet, Call, Storage, Config, Event} = 26, - Vesting: pallet_grants::{Pallet, Call, Storage, Config, Event} = 27, - - // Neat things - Utility: pallet_utility::{Pallet, Call, Event} = 28, - Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 29, - Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 30, - - // Nodle Stack - EmergencyShutdown: pallet_emergency_shutdown::{Pallet, Call, Event, Storage} = 33, - Allocations: pallet_allocations::{Pallet, Call, Event, Storage} = 34, - AllocationsOracles: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 35, - - WnodlOracleMembership: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 36, - KnownCustomerMembership: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 37, - Wnodl: pallet_wnodl::{Pallet, Call, Storage, Event, Config} = 38, - } + pub enum Runtime where + Block = Block, + NodeBlock = primitives::Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + // System + System: frame_system::{Pallet, Call, Storage, Config, Event} = 0, + Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 1, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 2, + TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 3, + RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 4, + + // Consensus + Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned} = 5, + Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned} = 6, + Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent} = 7, + ImOnline: pallet_im_online::{Pallet, Call, Storage, Event, ValidateUnsigned, Config} = 8, + Offences: pallet_offences::{Pallet, Storage, Event} = 9, + ValidatorsSet: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 10, + Poa: pallet_poa::{Pallet, Storage} = 11, + Session: pallet_session::{Pallet, Call, Storage, Event, Config} = 12, + Historical: pallet_session_historical::{Pallet} = 13, + AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config} = 14, + + // Governance + TechnicalCommittee: pallet_collective::::{Pallet, Call, Storage, Origin, Event, Config} = 15, + TechnicalMembership: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 16, + FinancialCommittee: pallet_collective::::{Pallet, Call, Storage, Origin, Event, Config} = 17, + FinancialMembership: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 18, + RootCommittee: pallet_collective::::{Pallet, Call, Storage, Origin, Event, Config} = 19, + RootMembership: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 20, + Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 21, + Amendments: pallet_amendments::{Pallet, Call, Storage, Event} = 22, + Mandate: pallet_mandate::{Pallet, Call, Event} = 23, + CompanyReserve: pallet_reserve::::{Pallet, Call, Storage, Config, Event} = 24, + InternationalReserve: pallet_reserve::::{Pallet, Call, Storage, Config, Event} = 25, + UsaReserve: pallet_reserve::::{Pallet, Call, Storage, Config, Event} = 26, + Vesting: pallet_grants::{Pallet, Call, Storage, Config, Event} = 27, + + // Neat things + Utility: pallet_utility::{Pallet, Call, Event} = 28, + Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 29, + Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 30, + + // Nodle Stack + EmergencyShutdown: pallet_emergency_shutdown::{Pallet, Call, Event, Storage} = 33, + Allocations: pallet_allocations::{Pallet, Call, Event, Storage} = 34, + AllocationsOracles: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 35, + + WnodlOracleMembership: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 36, + KnownCustomerMembership: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 37, + Wnodl: pallet_wnodl::{Pallet, Call, Storage, Event, Config} = 38, + } } /// The address format for describing accounts. @@ -160,284 +160,284 @@ pub type Executive = pub type BalancesCall = pallet_balances::Call; sp_api::impl_runtime_apis! { - impl sp_api::Core for Runtime { - fn version() -> RuntimeVersion { - version::VERSION - } - - fn execute_block(block: Block) { - Executive::execute_block(block) - } - - fn initialize_block(header: &::Header) { - Executive::initialize_block(header) - } - } - - impl sp_api::Metadata for Runtime { - fn metadata() -> OpaqueMetadata { - OpaqueMetadata::new(Runtime::metadata().into()) - } - } - - impl sp_block_builder::BlockBuilder for Runtime { - fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { - Executive::apply_extrinsic(extrinsic) - } - - fn finalize_block() -> ::Header { - Executive::finalize_block() - } - - fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { - data.create_extrinsics() - } - - fn check_inherents( - block: Block, - data: sp_inherents::InherentData, - ) -> sp_inherents::CheckInherentsResult { - data.check_extrinsics(&block) - } - } - - impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { - fn validate_transaction( - source: TransactionSource, - tx: ::Extrinsic, - block_hash: ::Hash, - ) -> TransactionValidity { - Executive::validate_transaction(source, tx, block_hash) - } - } - - impl sp_offchain::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &::Header) { - Executive::offchain_worker(header) - } - } - - impl fg_primitives::GrandpaApi for Runtime { - fn grandpa_authorities() -> GrandpaAuthorityList { - 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< - ::Hash, - NumberFor, - >, - 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: GrandpaId, - ) -> Option { - use codec::Encode; - - Historical::prove((fg_primitives::KEY_TYPE, authority_id)) - .map(|p| p.encode()) - .map(fg_primitives::OpaqueKeyOwnershipProof::new) - } - } - - impl sp_consensus_babe::BabeApi for Runtime { - fn configuration() -> sp_consensus_babe::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. - // - // c: crate::constants::PRIMARY_PROBABILITY, - // allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryPlainSlots, - sp_consensus_babe::BabeGenesisConfiguration { - slot_duration: Babe::slot_duration(), - epoch_length: EpochDuration::get(), - c: constants::BABE_GENESIS_EPOCH_CONFIG.c, - genesis_authorities: Babe::authorities().to_vec(), - randomness: Babe::randomness(), - allowed_slots: constants::BABE_GENESIS_EPOCH_CONFIG.allowed_slots, - } - } - - fn current_epoch_start() -> sp_consensus_babe::Slot { - Babe::current_epoch_start() - } - - fn current_epoch() -> sp_consensus_babe::Epoch { - Babe::current_epoch() - } - - fn next_epoch() -> sp_consensus_babe::Epoch { - Babe::next_epoch() - } - - fn generate_key_ownership_proof( - _slot_number: sp_consensus_babe::Slot, - authority_id: sp_consensus_babe::AuthorityId, - ) -> Option { - use codec::Encode; - Historical::prove((sp_consensus_babe::KEY_TYPE, authority_id)) - .map(|p| p.encode()) - .map(sp_consensus_babe::OpaqueKeyOwnershipProof::new) - } - - fn submit_report_equivocation_unsigned_extrinsic( - equivocation_proof: sp_consensus_babe::EquivocationProof<::Header>, - key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof, - ) -> Option<()> { - let key_owner_proof = key_owner_proof.decode()?; - - Babe::submit_unsigned_equivocation_report( - equivocation_proof, - key_owner_proof, - ) - } - } - - impl sp_authority_discovery::AuthorityDiscoveryApi for Runtime { - fn authorities() -> Vec { - AuthorityDiscovery::authorities() - } - } - - impl sp_session::SessionKeys for Runtime { - fn generate_session_keys(seed: Option>) -> Vec { - SessionKeys::generate(seed) - } - - fn decode_session_keys( - encoded: Vec, - ) -> Option, sp_core::crypto::KeyTypeId)>> { - SessionKeys::decode_into_raw_public_keys(&encoded) - } - } - - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Index { - System::account_nonce(account) - } - } - - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi< - Block, - Balance, - > for Runtime { - fn query_info(uxt: ::Extrinsic, len: u32) -> RuntimeDispatchInfo { - TransactionPayment::query_info(uxt, len) - } - - fn query_fee_details(uxt: ::Extrinsic, len: u32) -> FeeDetails { - TransactionPayment::query_fee_details(uxt, len) - } - } - - #[cfg(feature = "runtime-benchmarks")] - impl frame_benchmarking::Benchmark for Runtime { - fn benchmark_metadata(extra: bool) -> ( - Vec, - Vec, - ) { - use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; - use frame_support::traits::StorageInfoTrait; - - // Trying to add benchmarks directly to the Session Pallet caused cyclic dependency - // issues. To get around that, we separated the Session benchmarks into its own crate, - // which is why we need these two lines below. - // use pallet_loans_benchmarking::Pallet as LoansBench; - use frame_system_benchmarking::Pallet as SystemBench; - - let mut list = Vec::::new(); - - list_benchmark!(list, extra, frame_system, SystemBench::); - list_benchmark!(list, extra, pallet_timestamp, Timestamp); - list_benchmark!(list, extra, pallet_balances, Balances); - list_benchmark!(list, extra, pallet_babe, Babe); - list_benchmark!(list, extra, pallet_grandpa, Grandpa); - list_benchmark!(list, extra, pallet_im_online, ImOnline); - list_benchmark!(list, extra, pallet_collective, TechnicalCommittee); - list_benchmark!(list, extra, pallet_scheduler, Scheduler); - list_benchmark!(list, extra, pallet_preimage, Preimage); - list_benchmark!(list, extra, pallet_amendments, Amendments); - list_benchmark!(list, extra, pallet_multisig, Multisig); - list_benchmark!(list, extra, pallet_reserve, CompanyReserve); - list_benchmark!(list, extra, pallet_grants, Vesting); - list_benchmark!(list, extra, pallet_utility, Utility); - list_benchmark!(list, extra, pallet_emergency_shutdown, EmergencyShutdown); - list_benchmark!(list, extra, pallet_allocations, Allocations); - list_benchmark!(list, extra, pallet_wnodl, Wnodl); - - let storage_info = AllPalletsWithSystem::storage_info(); - - (list, storage_info) - } - - fn dispatch_benchmark( - config: frame_benchmarking::BenchmarkConfig, - ) -> Result, sp_runtime::RuntimeString> { - // We did not include the offences and sessions benchmarks as they are parity - // specific and were causing some issues at compile time as they depend on the - // presence of the staking and elections pallets. - - use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, add_benchmark}; - - use frame_system_benchmarking::Pallet as SystemBench; - - impl frame_system_benchmarking::Config for Runtime {} - - let whitelist: Vec = vec![]; - let mut batches = Vec::::new(); - let params = (&config, &whitelist); - - add_benchmark!(params, batches, frame_system, SystemBench::); - add_benchmark!(params, batches, pallet_timestamp, Timestamp); - add_benchmark!(params, batches, pallet_balances, Balances); - add_benchmark!(params, batches, pallet_babe, Babe); - add_benchmark!(params, batches, pallet_grandpa, Grandpa); - add_benchmark!(params, batches, pallet_im_online, ImOnline); - add_benchmark!(params, batches, pallet_collective, TechnicalCommittee); - add_benchmark!(params, batches, pallet_scheduler, Scheduler); - add_benchmark!(params, batches, pallet_preimage, Preimage); - add_benchmark!(params, batches, pallet_amendments, Amendments); - add_benchmark!(params, batches, pallet_multisig, Multisig); - add_benchmark!(params, batches, pallet_reserve, CompanyReserve); - add_benchmark!(params, batches, pallet_grants, Vesting); - add_benchmark!(params, batches, pallet_utility, Utility); - add_benchmark!(params, batches, pallet_emergency_shutdown, EmergencyShutdown); - add_benchmark!(params, batches, pallet_allocations, Allocations); - add_benchmark!(params, batches, pallet_wnodl, Wnodl); - - if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } - Ok(batches) - } - } - - #[cfg(feature = "try-runtime")] - impl frame_try_runtime::TryRuntime for Runtime { - fn on_runtime_upgrade() -> (Weight, Weight) { - // NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to - // have a backtrace here. If any of the pre/post migration checks fail, we shall stop - // right here and right now. - let weight = Executive::try_runtime_upgrade().unwrap(); - (weight, constants::RuntimeBlockWeights::get().max_block) - } - - fn execute_block_no_check(block: Block) -> Weight { - Executive::execute_block_no_check(block) - } - } + impl sp_api::Core for Runtime { + fn version() -> RuntimeVersion { + version::VERSION + } + + fn execute_block(block: Block) { + Executive::execute_block(block) + } + + fn initialize_block(header: &::Header) { + Executive::initialize_block(header) + } + } + + impl sp_api::Metadata for Runtime { + fn metadata() -> OpaqueMetadata { + OpaqueMetadata::new(Runtime::metadata().into()) + } + } + + impl sp_block_builder::BlockBuilder for Runtime { + fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { + Executive::apply_extrinsic(extrinsic) + } + + fn finalize_block() -> ::Header { + Executive::finalize_block() + } + + fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { + data.create_extrinsics() + } + + fn check_inherents( + block: Block, + data: sp_inherents::InherentData, + ) -> sp_inherents::CheckInherentsResult { + data.check_extrinsics(&block) + } + } + + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { + fn validate_transaction( + source: TransactionSource, + tx: ::Extrinsic, + block_hash: ::Hash, + ) -> TransactionValidity { + Executive::validate_transaction(source, tx, block_hash) + } + } + + impl sp_offchain::OffchainWorkerApi for Runtime { + fn offchain_worker(header: &::Header) { + Executive::offchain_worker(header) + } + } + + impl fg_primitives::GrandpaApi for Runtime { + fn grandpa_authorities() -> GrandpaAuthorityList { + 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< + ::Hash, + NumberFor, + >, + 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: GrandpaId, + ) -> Option { + use codec::Encode; + + Historical::prove((fg_primitives::KEY_TYPE, authority_id)) + .map(|p| p.encode()) + .map(fg_primitives::OpaqueKeyOwnershipProof::new) + } + } + + impl sp_consensus_babe::BabeApi for Runtime { + fn configuration() -> sp_consensus_babe::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. + // + // c: crate::constants::PRIMARY_PROBABILITY, + // allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryPlainSlots, + sp_consensus_babe::BabeGenesisConfiguration { + slot_duration: Babe::slot_duration(), + epoch_length: EpochDuration::get(), + c: constants::BABE_GENESIS_EPOCH_CONFIG.c, + genesis_authorities: Babe::authorities().to_vec(), + randomness: Babe::randomness(), + allowed_slots: constants::BABE_GENESIS_EPOCH_CONFIG.allowed_slots, + } + } + + fn current_epoch_start() -> sp_consensus_babe::Slot { + Babe::current_epoch_start() + } + + fn current_epoch() -> sp_consensus_babe::Epoch { + Babe::current_epoch() + } + + fn next_epoch() -> sp_consensus_babe::Epoch { + Babe::next_epoch() + } + + fn generate_key_ownership_proof( + _slot_number: sp_consensus_babe::Slot, + authority_id: sp_consensus_babe::AuthorityId, + ) -> Option { + use codec::Encode; + Historical::prove((sp_consensus_babe::KEY_TYPE, authority_id)) + .map(|p| p.encode()) + .map(sp_consensus_babe::OpaqueKeyOwnershipProof::new) + } + + fn submit_report_equivocation_unsigned_extrinsic( + equivocation_proof: sp_consensus_babe::EquivocationProof<::Header>, + key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof, + ) -> Option<()> { + let key_owner_proof = key_owner_proof.decode()?; + + Babe::submit_unsigned_equivocation_report( + equivocation_proof, + key_owner_proof, + ) + } + } + + impl sp_authority_discovery::AuthorityDiscoveryApi for Runtime { + fn authorities() -> Vec { + AuthorityDiscovery::authorities() + } + } + + impl sp_session::SessionKeys for Runtime { + fn generate_session_keys(seed: Option>) -> Vec { + SessionKeys::generate(seed) + } + + fn decode_session_keys( + encoded: Vec, + ) -> Option, sp_core::crypto::KeyTypeId)>> { + SessionKeys::decode_into_raw_public_keys(&encoded) + } + } + + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(account: AccountId) -> Index { + System::account_nonce(account) + } + } + + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi< + Block, + Balance, + > for Runtime { + fn query_info(uxt: ::Extrinsic, len: u32) -> RuntimeDispatchInfo { + TransactionPayment::query_info(uxt, len) + } + + fn query_fee_details(uxt: ::Extrinsic, len: u32) -> FeeDetails { + TransactionPayment::query_fee_details(uxt, len) + } + } + + #[cfg(feature = "runtime-benchmarks")] + impl frame_benchmarking::Benchmark for Runtime { + fn benchmark_metadata(extra: bool) -> ( + Vec, + Vec, + ) { + use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + use frame_support::traits::StorageInfoTrait; + + // Trying to add benchmarks directly to the Session Pallet caused cyclic dependency + // issues. To get around that, we separated the Session benchmarks into its own crate, + // which is why we need these two lines below. + // use pallet_loans_benchmarking::Pallet as LoansBench; + use frame_system_benchmarking::Pallet as SystemBench; + + let mut list = Vec::::new(); + + list_benchmark!(list, extra, frame_system, SystemBench::); + list_benchmark!(list, extra, pallet_timestamp, Timestamp); + list_benchmark!(list, extra, pallet_balances, Balances); + list_benchmark!(list, extra, pallet_babe, Babe); + list_benchmark!(list, extra, pallet_grandpa, Grandpa); + list_benchmark!(list, extra, pallet_im_online, ImOnline); + list_benchmark!(list, extra, pallet_collective, TechnicalCommittee); + list_benchmark!(list, extra, pallet_scheduler, Scheduler); + list_benchmark!(list, extra, pallet_preimage, Preimage); + list_benchmark!(list, extra, pallet_amendments, Amendments); + list_benchmark!(list, extra, pallet_multisig, Multisig); + list_benchmark!(list, extra, pallet_reserve, CompanyReserve); + list_benchmark!(list, extra, pallet_grants, Vesting); + list_benchmark!(list, extra, pallet_utility, Utility); + list_benchmark!(list, extra, pallet_emergency_shutdown, EmergencyShutdown); + list_benchmark!(list, extra, pallet_allocations, Allocations); + list_benchmark!(list, extra, pallet_wnodl, Wnodl); + + let storage_info = AllPalletsWithSystem::storage_info(); + + (list, storage_info) + } + + fn dispatch_benchmark( + config: frame_benchmarking::BenchmarkConfig, + ) -> Result, sp_runtime::RuntimeString> { + // We did not include the offences and sessions benchmarks as they are parity + // specific and were causing some issues at compile time as they depend on the + // presence of the staking and elections pallets. + + use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, add_benchmark}; + + use frame_system_benchmarking::Pallet as SystemBench; + + impl frame_system_benchmarking::Config for Runtime {} + + let whitelist: Vec = vec![]; + let mut batches = Vec::::new(); + let params = (&config, &whitelist); + + add_benchmark!(params, batches, frame_system, SystemBench::); + add_benchmark!(params, batches, pallet_timestamp, Timestamp); + add_benchmark!(params, batches, pallet_balances, Balances); + add_benchmark!(params, batches, pallet_babe, Babe); + add_benchmark!(params, batches, pallet_grandpa, Grandpa); + add_benchmark!(params, batches, pallet_im_online, ImOnline); + add_benchmark!(params, batches, pallet_collective, TechnicalCommittee); + add_benchmark!(params, batches, pallet_scheduler, Scheduler); + add_benchmark!(params, batches, pallet_preimage, Preimage); + add_benchmark!(params, batches, pallet_amendments, Amendments); + add_benchmark!(params, batches, pallet_multisig, Multisig); + add_benchmark!(params, batches, pallet_reserve, CompanyReserve); + add_benchmark!(params, batches, pallet_grants, Vesting); + add_benchmark!(params, batches, pallet_utility, Utility); + add_benchmark!(params, batches, pallet_emergency_shutdown, EmergencyShutdown); + add_benchmark!(params, batches, pallet_allocations, Allocations); + add_benchmark!(params, batches, pallet_wnodl, Wnodl); + + if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } + Ok(batches) + } + } + + #[cfg(feature = "try-runtime")] + impl frame_try_runtime::TryRuntime for Runtime { + fn on_runtime_upgrade() -> (Weight, Weight) { + // NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to + // have a backtrace here. If any of the pre/post migration checks fail, we shall stop + // right here and right now. + let weight = Executive::try_runtime_upgrade().unwrap(); + (weight, constants::RuntimeBlockWeights::get().max_block) + } + + fn execute_block_no_check(block: Block) -> Weight { + Executive::execute_block_no_check(block) + } + } } #[cfg(test)] diff --git a/runtimes/main/src/pallets_util.rs b/runtimes/main/src/pallets_util.rs index 8c7e3adaa7f..c7c063b118e 100644 --- a/runtimes/main/src/pallets_util.rs +++ b/runtimes/main/src/pallets_util.rs @@ -19,8 +19,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use crate::{ - constants, pallets_governance::FinancialCollective, Balances, Call, Event, Origin, - OriginCaller, Preimage, Runtime, + constants, pallets_governance::FinancialCollective, Balances, Call, Event, Origin, OriginCaller, Preimage, Runtime, }; use frame_support::{parameter_types, traits::EqualPrivilegeOnly, weights::Weight}; @@ -64,38 +63,38 @@ impl pallet_multisig::Config for Runtime { impl pallet_randomness_collective_flip::Config for Runtime {} parameter_types! { - pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * - constants::RuntimeBlockWeights::get().max_block; - pub const MaxScheduledPerBlock: u32 = 50; - pub const NoPreimagePostponement: Option = Some(10); + pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * + constants::RuntimeBlockWeights::get().max_block; + pub const MaxScheduledPerBlock: u32 = 50; + pub const NoPreimagePostponement: Option = Some(10); } impl pallet_scheduler::Config for Runtime { - type Event = Event; - type Origin = Origin; - type PalletsOrigin = OriginCaller; - type Call = Call; - type MaximumWeight = MaximumSchedulerWeight; - type ScheduleOrigin = EnsureRoot; - type MaxScheduledPerBlock = MaxScheduledPerBlock; - type OriginPrivilegeCmp = EqualPrivilegeOnly; - type WeightInfo = pallet_scheduler::weights::SubstrateWeight; - type PreimageProvider = Preimage; - type NoPreimagePostponement = NoPreimagePostponement; + type Event = Event; + type Origin = Origin; + type PalletsOrigin = OriginCaller; + type Call = Call; + type MaximumWeight = MaximumSchedulerWeight; + type ScheduleOrigin = EnsureRoot; + type MaxScheduledPerBlock = MaxScheduledPerBlock; + type OriginPrivilegeCmp = EqualPrivilegeOnly; + type WeightInfo = pallet_scheduler::weights::SubstrateWeight; + type PreimageProvider = Preimage; + type NoPreimagePostponement = NoPreimagePostponement; } parameter_types! { - pub const PreimageMaxSize: u32 = 4096 * 1024; - pub const PreimageBaseDeposit: Balance = constants::deposit(2, 64); - pub const PreimageByteDeposit: Balance = constants::deposit(0, 1); + pub const PreimageMaxSize: u32 = 4096 * 1024; + pub const PreimageBaseDeposit: Balance = constants::deposit(2, 64); + pub const PreimageByteDeposit: Balance = constants::deposit(0, 1); } impl pallet_preimage::Config for Runtime { - type WeightInfo = pallet_preimage::weights::SubstrateWeight; - type Event = Event; - type Currency = Balances; - type ManagerOrigin = EnsureRoot; - type MaxSize = PreimageMaxSize; - type BaseDeposit = PreimageBaseDeposit; - type ByteDeposit = PreimageByteDeposit; + type WeightInfo = pallet_preimage::weights::SubstrateWeight; + type Event = Event; + type Currency = Balances; + type ManagerOrigin = EnsureRoot; + type MaxSize = PreimageMaxSize; + type BaseDeposit = PreimageBaseDeposit; + type ByteDeposit = PreimageByteDeposit; } diff --git a/runtimes/staking/src/lib.rs b/runtimes/staking/src/lib.rs index 9bb97c479b0..b30a5215e01 100644 --- a/runtimes/staking/src/lib.rs +++ b/runtimes/staking/src/lib.rs @@ -70,40 +70,40 @@ pub use version::native_version; pub use version::VERSION; construct_runtime! { - pub enum Runtime where - Block = Block, - NodeBlock = primitives::Block, - UncheckedExtrinsic = UncheckedExtrinsic - { - // System - System: frame_system::{Pallet, Call, Storage, Config, Event} = 0, - Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 1, - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 2, - TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 3, - RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 4, - - // Consensus - Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned} = 5, - Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned} = 6, - Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent} = 7, - ImOnline: pallet_im_online::{Pallet, Call, Storage, Event, ValidateUnsigned, Config} = 8, - Offences: pallet_offences::{Pallet, Storage, Event} = 9, - Staking: pallet_staking::{Pallet, Call, Storage, Event, Config} = 11, - Session: pallet_session::{Pallet, Call, Storage, Event, Config} = 12, - Historical: pallet_session_historical::{Pallet} = 13, - AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config} = 14, - - // Governance - RootCommittee: pallet_collective::::{Pallet, Call, Storage, Origin, Event, Config} = 19, - RootMembership: pallet_membership::{Pallet, Call, Storage, Event, Config} = 20, - Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 21, - Mandate: pallet_mandate::{Pallet, Call, Event} = 23, - - // Neat things - Utility: pallet_utility::{Pallet, Call, Event} = 28, - Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 29, - Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 30, - } + pub enum Runtime where + Block = Block, + NodeBlock = primitives::Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + // System + System: frame_system::{Pallet, Call, Storage, Config, Event} = 0, + Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 1, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 2, + TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 3, + RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 4, + + // Consensus + Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned} = 5, + Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned} = 6, + Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent} = 7, + ImOnline: pallet_im_online::{Pallet, Call, Storage, Event, ValidateUnsigned, Config} = 8, + Offences: pallet_offences::{Pallet, Storage, Event} = 9, + Staking: pallet_staking::{Pallet, Call, Storage, Event, Config} = 11, + Session: pallet_session::{Pallet, Call, Storage, Event, Config} = 12, + Historical: pallet_session_historical::{Pallet} = 13, + AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config} = 14, + + // Governance + RootCommittee: pallet_collective::::{Pallet, Call, Storage, Origin, Event, Config} = 19, + RootMembership: pallet_membership::{Pallet, Call, Storage, Event, Config} = 20, + Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 21, + Mandate: pallet_mandate::{Pallet, Call, Event} = 23, + + // Neat things + Utility: pallet_utility::{Pallet, Call, Event} = 28, + Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 29, + Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 30, + } } /// The address format for describing accounts. @@ -139,272 +139,272 @@ pub type Executive = pub type BalancesCall = pallet_balances::Call; sp_api::impl_runtime_apis! { - impl sp_api::Core for Runtime { - fn version() -> RuntimeVersion { - version::VERSION - } - - fn execute_block(block: Block) { - Executive::execute_block(block) - } - - fn initialize_block(header: &::Header) { - Executive::initialize_block(header) - } - } - - impl sp_api::Metadata for Runtime { - fn metadata() -> OpaqueMetadata { - OpaqueMetadata::new(Runtime::metadata().into()) - } - } - - impl sp_block_builder::BlockBuilder for Runtime { - fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { - Executive::apply_extrinsic(extrinsic) - } - - fn finalize_block() -> ::Header { - Executive::finalize_block() - } - - fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { - data.create_extrinsics() - } - - fn check_inherents( - block: Block, - data: sp_inherents::InherentData, - ) -> sp_inherents::CheckInherentsResult { - data.check_extrinsics(&block) - } - } - - impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { - fn validate_transaction( - source: TransactionSource, - tx: ::Extrinsic, - block_hash: ::Hash, - ) -> TransactionValidity { - Executive::validate_transaction(source, tx, block_hash) - } - } - - impl sp_offchain::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &::Header) { - Executive::offchain_worker(header) - } - } - - impl fg_primitives::GrandpaApi for Runtime { - fn grandpa_authorities() -> GrandpaAuthorityList { - 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< - ::Hash, - NumberFor, - >, - 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: GrandpaId, - ) -> Option { - use codec::Encode; - - Historical::prove((fg_primitives::KEY_TYPE, authority_id)) - .map(|p| p.encode()) - .map(fg_primitives::OpaqueKeyOwnershipProof::new) - } - } - - impl sp_consensus_babe::BabeApi for Runtime { - fn configuration() -> sp_consensus_babe::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. - // - sp_consensus_babe::BabeGenesisConfiguration { - slot_duration: Babe::slot_duration(), - epoch_length: EpochDuration::get(), - c: constants::BABE_GENESIS_EPOCH_CONFIG.c, - genesis_authorities: Babe::authorities().to_vec(), - randomness: Babe::randomness(), - allowed_slots: constants::BABE_GENESIS_EPOCH_CONFIG.allowed_slots, - } - } - - fn current_epoch_start() -> sp_consensus_babe::Slot { - Babe::current_epoch_start() - } - - fn current_epoch() -> sp_consensus_babe::Epoch { - Babe::current_epoch() - } - - fn next_epoch() -> sp_consensus_babe::Epoch { - Babe::next_epoch() - } - - fn generate_key_ownership_proof( - _slot_number: sp_consensus_babe::Slot, - authority_id: sp_consensus_babe::AuthorityId, - ) -> Option { - use codec::Encode; - Historical::prove((sp_consensus_babe::KEY_TYPE, authority_id)) - .map(|p| p.encode()) - .map(sp_consensus_babe::OpaqueKeyOwnershipProof::new) - } - - fn submit_report_equivocation_unsigned_extrinsic( - equivocation_proof: sp_consensus_babe::EquivocationProof<::Header>, - key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof, - ) -> Option<()> { - let key_owner_proof = key_owner_proof.decode()?; - - Babe::submit_unsigned_equivocation_report( - equivocation_proof, - key_owner_proof, - ) - } - } - - impl sp_authority_discovery::AuthorityDiscoveryApi for Runtime { - fn authorities() -> Vec { - AuthorityDiscovery::authorities() - } - } - - impl sp_session::SessionKeys for Runtime { - fn generate_session_keys(seed: Option>) -> Vec { - SessionKeys::generate(seed) - } - - fn decode_session_keys( - encoded: Vec, - ) -> Option, sp_core::crypto::KeyTypeId)>> { - SessionKeys::decode_into_raw_public_keys(&encoded) - } - } - - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Index { - System::account_nonce(account) - } - } - - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi< - Block, - Balance, - > for Runtime { - fn query_info(uxt: ::Extrinsic, len: u32) -> RuntimeDispatchInfo { - TransactionPayment::query_info(uxt, len) - } - - fn query_fee_details(uxt: ::Extrinsic, len: u32) -> FeeDetails { - TransactionPayment::query_fee_details(uxt, len) - } - } - - #[cfg(feature = "runtime-benchmarks")] - impl frame_benchmarking::Benchmark for Runtime { - fn benchmark_metadata(extra: bool) -> ( - Vec, - Vec, - ) { - use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; - use frame_support::traits::StorageInfoTrait; - - // Trying to add benchmarks directly to the Session Pallet caused cyclic dependency - // issues. To get around that, we separated the Session benchmarks into its own crate, - // which is why we need these two lines below. - // use pallet_loans_benchmarking::Pallet as LoansBench; - use frame_system_benchmarking::Pallet as SystemBench; - - let mut list = Vec::::new(); - - list_benchmark!(list, extra, frame_system, SystemBench::); - list_benchmark!(list, extra, pallet_timestamp, Timestamp); - list_benchmark!(list, extra, pallet_balances, Balances); - list_benchmark!(list, extra, pallet_babe, Babe); - list_benchmark!(list, extra, pallet_grandpa, Grandpa); - list_benchmark!(list, extra, pallet_im_online, ImOnline); - list_benchmark!(list, extra, pallet_staking, Staking); - list_benchmark!(list, extra, pallet_collective, RootCommittee); - list_benchmark!(list, extra, pallet_scheduler, Scheduler); - list_benchmark!(list, extra, pallet_preimage, Preimage); - list_benchmark!(list, extra, pallet_utility, Utility); - list_benchmark!(list, extra, pallet_multisig, Multisig); - - let storage_info = AllPalletsWithSystem::storage_info(); - - (list, storage_info) - } - - fn dispatch_benchmark( - config: frame_benchmarking::BenchmarkConfig, - ) -> Result, sp_runtime::RuntimeString> { - // We did not include the offences and sessions benchmarks as they are parity - // specific and were causing some issues at compile time as they depend on the - // presence of the staking and elections pallets. - - use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, add_benchmark}; - - use frame_system_benchmarking::Pallet as SystemBench; - - impl frame_system_benchmarking::Config for Runtime {} - - let whitelist: Vec = vec![]; - let mut batches = Vec::::new(); - let params = (&config, &whitelist); - - add_benchmark!(params, batches, frame_system, SystemBench::); - add_benchmark!(params, batches, pallet_timestamp, Timestamp); - add_benchmark!(params, batches, pallet_balances, Balances); - add_benchmark!(params, batches, pallet_babe, Babe); - add_benchmark!(params, batches, pallet_grandpa, Grandpa); - add_benchmark!(params, batches, pallet_im_online, ImOnline); - add_benchmark!(params, batches, pallet_staking, Staking); - add_benchmark!(params, batches, pallet_collective, RootCommittee); - add_benchmark!(params, batches, pallet_scheduler, Scheduler); - add_benchmark!(params, batches, pallet_preimage, Preimage); - add_benchmark!(params, batches, pallet_utility, Utility); - add_benchmark!(params, batches, pallet_multisig, Multisig); - - if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } - Ok(batches) - } - } - - #[cfg(feature = "try-runtime")] - impl frame_try_runtime::TryRuntime for Runtime { - fn on_runtime_upgrade() -> (Weight, Weight) { - // NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to - // have a backtrace here. If any of the pre/post migration checks fail, we shall stop - // right here and right now. - let weight = Executive::try_runtime_upgrade().unwrap(); - (weight, constants::RuntimeBlockWeights::get().max_block) - } - - fn execute_block_no_check(block: Block) -> Weight { - Executive::execute_block_no_check(block) - } - } + impl sp_api::Core for Runtime { + fn version() -> RuntimeVersion { + version::VERSION + } + + fn execute_block(block: Block) { + Executive::execute_block(block) + } + + fn initialize_block(header: &::Header) { + Executive::initialize_block(header) + } + } + + impl sp_api::Metadata for Runtime { + fn metadata() -> OpaqueMetadata { + OpaqueMetadata::new(Runtime::metadata().into()) + } + } + + impl sp_block_builder::BlockBuilder for Runtime { + fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { + Executive::apply_extrinsic(extrinsic) + } + + fn finalize_block() -> ::Header { + Executive::finalize_block() + } + + fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { + data.create_extrinsics() + } + + fn check_inherents( + block: Block, + data: sp_inherents::InherentData, + ) -> sp_inherents::CheckInherentsResult { + data.check_extrinsics(&block) + } + } + + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { + fn validate_transaction( + source: TransactionSource, + tx: ::Extrinsic, + block_hash: ::Hash, + ) -> TransactionValidity { + Executive::validate_transaction(source, tx, block_hash) + } + } + + impl sp_offchain::OffchainWorkerApi for Runtime { + fn offchain_worker(header: &::Header) { + Executive::offchain_worker(header) + } + } + + impl fg_primitives::GrandpaApi for Runtime { + fn grandpa_authorities() -> GrandpaAuthorityList { + 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< + ::Hash, + NumberFor, + >, + 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: GrandpaId, + ) -> Option { + use codec::Encode; + + Historical::prove((fg_primitives::KEY_TYPE, authority_id)) + .map(|p| p.encode()) + .map(fg_primitives::OpaqueKeyOwnershipProof::new) + } + } + + impl sp_consensus_babe::BabeApi for Runtime { + fn configuration() -> sp_consensus_babe::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. + // + sp_consensus_babe::BabeGenesisConfiguration { + slot_duration: Babe::slot_duration(), + epoch_length: EpochDuration::get(), + c: constants::BABE_GENESIS_EPOCH_CONFIG.c, + genesis_authorities: Babe::authorities().to_vec(), + randomness: Babe::randomness(), + allowed_slots: constants::BABE_GENESIS_EPOCH_CONFIG.allowed_slots, + } + } + + fn current_epoch_start() -> sp_consensus_babe::Slot { + Babe::current_epoch_start() + } + + fn current_epoch() -> sp_consensus_babe::Epoch { + Babe::current_epoch() + } + + fn next_epoch() -> sp_consensus_babe::Epoch { + Babe::next_epoch() + } + + fn generate_key_ownership_proof( + _slot_number: sp_consensus_babe::Slot, + authority_id: sp_consensus_babe::AuthorityId, + ) -> Option { + use codec::Encode; + Historical::prove((sp_consensus_babe::KEY_TYPE, authority_id)) + .map(|p| p.encode()) + .map(sp_consensus_babe::OpaqueKeyOwnershipProof::new) + } + + fn submit_report_equivocation_unsigned_extrinsic( + equivocation_proof: sp_consensus_babe::EquivocationProof<::Header>, + key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof, + ) -> Option<()> { + let key_owner_proof = key_owner_proof.decode()?; + + Babe::submit_unsigned_equivocation_report( + equivocation_proof, + key_owner_proof, + ) + } + } + + impl sp_authority_discovery::AuthorityDiscoveryApi for Runtime { + fn authorities() -> Vec { + AuthorityDiscovery::authorities() + } + } + + impl sp_session::SessionKeys for Runtime { + fn generate_session_keys(seed: Option>) -> Vec { + SessionKeys::generate(seed) + } + + fn decode_session_keys( + encoded: Vec, + ) -> Option, sp_core::crypto::KeyTypeId)>> { + SessionKeys::decode_into_raw_public_keys(&encoded) + } + } + + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(account: AccountId) -> Index { + System::account_nonce(account) + } + } + + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi< + Block, + Balance, + > for Runtime { + fn query_info(uxt: ::Extrinsic, len: u32) -> RuntimeDispatchInfo { + TransactionPayment::query_info(uxt, len) + } + + fn query_fee_details(uxt: ::Extrinsic, len: u32) -> FeeDetails { + TransactionPayment::query_fee_details(uxt, len) + } + } + + #[cfg(feature = "runtime-benchmarks")] + impl frame_benchmarking::Benchmark for Runtime { + fn benchmark_metadata(extra: bool) -> ( + Vec, + Vec, + ) { + use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + use frame_support::traits::StorageInfoTrait; + + // Trying to add benchmarks directly to the Session Pallet caused cyclic dependency + // issues. To get around that, we separated the Session benchmarks into its own crate, + // which is why we need these two lines below. + // use pallet_loans_benchmarking::Pallet as LoansBench; + use frame_system_benchmarking::Pallet as SystemBench; + + let mut list = Vec::::new(); + + list_benchmark!(list, extra, frame_system, SystemBench::); + list_benchmark!(list, extra, pallet_timestamp, Timestamp); + list_benchmark!(list, extra, pallet_balances, Balances); + list_benchmark!(list, extra, pallet_babe, Babe); + list_benchmark!(list, extra, pallet_grandpa, Grandpa); + list_benchmark!(list, extra, pallet_im_online, ImOnline); + list_benchmark!(list, extra, pallet_staking, Staking); + list_benchmark!(list, extra, pallet_collective, RootCommittee); + list_benchmark!(list, extra, pallet_scheduler, Scheduler); + list_benchmark!(list, extra, pallet_preimage, Preimage); + list_benchmark!(list, extra, pallet_utility, Utility); + list_benchmark!(list, extra, pallet_multisig, Multisig); + + let storage_info = AllPalletsWithSystem::storage_info(); + + (list, storage_info) + } + + fn dispatch_benchmark( + config: frame_benchmarking::BenchmarkConfig, + ) -> Result, sp_runtime::RuntimeString> { + // We did not include the offences and sessions benchmarks as they are parity + // specific and were causing some issues at compile time as they depend on the + // presence of the staking and elections pallets. + + use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, add_benchmark}; + + use frame_system_benchmarking::Pallet as SystemBench; + + impl frame_system_benchmarking::Config for Runtime {} + + let whitelist: Vec = vec![]; + let mut batches = Vec::::new(); + let params = (&config, &whitelist); + + add_benchmark!(params, batches, frame_system, SystemBench::); + add_benchmark!(params, batches, pallet_timestamp, Timestamp); + add_benchmark!(params, batches, pallet_balances, Balances); + add_benchmark!(params, batches, pallet_babe, Babe); + add_benchmark!(params, batches, pallet_grandpa, Grandpa); + add_benchmark!(params, batches, pallet_im_online, ImOnline); + add_benchmark!(params, batches, pallet_staking, Staking); + add_benchmark!(params, batches, pallet_collective, RootCommittee); + add_benchmark!(params, batches, pallet_scheduler, Scheduler); + add_benchmark!(params, batches, pallet_preimage, Preimage); + add_benchmark!(params, batches, pallet_utility, Utility); + add_benchmark!(params, batches, pallet_multisig, Multisig); + + if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } + Ok(batches) + } + } + + #[cfg(feature = "try-runtime")] + impl frame_try_runtime::TryRuntime for Runtime { + fn on_runtime_upgrade() -> (Weight, Weight) { + // NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to + // have a backtrace here. If any of the pre/post migration checks fail, we shall stop + // right here and right now. + let weight = Executive::try_runtime_upgrade().unwrap(); + (weight, constants::RuntimeBlockWeights::get().max_block) + } + + fn execute_block_no_check(block: Block) -> Weight { + Executive::execute_block_no_check(block) + } + } } #[cfg(test)] diff --git a/runtimes/staking/src/pallets_util.rs b/runtimes/staking/src/pallets_util.rs index eddf83ddb75..00baa31f9cf 100644 --- a/runtimes/staking/src/pallets_util.rs +++ b/runtimes/staking/src/pallets_util.rs @@ -53,38 +53,38 @@ impl pallet_multisig::Config for Runtime { impl pallet_randomness_collective_flip::Config for Runtime {} parameter_types! { - pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * - constants::RuntimeBlockWeights::get().max_block; - pub const MaxScheduledPerBlock: u32 = 50; - pub const NoPreimagePostponement: Option = Some(10); + pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * + constants::RuntimeBlockWeights::get().max_block; + pub const MaxScheduledPerBlock: u32 = 50; + pub const NoPreimagePostponement: Option = Some(10); } impl pallet_scheduler::Config for Runtime { - type Event = Event; - type Origin = Origin; - type PalletsOrigin = OriginCaller; - type Call = Call; - type MaximumWeight = MaximumSchedulerWeight; - type ScheduleOrigin = EnsureRoot; - type OriginPrivilegeCmp = EqualPrivilegeOnly; - type MaxScheduledPerBlock = MaxScheduledPerBlock; - type WeightInfo = pallet_scheduler::weights::SubstrateWeight; - type PreimageProvider = Preimage; - type NoPreimagePostponement = NoPreimagePostponement; + type Event = Event; + type Origin = Origin; + type PalletsOrigin = OriginCaller; + type Call = Call; + type MaximumWeight = MaximumSchedulerWeight; + type ScheduleOrigin = EnsureRoot; + type OriginPrivilegeCmp = EqualPrivilegeOnly; + type MaxScheduledPerBlock = MaxScheduledPerBlock; + type WeightInfo = pallet_scheduler::weights::SubstrateWeight; + type PreimageProvider = Preimage; + type NoPreimagePostponement = NoPreimagePostponement; } parameter_types! { - pub const PreimageMaxSize: u32 = 4096 * 1024; - pub const PreimageBaseDeposit: Balance = constants::deposit(2, 64); - pub const PreimageByteDeposit: Balance = constants::deposit(0, 1); + pub const PreimageMaxSize: u32 = 4096 * 1024; + pub const PreimageBaseDeposit: Balance = constants::deposit(2, 64); + pub const PreimageByteDeposit: Balance = constants::deposit(0, 1); } impl pallet_preimage::Config for Runtime { - type WeightInfo = pallet_preimage::weights::SubstrateWeight; - type Event = Event; - type Currency = Balances; - type ManagerOrigin = EnsureRoot; - type MaxSize = PreimageMaxSize; - type BaseDeposit = PreimageBaseDeposit; - type ByteDeposit = PreimageByteDeposit; + type WeightInfo = pallet_preimage::weights::SubstrateWeight; + type Event = Event; + type Currency = Balances; + type ManagerOrigin = EnsureRoot; + type MaxSize = PreimageMaxSize; + type BaseDeposit = PreimageBaseDeposit; + type ByteDeposit = PreimageByteDeposit; }