Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: various improvements and fixes #243

Merged
merged 15 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion networks/mainnet.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pop up parachain -f ./tests/networks/pop.toml
# pop up parachain -f ./networks/mainnet.toml

[relaychain]
chain = "paseo-local"
Expand Down
3 changes: 3 additions & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ cumulus-relay-chain-interface.workspace = true
[build-dependencies]
substrate-build-script-utils.workspace = true

[dev-dependencies]
pallet-multisig.workspace = true

[features]
runtime-benchmarks = [
"cumulus-primitives-core/runtime-benchmarks",
Expand Down
52 changes: 48 additions & 4 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub type DevnetChainSpec = sc_service::GenericChainSpec<Extensions>;
/// Specialized `ChainSpec` for the testnet parachain runtime.
pub type TestnetChainSpec = sc_service::GenericChainSpec<Extensions>;

/// Specialized `ChainSpec` for the live parachain runtime.
/// Specialized `ChainSpec` for the mainnet parachain runtime.
pub type MainnetChainSpec = sc_service::GenericChainSpec<Extensions>;

/// The default XCM version to set in genesis config.
Expand Down Expand Up @@ -94,12 +94,16 @@ fn configure_for_relay(
match relay {
Relay::Paseo | Relay::PaseoLocal => {
para_id = 4001;
properties.insert("ss58Format".into(), 42.into());
properties.insert("tokenSymbol".into(), "PAS".into());
properties.insert("tokenDecimals".into(), 10.into());

let relay_chain =
if let Relay::Paseo = relay { "paseo".into() } else { "paseo-local".into() };
let relay_chain = if let Relay::Paseo = relay {
properties.insert("ss58Format".into(), 0.into());
"paseo".into()
} else {
properties.insert("ss58Format".into(), 42.into());
"paseo-local".into()
};
(Extensions { relay_chain, para_id }, para_id)
},
Relay::Polkadot => {
Expand Down Expand Up @@ -341,3 +345,43 @@ fn devnet_genesis(
"sudo": { "key": Some(root) }
})
}

#[test]
fn sudo_key_valid() {
// Source: https://github.com/paritytech/extended-parachain-template/blob/d08cec37117731953119ecaed79522a0812b46f5/node/src/chain_spec.rs#L79
fn get_multisig_sudo_key(mut authority_set: Vec<AccountId>, threshold: u16) -> AccountId {
assert!(threshold > 0, "Threshold for sudo multisig cannot be 0");
assert!(!authority_set.is_empty(), "Sudo authority set cannot be empty");
assert!(
authority_set.len() >= threshold.into(),
"Threshold must be less than or equal to authority set members"
);
// Sorting is done to deterministically order the multisig set
// So that a single authority set (A, B, C) may generate only a single unique multisig key
// Otherwise, (B, A, C) or (C, A, B) could produce different keys and cause chaos
authority_set.sort();

// Define a multisig threshold for `threshold / authority_set.len()` members
pallet_multisig::Pallet::<pop_runtime_mainnet::Runtime>::multi_account_id(
&authority_set[..],
threshold,
)
}

assert_eq!(
get_multisig_sudo_key(
vec![
AccountId::from_ss58check("15VPagCVayS6XvT5RogPYop3BJTJzwqR2mCGR1kVn3w58ygg")
.unwrap(),
AccountId::from_ss58check("142zako1kfvrpQ7pJKYR8iGUD58i4wjb78FUsmJ9WcXmkM5z")
.unwrap(),
AccountId::from_ss58check("15k9niqckMg338cFBoz9vWFGwnCtwPBquKvqJEfHApijZkDz")
.unwrap(),
AccountId::from_ss58check("14G3CUFnZUBnHZUhahexSZ6AgemaW9zMHBnGccy3df7actf4")
.unwrap(),
],
2
),
AccountId::from_ss58check("15NMV2JX1NeMwarQiiZvuJ8ixUcvayFDcu1F9Wz1HNpSc8gP").unwrap()
)
}
4 changes: 2 additions & 2 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn runtime(id: &str) -> Runtime {
Runtime::Devnet
} else if id.starts_with("test") || id.ends_with("testnet") {
Runtime::Testnet
} else if id.eq("pop") || id.ends_with("live") || id.ends_with("mainnet") {
} else if id.eq("pop") || id.ends_with("mainnet") {
Runtime::Mainnet
} else {
log::warn!(
Expand Down Expand Up @@ -75,7 +75,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
"dev" | "devnet" | "dev-paseo" =>
Box::new(chain_spec::development_config(Relay::PaseoLocal)),
"test" | "testnet" | "pop-paseo" => Box::new(chain_spec::testnet_config(Relay::Paseo)),
"pop-network" | "pop" | "pop-polkadot" | "mainnet" =>
"pop" | "mainnet" | "pop-polkadot" | "pop-network" =>
Box::new(chain_spec::mainnet_config(Relay::Polkadot)),
"" | "local" => Box::new(chain_spec::development_config(Relay::PaseoLocal)),
path => {
Expand Down
25 changes: 1 addition & 24 deletions runtime/mainnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors.workspace = true
description.workspace = true
edition.workspace = true
homepage.workspace = true
license = "Unlicense"
license.workspace = true
name = "pop-runtime-mainnet"
repository.workspace = true
version = "0.1.0"
Expand All @@ -16,13 +16,10 @@ substrate-wasm-builder.workspace = true

[dependencies]
codec.workspace = true
hex-literal.workspace = true
log.workspace = true
scale-info.workspace = true
smallvec.workspace = true

# Local
pop-primitives.workspace = true
pop-runtime-common = { workspace = true, default-features = false }

# Substrate
Expand All @@ -34,16 +31,11 @@ frame-system.workspace = true
frame-system-benchmarking.workspace = true
frame-system-rpc-runtime-api.workspace = true
frame-try-runtime.workspace = true
pallet-assets.workspace = true
pallet-aura.workspace = true
pallet-authorship.workspace = true
pallet-balances.workspace = true
pallet-contracts.workspace = true
pallet-message-queue.workspace = true
pallet-multisig.workspace = true
pallet-nft-fractionalization.workspace = true
pallet-nfts.workspace = true
pallet-nfts-runtime-api.workspace = true
pallet-preimage.workspace = true
pallet-proxy.workspace = true
pallet-scheduler.workspace = true
Expand Down Expand Up @@ -115,18 +107,12 @@ std = [
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"frame-try-runtime/std",
"log/std",
"pallet-assets/std",
"pallet-aura/std",
"pallet-authorship/std",
"pallet-balances/std",
"pallet-collator-selection/std",
"pallet-contracts/std",
"pallet-message-queue/std",
"pallet-multisig/std",
"pallet-nft-fractionalization/std",
"pallet-nfts-runtime-api/std",
"pallet-nfts/std",
"pallet-preimage/std",
"pallet-proxy/std",
"pallet-scheduler/std",
Expand All @@ -141,7 +127,6 @@ std = [
"parachains-common/std",
"polkadot-parachain-primitives/std",
"polkadot-runtime-common/std",
"pop-primitives/std",
"pop-runtime-common/std",
"scale-info/std",
"sp-api/std",
Expand Down Expand Up @@ -172,14 +157,10 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-collator-selection/runtime-benchmarks",
"pallet-contracts/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-nft-fractionalization/runtime-benchmarks",
"pallet-nfts/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
Expand All @@ -205,16 +186,12 @@ try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"frame-try-runtime/try-runtime",
"pallet-assets/try-runtime",
"pallet-aura/try-runtime",
"pallet-authorship/try-runtime",
"pallet-balances/try-runtime",
"pallet-collator-selection/try-runtime",
"pallet-contracts/try-runtime",
"pallet-message-queue/try-runtime",
"pallet-multisig/try-runtime",
"pallet-nft-fractionalization/try-runtime",
"pallet-nfts/try-runtime",
"pallet-preimage/try-runtime",
"pallet-proxy/try-runtime",
"pallet-scheduler/try-runtime",
Expand Down
2 changes: 1 addition & 1 deletion runtime/mainnet/build.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#[cfg(all(feature = "std", feature = "metadata-hash"))]
fn main() {
substrate_wasm_builder::WasmBuilder::init_with_defaults()
.enable_metadata_hash("PAS", 10)
.enable_metadata_hash("DOT", 10)
.build()
}

#[cfg(all(feature = "std", not(feature = "metadata-hash")))]
fn main() {
substrate_wasm_builder::WasmBuilder::build_using_defaults()
}

/// The wasm builder is deactivated when compiling
/// this crate for wasm to speed up the compilation.
#[cfg(not(feature = "std"))]
fn main() {}

Check warning on line 16 in runtime/mainnet/build.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for the crate

warning: missing documentation for the crate --> runtime/mainnet/build.rs:1:1 | 1 | / #[cfg(all(feature = "std", feature = "metadata-hash"))] 2 | | fn main() { 3 | | substrate_wasm_builder::WasmBuilder::init_with_defaults() 4 | | .enable_metadata_hash("DOT", 10) ... | 15 | | #[cfg(not(feature = "std"))] 16 | | fn main() {} | |____________^ | = note: requested on the command line with `-W missing-docs`
3 changes: 1 addition & 2 deletions runtime/mainnet/src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
mod proxy;
// Public due to integration tests crate.
pub mod xcm;
pub(crate) mod xcm;
80 changes: 61 additions & 19 deletions runtime/mainnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
}

#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {

Check warning on line 174 in runtime/mainnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a constant

warning: missing documentation for a constant --> runtime/mainnet/src/lib.rs:174:1 | 174 | pub const VERSION: RuntimeVersion = RuntimeVersion { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec_name: create_runtime_str!("pop"),
impl_name: create_runtime_str!("pop"),
authoring_version: 1,
Expand Down Expand Up @@ -236,14 +236,6 @@
}
}

/// A type to identify allowed calls to the Runtime from contracts. Used by Pop API
pub struct AllowedApiCalls;
impl Contains<RuntimeCall> for AllowedApiCalls {
fn contains(_c: &RuntimeCall) -> bool {
false
}
}

/// The default types are being injected by [`derive_impl`](`frame_support::derive_impl`) from
/// [`ParaChainDefaultConfig`](`struct@frame_system::config_preludes::ParaChainDefaultConfig`),
/// but overridden as needed.
Expand Down Expand Up @@ -364,16 +356,16 @@

parameter_types! {
pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
pub MessageQueueIdleServiceWeight: Weight = Perbill::from_percent(20) * RuntimeBlockWeights::get().max_block;
}

impl pallet_message_queue::Config for Runtime {
type HeapSize = sp_core::ConstU32<{ 103 * 1024 }>;
type IdleMaxServiceWeight = ();
type MaxStale = sp_core::ConstU32<8>;
type HeapSize = ConstU32<{ 64 * 1024 }>;
type IdleMaxServiceWeight = MessageQueueIdleServiceWeight;
type MaxStale = ConstU32<8>;
#[cfg(feature = "runtime-benchmarks")]
type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<
cumulus_primitives_core::AggregateMessageOrigin,
>;
type MessageProcessor =
pallet_message_queue::mock_helpers::NoopMessageProcessor<AggregateMessageOrigin>;
#[cfg(not(feature = "runtime-benchmarks"))]
type MessageProcessor = xcm_builder::ProcessXcmMessage<
AggregateMessageOrigin,
Expand All @@ -395,14 +387,14 @@
type ChannelInfo = ParachainSystem;
type ControllerOrigin = EnsureRoot<AccountId>;
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
// Limit the number of messages and signals a HRML channel can have at most
// Limit the number of messages and signals a HRMP channel can have at most
type MaxActiveOutboundChannels = ConstU32<128>;
type MaxInboundSuspended = sp_core::ConstU32<1_000>;
// Limit the number of HRML channels
type MaxInboundSuspended = ConstU32<1_000>;
// Limit the number of HRMP channels
type MaxPageSize = ConstU32<{ 103 * 1024 }>;
type PriceForSiblingDelivery = NoPriceForMessageDelivery<ParaId>;
type RuntimeEvent = RuntimeEvent;
type VersionWrapper = ();
type VersionWrapper = PolkadotXcm;
type WeightInfo = ();
// Enqueue XCMP messages from siblings for later processing.
type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
Expand Down Expand Up @@ -437,7 +429,6 @@

parameter_types! {
pub const PotId: PalletId = PalletId(*b"PotStake");
pub const SessionLength: BlockNumber = 6 * HOURS;
// StakingAdmin pluralistic body.
pub const StakingAdminBodyId: BodyId = BodyId::Defense;
}
Expand Down Expand Up @@ -529,7 +520,7 @@
type WeightInfo = pallet_utility::weights::SubstrateWeight<Runtime>;
}

#[frame_support::runtime]

Check warning on line 523 in runtime/mainnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for an associated function

warning: missing documentation for an associated function --> runtime/mainnet/src/lib.rs:523:1 | 523 | #[frame_support::runtime] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in the attribute macro `frame_support::runtime` (in Nightly builds, run with -Z macro-backtrace for more info)

Check warning on line 523 in runtime/mainnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a type alias

warning: missing documentation for a type alias --> runtime/mainnet/src/lib.rs:523:1 | 523 | #[frame_support::runtime] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in the attribute macro `frame_support::runtime` (in Nightly builds, run with -Z macro-backtrace for more info)

Check warning on line 523 in runtime/mainnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a struct field

warning: missing documentation for a struct field --> runtime/mainnet/src/lib.rs:523:1 | 523 | #[frame_support::runtime] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in the attribute macro `frame_support::runtime` (in Nightly builds, run with -Z macro-backtrace for more info)

Check warning on line 523 in runtime/mainnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a variant

warning: missing documentation for a variant --> runtime/mainnet/src/lib.rs:523:1 | 523 | #[frame_support::runtime] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in the attribute macro `frame_support::runtime` (in Nightly builds, run with -Z macro-backtrace for more info)

Check warning on line 523 in runtime/mainnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for an enum

warning: missing documentation for an enum --> runtime/mainnet/src/lib.rs:523:1 | 523 | #[frame_support::runtime] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in the attribute macro `frame_support::runtime` (in Nightly builds, run with -Z macro-backtrace for more info)

Check warning on line 523 in runtime/mainnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a struct

warning: missing documentation for a struct --> runtime/mainnet/src/lib.rs:523:1 | 523 | #[frame_support::runtime] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in the attribute macro `frame_support::runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
mod runtime {
// Create the runtime by composing the FRAME pallets that were previously configured.
#[runtime::runtime]
Expand Down Expand Up @@ -622,245 +613,296 @@
);
}

impl_runtime_apis! {

impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration {
sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
}

fn authorities() -> Vec<AuraId> {
pallet_aura::Authorities::<Runtime>::get().into_inner()
}
}

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) -> ExtrinsicInclusionMode{
Executive::initialize_block(header)
}
}

impl sp_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() -> sp_std::vec::Vec<u32> {
Runtime::metadata_versions()
}
}

impl sp_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: sp_inherents::InherentData) -> Vec<<Block as BlockT>::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<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 sp_offchain::OffchainWorkerApi<Block> for Runtime {
fn offchain_worker(header: &<Block as BlockT>::Header) {
Executive::offchain_worker(header)
}
}

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>, 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<Block, Balance> for Runtime {
fn query_info(
uxt: <Block as BlockT>::Extrinsic,
len: u32,
) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
TransactionPayment::query_info(uxt, len)
}
fn query_fee_details(
uxt: <Block as BlockT>::Extrinsic,
len: u32,
) -> pallet_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 pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
for Runtime
{
fn query_call_info(
call: RuntimeCall,
len: u32,
) -> pallet_transaction_payment::RuntimeDispatchInfo<Balance> {
TransactionPayment::query_call_info(call, len)
}
fn query_call_fee_details(
call: RuntimeCall,
len: u32,
) -> pallet_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)
}
}

impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
fn can_build_upon(
included_hash: <Block as BlockT>::Hash,
slot: cumulus_primitives_aura::Slot,
) -> bool {
ConsensusHook::can_build_upon(included_hash, slot)
}
}

impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
ParachainSystem::collect_collation_info(header)
}
}

#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
let weight = Executive::try_runtime_upgrade(checks).unwrap();
(weight, RuntimeBlockWeights::get().max_block)
}

fn execute_block(
block: Block,
state_root_check: bool,
signature_check: bool,
select: frame_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).unwrap()
}
}

#[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 frame_system_benchmarking::Pallet as SystemBench;
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;

let mut list = Vec::<BenchmarkList>::new();
list_benchmarks!(list, extra);

let storage_info = AllPalletsWithSystem::storage_info();
(list, storage_info)
}

fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{BenchmarkError, Benchmarking, BenchmarkBatch};

use frame_system_benchmarking::Pallet as SystemBench;
impl frame_system_benchmarking::Config for Runtime {
fn setup_set_code_requirements(code: &sp_std::vec::Vec<u8>) -> Result<(), BenchmarkError> {
ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
Ok(())
}

fn verify_set_code() {
System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
}
}

use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
impl cumulus_pallet_session_benchmarking::Config for Runtime {}

use frame_support::traits::WhitelistedStorageKeys;
let whitelist = AllPalletsWithSystem::whitelisted_storage_keys();

let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&config, &whitelist);
add_benchmarks!(params, batches);

if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
}
}

impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
build_state::<RuntimeGenesisConfig>(config)
}

fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
get_preset::<RuntimeGenesisConfig>(id, |_| None)
}

fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
Default::default()
}
}
}

Check warning on line 852 in runtime/mainnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a function

warning: missing documentation for a function --> runtime/mainnet/src/lib.rs:616:1 | 616 | / impl_runtime_apis! { 617 | | 618 | | impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime { 619 | | fn slot_duration() -> sp_consensus_aura::SlotDuration { ... | 851 | | } 852 | | } | |_^ | = note: this warning originates in the macro `impl_runtime_apis` (in Nightly builds, run with -Z macro-backtrace for more info)

Check warning on line 852 in runtime/mainnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a module

warning: missing documentation for a module --> runtime/mainnet/src/lib.rs:616:1 | 616 | / impl_runtime_apis! { 617 | | 618 | | impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime { 619 | | fn slot_duration() -> sp_consensus_aura::SlotDuration { ... | 851 | | } 852 | | } | |_^ | = note: this warning originates in the macro `impl_runtime_apis` (in Nightly builds, run with -Z macro-backtrace for more info)

Check warning on line 852 in runtime/mainnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a constant

warning: missing documentation for a constant --> runtime/mainnet/src/lib.rs:616:1 | 616 | / impl_runtime_apis! { 617 | | 618 | | impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime { 619 | | fn slot_duration() -> sp_consensus_aura::SlotDuration { ... | 851 | | } 852 | | } | |_^ | = note: this warning originates in the macro `impl_runtime_apis` (in Nightly builds, run with -Z macro-backtrace for more info)

Check warning on line 852 in runtime/mainnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a struct

warning: missing documentation for a struct --> runtime/mainnet/src/lib.rs:616:1 | 616 | / impl_runtime_apis! { 617 | | 618 | | impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime { 619 | | fn slot_duration() -> sp_consensus_aura::SlotDuration { ... | 851 | | } 852 | | } | |_^ | = note: this warning originates in the macro `impl_runtime_apis` (in Nightly builds, run with -Z macro-backtrace for more info)

cumulus_pallet_parachain_system::register_validate_block! {
Runtime = Runtime,
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
}

#[cfg(test)]
mod tests {
use std::any::TypeId;

use pallet_balances::AdjustmentDirection;
use BalancesCall::*;
use RuntimeCall::Balances;

use super::*;
#[test]
fn filtering_force_adjust_total_issuance_works() {
assert!(FilteredCalls::contains(&Balances(force_adjust_total_issuance {
direction: AdjustmentDirection::Increase,
delta: 0
})));
}

#[test]
fn filtering_force_set_balance_works() {
assert!(FilteredCalls::contains(&Balances(force_set_balance {
who: MultiAddress::Address32([0u8; 32]),
new_free: 0,
})));
}

#[test]
fn filtering_force_transfer_works() {
assert!(FilteredCalls::contains(&Balances(force_transfer {
source: MultiAddress::Address32([0u8; 32]),
dest: MultiAddress::Address32([0u8; 32]),
value: 0,
})));
}

#[test]
fn filtering_force_unreserve_works() {
assert!(FilteredCalls::contains(&Balances(force_unreserve {
who: MultiAddress::Address32([0u8; 32]),
amount: 0
})));
}

#[test]
fn filtering_configured() {
assert_eq!(
TypeId::of::<<Runtime as frame_system::Config>::BaseCallFilter>(),
TypeId::of::<EverythingBut<FilteredCalls>>(),
);
}
}
2 changes: 1 addition & 1 deletion runtime/testnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
}

#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {

Check warning on line 179 in runtime/testnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a constant

warning: missing documentation for a constant --> runtime/testnet/src/lib.rs:179:1 | 179 | pub const VERSION: RuntimeVersion = RuntimeVersion { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec_name: create_runtime_str!("pop"),
impl_name: create_runtime_str!("pop"),
authoring_version: 1,
Expand Down Expand Up @@ -233,7 +233,7 @@
})
.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
.build_or_panic();
pub const SS58Prefix: u16 = 42;
pub const SS58Prefix: u16 = 0;
}

/// A type to identify filtered calls.
Expand Down Expand Up @@ -551,7 +551,7 @@
type WeightInfo = pallet_utility::weights::SubstrateWeight<Runtime>;
}

#[frame_support::runtime]

Check warning on line 554 in runtime/testnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for an associated function

warning: missing documentation for an associated function --> runtime/testnet/src/lib.rs:554:1 | 554 | #[frame_support::runtime] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in the attribute macro `frame_support::runtime` (in Nightly builds, run with -Z macro-backtrace for more info)

Check warning on line 554 in runtime/testnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a type alias

warning: missing documentation for a type alias --> runtime/testnet/src/lib.rs:554:1 | 554 | #[frame_support::runtime] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in the attribute macro `frame_support::runtime` (in Nightly builds, run with -Z macro-backtrace for more info)

Check warning on line 554 in runtime/testnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a struct field

warning: missing documentation for a struct field --> runtime/testnet/src/lib.rs:554:1 | 554 | #[frame_support::runtime] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in the attribute macro `frame_support::runtime` (in Nightly builds, run with -Z macro-backtrace for more info)

Check warning on line 554 in runtime/testnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a variant

warning: missing documentation for a variant --> runtime/testnet/src/lib.rs:554:1 | 554 | #[frame_support::runtime] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in the attribute macro `frame_support::runtime` (in Nightly builds, run with -Z macro-backtrace for more info)

Check warning on line 554 in runtime/testnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for an enum

warning: missing documentation for an enum --> runtime/testnet/src/lib.rs:554:1 | 554 | #[frame_support::runtime] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in the attribute macro `frame_support::runtime` (in Nightly builds, run with -Z macro-backtrace for more info)

Check warning on line 554 in runtime/testnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a struct

warning: missing documentation for a struct --> runtime/testnet/src/lib.rs:554:1 | 554 | #[frame_support::runtime] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in the attribute macro `frame_support::runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
mod runtime {
// Create the runtime by composing the FRAME pallets that were previously configured.
#[runtime::runtime]
Expand Down Expand Up @@ -656,354 +656,354 @@
);
}

impl_runtime_apis! {

impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration {
sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
}

fn authorities() -> Vec<AuraId> {
pallet_aura::Authorities::<Runtime>::get().into_inner()
}
}

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) -> ExtrinsicInclusionMode{
Executive::initialize_block(header)
}
}

impl sp_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() -> sp_std::vec::Vec<u32> {
Runtime::metadata_versions()
}
}

impl sp_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: sp_inherents::InherentData) -> Vec<<Block as BlockT>::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<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 sp_offchain::OffchainWorkerApi<Block> for Runtime {
fn offchain_worker(header: &<Block as BlockT>::Header) {
Executive::offchain_worker(header)
}
}

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>, 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<Block, Balance> for Runtime {
fn query_info(
uxt: <Block as BlockT>::Extrinsic,
len: u32,
) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
TransactionPayment::query_info(uxt, len)
}
fn query_fee_details(
uxt: <Block as BlockT>::Extrinsic,
len: u32,
) -> pallet_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 pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
for Runtime
{
fn query_call_info(
call: RuntimeCall,
len: u32,
) -> pallet_transaction_payment::RuntimeDispatchInfo<Balance> {
TransactionPayment::query_call_info(call, len)
}
fn query_call_fee_details(
call: RuntimeCall,
len: u32,
) -> pallet_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)
}
}

impl pallet_contracts::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash, EventRecord>
for Runtime
{
fn call(
origin: AccountId,
dest: AccountId,
value: Balance,
gas_limit: Option<Weight>,
storage_deposit_limit: Option<Balance>,
input_data: Vec<u8>,
) -> pallet_contracts::ContractExecResult<Balance, EventRecord> {
let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
Contracts::bare_call(
origin,
dest,
value,
gas_limit,
storage_deposit_limit,
input_data,
CONTRACTS_DEBUG_OUTPUT,
CONTRACTS_EVENTS,
pallet_contracts::Determinism::Enforced,
)
}

fn instantiate(
origin: AccountId,
value: Balance,
gas_limit: Option<Weight>,
storage_deposit_limit: Option<Balance>,
code: pallet_contracts::Code<Hash>,
data: Vec<u8>,
salt: Vec<u8>,
) -> pallet_contracts::ContractInstantiateResult<AccountId, Balance, EventRecord>
{
let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
Contracts::bare_instantiate(
origin,
value,
gas_limit,
storage_deposit_limit,
code,
data,
salt,
CONTRACTS_DEBUG_OUTPUT,
CONTRACTS_EVENTS,
)
}

fn upload_code(
origin: AccountId,
code: Vec<u8>,
storage_deposit_limit: Option<Balance>,
determinism: pallet_contracts::Determinism,
) -> pallet_contracts::CodeUploadResult<Hash, Balance>
{
Contracts::bare_upload_code(origin, code, storage_deposit_limit, determinism)
}

fn get_storage(
address: AccountId,
key: Vec<u8>,
) -> pallet_contracts::GetStorageResult {
Contracts::get_storage(address, key)
}
}

impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
fn can_build_upon(
included_hash: <Block as BlockT>::Hash,
slot: cumulus_primitives_aura::Slot,
) -> bool {
ConsensusHook::can_build_upon(included_hash, slot)
}
}

impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
ParachainSystem::collect_collation_info(header)
}
}

impl pallet_nfts_runtime_api::NftsApi<Block, AccountId, u32, u32> for Runtime {
fn owner(collection: u32, item: u32) -> Option<AccountId> {
<Nfts as Inspect<AccountId>>::owner(&collection, &item)
}

fn collection_owner(collection: u32) -> Option<AccountId> {
<Nfts as Inspect<AccountId>>::collection_owner(&collection)
}

fn attribute(
collection: u32,
item: u32,
key: Vec<u8>,
) -> Option<Vec<u8>> {
<Nfts as Inspect<AccountId>>::attribute(&collection, &item, &key)
}

fn custom_attribute(
account: AccountId,
collection: u32,
item: u32,
key: Vec<u8>,
) -> Option<Vec<u8>> {
<Nfts as Inspect<AccountId>>::custom_attribute(
&account,
&collection,
&item,
&key,
)
}

fn system_attribute(
collection: u32,
item: Option<u32>,
key: Vec<u8>,
) -> Option<Vec<u8>> {
<Nfts as Inspect<AccountId>>::system_attribute(&collection, item.as_ref(), &key)
}

fn collection_attribute(collection: u32, key: Vec<u8>) -> Option<Vec<u8>> {
<Nfts as Inspect<AccountId>>::collection_attribute(&collection, &key)
}
}

#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
let weight = Executive::try_runtime_upgrade(checks).unwrap();
(weight, RuntimeBlockWeights::get().max_block)
}

fn execute_block(
block: Block,
state_root_check: bool,
signature_check: bool,
select: frame_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).unwrap()
}
}

#[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 frame_system_benchmarking::Pallet as SystemBench;
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;

let mut list = Vec::<BenchmarkList>::new();
list_benchmarks!(list, extra);

let storage_info = AllPalletsWithSystem::storage_info();
(list, storage_info)
}

fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{BenchmarkError, Benchmarking, BenchmarkBatch};

use frame_system_benchmarking::Pallet as SystemBench;
impl frame_system_benchmarking::Config for Runtime {
fn setup_set_code_requirements(code: &sp_std::vec::Vec<u8>) -> Result<(), BenchmarkError> {
ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
Ok(())
}

fn verify_set_code() {
System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
}
}

use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
impl cumulus_pallet_session_benchmarking::Config for Runtime {}

use frame_support::traits::WhitelistedStorageKeys;
let whitelist = AllPalletsWithSystem::whitelisted_storage_keys();

let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&config, &whitelist);
add_benchmarks!(params, batches);

if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
}
}

impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
build_state::<RuntimeGenesisConfig>(config)
}

fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
get_preset::<RuntimeGenesisConfig>(id, |_| None)
}

fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
Default::default()
}
}
}

Check warning on line 1006 in runtime/testnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a function

warning: missing documentation for a function --> runtime/testnet/src/lib.rs:659:1 | 659 | / impl_runtime_apis! { 660 | | 661 | | impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime { 662 | | fn slot_duration() -> sp_consensus_aura::SlotDuration { ... | 1005 | | } 1006 | | } | |_^ | = note: this warning originates in the macro `impl_runtime_apis` (in Nightly builds, run with -Z macro-backtrace for more info)

Check warning on line 1006 in runtime/testnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a module

warning: missing documentation for a module --> runtime/testnet/src/lib.rs:659:1 | 659 | / impl_runtime_apis! { 660 | | 661 | | impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime { 662 | | fn slot_duration() -> sp_consensus_aura::SlotDuration { ... | 1005 | | } 1006 | | } | |_^ | = note: this warning originates in the macro `impl_runtime_apis` (in Nightly builds, run with -Z macro-backtrace for more info)

Check warning on line 1006 in runtime/testnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a constant

warning: missing documentation for a constant --> runtime/testnet/src/lib.rs:659:1 | 659 | / impl_runtime_apis! { 660 | | 661 | | impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime { 662 | | fn slot_duration() -> sp_consensus_aura::SlotDuration { ... | 1005 | | } 1006 | | } | |_^ | = note: this warning originates in the macro `impl_runtime_apis` (in Nightly builds, run with -Z macro-backtrace for more info)

Check warning on line 1006 in runtime/testnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a struct

warning: missing documentation for a struct --> runtime/testnet/src/lib.rs:659:1 | 659 | / impl_runtime_apis! { 660 | | 661 | | impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime { 662 | | fn slot_duration() -> sp_consensus_aura::SlotDuration { ... | 1005 | | } 1006 | | } | |_^ | = note: this warning originates in the macro `impl_runtime_apis` (in Nightly builds, run with -Z macro-backtrace for more info)

cumulus_pallet_parachain_system::register_validate_block! {
Runtime = Runtime,
Expand Down
Loading