90fd044766
- snowbridge-pezpallet-* → pezsnowbridge-pezpallet-* (201 refs) - pallet/ directories → pezpallet/ (4 locations) - Fixed pezpallet.rs self-include recursion bug - Fixed sc-chain-spec hardcoded crate name in derive macro - Reverted .pezpallet_by_name() to .pallet_by_name() (subxt API) - Added BizinikiwiConfig type alias for zombienet tests - Deleted obsolete session state files Verified: pezsnowbridge-pezpallet-*, pezpallet-staking, pezpallet-staking-async, pezframe-benchmarking-cli all pass cargo check
305 lines
10 KiB
Rust
305 lines
10 KiB
Rust
// This is free and unencumbered software released into the public domain.
|
|
//
|
|
// Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
// distribute this software, either in source code form or as a compiled
|
|
// binary, for any purpose, commercial or non-commercial, and by any
|
|
// means.
|
|
//
|
|
// In jurisdictions that recognize copyright laws, the author or authors
|
|
// of this software dedicate any and all copyright interest in the
|
|
// software to the public domain. We make this dedication for the benefit
|
|
// of the public at large and to the detriment of our heirs and
|
|
// successors. We intend this dedication to be an overt act of
|
|
// relinquishment in perpetuity of all present and future rights to this
|
|
// software under copyright law.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
// OTHER DEALINGS IN THE SOFTWARE.
|
|
//
|
|
// For more information, please refer to <http://unlicense.org>
|
|
|
|
// External crates imports
|
|
use alloc::vec::Vec;
|
|
use pezframe_support::{
|
|
genesis_builder_helper::{build_state, get_preset},
|
|
weights::Weight,
|
|
};
|
|
use pezpallet_grandpa::AuthorityId as GrandpaId;
|
|
use pezsp_api::impl_runtime_apis;
|
|
use pezsp_consensus_aura::sr25519::AuthorityId as AuraId;
|
|
use pezsp_core::{crypto::KeyTypeId, OpaqueMetadata};
|
|
use pezsp_runtime::{
|
|
traits::{Block as BlockT, NumberFor},
|
|
transaction_validity::{TransactionSource, TransactionValidity},
|
|
ApplyExtrinsicResult,
|
|
};
|
|
use pezsp_version::RuntimeVersion;
|
|
|
|
// Local module imports
|
|
use super::{
|
|
AccountId, Aura, Balance, Block, Executive, Grandpa, InherentDataExt, Nonce, Runtime,
|
|
RuntimeCall, RuntimeGenesisConfig, SessionKeys, System, TransactionPayment, VERSION,
|
|
};
|
|
|
|
impl_runtime_apis! {
|
|
impl pezsp_api::Core<Block> for Runtime {
|
|
fn version() -> RuntimeVersion {
|
|
VERSION
|
|
}
|
|
|
|
fn execute_block(block: <Block as BlockT>::LazyBlock) {
|
|
Executive::execute_block(block);
|
|
}
|
|
|
|
fn initialize_block(header: &<Block as BlockT>::Header) -> pezsp_runtime::ExtrinsicInclusionMode {
|
|
Executive::initialize_block(header)
|
|
}
|
|
}
|
|
|
|
impl pezsp_api::Metadata<Block> for Runtime {
|
|
fn metadata() -> OpaqueMetadata {
|
|
OpaqueMetadata::new(Runtime::metadata().into())
|
|
}
|
|
|
|
fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
|
|
Runtime::metadata_at_version(version)
|
|
}
|
|
|
|
fn metadata_versions() -> Vec<u32> {
|
|
Runtime::metadata_versions()
|
|
}
|
|
}
|
|
|
|
impl pezframe_support::view_functions::runtime_api::RuntimeViewFunction<Block> for Runtime {
|
|
fn execute_view_function(id: pezframe_support::view_functions::ViewFunctionId, input: Vec<u8>) -> Result<Vec<u8>, pezframe_support::view_functions::ViewFunctionDispatchError> {
|
|
Runtime::execute_view_function(id, input)
|
|
}
|
|
}
|
|
|
|
impl pezsp_block_builder::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: pezsp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
|
|
data.create_extrinsics()
|
|
}
|
|
|
|
fn check_inherents(
|
|
block: <Block as BlockT>::LazyBlock,
|
|
data: pezsp_inherents::InherentData,
|
|
) -> pezsp_inherents::CheckInherentsResult {
|
|
data.check_extrinsics(&block)
|
|
}
|
|
}
|
|
|
|
impl pezsp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
|
|
fn validate_transaction(
|
|
source: TransactionSource,
|
|
tx: <Block as BlockT>::Extrinsic,
|
|
block_hash: <Block as BlockT>::Hash,
|
|
) -> TransactionValidity {
|
|
Executive::validate_transaction(source, tx, block_hash)
|
|
}
|
|
}
|
|
|
|
impl pezsp_offchain::OffchainWorkerApi<Block> for Runtime {
|
|
fn offchain_worker(header: &<Block as BlockT>::Header) {
|
|
Executive::offchain_worker(header)
|
|
}
|
|
}
|
|
|
|
impl pezsp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
|
|
fn slot_duration() -> pezsp_consensus_aura::SlotDuration {
|
|
pezsp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
|
|
}
|
|
|
|
fn authorities() -> Vec<AuraId> {
|
|
pezpallet_aura::Authorities::<Runtime>::get().into_inner()
|
|
}
|
|
}
|
|
|
|
impl pezsp_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>, KeyTypeId)>> {
|
|
SessionKeys::decode_into_raw_public_keys(&encoded)
|
|
}
|
|
}
|
|
|
|
impl pezsp_consensus_grandpa::GrandpaApi<Block> for Runtime {
|
|
fn grandpa_authorities() -> pezsp_consensus_grandpa::AuthorityList {
|
|
Grandpa::grandpa_authorities()
|
|
}
|
|
|
|
fn current_set_id() -> pezsp_consensus_grandpa::SetId {
|
|
Grandpa::current_set_id()
|
|
}
|
|
|
|
fn submit_report_equivocation_unsigned_extrinsic(
|
|
_equivocation_proof: pezsp_consensus_grandpa::EquivocationProof<
|
|
<Block as BlockT>::Hash,
|
|
NumberFor<Block>,
|
|
>,
|
|
_key_owner_proof: pezsp_consensus_grandpa::OpaqueKeyOwnershipProof,
|
|
) -> Option<()> {
|
|
None
|
|
}
|
|
|
|
fn generate_key_ownership_proof(
|
|
_set_id: pezsp_consensus_grandpa::SetId,
|
|
_authority_id: GrandpaId,
|
|
) -> Option<pezsp_consensus_grandpa::OpaqueKeyOwnershipProof> {
|
|
// NOTE: this is the only implementation possible since we've
|
|
// defined our key owner proof type as a bottom type (i.e. a type
|
|
// with no values).
|
|
None
|
|
}
|
|
}
|
|
|
|
impl pezframe_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
|
|
fn account_nonce(account: AccountId) -> Nonce {
|
|
System::account_nonce(account)
|
|
}
|
|
}
|
|
|
|
impl pezpallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
|
|
fn query_info(
|
|
uxt: <Block as BlockT>::Extrinsic,
|
|
len: u32,
|
|
) -> pezpallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
|
|
TransactionPayment::query_info(uxt, len)
|
|
}
|
|
fn query_fee_details(
|
|
uxt: <Block as BlockT>::Extrinsic,
|
|
len: u32,
|
|
) -> pezpallet_transaction_payment::FeeDetails<Balance> {
|
|
TransactionPayment::query_fee_details(uxt, len)
|
|
}
|
|
fn query_weight_to_fee(weight: Weight) -> Balance {
|
|
TransactionPayment::weight_to_fee(weight)
|
|
}
|
|
fn query_length_to_fee(length: u32) -> Balance {
|
|
TransactionPayment::length_to_fee(length)
|
|
}
|
|
}
|
|
|
|
impl pezpallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
|
|
for Runtime
|
|
{
|
|
fn query_call_info(
|
|
call: RuntimeCall,
|
|
len: u32,
|
|
) -> pezpallet_transaction_payment::RuntimeDispatchInfo<Balance> {
|
|
TransactionPayment::query_call_info(call, len)
|
|
}
|
|
fn query_call_fee_details(
|
|
call: RuntimeCall,
|
|
len: u32,
|
|
) -> pezpallet_transaction_payment::FeeDetails<Balance> {
|
|
TransactionPayment::query_call_fee_details(call, len)
|
|
}
|
|
fn query_weight_to_fee(weight: Weight) -> Balance {
|
|
TransactionPayment::weight_to_fee(weight)
|
|
}
|
|
fn query_length_to_fee(length: u32) -> Balance {
|
|
TransactionPayment::length_to_fee(length)
|
|
}
|
|
}
|
|
|
|
#[cfg(feature = "runtime-benchmarks")]
|
|
impl pezframe_benchmarking::Benchmark<Block> for Runtime {
|
|
fn benchmark_metadata(extra: bool) -> (
|
|
Vec<pezframe_benchmarking::BenchmarkList>,
|
|
Vec<pezframe_support::traits::StorageInfo>,
|
|
) {
|
|
use pezframe_benchmarking::{baseline, BenchmarkList};
|
|
use pezframe_support::traits::StorageInfoTrait;
|
|
use pezframe_system_benchmarking::Pezpallet as SystemBench;
|
|
use pezframe_system_benchmarking::extensions::Pezpallet as SystemExtensionsBench;
|
|
use baseline::Pezpallet as BaselineBench;
|
|
use super::*;
|
|
|
|
let mut list = Vec::<BenchmarkList>::new();
|
|
list_benchmarks!(list, extra);
|
|
|
|
let storage_info = AllPalletsWithSystem::storage_info();
|
|
|
|
(list, storage_info)
|
|
}
|
|
|
|
#[allow(non_local_definitions)]
|
|
fn dispatch_benchmark(
|
|
config: pezframe_benchmarking::BenchmarkConfig
|
|
) -> Result<Vec<pezframe_benchmarking::BenchmarkBatch>, alloc::string::String> {
|
|
use pezframe_benchmarking::{baseline, BenchmarkBatch};
|
|
use pezsp_storage::TrackedStorageKey;
|
|
use pezframe_system_benchmarking::Pezpallet as SystemBench;
|
|
use pezframe_system_benchmarking::extensions::Pezpallet as SystemExtensionsBench;
|
|
use baseline::Pezpallet as BaselineBench;
|
|
use super::*;
|
|
|
|
impl pezframe_system_benchmarking::Config for Runtime {}
|
|
impl baseline::Config for Runtime {}
|
|
|
|
use pezframe_support::traits::WhitelistedStorageKeys;
|
|
let whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
|
|
|
|
let mut batches = Vec::<BenchmarkBatch>::new();
|
|
let params = (&config, &whitelist);
|
|
add_benchmarks!(params, batches);
|
|
|
|
Ok(batches)
|
|
}
|
|
}
|
|
|
|
#[cfg(feature = "try-runtime")]
|
|
impl pezframe_try_runtime::TryRuntime<Block> for Runtime {
|
|
fn on_runtime_upgrade(checks: pezframe_try_runtime::UpgradeCheckSelect) -> (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(checks).unwrap();
|
|
(weight, super::configs::RuntimeBlockWeights::get().max_block)
|
|
}
|
|
|
|
fn execute_block(
|
|
block: <Block as BlockT>::LazyBlock,
|
|
state_root_check: bool,
|
|
signature_check: bool,
|
|
select: pezframe_try_runtime::TryStateSelect
|
|
) -> Weight {
|
|
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
|
|
// have a backtrace here.
|
|
Executive::try_execute_block(block, state_root_check, signature_check, select).expect("execute-block failed")
|
|
}
|
|
}
|
|
|
|
impl pezsp_genesis_builder::GenesisBuilder<Block> for Runtime {
|
|
fn build_state(config: Vec<u8>) -> pezsp_genesis_builder::Result {
|
|
build_state::<RuntimeGenesisConfig>(config)
|
|
}
|
|
|
|
fn get_preset(id: &Option<pezsp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
|
|
get_preset::<RuntimeGenesisConfig>(id, crate::genesis_config_presets::get_preset)
|
|
}
|
|
|
|
fn preset_names() -> Vec<pezsp_genesis_builder::PresetId> {
|
|
crate::genesis_config_presets::preset_names()
|
|
}
|
|
}
|
|
}
|