v3 into main (#390)

This commit is contained in:
Amar Singh
2024-12-25 00:20:08 -05:00
committed by GitHub
parent 8cb7cda000
commit 9158633607
36 changed files with 3296 additions and 1222 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
name: substrate-runtimes
title: Substrate Runtimes
version: 2.0.2
version: 3.0.0
nav:
- modules/ROOT/nav.adoc
asciidoc:
+663 -135
View File
File diff suppressed because it is too large Load Diff
+13 -2
View File
@@ -28,8 +28,8 @@ serde_json = "1.0.121"
smallvec = "1.11.0"
# TODO: update to release
openzeppelin-polkadot-wrappers = { git = "https://github.com/openzeppelin/polkadot-runtime-wrappers", default-features = false, tag = "v0.1-rc1" }
openzeppelin-polkadot-wrappers-proc = { git = "https://github.com/openzeppelin/polkadot-runtime-wrappers", default-features = false, tag = "v0.1-rc1" }
openzeppelin-pallet-abstractions = { git = "https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions", default-features = false, tag = "v0.1-rc3" }
openzeppelin-pallet-abstractions-proc = { git = "https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions", default-features = false, tag = "v0.1-rc3" }
# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
@@ -67,6 +67,7 @@ sc-cli = { git = "https://github.com/paritytech/polkadot-sdk", default-features
sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
sc-consensus-slots = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
sc-executor = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
sc-network = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
@@ -123,6 +124,7 @@ cumulus-client-collator = { git = "https://github.com/paritytech/polkadot-sdk",
cumulus-client-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
cumulus-client-consensus-common = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
cumulus-client-consensus-proposer = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
cumulus-client-parachain-inherent = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
cumulus-client-service = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
@@ -133,6 +135,7 @@ cumulus-primitives-aura = { git = "https://github.com/paritytech/polkadot-sdk",
cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
cumulus-primitives-storage-weight-reclaim = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
cumulus-primitives-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
cumulus-primitives-utility = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
cumulus-relay-chain-interface = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
cumulus-test-relay-sproof-builder = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
@@ -184,7 +187,15 @@ xcm-primitives = { git = "https://github.com/OpenZeppelin/moonbeam.git", branch
substrate-runtimes-fuzzers = { git = "https://github.com/srlabs/substrate-runtime-fuzzer.git", default-features = false, tag = "polkadot-v1.12.0" }
ziggy = { version = "0.8", default-features = false }
# Tanssi
ccp-authorities-noting-inherent = { git = "https://github.com/OpenZeppelin/dancekit", default-features = false, tag = "polkadot-stable2407-1" }
dp-consensus = { git = "https://github.com/OpenZeppelin/dancekit", default-features = false, tag = "polkadot-stable2407-1" }
ethereum = { version = "0.15.0" }
nimbus-consensus = { git = "https://github.com/OpenZeppelin/moonkit", default-features = false, tag = "polkadot-stable2407-1" }
nimbus-primitives = { git = "https://github.com/OpenZeppelin/moonkit", default-features = false, tag = "polkadot-stable2407-1" }
pallet-author-inherent = { git = "https://github.com/OpenZeppelin/moonkit", default-features = false, tag = "polkadot-stable2407-1" }
pallet-cc-authorities-noting = { git = "https://github.com/OpenZeppelin/dancekit", default-features = false, tag = "polkadot-stable2407-1" }
tc-consensus = { git = "https://github.com/KitHat/tanssi", branch = "polkadot-stable2407-1", default-features = false }
[workspace.lints.clippy]
large_enum_variant = "allow"
+11 -10
View File
@@ -7,7 +7,7 @@ edition = { workspace = true }
license = { workspace = true }
publish = false
repository = { workspace = true }
version = "2.0.0"
version = "3.0.0"
[dependencies]
clap = { workspace = true }
@@ -34,6 +34,7 @@ sc-cli = { workspace = true }
sc-client-api = { workspace = true }
sc-consensus = { workspace = true }
sc-consensus-aura = { workspace = true }
sc-consensus-slots = { workspace = true }
sc-executor = { workspace = true }
sc-network = { workspace = true }
sc-network-sync = { workspace = true }
@@ -70,10 +71,12 @@ cumulus-client-collator = { workspace = true }
cumulus-client-consensus-aura = { workspace = true }
cumulus-client-consensus-common = { workspace = true }
cumulus-client-consensus-proposer = { workspace = true }
cumulus-client-parachain-inherent = { workspace = true }
cumulus-client-service = { workspace = true }
cumulus-primitives-core = { workspace = true }
cumulus-primitives-parachain-inherent = { workspace = true }
cumulus-relay-chain-interface = { workspace = true }
cumulus-test-relay-sproof-builder = { workspace = true }
# Frontier
fc-api = { workspace = true }
@@ -87,21 +90,19 @@ fp-dynamic-fee = { workspace = true, features = [ "std" ] }
fp-evm = { workspace = true }
fp-rpc = { workspace = true }
# Tanssi
ccp-authorities-noting-inherent = { workspace = true }
nimbus-consensus = { workspace = true }
tc-consensus = { workspace = true }
[build-dependencies]
substrate-build-script-utils = { workspace = true }
[features]
default = []
async-backing = []
runtime-benchmarks = [
"evm-runtime-template/runtime-benchmarks",
"frame-benchmarking-cli/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"polkadot-cli/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"sc-service/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
runtime-benchmarks = [ "evm-runtime-template/runtime-benchmarks", "frame-benchmarking-cli/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", "polkadot-cli/runtime-benchmarks", "polkadot-primitives/runtime-benchmarks", "sc-service/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "tc-consensus/runtime-benchmarks" ]
tanssi = []
try-runtime = [
"evm-runtime-template/try-runtime",
"polkadot-cli/try-runtime",
+79 -4
View File
@@ -1,16 +1,19 @@
use std::collections::BTreeMap;
use cumulus_primitives_core::ParaId;
use evm_runtime_template::{
AccountId, AuraId, OpenZeppelinPrecompiles as Precompiles, Runtime, Signature,
};
use evm_runtime_template::{AccountId, OpenZeppelinPrecompiles as Precompiles, Runtime};
#[cfg(not(feature = "tanssi"))]
use evm_runtime_template::{AuraId, Signature};
use fp_evm::GenesisAccount;
use hex_literal::hex;
use log::error;
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
use sp_core::{ecdsa, Pair, Public, H160};
use sp_core::H160;
#[cfg(not(feature = "tanssi"))]
use sp_core::{ecdsa, Pair, Public};
#[cfg(not(feature = "tanssi"))]
use sp_runtime::traits::{IdentifyAccount, Verify};
use crate::contracts::{parse_contracts, ContractsPath};
@@ -22,6 +25,7 @@ pub type ChainSpec = sc_service::GenericChainSpec<Extensions>;
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
/// Helper function to generate a crypto pair from seed
#[cfg(not(feature = "tanssi"))]
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
.expect("static values are valid; qed")
@@ -45,17 +49,20 @@ impl Extensions {
}
}
#[cfg(not(feature = "tanssi"))]
type AccountPublic = <Signature as Verify>::Signer;
/// Generate collator keys from seed.
///
/// This function's return type must always match the session keys of the chain
/// in tuple format.
#[cfg(not(feature = "tanssi"))]
pub fn get_collator_keys_from_seed(seed: &str) -> AuraId {
get_from_seed::<AuraId>(seed)
}
/// Helper function to generate an account ID from seed
#[cfg(not(feature = "tanssi"))]
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
where
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
@@ -67,6 +74,7 @@ where
///
/// The input must be a tuple of individual keys (a single arg for now since we
/// have just one key).
#[cfg(not(feature = "tanssi"))]
pub fn template_session_keys(keys: AuraId) -> evm_runtime_template::SessionKeys {
evm_runtime_template::SessionKeys { aura: keys }
}
@@ -94,6 +102,7 @@ pub fn development_config(contracts_path: ContractsPath) -> ChainSpec {
.with_chain_type(ChainType::Development)
.with_genesis_config_patch(testnet_genesis(
// initial collators.
#[cfg(not(feature = "tanssi"))]
vec![
(
get_account_id_from_seed::<ecdsa::Public>("Alice"),
@@ -140,6 +149,7 @@ pub fn local_testnet_config(contracts_path: ContractsPath) -> ChainSpec {
.with_chain_type(ChainType::Local)
.with_genesis_config_patch(testnet_genesis(
// initial collators.
#[cfg(not(feature = "tanssi"))]
vec![
(
get_account_id_from_seed::<ecdsa::Public>("Alice"),
@@ -165,6 +175,7 @@ pub fn local_testnet_config(contracts_path: ContractsPath) -> ChainSpec {
.build()
}
#[cfg(not(feature = "tanssi"))]
fn testnet_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
#[cfg(not(feature = "runtime-benchmarks"))] endowed_accounts: Vec<AccountId>,
@@ -245,3 +256,67 @@ fn testnet_genesis(
"sudo": { "key": Some(root) }
})
}
#[cfg(feature = "tanssi")]
fn testnet_genesis(
#[cfg(not(feature = "runtime-benchmarks"))] endowed_accounts: Vec<AccountId>,
#[cfg(feature = "runtime-benchmarks")] mut endowed_accounts: Vec<AccountId>,
root: AccountId,
id: ParaId,
contracts_path: ContractsPath,
) -> serde_json::Value {
let contracts = parse_contracts(contracts_path)
.map_err(|e| error!("Error while parsing contracts: {e:?}"))
.unwrap_or_default();
let precompiles = Precompiles::<Runtime>::used_addresses()
.map(|addr| {
(
addr,
GenesisAccount {
nonce: Default::default(),
balance: Default::default(),
storage: Default::default(),
// bytecode to revert without returning data
// (PUSH1 0x00 PUSH1 0x00 REVERT)
code: vec![0x60, 0x00, 0x60, 0x00, 0xFD],
},
)
})
.into_iter();
let accounts: BTreeMap<H160, GenesisAccount> = contracts
.into_iter()
.map(|(address, contract)| {
(
address,
GenesisAccount {
code: contract.bytecode(),
nonce: Default::default(),
balance: Default::default(),
storage: Default::default(),
},
)
})
.chain(precompiles)
.collect();
#[cfg(feature = "runtime-benchmarks")]
endowed_accounts.push(AccountId::from(hex!("1000000000000000000000000000000000000001")));
serde_json::json!({
"balances": {
"balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::<Vec<_>>(),
},
"parachainInfo": {
"parachainId": id,
},
"treasury": {},
"evmChainId": {
"chainId": 9999
},
"evm": {
"accounts": accounts
},
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
},
"sudo": { "key": Some(root) }
})
}
+2
View File
@@ -9,6 +9,8 @@ mod cli;
mod command;
mod contracts;
mod eth;
#[cfg_attr(feature = "tanssi", path = "tanssi_rpc/mod.rs")]
mod rpc;
fn main() -> sc_cli::Result<()> {
+70 -11
View File
@@ -6,23 +6,27 @@ use std::{path::Path, sync::Arc, time::Duration};
use cumulus_client_cli::CollatorOptions;
// Cumulus Imports
#[cfg(not(feature = "tanssi"))]
use cumulus_client_collator::service::CollatorService;
use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport;
#[cfg(not(feature = "tanssi"))]
use cumulus_client_consensus_proposer::Proposer;
use cumulus_client_service::{
build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks,
BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, StartRelayChainTasksParams,
};
#[cfg(not(feature = "tanssi"))]
use cumulus_primitives_core::relay_chain::CollatorPair;
#[cfg(feature = "async-backing")]
use cumulus_primitives_core::relay_chain::ValidationCode;
use cumulus_primitives_core::{relay_chain::CollatorPair, ParaId};
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
use cumulus_primitives_core::ParaId;
#[cfg(not(feature = "tanssi"))]
use cumulus_relay_chain_interface::OverseerHandle;
use cumulus_relay_chain_interface::RelayChainInterface;
#[cfg(not(feature = "tanssi"))]
use evm_runtime_template::opaque::Hash;
// Local Runtime Types
use evm_runtime_template::{
configs::TransactionConverter,
opaque::{Block, Hash},
RuntimeApi,
};
use evm_runtime_template::{configs::TransactionConverter, opaque::Block, RuntimeApi};
// Substrate Imports
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
use sc_client_api::Backend;
@@ -30,10 +34,16 @@ use sc_consensus::ImportQueue;
use sc_executor::WasmExecutor;
use sc_network::{config::FullNetworkConfiguration, NetworkBlock};
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
#[cfg(not(feature = "tanssi"))]
use sc_telemetry::TelemetryHandle;
use sc_telemetry::{Telemetry, TelemetryWorker, TelemetryWorkerHandle};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_core::{H256, U256};
use sp_core::H256;
#[cfg(not(feature = "tanssi"))]
use sp_core::U256;
#[cfg(not(feature = "tanssi"))]
use sp_keystore::KeystorePtr;
#[cfg(not(feature = "tanssi"))]
use substrate_prometheus_endpoint::Registry;
use crate::eth::{
@@ -121,8 +131,13 @@ pub fn new_partial(
client.clone(),
);
let block_import = ParachainBlockImport::new(client.clone(), backend.clone());
#[cfg(feature = "tanssi")]
let (block_import, import_queue) =
import_queue(config, client.clone(), backend.clone(), &task_manager);
#[cfg(not(feature = "tanssi"))]
let block_import = ParachainBlockImport::new(client.clone(), backend.clone());
#[cfg(not(feature = "tanssi"))]
let import_queue = build_import_queue(
client.clone(),
block_import.clone(),
@@ -180,6 +195,35 @@ pub fn new_partial(
})
}
#[cfg(feature = "tanssi")]
pub fn import_queue(
parachain_config: &Configuration,
client: Arc<ParachainClient>,
backend: Arc<ParachainBackend>,
task_manager: &TaskManager,
) -> (ParachainBlockImport, sc_consensus::BasicQueue<Block>) {
// The nimbus import queue ONLY checks the signature correctness
// Any other checks corresponding to the author-correctness should be done
// in the runtime
let block_import = ParachainBlockImport::new(client.clone(), backend);
let import_queue = nimbus_consensus::import_queue(
client,
block_import.clone(),
move |_, _| async move {
let time = sp_timestamp::InherentDataProvider::from_system_time();
Ok((time,))
},
&task_manager.spawn_essential_handle(),
parachain_config.prometheus_registry(),
false,
)
.expect("function never fails");
(block_import, import_queue)
}
/// Start a node with the given parachain `Configuration` and relay chain
/// `Configuration`.
///
@@ -201,8 +245,11 @@ async fn start_node_impl(
let FrontierPartialComponents { filter_pool, fee_history_cache, fee_history_cache_limit } =
new_frontier_partial(eth_config)?;
#[cfg(not(feature = "tanssi"))]
let (block_import, mut telemetry, telemetry_worker_handle, frontier_backend, overrides) =
params.other;
#[cfg(feature = "tanssi")]
let (_, mut telemetry, telemetry_worker_handle, frontier_backend, overrides) = params.other;
let frontier_backend = Arc::new(frontier_backend);
let net_config: FullNetworkConfiguration<Block, H256, sc_network::NetworkWorker<_, _>> =
@@ -212,7 +259,7 @@ async fn start_node_impl(
let backend = params.backend.clone();
let mut task_manager = params.task_manager;
let (relay_chain_interface, collator_key) = build_relay_chain_interface(
let relay_chain_interface = build_relay_chain_interface(
polkadot_config,
&parachain_config,
telemetry_worker_handle,
@@ -223,10 +270,16 @@ async fn start_node_impl(
.await
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;
#[cfg(not(feature = "tanssi"))]
let (relay_chain_interface, collator_key) = relay_chain_interface;
#[cfg(feature = "tanssi")]
let (relay_chain_interface, _) = relay_chain_interface;
let validator = parachain_config.role.is_authority();
let prometheus_registry = parachain_config.prometheus_registry().cloned();
let transaction_pool = params.transaction_pool.clone();
let import_queue_service = params.import_queue.service();
#[cfg(not(feature = "tanssi"))]
let slot_duration = sc_consensus_aura::slot_duration(&*client)?;
let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) =
@@ -274,8 +327,10 @@ async fn start_node_impl(
let rpc_builder = {
let client = client.clone();
let transaction_pool = transaction_pool.clone();
#[cfg(not(feature = "tanssi"))]
let target_gas_price = eth_config.target_gas_price;
let enable_dev_signer = eth_config.enable_dev_signer;
#[cfg(not(feature = "tanssi"))]
let pending_create_inherent_data_providers = move |_, ()| async move {
let current = sp_timestamp::InherentDataProvider::from_system_time();
let next_slot = current.timestamp().as_millis() + slot_duration.as_millis();
@@ -326,6 +381,7 @@ async fn start_node_impl(
fee_history_cache_limit,
execute_gas_limit_multiplier,
forced_parent_hashes: None,
#[cfg(not(feature = "tanssi"))]
pending_create_inherent_data_providers,
};
let deps = crate::rpc::FullDeps {
@@ -428,6 +484,7 @@ async fn start_node_impl(
)
.await;
#[cfg(not(feature = "tanssi"))]
if validator {
start_consensus(
client.clone(),
@@ -453,6 +510,7 @@ async fn start_node_impl(
Ok((task_manager, client))
}
#[cfg(not(feature = "tanssi"))]
/// Build the import queue for the parachain runtime.
fn build_import_queue(
client: Arc<ParachainClient>,
@@ -480,6 +538,7 @@ fn build_import_queue(
))
}
#[cfg(not(feature = "tanssi"))]
fn start_consensus(
client: Arc<ParachainClient>,
#[cfg(feature = "async-backing")] backend: Arc<ParachainBackend>,
+240
View File
@@ -0,0 +1,240 @@
use std::{collections::BTreeMap, sync::Arc};
use cumulus_client_parachain_inherent::ParachainInherentData;
use cumulus_primitives_core::PersistedValidationData;
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
// Frontier
pub use fc_rpc::{EthBlockDataCacheTask, EthConfig};
pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool};
pub use fc_storage::StorageOverride;
use fp_rpc::{ConvertTransaction, ConvertTransactionRuntimeApi, EthereumRuntimeRPCApi};
use jsonrpsee::RpcModule;
// Substrate
use sc_client_api::{
backend::{Backend, StorageProvider},
client::BlockchainEvents,
AuxStore, UsageProvider,
};
use sc_network::service::traits::NetworkService;
use sc_network_sync::SyncingService;
use sc_rpc::SubscriptionTaskExecutor;
use sc_transaction_pool::{ChainApi, Pool};
use sc_transaction_pool_api::TransactionPool;
use sp_api::{CallApiAt, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder as BlockBuilderApi;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use sp_core::H256;
use sp_runtime::traits::Block as BlockT;
/// Extra dependencies for Ethereum compatibility.
pub struct EthDeps<B: BlockT, C, P, A: ChainApi, CT> {
/// The client instance to use.
pub client: Arc<C>,
/// Transaction pool instance.
pub pool: Arc<P>,
/// Graph pool instance.
pub graph: Arc<Pool<A>>,
/// Ethereum transaction converter.
pub converter: Option<CT>,
/// The Node authority flag
pub is_authority: bool,
/// Whether to enable dev signer
pub enable_dev_signer: bool,
/// Network service
pub network: Arc<dyn NetworkService>,
/// Chain syncing service
pub sync: Arc<SyncingService<B>>,
/// Frontier Backend.
pub frontier_backend: Arc<dyn fc_api::Backend<B>>,
/// Ethereum data access overrides.
pub overrides: Arc<dyn StorageOverride<B>>,
/// Cache for Ethereum block data.
pub block_data_cache: Arc<EthBlockDataCacheTask<B>>,
/// EthFilterApi pool.
pub filter_pool: Option<FilterPool>,
/// Maximum number of logs in a query.
pub max_past_logs: u32,
/// Fee history cache.
pub fee_history_cache: FeeHistoryCache,
/// Maximum fee history cache size.
pub fee_history_cache_limit: FeeHistoryCacheLimit,
/// Maximum allowed gas limit will be ` block.gas_limit * execute_gas_limit_multiplier` when
/// using eth_call/eth_estimateGas.
pub execute_gas_limit_multiplier: u64,
/// Mandated parent hashes for a given block hash.
pub forced_parent_hashes: Option<BTreeMap<H256, H256>>,
}
#[cfg(feature = "tanssi")]
/// Instantiate Ethereum-compatible RPC extensions.
pub fn create_eth<B, C, BE, P, A, CT, EC>(
mut io: RpcModule<()>,
deps: EthDeps<B, C, P, A, CT>,
subscription_task_executor: SubscriptionTaskExecutor,
pubsub_notification_sinks: Arc<
fc_mapping_sync::EthereumBlockNotificationSinks<
fc_mapping_sync::EthereumBlockNotification<B>,
>,
>,
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
where
B: BlockT<Hash = H256>,
C: CallApiAt<B> + ProvideRuntimeApi<B>,
C::Api: BlockBuilderApi<B> + ConvertTransactionRuntimeApi<B> + EthereumRuntimeRPCApi<B>,
C: HeaderBackend<B> + HeaderMetadata<B, Error = BlockChainError>,
C: BlockchainEvents<B> + AuxStore + UsageProvider<B> + StorageProvider<B, BE> + 'static,
BE: Backend<B> + 'static,
P: TransactionPool<Block = B> + 'static,
A: ChainApi<Block = B> + 'static,
CT: ConvertTransaction<<B as BlockT>::Extrinsic> + Send + Sync + 'static,
EC: EthConfig<B, C>,
{
use fc_rpc::{
Debug, DebugApiServer, Eth, EthApiServer, EthDevSigner, EthFilter, EthFilterApiServer,
EthPubSub, EthPubSubApiServer, EthSigner, Net, NetApiServer, Web3, Web3ApiServer,
};
#[cfg(feature = "txpool")]
use fc_rpc::{TxPool, TxPoolApiServer};
let EthDeps {
client,
pool,
graph,
converter,
is_authority,
enable_dev_signer,
network,
sync,
frontier_backend,
overrides,
block_data_cache,
filter_pool,
max_past_logs,
fee_history_cache,
fee_history_cache_limit,
execute_gas_limit_multiplier,
forced_parent_hashes,
} = deps;
let authorities = vec![tc_consensus::get_aura_id_from_seed("alice")];
let authorities_for_cdp = authorities.clone();
let pending_create_inherent_data_providers = move |_, _| {
let authorities_for_cidp = authorities.clone();
async move {
let mocked_authorities_noting =
ccp_authorities_noting_inherent::MockAuthoritiesNotingInherentDataProvider {
current_para_block: 1000,
relay_offset: 1000,
relay_blocks_per_para_block: 2,
orchestrator_para_id: 1000u32.into(),
container_para_id: 2000u32.into(),
authorities: authorities_for_cidp,
};
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
// Create a dummy parachain inherent data provider which is required to pass
// the checks by the para chain system. We use dummy values because in the 'pending context'
// neither do we have access to the real values nor do we need them.
let (relay_parent_storage_root, relay_chain_state) = RelayStateSproofBuilder {
additional_key_values: mocked_authorities_noting.get_key_values(),
..Default::default()
}
.into_state_root_and_proof();
let vfp = PersistedValidationData {
// This is a hack to make `cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases`
// happy. Relay parent number can't be bigger than u32::MAX.
relay_parent_number: u32::MAX,
relay_parent_storage_root,
..Default::default()
};
let parachain_inherent_data = ParachainInherentData {
validation_data: vfp,
relay_chain_state,
downward_messages: Default::default(),
horizontal_messages: Default::default(),
};
Ok((timestamp, parachain_inherent_data, mocked_authorities_noting))
}
};
let mut signers = Vec::new();
if enable_dev_signer {
signers.push(Box::new(EthDevSigner::new()) as Box<dyn EthSigner>);
}
io.merge(
Eth::<B, C, P, CT, BE, A, _, EC>::new(
client.clone(),
pool.clone(),
graph.clone(),
converter,
sync.clone(),
signers,
overrides.clone(),
frontier_backend.clone(),
is_authority,
block_data_cache.clone(),
fee_history_cache,
fee_history_cache_limit,
execute_gas_limit_multiplier,
forced_parent_hashes,
pending_create_inherent_data_providers,
Some(Box::new(tc_consensus::ContainerManualSealAuraConsensusDataProvider::new(
sp_consensus_aura::SlotDuration::from_millis(
evm_runtime_template::constants::SLOT_DURATION,
),
authorities_for_cdp.clone(),
))),
)
.replace_config::<EC>()
.into_rpc(),
)?;
if let Some(filter_pool) = filter_pool {
io.merge(
EthFilter::new(
client.clone(),
frontier_backend.clone(),
graph.clone(),
filter_pool,
500_usize, // max stored filters
max_past_logs,
block_data_cache.clone(),
)
.into_rpc(),
)?;
}
io.merge(
EthPubSub::new(
pool,
client.clone(),
sync,
subscription_task_executor,
overrides.clone(),
pubsub_notification_sinks,
)
.into_rpc(),
)?;
io.merge(
Net::new(
client.clone(),
network,
// Whether to format the `peer_count` response as Hex (default) or not.
true,
)
.into_rpc(),
)?;
io.merge(Web3::new(client.clone()).into_rpc())?;
io.merge(Debug::new(client.clone(), frontier_backend, overrides, block_data_cache).into_rpc())?;
#[cfg(feature = "txpool")]
io.merge(TxPool::new(client, graph).into_rpc())?;
Ok(io)
}
+98
View File
@@ -0,0 +1,98 @@
//! A collection of node-specific RPC methods.
//! Substrate provides the `sc-rpc` crate, which defines the core RPC layer
//! used by Substrate nodes. This file extends those RPC definitions with
//! capabilities that are specific to this project's runtime configuration.
#![warn(missing_docs)]
mod eth;
use std::sync::Arc;
use evm_runtime_template::{opaque::Block, AccountId, Balance, Nonce};
use sc_client_api::{backend::Backend, AuxStore, BlockchainEvents, StorageProvider, UsageProvider};
pub use sc_rpc::DenyUnsafe;
use sc_rpc::SubscriptionTaskExecutor;
use sc_transaction_pool::ChainApi;
use sc_transaction_pool_api::TransactionPool;
use sp_api::{CallApiAt, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use sp_runtime::traits::Block as BlockT;
pub use self::eth::EthDeps;
use crate::rpc::eth::create_eth;
/// A type representing all RPC extensions.
pub type RpcExtension = jsonrpsee::RpcModule<()>;
/// Full client dependencies
pub struct FullDeps<C, P, A: ChainApi, CT> {
/// The client instance to use.
pub client: Arc<C>,
/// Transaction pool instance.
pub pool: Arc<P>,
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,
/// Ethereum-compatibility specific dependencies.
pub eth: EthDeps<Block, C, P, A, CT>,
}
pub struct DefaultEthConfig<C, BE>(std::marker::PhantomData<(C, BE)>);
impl<C, BE> fc_rpc::EthConfig<Block, C> for DefaultEthConfig<C, BE>
where
C: StorageProvider<Block, BE> + Sync + Send + 'static,
BE: Backend<Block> + 'static,
{
type EstimateGasAdapter = ();
type RuntimeStorageOverride =
fc_rpc::frontier_backend_client::SystemAccountId20StorageOverride<Block, C, BE>;
}
/// Instantiate all RPC extensions.
pub fn create_full<C, P, A, CT, BE>(
deps: FullDeps<C, P, A, CT>,
subscription_task_executor: SubscriptionTaskExecutor,
pubsub_notification_sinks: Arc<
fc_mapping_sync::EthereumBlockNotificationSinks<
fc_mapping_sync::EthereumBlockNotification<Block>,
>,
>,
) -> Result<RpcExtension, Box<dyn std::error::Error + Send + Sync>>
where
C: ProvideRuntimeApi<Block>
+ HeaderBackend<Block>
+ AuxStore
+ HeaderMetadata<Block, Error = BlockChainError>
+ Send
+ Sync
+ CallApiAt<Block>
+ UsageProvider<Block>
+ StorageProvider<Block, BE>
+ BlockchainEvents<Block>
+ 'static,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: BlockBuilder<Block>,
C::Api: fp_rpc::ConvertTransactionRuntimeApi<Block>,
C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,
P: TransactionPool<Block = Block> + Sync + Send + 'static,
A: ChainApi<Block = Block> + 'static,
CT: fp_rpc::ConvertTransaction<<Block as BlockT>::Extrinsic> + Send + Sync + 'static,
BE: Backend<Block> + 'static,
{
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use substrate_frame_rpc_system::{System, SystemApiServer};
let mut module = RpcExtension::new(());
let FullDeps { client, pool, deny_unsafe, eth } = deps;
module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
module.merge(TransactionPayment::new(client).into_rpc())?;
let module = create_eth::<_, _, _, _, _, _, DefaultEthConfig<C, BE>>(
module,
eth,
subscription_task_executor,
pubsub_notification_sinks,
)?;
Ok(module)
}
+24 -5
View File
@@ -5,7 +5,7 @@ description = "An EVM parachain runtime template"
edition = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
version = "1.0.0"
version = "3.0.0"
[package.metadata.docs.rs]
targets = [ "x86_64-unknown-linux-gnu" ]
@@ -17,8 +17,8 @@ parity-scale-codec = { workspace = true, features = [ "derive" ] }
scale-info = { workspace = true, features = [ "derive" ] }
smallvec = { workspace = true }
openzeppelin-polkadot-wrappers = { workspace = true }
openzeppelin-polkadot-wrappers-proc = { workspace = true }
openzeppelin-pallet-abstractions = { workspace = true }
openzeppelin-pallet-abstractions-proc = { workspace = true }
# Substrate
frame-benchmarking = { workspace = true, optional = true }
@@ -80,6 +80,7 @@ cumulus-pallet-xcmp-queue = { workspace = true }
cumulus-primitives-aura = { workspace = true }
cumulus-primitives-core = { workspace = true }
cumulus-primitives-storage-weight-reclaim = { workspace = true }
cumulus-primitives-timestamp = { workspace = true }
cumulus-primitives-utility = { workspace = true }
pallet-collator-selection = { workspace = true }
parachain-info = { workspace = true }
@@ -110,6 +111,11 @@ pallet-xcm-transactor = { workspace = true }
pallet-xcm-weight-trader = { workspace = true }
xcm-primitives = { workspace = true }
# Tanssi
dp-consensus = { workspace = true }
nimbus-primitives = { workspace = true }
pallet-author-inherent = { workspace = true }
pallet-cc-authorities-noting = { workspace = true }
[dev-dependencies]
ethereum = { workspace = true }
@@ -134,6 +140,7 @@ std = [
"cumulus-primitives-core/std",
"cumulus-primitives-storage-weight-reclaim/std",
"cumulus-primitives-utility/std",
"dp-consensus/std",
"fp-account/std",
"fp-account/std",
"fp-evm/std",
@@ -148,14 +155,17 @@ std = [
"frame-system/std",
"frame-try-runtime?/std",
"log/std",
"openzeppelin-polkadot-wrappers/std",
"nimbus-primitives/std",
"openzeppelin-pallet-abstractions/std",
"orml-xtokens/std",
"pallet-asset-manager/std",
"pallet-assets/std",
"pallet-aura/std",
"pallet-author-inherent/std",
"pallet-authorship/std",
"pallet-balances/std",
"pallet-base-fee/std",
"pallet-cc-authorities-noting/std",
"pallet-collator-selection/std",
"pallet-conviction-voting/std",
"pallet-erc20-xcm-bridge/std",
@@ -203,7 +213,7 @@ std = [
"xcm-primitives/std",
"xcm/std",
]
async-backing = [ "openzeppelin-polkadot-wrappers-proc/async-backing" ]
async-backing = [ "openzeppelin-pallet-abstractions-proc/async-backing" ]
metadata-hash = [ "substrate-wasm-builder/metadata-hash" ]
runtime-benchmarks = [
"assets-common/runtime-benchmarks",
@@ -211,14 +221,18 @@ runtime-benchmarks = [
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
"cumulus-primitives-utility/runtime-benchmarks",
"dp-consensus/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"hex-literal",
"nimbus-primitives/runtime-benchmarks",
"pallet-asset-manager/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-author-inherent/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-cc-authorities-noting/runtime-benchmarks",
"pallet-collator-selection/runtime-benchmarks",
"pallet-conviction-voting/runtime-benchmarks",
"pallet-ethereum/runtime-benchmarks",
@@ -255,13 +269,16 @@ try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"frame-try-runtime/try-runtime",
"nimbus-primitives/try-runtime",
"orml-xtokens/try-runtime",
"pallet-asset-manager/try-runtime",
"pallet-assets/try-runtime",
"pallet-aura/try-runtime",
"pallet-author-inherent/try-runtime",
"pallet-authorship/try-runtime",
"pallet-balances/try-runtime",
"pallet-base-fee/try-runtime",
"pallet-cc-authorities-noting/try-runtime",
"pallet-collator-selection/try-runtime",
"pallet-conviction-voting/try-runtime",
"pallet-erc20-xcm-bridge/try-runtime",
@@ -289,6 +306,8 @@ try-runtime = [
"sp-runtime/try-runtime",
]
tanssi = []
# A feature that should be enabled when the runtime should be built for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller, like logging for example.
+69 -16
View File
@@ -1,13 +1,18 @@
pub mod asset_config;
pub mod governance;
pub mod weight;
pub mod xcm_config;
use asset_config::*;
#[cfg(feature = "tanssi")]
use cumulus_pallet_parachain_system::ExpectParentIncluded;
#[cfg(feature = "async-backing")]
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
#[cfg(not(feature = "async-backing"))]
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
#[cfg(not(feature = "tanssi"))]
use frame_support::PalletId;
use frame_support::{
derive_impl,
dispatch::DispatchClass,
@@ -17,7 +22,6 @@ use frame_support::{
EitherOfDiverse, Everything, FindAuthor, Nothing, TransformOrigin,
},
weights::{ConstantMultiplier, Weight},
PalletId,
};
use frame_system::{
limits::{BlockLength, BlockWeights},
@@ -25,16 +29,26 @@ use frame_system::{
};
pub use governance::origins::pallet_custom_origins;
use governance::{origins::Treasurer, tracks, Spender, WhitelistedCaller};
use openzeppelin_polkadot_wrappers::{
impl_openzeppelin_assets, impl_openzeppelin_consensus, impl_openzeppelin_evm,
impl_openzeppelin_governance, impl_openzeppelin_system, impl_openzeppelin_xcm, AssetsConfig,
ConsensusConfig, EvmConfig, GovernanceConfig, SystemConfig, XcmConfig,
#[cfg(feature = "tanssi")]
use nimbus_primitives::NimbusId;
use openzeppelin_pallet_abstractions::{
impl_openzeppelin_assets, impl_openzeppelin_evm, impl_openzeppelin_governance,
impl_openzeppelin_system, impl_openzeppelin_xcm, AssetsConfig, AssetsWeight, EvmConfig,
EvmWeight, GovernanceConfig, GovernanceWeight, SystemConfig, SystemWeight, XcmConfig,
XcmWeight,
};
#[cfg(not(feature = "tanssi"))]
use openzeppelin_pallet_abstractions::{
impl_openzeppelin_consensus, ConsensusConfig, ConsensusWeight,
};
#[cfg(feature = "tanssi")]
use openzeppelin_pallet_abstractions::{impl_openzeppelin_tanssi, TanssiConfig, TanssiWeight};
use pallet_ethereum::PostLogContent;
use pallet_evm::{EVMCurrencyAdapter, EnsureAccountId20, IdentityAddressMapping};
use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling};
use parity_scale_codec::{Decode, Encode};
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
#[cfg(not(feature = "tanssi"))]
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{H160, U256};
use sp_runtime::{
@@ -57,39 +71,58 @@ use xcm_primitives::{AbsoluteAndRelativeReserve, AccountIdToLocation, AsAssetTyp
#[cfg(feature = "runtime-benchmarks")]
use crate::benchmark::{OpenHrmpChannel, PayWithEnsure};
#[cfg(feature = "tanssi")]
use crate::AuthorInherent;
#[cfg(not(feature = "tanssi"))]
use crate::{
constants::HOURS,
types::{BlockNumber, CollatorSelectionUpdateOrigin, ConsensusHook},
Aura, CollatorSelection, Session, SessionKeys,
};
use crate::{
constants::{
currency::{deposit, CENTS, EXISTENTIAL_DEPOSIT, MICROCENTS, MILLICENTS},
AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, MAX_BLOCK_LENGTH,
NORMAL_DISPATCH_RATIO, WEIGHT_PER_GAS,
AVERAGE_ON_INITIALIZE_RATIO, DAYS, MAXIMUM_BLOCK_WEIGHT, MAX_BLOCK_LENGTH,
NORMAL_DISPATCH_RATIO, SLOT_DURATION, WEIGHT_PER_GAS,
},
opaque,
types::{
AccountId, AssetId, AssetKind, Balance, Beneficiary, Block, BlockNumber,
CollatorSelectionUpdateOrigin, ConsensusHook, Hash, MessageQueueServiceWeight, Nonce,
PrecompilesValue, PriceForSiblingParachainDelivery, ProxyType, TreasuryInteriorLocation,
TreasuryPalletId, TreasuryPaymaster, Version,
AccountId, AssetId, AssetKind, Balance, Beneficiary, Block, Hash,
MessageQueueServiceWeight, Nonce, PrecompilesValue, PriceForSiblingParachainDelivery,
ProxyType, TreasuryInteriorLocation, TreasuryPalletId, TreasuryPaymaster, Version,
},
weights::{self, BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
AllPalletsWithSystem, AssetManager, Aura, Balances, BaseFee, CollatorSelection, EVMChainId,
Erc20XcmBridge, MessageQueue, OpenZeppelinPrecompiles, OriginCaller, PalletInfo, ParachainInfo,
weights::{BlockExecutionWeight, ExtrinsicBaseWeight},
AllPalletsWithSystem, AssetManager, Balances, BaseFee, EVMChainId, Erc20XcmBridge,
MessageQueue, OpenZeppelinPrecompiles, OriginCaller, PalletInfo, ParachainInfo,
ParachainSystem, PolkadotXcm, Preimage, Referenda, Runtime, RuntimeCall, RuntimeEvent,
RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask, Scheduler, Session,
SessionKeys, System, Timestamp, Treasury, UncheckedExtrinsic, WeightToFee, XcmpQueue,
RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask, Scheduler, System,
Timestamp, Treasury, UncheckedExtrinsic, WeightToFee, XcmpQueue,
};
// OpenZeppelin runtime wrappers configuration
pub struct OpenZeppelinRuntime;
impl SystemConfig for OpenZeppelinRuntime {
type AccountId = AccountId;
#[cfg(not(feature = "tanssi"))]
type ConsensusHook = ConsensusHook;
#[cfg(feature = "tanssi")]
type ConsensusHook = ExpectParentIncluded;
type ExistentialDeposit = ConstU128<EXISTENTIAL_DEPOSIT>;
type Lookup = IdentityLookup<AccountId>;
#[cfg(not(feature = "tanssi"))]
type OnTimestampSet = Aura;
#[cfg(feature = "tanssi")]
type OnTimestampSet = ();
type PreimageOrigin = EnsureRoot<AccountId>;
type ProxyType = ProxyType;
type SS58Prefix = ConstU16<42>;
type ScheduleOrigin = EnsureRoot<AccountId>;
type SlotDuration = ConstU64<SLOT_DURATION>;
type Version = Version;
}
#[cfg(feature = "tanssi")]
impl TanssiConfig for OpenZeppelinRuntime {}
#[cfg(not(feature = "tanssi"))]
impl ConsensusConfig for OpenZeppelinRuntime {
type CollatorSelectionUpdateOrigin = CollatorSelectionUpdateOrigin;
}
@@ -158,7 +191,10 @@ impl EvmConfig for OpenZeppelinRuntime {
type AddressMapping = IdentityAddressMapping;
type CallOrigin = EnsureAccountId20;
type Erc20XcmBridgeTransferGasLimit = ConstU64<800_000>;
#[cfg(not(feature = "tanssi"))]
type FindAuthor = FindAuthorSession<Aura>;
#[cfg(feature = "tanssi")]
type FindAuthor = FindAuthorSession<AuthorInherent>;
type LocationToH160 = LocationToH160;
type PrecompilesType = OpenZeppelinPrecompiles<Runtime>;
type PrecompilesValue = PrecompilesValue;
@@ -181,12 +217,16 @@ impl AssetsConfig for OpenZeppelinRuntime {
}
impl_openzeppelin_assets!(OpenZeppelinRuntime);
impl_openzeppelin_system!(OpenZeppelinRuntime);
#[cfg(not(feature = "tanssi"))]
impl_openzeppelin_consensus!(OpenZeppelinRuntime);
#[cfg(feature = "tanssi")]
impl_openzeppelin_tanssi!();
impl_openzeppelin_governance!(OpenZeppelinRuntime);
impl_openzeppelin_xcm!(OpenZeppelinRuntime);
impl_openzeppelin_evm!(OpenZeppelinRuntime);
pub struct FindAuthorSession<F>(PhantomData<F>);
#[cfg(not(feature = "tanssi"))]
impl<F: FindAuthor<u32>> FindAuthor<H160> for FindAuthorSession<F> {
fn find_author<'a, I>(digests: I) -> Option<H160>
where
@@ -200,6 +240,19 @@ impl<F: FindAuthor<u32>> FindAuthor<H160> for FindAuthorSession<F> {
}
}
#[cfg(feature = "tanssi")]
impl<F: FindAuthor<NimbusId>> FindAuthor<H160> for FindAuthorSession<F> {
fn find_author<'a, I>(digests: I) -> Option<H160>
where
I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,
{
if let Some(author) = F::find_author(digests) {
return Some(H160::from_slice(&author.encode()[0..20]));
}
None
}
}
#[derive(Clone)]
pub struct TransactionConverter;
@@ -0,0 +1,62 @@
#[cfg(not(feature = "tanssi"))]
use openzeppelin_pallet_abstractions::ConsensusWeight;
#[cfg(feature = "tanssi")]
use openzeppelin_pallet_abstractions::TanssiWeight;
use openzeppelin_pallet_abstractions::{
AssetsWeight, EvmWeight, GovernanceWeight, SystemWeight, XcmWeight,
};
use crate::{
configs::OpenZeppelinRuntime,
weights::{self, RocksDbWeight},
Runtime,
};
impl SystemWeight for OpenZeppelinRuntime {
type Balances = weights::pallet_balances::WeightInfo<Runtime>;
type DbWeight = RocksDbWeight;
type Multisig = weights::pallet_multisig::WeightInfo<Runtime>;
type ParachainSystem = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
type Preimage = weights::pallet_preimage::WeightInfo<Runtime>;
type Proxy = weights::pallet_proxy::WeightInfo<Runtime>;
type Scheduler = weights::pallet_scheduler::WeightInfo<Runtime>;
type Timestamp = weights::pallet_timestamp::WeightInfo<Runtime>;
type Utility = weights::pallet_utility::WeightInfo<Runtime>;
}
#[cfg(not(feature = "tanssi"))]
impl ConsensusWeight for OpenZeppelinRuntime {
type CollatorSelection = weights::pallet_collator_selection::WeightInfo<Runtime>;
type Session = weights::pallet_session::WeightInfo<Runtime>;
}
impl AssetsWeight for OpenZeppelinRuntime {
type AssetManager = weights::pallet_asset_manager::WeightInfo<Runtime>;
type Assets = weights::pallet_assets::WeightInfo<Runtime>;
}
impl GovernanceWeight for OpenZeppelinRuntime {
type ConvictionVoting = weights::pallet_conviction_voting::WeightInfo<Runtime>;
type Referenda = weights::pallet_referenda::WeightInfo<Runtime>;
type Sudo = weights::pallet_sudo::WeightInfo<Runtime>;
type Treasury = weights::pallet_treasury::WeightInfo<Runtime>;
type Whitelist = weights::pallet_whitelist::WeightInfo<Runtime>;
}
impl XcmWeight for OpenZeppelinRuntime {
type MessageQueue = weights::pallet_message_queue::WeightInfo<Runtime>;
type Xcm = weights::pallet_xcm::WeightInfo<Runtime>;
type XcmTransactor = weights::pallet_xcm_transactor::WeightInfo<Runtime>;
type XcmWeightTrader = weights::pallet_xcm_weight_trader::WeightInfo<Runtime>;
type XcmpQueue = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
}
impl EvmWeight for OpenZeppelinRuntime {
type Evm = weights::pallet_evm::WeightInfo<Runtime>;
}
#[cfg(feature = "tanssi")]
impl TanssiWeight for OpenZeppelinRuntime {
type AuthorInherent = pallet_author_inherent::weights::SubstrateWeight<Runtime>;
type AuthoritiesNoting = pallet_cc_authorities_noting::weights::SubstrateWeight<Runtime>;
}
+80 -13
View File
@@ -168,11 +168,16 @@ pub mod opaque {
pub type Hash = <BlakeTwo256 as HashT>::Output;
}
#[cfg(not(feature = "tanssi"))]
impl_opaque_keys! {
pub struct SessionKeys {
pub aura: Aura,
}
}
#[cfg(feature = "tanssi")]
impl_opaque_keys! {
pub struct SessionKeys {}
}
/// The version information used to identify this runtime when compiled
/// natively.
@@ -183,50 +188,60 @@ pub fn native_version() -> NativeVersion {
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
}
use openzeppelin_polkadot_wrappers_proc::openzeppelin_construct_runtime;
use openzeppelin_pallet_abstractions_proc::openzeppelin_construct_runtime;
#[cfg(not(feature = "tanssi"))]
#[openzeppelin_construct_runtime]
mod runtime {
#[abstraction]
struct System;
#[abstraction]
struct Consensus;
#[abstraction]
struct XCM;
#[abstraction]
struct Assets;
#[abstraction]
struct Governance;
#[abstraction]
struct EVM;
}
use openzeppelin_polkadot_wrappers_proc::openzeppelin_runtime_apis;
#[cfg(feature = "tanssi")]
#[openzeppelin_construct_runtime]
mod runtime {
struct System;
struct Tanssi;
struct XCM;
struct Assets;
struct Governance;
struct EVM;
}
use openzeppelin_pallet_abstractions_proc::openzeppelin_runtime_apis;
#[cfg(not(feature = "tanssi"))]
#[openzeppelin_runtime_apis]
mod apis {
type Runtime = Runtime;
type Block = Block;
#[abstraction]
mod evm {
type RuntimeCall = RuntimeCall;
type Executive = Executive;
type Ethereum = Ethereum;
}
#[abstraction]
mod assets {
type RuntimeCall = RuntimeCall;
type TransactionPayment = TransactionPayment;
type Balance = Balance;
}
#[abstraction]
mod consensus {
type SessionKeys = SessionKeys;
#[cfg(not(feature = "async-backing"))]
@@ -237,7 +252,6 @@ mod apis {
type ConsensusHook = ConsensusHook;
}
#[abstraction]
mod system {
type Executive = Executive;
type System = System;
@@ -249,7 +263,60 @@ mod apis {
type RuntimeBlockWeights = RuntimeBlockWeights;
}
#[abstraction]
mod benchmarks {
type AllPalletsWithSystem = AllPalletsWithSystem;
type Assets = Assets;
type AssetManager = AssetManager;
type AssetType = AssetType;
type RuntimeOrigin = RuntimeOrigin;
type RelayLocation = RelayLocation;
type ParachainSystem = ParachainSystem;
type System = System;
type ExistentialDeposit = ExistentialDeposit;
type AssetId = AssetId;
type XCMConfig = XcmExecutorConfig;
type AccountId = AccountId;
type Cents = CENTS;
type FeeAssetId = FeeAssetId;
type TransactionByteFee = TransactionByteFee;
type Address = Address;
type Balances = Balances;
}
}
#[cfg(feature = "tanssi")]
#[openzeppelin_runtime_apis]
mod apis {
type Runtime = Runtime;
type Block = Block;
mod evm {
type RuntimeCall = RuntimeCall;
type Executive = Executive;
type Ethereum = Ethereum;
}
mod assets {
type RuntimeCall = RuntimeCall;
type TransactionPayment = TransactionPayment;
type Balance = Balance;
}
mod tanssi {
type SessionKeys = SessionKeys;
}
mod system {
type Executive = Executive;
type System = System;
type ParachainSystem = ParachainSystem;
type RuntimeVersion = VERSION;
type AccountId = AccountId;
type Nonce = Nonce;
type RuntimeGenesisConfig = RuntimeGenesisConfig;
type RuntimeBlockWeights = RuntimeBlockWeights;
}
mod benchmarks {
type AllPalletsWithSystem = AllPalletsWithSystem;
type Assets = Assets;
+17 -14
View File
@@ -1,11 +1,10 @@
use fp_account::EthereumSignature;
use frame_support::{
parameter_types,
traits::{EitherOfDiverse, InstanceFilter},
weights::Weight,
PalletId,
};
#[cfg(not(feature = "tanssi"))]
use frame_support::traits::EitherOfDiverse;
use frame_support::{parameter_types, traits::InstanceFilter, weights::Weight, PalletId};
#[cfg(not(feature = "tanssi"))]
use frame_system::EnsureRoot;
#[cfg(not(feature = "tanssi"))]
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use polkadot_runtime_common::impls::{
@@ -26,19 +25,19 @@ use xcm::{
use xcm_builder::PayOverXcm;
use crate::{
configs::{
xcm_config::{self, RelayLocation},
FeeAssetId, StakingAdminBodyId, ToSiblingBaseDeliveryFee, TransactionByteFee,
},
configs::{xcm_config, FeeAssetId, ToSiblingBaseDeliveryFee, TransactionByteFee},
constants::HOURS,
};
pub use crate::{
#[cfg(not(feature = "tanssi"))]
use crate::{
configs::{xcm_config::RelayLocation, StakingAdminBodyId},
constants::{
BLOCK_PROCESSING_VELOCITY, RELAY_CHAIN_SLOT_DURATION_MILLIS, UNINCLUDED_SEGMENT_CAPACITY,
VERSION,
},
AllPalletsWithSystem, OpenZeppelinPrecompiles, Runtime, RuntimeBlockWeights, RuntimeCall,
Treasury, XcmpQueue,
};
pub use crate::{
constants::VERSION, AllPalletsWithSystem, OpenZeppelinPrecompiles, Runtime,
RuntimeBlockWeights, RuntimeCall, Treasury, XcmpQueue,
};
/// Unchecked extrinsic type as expected by this runtime.
@@ -107,6 +106,7 @@ pub type PriceForSiblingParachainDelivery = polkadot_runtime_common::xcm_sender:
>;
/// Configures the number of blocks that can be created without submission of validity proof to the relay chain
#[cfg(not(feature = "tanssi"))]
pub type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
Runtime,
RELAY_CHAIN_SLOT_DURATION_MILLIS,
@@ -116,6 +116,7 @@ pub type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
/// We allow root and the StakingAdmin to execute privileged collator selection
/// operations.
#[cfg(not(feature = "tanssi"))]
pub type CollatorSelectionUpdateOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureXcm<IsVoiceOfBody<RelayLocation, StakingAdminBodyId>>,
@@ -162,6 +163,7 @@ pub enum ProxyType {
/// Allows to finish the proxy
CancelProxy,
/// Allows to operate with collators list (invulnerables, candidates, etc.)
#[cfg(not(feature = "tanssi"))]
Collator,
}
@@ -175,6 +177,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })
| RuntimeCall::Multisig { .. }
),
#[cfg(not(feature = "tanssi"))]
ProxyType::Collator => {
matches!(c, RuntimeCall::CollatorSelection { .. } | RuntimeCall::Multisig { .. })
}
+2
View File
@@ -24,6 +24,7 @@ pub mod extrinsic_weights;
pub mod pallet_asset_manager;
pub mod pallet_assets;
pub mod pallet_balances;
#[cfg(not(feature = "tanssi"))]
pub mod pallet_collator_selection;
pub mod pallet_conviction_voting;
pub mod pallet_evm;
@@ -33,6 +34,7 @@ pub mod pallet_preimage;
pub mod pallet_proxy;
pub mod pallet_referenda;
pub mod pallet_scheduler;
#[cfg(not(feature = "tanssi"))]
pub mod pallet_session;
pub mod pallet_sudo;
pub mod pallet_timestamp;
+2 -4
View File
@@ -146,9 +146,7 @@ mod runtime_tests {
fn assets_constants() {
assert_eq!(<Runtime as pallet_assets::Config>::AssetDeposit::get(), 10 * CENTS);
// TODO: uncomment once patch is merged and updated RC is released and pointed to in deps
//assert_eq!(<Runtime as pallet_assets::Config>::AssetAccountDeposit::get(), deposit(1, 16));
assert_eq!(<Runtime as pallet_assets::Config>::AssetAccountDeposit::get(), MILLICENTS);
assert_eq!(<Runtime as pallet_assets::Config>::AssetAccountDeposit::get(), deposit(1, 16));
assert_eq!(<Runtime as pallet_assets::Config>::ApprovalDeposit::get(), MILLICENTS);
@@ -239,7 +237,7 @@ mod runtime_tests {
pallet_id_to_string(PalletId(*b"PotStake"))
);
assert_eq!(configs::Period::get(), 6 * HOURS);
assert_eq!(configs::SessionLength::get(), 6 * HOURS);
assert_eq!(configs::StakingAdminBodyId::get(), BodyId::Defense);
+1
View File
@@ -59,6 +59,7 @@ std = [
"sp-consensus-aura/std",
"sp-runtime/std",
]
tanssi = []
try-runtime = [
"evm-runtime-template/try-runtime",
"frame-support/try-runtime",
+15 -7
View File
@@ -8,9 +8,11 @@ use evm_runtime_template::{
constants::SLOT_DURATION, AccountId, AllPalletsWithSystem, Balance, Balances, EVMChainIdConfig,
Executive, Runtime, RuntimeCall, RuntimeOrigin, SudoConfig, UncheckedExtrinsic,
};
#[cfg(not(feature = "tanssi"))]
use frame_support::traits::Get;
use frame_support::{
dispatch::GetDispatchInfo,
traits::{Get, IntegrityTest, TryState, TryStateSelect},
traits::{IntegrityTest, TryState, TryStateSelect},
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
};
use frame_system::Account;
@@ -25,15 +27,20 @@ use sp_runtime::{
use sp_state_machine::BasicExternalities;
fn generate_genesis(accounts: &[AccountId]) -> Storage {
use evm_runtime_template::{
BalancesConfig, CollatorSelectionConfig, RuntimeGenesisConfig, SessionConfig, SessionKeys,
};
use evm_runtime_template::{BalancesConfig, RuntimeGenesisConfig};
#[cfg(not(feature = "tanssi"))]
use evm_runtime_template::{CollatorSelectionConfig, SessionConfig, SessionKeys};
#[cfg(not(feature = "tanssi"))]
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_runtime::{app_crypto::ByteArray, BuildStorage};
#[cfg(not(feature = "tanssi"))]
use sp_runtime::app_crypto::ByteArray;
use sp_runtime::BuildStorage;
// Configure endowed accounts with initial balance of 1 << 60.
let balances = accounts.iter().cloned().map(|k| (k, 1 << 60)).collect();
#[cfg(not(feature = "tanssi"))]
let invulnerables: Vec<AccountId> = vec![[0; 32].into()];
#[cfg(not(feature = "tanssi"))]
let session_keys = vec![(
[0; 32].into(),
[0; 32].into(),
@@ -44,14 +51,14 @@ fn generate_genesis(accounts: &[AccountId]) -> Storage {
RuntimeGenesisConfig {
system: Default::default(),
balances: BalancesConfig { balances },
aura: Default::default(),
#[cfg(not(feature = "tanssi"))]
session: SessionConfig { keys: session_keys },
#[cfg(not(feature = "tanssi"))]
collator_selection: CollatorSelectionConfig {
invulnerables,
candidacy_bond: 1 << 57,
desired_candidates: 1,
},
aura_ext: Default::default(),
parachain_info: Default::default(),
parachain_system: Default::default(),
polkadot_xcm: Default::default(),
@@ -261,6 +268,7 @@ fn recursive_call_filter(call: &RuntimeCall, origin: usize) -> bool {
RuntimeCall::System(
frame_system::Call::set_code { .. } | frame_system::Call::kill_prefix { .. },
) => false,
#[cfg(not(feature = "tanssi"))]
RuntimeCall::CollatorSelection(
pallet_collator_selection::Call::set_desired_candidates { max },
) =>
+1189 -634
View File
File diff suppressed because it is too large Load Diff
+9 -2
View File
@@ -26,8 +26,8 @@ serde_json = "1.0.121"
smallvec = "1.11.0"
# TODO: update to release
openzeppelin-polkadot-wrappers = { git = "https://github.com/openzeppelin/polkadot-runtime-wrappers", default-features = false, tag = "v0.1-rc1" }
openzeppelin-polkadot-wrappers-proc = { git = "https://github.com/openzeppelin/polkadot-runtime-wrappers", default-features = false, tag = "v0.1-rc1" }
openzeppelin-pallet-abstractions = { git = "https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions", default-features = false, tag = "v0.1-rc3" }
openzeppelin-pallet-abstractions-proc = { git = "https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions", default-features = false, tag = "v0.1-rc3" }
# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
@@ -130,6 +130,7 @@ cumulus-primitives-aura = { git = "https://github.com/paritytech/polkadot-sdk",
cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
cumulus-primitives-storage-weight-reclaim = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
cumulus-primitives-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
cumulus-primitives-utility = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
cumulus-relay-chain-interface = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
cumulus-test-relay-sproof-builder = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
@@ -151,6 +152,12 @@ orml-xtokens = { git = "https://github.com/OpenZeppelin/open-runtime-module-libr
# Fuzzer
ziggy = { version = "1.0.2", default-features = false }
# Tanssi
dp-consensus = { git = "https://github.com/OpenZeppelin/dancekit", default-features = false, tag = "polkadot-stable2407-1" }
nimbus-consensus = { git = "https://github.com/OpenZeppelin/moonkit", default-features = false, tag = "polkadot-stable2407-1" }
nimbus-primitives = { git = "https://github.com/OpenZeppelin/moonkit", default-features = false, tag = "polkadot-stable2407-1" }
pallet-author-inherent = { git = "https://github.com/OpenZeppelin/moonkit", default-features = false, tag = "polkadot-stable2407-1" }
pallet-cc-authorities-noting = { git = "https://github.com/OpenZeppelin/dancekit", default-features = false, tag = "polkadot-stable2407-1" }
[workspace.lints.clippy]
large_enum_variant = "allow"
+5 -1
View File
@@ -7,7 +7,7 @@ edition = { workspace = true }
license = { workspace = true }
publish = false
repository = { workspace = true }
version = "2.0.0"
version = "3.0.0"
[dependencies]
clap = { workspace = true }
@@ -70,6 +70,9 @@ cumulus-primitives-core = { workspace = true }
cumulus-primitives-parachain-inherent = { workspace = true }
cumulus-relay-chain-interface = { workspace = true }
# Tanssi
nimbus-consensus = { workspace = true }
[build-dependencies]
substrate-build-script-utils = { workspace = true }
@@ -85,6 +88,7 @@ runtime-benchmarks = [
"sc-service/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
tanssi = []
try-runtime = [
"generic-runtime-template/try-runtime",
"polkadot-cli/try-runtime",
+30 -3
View File
@@ -1,7 +1,7 @@
use cumulus_primitives_core::ParaId;
use generic_runtime_template::{
constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AuraId, Signature,
};
#[cfg(not(feature = "tanssi"))]
use generic_runtime_template::{constants::currency::EXISTENTIAL_DEPOSIT, AuraId};
use generic_runtime_template::{AccountId, Signature};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
@@ -44,6 +44,7 @@ type AccountPublic = <Signature as Verify>::Signer;
///
/// This function's return type must always match the session keys of the chain
/// in tuple format.
#[cfg(not(feature = "tanssi"))]
pub fn get_collator_keys_from_seed(seed: &str) -> AuraId {
get_from_seed::<AuraId>(seed)
}
@@ -60,6 +61,8 @@ where
///
/// The input must be a tuple of individual keys (a single arg for now since we
/// have just one key).
///
#[cfg(not(feature = "tanssi"))]
pub fn template_session_keys(keys: AuraId) -> generic_runtime_template::SessionKeys {
generic_runtime_template::SessionKeys { aura: keys }
}
@@ -86,6 +89,7 @@ pub fn development_config() -> ChainSpec {
.with_chain_type(ChainType::Development)
.with_genesis_config_patch(testnet_genesis(
// initial collators.
#[cfg(not(feature = "tanssi"))]
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
@@ -137,6 +141,7 @@ pub fn local_testnet_config() -> ChainSpec {
.with_chain_type(ChainType::Local)
.with_genesis_config_patch(testnet_genesis(
// initial collators.
#[cfg(not(feature = "tanssi"))]
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
@@ -169,6 +174,7 @@ pub fn local_testnet_config() -> ChainSpec {
.build()
}
#[cfg(not(feature = "tanssi"))]
fn testnet_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
@@ -205,3 +211,24 @@ fn testnet_genesis(
"sudo": { "key": Some(root) }
})
}
#[cfg(feature = "tanssi")]
fn testnet_genesis(
endowed_accounts: Vec<AccountId>,
root: AccountId,
id: ParaId,
) -> serde_json::Value {
serde_json::json!({
"balances": {
"balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::<Vec<_>>(),
},
"parachainInfo": {
"parachainId": id,
},
"treasury": {},
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
},
"sudo": { "key": Some(root) }
})
}
+4 -1
View File
@@ -115,7 +115,10 @@ pub fn run() -> Result<()> {
match &cli.subcommand {
Some(Subcommand::BuildSpec(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
runner.sync_run(|config| {
let chain_spec = config.chain_spec;
cmd.run(chain_spec, config.network)
})
},
Some(Subcommand::CheckBlock(cmd)) => {
construct_async_run!(|components, cli, cmd, config| {
+72 -13
View File
@@ -5,18 +5,24 @@ use std::{sync::Arc, time::Duration};
use cumulus_client_cli::CollatorOptions;
// Cumulus Imports
#[cfg(not(feature = "tanssi"))]
use cumulus_client_collator::service::CollatorService;
use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport;
#[cfg(not(feature = "tanssi"))]
use cumulus_client_consensus_proposer::Proposer;
use cumulus_client_service::{
build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks,
BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, ParachainHostFunctions,
StartRelayChainTasksParams,
};
#[cfg(not(feature = "tanssi"))]
use cumulus_primitives_core::relay_chain::CollatorPair;
#[cfg(feature = "async-backing")]
use cumulus_primitives_core::relay_chain::ValidationCode;
use cumulus_primitives_core::{relay_chain::CollatorPair, ParaId};
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
use cumulus_primitives_core::ParaId;
#[cfg(not(feature = "tanssi"))]
use cumulus_relay_chain_interface::OverseerHandle;
use cumulus_relay_chain_interface::RelayChainInterface;
// Substrate Imports
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
// Local Runtime Types
@@ -29,9 +35,13 @@ use sc_consensus::ImportQueue;
use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
use sc_network::NetworkBlock;
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
#[cfg(not(feature = "tanssi"))]
use sc_telemetry::TelemetryHandle;
use sc_telemetry::{Telemetry, TelemetryWorker, TelemetryWorkerHandle};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
#[cfg(not(feature = "tanssi"))]
use sp_keystore::KeystorePtr;
#[cfg(not(feature = "tanssi"))]
use substrate_prometheus_endpoint::Registry;
type ParachainExecutor = WasmExecutor<ParachainHostFunctions>;
@@ -104,15 +114,23 @@ pub fn new_partial(config: &Configuration) -> Result<Service, sc_service::Error>
client.clone(),
);
let block_import = ParachainBlockImport::new(client.clone(), backend.clone());
let import_queue = build_import_queue(
client.clone(),
block_import.clone(),
config,
telemetry.as_ref().map(|telemetry| telemetry.handle()),
&task_manager,
)?;
#[cfg(feature = "tanssi")]
let (block_import, import_queue) =
import_queue(config, client.clone(), backend.clone(), &task_manager);
#[cfg(not(feature = "tanssi"))]
let (block_import, import_queue) = {
let block_import = ParachainBlockImport::new(client.clone(), backend.clone());
(
block_import.clone(),
build_import_queue(
client.clone(),
block_import,
config,
telemetry.as_ref().map(|telemetry| telemetry.handle()),
&task_manager,
)?,
)
};
Ok(PartialComponents {
backend,
@@ -140,7 +158,10 @@ async fn start_node_impl(
let parachain_config = prepare_node_config(parachain_config);
let params = new_partial(&parachain_config)?;
#[cfg(not(feature = "tanssi"))]
let (block_import, mut telemetry, telemetry_worker_handle) = params.other;
#[cfg(feature = "tanssi")]
let (_, mut telemetry, telemetry_worker_handle) = params.other;
let net_config = sc_network::config::FullNetworkConfiguration::<
_,
_,
@@ -151,7 +172,7 @@ async fn start_node_impl(
let backend = params.backend.clone();
let mut task_manager = params.task_manager;
let (relay_chain_interface, collator_key) = build_relay_chain_interface(
let relay_chain_interface = build_relay_chain_interface(
polkadot_config,
&parachain_config,
telemetry_worker_handle,
@@ -162,7 +183,13 @@ async fn start_node_impl(
.await
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;
#[cfg(not(feature = "tanssi"))]
let (relay_chain_interface, collator_key) = relay_chain_interface;
#[cfg(feature = "tanssi")]
let (relay_chain_interface, _) = relay_chain_interface;
let validator = parachain_config.role.is_authority();
#[cfg(not(feature = "tanssi"))]
let prometheus_registry = parachain_config.prometheus_registry().cloned();
let transaction_pool = params.transaction_pool.clone();
let import_queue_service = params.import_queue.service();
@@ -291,6 +318,7 @@ async fn start_node_impl(
sync_service: sync_service.clone(),
})?;
#[cfg(not(feature = "tanssi"))]
if validator {
start_consensus(
client.clone(),
@@ -316,7 +344,37 @@ async fn start_node_impl(
Ok((task_manager, client))
}
#[cfg(feature = "tanssi")]
pub fn import_queue(
parachain_config: &Configuration,
client: Arc<ParachainClient>,
backend: Arc<ParachainBackend>,
task_manager: &TaskManager,
) -> (ParachainBlockImport, sc_consensus::BasicQueue<Block>) {
// The nimbus import queue ONLY checks the signature correctness
// Any other checks corresponding to the author-correctness should be done
// in the runtime
let block_import = ParachainBlockImport::new(client.clone(), backend);
let import_queue = nimbus_consensus::import_queue(
client,
block_import.clone(),
move |_, _| async move {
let time = sp_timestamp::InherentDataProvider::from_system_time();
Ok((time,))
},
&task_manager.spawn_essential_handle(),
parachain_config.prometheus_registry(),
false,
)
.expect("function never fails");
(block_import, import_queue)
}
/// Build the import queue for the parachain runtime.
#[cfg(not(feature = "tanssi"))]
fn build_import_queue(
client: Arc<ParachainClient>,
block_import: ParachainBlockImport,
@@ -343,6 +401,7 @@ fn build_import_queue(
))
}
#[cfg(not(feature = "tanssi"))]
fn start_consensus(
client: Arc<ParachainClient>,
#[cfg(feature = "async-backing")] backend: Arc<ParachainBackend>,
+31 -14
View File
@@ -5,7 +5,7 @@ description = "A generic parachain runtime template"
edition = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
version = "2.0.0"
version = "3.0.0"
[package.metadata.docs.rs]
targets = [ "x86_64-unknown-linux-gnu" ]
@@ -17,8 +17,8 @@ parity-scale-codec = { workspace = true, features = [ "derive" ] }
scale-info = { workspace = true, features = [ "derive" ] }
smallvec = { workspace = true }
openzeppelin-polkadot-wrappers = { workspace = true }
openzeppelin-polkadot-wrappers-proc = { workspace = true }
openzeppelin-pallet-abstractions = { workspace = true }
openzeppelin-pallet-abstractions-proc = { workspace = true }
# Substrate
frame-benchmarking = { workspace = true, optional = true }
@@ -30,8 +30,6 @@ frame-system-benchmarking = { workspace = true, optional = true }
frame-system-rpc-runtime-api = { workspace = true }
frame-try-runtime = { workspace = true, optional = true }
pallet-assets = { workspace = true }
pallet-aura = { workspace = true }
pallet-authorship = { workspace = true }
pallet-balances = { workspace = true }
pallet-conviction-voting = { workspace = true }
pallet-message-queue = { workspace = true }
@@ -40,7 +38,6 @@ pallet-preimage = { workspace = true }
pallet-proxy = { workspace = true }
pallet-referenda = { workspace = true }
pallet-scheduler = { workspace = true }
pallet-session = { workspace = true }
pallet-sudo = { workspace = true }
pallet-timestamp = { workspace = true }
pallet-transaction-payment = { workspace = true }
@@ -62,6 +59,12 @@ sp-std = { workspace = true }
sp-transaction-pool = { workspace = true }
sp-version = { workspace = true }
cumulus-pallet-aura-ext = { workspace = true }
pallet-aura = { workspace = true }
pallet-authorship = { workspace = true }
pallet-collator-selection = { workspace = true }
pallet-session = { workspace = true }
# Polkadot
pallet-xcm = { workspace = true }
polkadot-parachain-primitives = { workspace = true }
@@ -72,7 +75,6 @@ xcm-executor = { workspace = true }
# Cumulus
assets-common = { workspace = true }
cumulus-pallet-aura-ext = { workspace = true }
cumulus-pallet-parachain-system = { workspace = true }
cumulus-pallet-session-benchmarking = { workspace = true }
cumulus-pallet-xcm = { workspace = true }
@@ -80,8 +82,8 @@ cumulus-pallet-xcmp-queue = { workspace = true }
cumulus-primitives-aura = { workspace = true }
cumulus-primitives-core = { workspace = true }
cumulus-primitives-storage-weight-reclaim = { workspace = true }
cumulus-primitives-timestamp = { workspace = true }
cumulus-primitives-utility = { workspace = true }
pallet-collator-selection = { workspace = true }
parachain-info = { workspace = true }
parachains-common = { workspace = true }
@@ -92,9 +94,14 @@ pallet-xcm-weight-trader = { workspace = true }
xcm-primitives = { workspace = true }
# ORML
dp-consensus = { workspace = true }
nimbus-primitives = { workspace = true }
orml-traits = { workspace = true }
orml-xcm-support = { workspace = true }
orml-xtokens = { workspace = true }
pallet-author-inherent = { workspace = true }
# Tanssi
pallet-cc-authorities-noting = { workspace = true }
[dev-dependencies]
polkadot-runtime-parachains = { workspace = true }
@@ -116,7 +123,9 @@ std = [
"cumulus-primitives-aura/std",
"cumulus-primitives-core/std",
"cumulus-primitives-storage-weight-reclaim/std",
"cumulus-primitives-timestamp/std",
"cumulus-primitives-utility/std",
"dp-consensus/std",
"frame-benchmarking?/std",
"frame-executive/std",
"frame-metadata-hash-extension/std",
@@ -126,13 +135,16 @@ std = [
"frame-system/std",
"frame-try-runtime?/std",
"log/std",
"openzeppelin-polkadot-wrappers/std",
"nimbus-primitives/std",
"openzeppelin-pallet-abstractions/std",
"orml-xtokens/std",
"pallet-asset-manager/std",
"pallet-assets/std",
"pallet-aura/std",
"pallet-author-inherent/std",
"pallet-authorship/std",
"pallet-balances/std",
"pallet-cc-authorities-noting/std",
"pallet-collator-selection/std",
"pallet-conviction-voting/std",
"pallet-message-queue/std",
@@ -183,15 +195,18 @@ runtime-benchmarks = [
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
"cumulus-primitives-utility/runtime-benchmarks",
"dp-consensus/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"hex-literal",
"nimbus-primitives/runtime-benchmarks",
"pallet-asset-manager/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-author-inherent/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-collator-selection/runtime-benchmarks",
"pallet-cc-authorities-noting/runtime-benchmarks",
"pallet-conviction-voting/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
@@ -224,12 +239,14 @@ try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"frame-try-runtime/try-runtime",
"nimbus-primitives/try-runtime",
"orml-xtokens/try-runtime",
"pallet-asset-manager/try-runtime",
"pallet-assets/try-runtime",
"pallet-aura/try-runtime",
"pallet-authorship/try-runtime",
"pallet-author-inherent/try-runtime",
"pallet-balances/try-runtime",
"pallet-cc-authorities-noting/try-runtime",
"pallet-collator-selection/try-runtime",
"pallet-conviction-voting/try-runtime",
"pallet-message-queue/try-runtime",
@@ -238,8 +255,6 @@ try-runtime = [
"pallet-proxy/try-runtime",
"pallet-referenda/try-runtime",
"pallet-scheduler/try-runtime",
"pallet-session/try-runtime",
"pallet-session/try-runtime",
"pallet-sudo/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
@@ -259,8 +274,10 @@ try-runtime = [
# to make it smaller, like logging for example.
on-chain-release-build = [ "sp-api/disable-logging" ]
async-backing = [ "openzeppelin-polkadot-wrappers-proc/async-backing" ]
async-backing = [ "openzeppelin-pallet-abstractions-proc/async-backing" ]
default = [ "std" ]
metadata-hash = [ "substrate-wasm-builder/metadata-hash" ]
tanssi = []
+57 -9
View File
@@ -1,11 +1,14 @@
use openzeppelin_polkadot_wrappers_proc::openzeppelin_runtime_apis;
use openzeppelin_pallet_abstractions_proc::openzeppelin_runtime_apis;
#[cfg(feature = "runtime-benchmarks")]
use crate::constants::currency::{CENTS, EXISTENTIAL_DEPOSIT};
#[cfg(not(feature = "async-backing"))]
#[cfg(all(not(feature = "async-backing"), not(feature = "tanssi")))]
use crate::Aura;
#[cfg(feature = "runtime-benchmarks")]
use crate::{
configs::xcm_config::RelayLocation,
constants::currency::{CENTS, EXISTENTIAL_DEPOSIT},
};
#[cfg(feature = "async-backing")]
use crate::{configs::XcmExecutorConfig, constants::SLOT_DURATION, types::ConsensusHook};
use crate::{constants::SLOT_DURATION, types::ConsensusHook};
use crate::{
constants::VERSION,
types::{AccountId, Balance, Block, Executive, Nonce},
@@ -16,19 +19,18 @@ use crate::{
#[cfg(feature = "runtime-benchmarks")]
type ExistentialDeposit = sp_core::ConstU128<EXISTENTIAL_DEPOSIT>;
#[cfg(not(feature = "tanssi"))]
#[openzeppelin_runtime_apis]
mod apis {
type Runtime = Runtime;
type Block = Block;
#[abstraction]
mod assets {
type RuntimeCall = RuntimeCall;
type TransactionPayment = TransactionPayment;
type Balance = Balance;
}
#[abstraction]
mod consensus {
type SessionKeys = SessionKeys;
#[cfg(not(feature = "async-backing"))]
@@ -39,7 +41,6 @@ mod apis {
type ConsensusHook = ConsensusHook;
}
#[abstraction]
mod system {
type Executive = Executive;
type System = System;
@@ -51,7 +52,54 @@ mod apis {
type RuntimeBlockWeights = RuntimeBlockWeights;
}
#[abstraction]
mod benchmarks {
type AllPalletsWithSystem = AllPalletsWithSystem;
type Assets = Assets;
type AssetManager = AssetManager;
type AssetType = AssetType;
type RuntimeOrigin = RuntimeOrigin;
type RelayLocation = RelayLocation;
type ParachainSystem = ParachainSystem;
type System = System;
type ExistentialDeposit = ExistentialDeposit;
type AssetId = AssetId;
type XCMConfig = XcmExecutorConfig;
type AccountId = AccountId;
type Cents = CENTS;
type FeeAssetId = FeeAssetId;
type TransactionByteFee = TransactionByteFee;
type Address = Address;
type Balances = Balances;
}
}
#[cfg(feature = "tanssi")]
#[openzeppelin_runtime_apis]
mod apis {
type Runtime = Runtime;
type Block = Block;
mod assets {
type RuntimeCall = RuntimeCall;
type TransactionPayment = TransactionPayment;
type Balance = Balance;
}
mod tanssi {
type SessionKeys = SessionKeys;
}
mod system {
type Executive = Executive;
type System = System;
type ParachainSystem = ParachainSystem;
type RuntimeVersion = VERSION;
type AccountId = AccountId;
type Nonce = Nonce;
type RuntimeGenesisConfig = RuntimeGenesisConfig;
type RuntimeBlockWeights = RuntimeBlockWeights;
}
mod benchmarks {
type AllPalletsWithSystem = AllPalletsWithSystem;
type Assets = Assets;
+48 -16
View File
@@ -1,14 +1,19 @@
pub mod asset_config;
pub use asset_config::AssetType;
pub mod governance;
pub mod weight;
pub mod xcm_config;
use asset_config::*;
#[cfg(feature = "tanssi")]
use cumulus_pallet_parachain_system::ExpectParentIncluded;
#[cfg(feature = "async-backing")]
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
#[cfg(not(feature = "async-backing"))]
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
#[cfg(not(feature = "tanssi"))]
use frame_support::PalletId;
use frame_support::{
derive_impl,
dispatch::DispatchClass,
@@ -18,7 +23,6 @@ use frame_support::{
EitherOfDiverse, Everything, Nothing, TransformOrigin,
},
weights::{ConstantMultiplier, Weight},
PalletId,
};
use frame_system::{
limits::{BlockLength, BlockWeights},
@@ -26,13 +30,20 @@ use frame_system::{
};
pub use governance::origins::pallet_custom_origins;
use governance::{origins::Treasurer, tracks, Spender, WhitelistedCaller};
use openzeppelin_polkadot_wrappers::{
impl_openzeppelin_assets, impl_openzeppelin_consensus, impl_openzeppelin_governance,
impl_openzeppelin_system, impl_openzeppelin_xcm, AssetsConfig, ConsensusConfig,
GovernanceConfig, SystemConfig, XcmConfig,
use openzeppelin_pallet_abstractions::{
impl_openzeppelin_assets, impl_openzeppelin_governance, impl_openzeppelin_system,
impl_openzeppelin_xcm, AssetsConfig, AssetsWeight, GovernanceConfig, GovernanceWeight,
SystemConfig, SystemWeight, XcmConfig, XcmWeight,
};
#[cfg(not(feature = "tanssi"))]
use openzeppelin_pallet_abstractions::{
impl_openzeppelin_consensus, ConsensusConfig, ConsensusWeight,
};
#[cfg(feature = "tanssi")]
use openzeppelin_pallet_abstractions::{impl_openzeppelin_tanssi, TanssiConfig, TanssiWeight};
use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling};
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
#[cfg(not(feature = "tanssi"))]
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_runtime::{
traits::{AccountIdLookup, BlakeTwo256, IdentityLookup},
@@ -53,37 +64,54 @@ use xcm_primitives::{AbsoluteAndRelativeReserve, AsAssetType};
#[cfg(feature = "runtime-benchmarks")]
use crate::benchmark::{OpenHrmpChannel, PayWithEnsure};
#[cfg(not(feature = "tanssi"))]
use crate::{
constants::HOURS,
types::{BlockNumber, CollatorSelectionUpdateOrigin, ConsensusHook},
SessionKeys,
};
use crate::{
constants::{
currency::{deposit, CENTS, EXISTENTIAL_DEPOSIT, MICROCENTS},
AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, MAX_BLOCK_LENGTH,
NORMAL_DISPATCH_RATIO,
AVERAGE_ON_INITIALIZE_RATIO, DAYS, MAXIMUM_BLOCK_WEIGHT, MAX_BLOCK_LENGTH,
NORMAL_DISPATCH_RATIO, SLOT_DURATION,
},
types::{
AccountId, AssetId, AssetKind, Balance, Beneficiary, Block, BlockNumber,
CollatorSelectionUpdateOrigin, ConsensusHook, Hash, MessageQueueServiceWeight, Nonce,
PriceForSiblingParachainDelivery, ProxyType, TreasuryAccount, TreasuryInteriorLocation,
TreasuryPalletId, TreasuryPaymaster, Version,
AccountId, AssetId, AssetKind, Balance, Beneficiary, Block, Hash,
MessageQueueServiceWeight, Nonce, PriceForSiblingParachainDelivery, ProxyType,
TreasuryAccount, TreasuryInteriorLocation, TreasuryPalletId, TreasuryPaymaster, Version,
},
weights::{self, BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
AllPalletsWithSystem, AssetManager, Aura, Balances, CollatorSelection, MessageQueue,
OriginCaller, PalletInfo, ParachainInfo, ParachainSystem, PolkadotXcm, Preimage, Referenda,
Runtime, RuntimeCall, RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin,
RuntimeTask, Scheduler, Session, SessionKeys, System, Treasury, WeightToFee, XcmpQueue,
weights::{BlockExecutionWeight, ExtrinsicBaseWeight},
AllPalletsWithSystem, AssetManager, Balances, MessageQueue, OriginCaller, PalletInfo,
ParachainInfo, ParachainSystem, PolkadotXcm, Preimage, Referenda, Runtime, RuntimeCall,
RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask, Scheduler,
System, Treasury, WeightToFee, XcmpQueue,
};
#[cfg(not(feature = "tanssi"))]
use crate::{Aura, CollatorSelection, Session};
// OpenZeppelin runtime wrappers configuration
pub struct OpenZeppelinRuntime;
impl SystemConfig for OpenZeppelinRuntime {
type AccountId = AccountId;
#[cfg(feature = "tanssi")]
type ConsensusHook = ExpectParentIncluded;
#[cfg(not(feature = "tanssi"))]
type ConsensusHook = ConsensusHook;
type ExistentialDeposit = ConstU128<EXISTENTIAL_DEPOSIT>;
type Lookup = AccountIdLookup<AccountId, ()>;
#[cfg(feature = "tanssi")]
type OnTimestampSet = ();
#[cfg(not(feature = "tanssi"))]
type OnTimestampSet = Aura;
type PreimageOrigin = EnsureRoot<AccountId>;
type ProxyType = ProxyType;
type SS58Prefix = ConstU16<42>;
type ScheduleOrigin = EnsureRoot<AccountId>;
type SlotDuration = ConstU64<SLOT_DURATION>;
type Version = Version;
}
#[cfg(not(feature = "tanssi"))]
impl ConsensusConfig for OpenZeppelinRuntime {
type CollatorSelectionUpdateOrigin = CollatorSelectionUpdateOrigin;
}
@@ -162,7 +190,11 @@ impl AssetsConfig for OpenZeppelinRuntime {
type WeightToFee = WeightToFee;
}
impl_openzeppelin_system!(OpenZeppelinRuntime);
#[cfg(not(feature = "tanssi"))]
impl_openzeppelin_consensus!(OpenZeppelinRuntime);
impl_openzeppelin_governance!(OpenZeppelinRuntime);
impl_openzeppelin_xcm!(OpenZeppelinRuntime);
impl_openzeppelin_assets!(OpenZeppelinRuntime);
#[cfg(feature = "tanssi")]
impl_openzeppelin_tanssi!();
@@ -0,0 +1,56 @@
#[cfg(not(feature = "tanssi"))]
use openzeppelin_pallet_abstractions::ConsensusWeight;
#[cfg(feature = "tanssi")]
use openzeppelin_pallet_abstractions::TanssiWeight;
use openzeppelin_pallet_abstractions::{AssetsWeight, GovernanceWeight, SystemWeight, XcmWeight};
use crate::{
configs::OpenZeppelinRuntime,
weights::{self, RocksDbWeight},
Runtime,
};
impl SystemWeight for OpenZeppelinRuntime {
type Balances = weights::pallet_balances::WeightInfo<Runtime>;
type DbWeight = RocksDbWeight;
type Multisig = weights::pallet_multisig::WeightInfo<Runtime>;
type ParachainSystem = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
type Preimage = weights::pallet_preimage::WeightInfo<Runtime>;
type Proxy = weights::pallet_proxy::WeightInfo<Runtime>;
type Scheduler = weights::pallet_scheduler::WeightInfo<Runtime>;
type Timestamp = weights::pallet_timestamp::WeightInfo<Runtime>;
type Utility = weights::pallet_utility::WeightInfo<Runtime>;
}
#[cfg(not(feature = "tanssi"))]
impl ConsensusWeight for OpenZeppelinRuntime {
type CollatorSelection = weights::pallet_collator_selection::WeightInfo<Runtime>;
type Session = weights::pallet_session::WeightInfo<Runtime>;
}
impl AssetsWeight for OpenZeppelinRuntime {
type AssetManager = weights::pallet_asset_manager::WeightInfo<Runtime>;
type Assets = weights::pallet_assets::WeightInfo<Runtime>;
}
impl GovernanceWeight for OpenZeppelinRuntime {
type ConvictionVoting = weights::pallet_conviction_voting::WeightInfo<Runtime>;
type Referenda = weights::pallet_referenda::WeightInfo<Runtime>;
type Sudo = weights::pallet_sudo::WeightInfo<Runtime>;
type Treasury = weights::pallet_treasury::WeightInfo<Runtime>;
type Whitelist = weights::pallet_whitelist::WeightInfo<Runtime>;
}
impl XcmWeight for OpenZeppelinRuntime {
type MessageQueue = weights::pallet_message_queue::WeightInfo<Runtime>;
type Xcm = weights::pallet_xcm::WeightInfo<Runtime>;
type XcmTransactor = weights::pallet_xcm_transactor::WeightInfo<Runtime>;
type XcmWeightTrader = weights::pallet_xcm_weight_trader::WeightInfo<Runtime>;
type XcmpQueue = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
}
#[cfg(feature = "tanssi")]
impl TanssiWeight for OpenZeppelinRuntime {
type AuthorInherent = pallet_author_inherent::weights::SubstrateWeight<Runtime>;
type AuthoritiesNoting = pallet_cc_authorities_noting::weights::SubstrateWeight<Runtime>;
}
+25 -8
View File
@@ -90,12 +90,18 @@ pub mod opaque {
pub type Hash = <BlakeTwo256 as HashT>::Output;
}
#[cfg(not(feature = "tanssi"))]
impl_opaque_keys! {
pub struct SessionKeys {
pub aura: Aura,
}
}
#[cfg(feature = "tanssi")]
impl_opaque_keys! {
pub struct SessionKeys { }
}
/// The version information used to identify this runtime when compiled
/// natively.
#[cfg(feature = "std")]
@@ -105,23 +111,34 @@ pub fn native_version() -> NativeVersion {
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
}
use openzeppelin_polkadot_wrappers_proc::openzeppelin_construct_runtime;
use openzeppelin_pallet_abstractions_proc::openzeppelin_construct_runtime;
#[cfg(feature = "tanssi")]
#[openzeppelin_construct_runtime]
mod runtime {
#[abstraction]
struct System;
#[abstraction]
struct Consensus;
#[abstraction]
struct XCM;
#[abstraction]
struct Assets;
#[abstraction]
struct Governance;
struct Tanssi;
}
#[cfg(not(feature = "tanssi"))]
#[openzeppelin_construct_runtime]
mod runtime {
struct System;
struct XCM;
struct Assets;
struct Governance;
struct Consensus;
}
#[cfg(test)]
+22 -18
View File
@@ -1,10 +1,9 @@
use frame_support::{
parameter_types,
traits::{EitherOfDiverse, InstanceFilter},
weights::Weight,
PalletId,
};
#[cfg(not(feature = "tanssi"))]
use frame_support::traits::EitherOfDiverse;
use frame_support::{parameter_types, traits::InstanceFilter, weights::Weight, PalletId};
#[cfg(not(feature = "tanssi"))]
use frame_system::EnsureRoot;
#[cfg(not(feature = "tanssi"))]
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use polkadot_runtime_common::impls::{
@@ -29,14 +28,15 @@ use crate::{
constants::{HOURS, VERSION},
Treasury,
};
pub use crate::{
configs::{
xcm_config::RelayLocation, FeeAssetId, StakingAdminBodyId, ToSiblingBaseDeliveryFee,
TransactionByteFee,
},
#[cfg(not(feature = "tanssi"))]
use crate::{
configs::{xcm_config::RelayLocation, StakingAdminBodyId},
constants::{
BLOCK_PROCESSING_VELOCITY, RELAY_CHAIN_SLOT_DURATION_MILLIS, UNINCLUDED_SEGMENT_CAPACITY,
},
};
pub use crate::{
configs::{FeeAssetId, ToSiblingBaseDeliveryFee, TransactionByteFee},
AllPalletsWithSystem, Runtime, RuntimeBlockWeights, RuntimeCall, XcmpQueue,
};
@@ -107,14 +107,8 @@ pub type PriceForSiblingParachainDelivery = polkadot_runtime_common::xcm_sender:
XcmpQueue,
>;
/// We allow root and the StakingAdmin to execute privileged collator selection
/// operations.
pub type CollatorSelectionUpdateOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureXcm<IsVoiceOfBody<RelayLocation, StakingAdminBodyId>>,
>;
/// Configures the number of blocks that can be created without submission of validity proof to the relay chain
#[cfg(not(feature = "tanssi"))]
pub type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
Runtime,
RELAY_CHAIN_SLOT_DURATION_MILLIS,
@@ -122,6 +116,14 @@ pub type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
UNINCLUDED_SEGMENT_CAPACITY,
>;
/// We allow root and the StakingAdmin to execute privileged collator selection
/// operations.
#[cfg(not(feature = "tanssi"))]
pub type CollatorSelectionUpdateOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureXcm<IsVoiceOfBody<RelayLocation, StakingAdminBodyId>>,
>;
/// These aliases are describing the Beneficiary and AssetKind for the Treasury pallet
pub type Beneficiary = VersionedLocation;
pub type AssetKind = VersionedLocatableAsset;
@@ -162,6 +164,7 @@ pub enum ProxyType {
NonTransfer,
/// Allows to finish the proxy
CancelProxy,
#[cfg(not(feature = "tanssi"))]
/// Allows to operate with collators list (invulnerables, candidates, etc.)
Collator,
}
@@ -176,6 +179,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })
| RuntimeCall::Multisig { .. }
),
#[cfg(not(feature = "tanssi"))]
ProxyType::Collator => {
matches!(c, RuntimeCall::CollatorSelection { .. } | RuntimeCall::Multisig { .. })
}
@@ -24,6 +24,7 @@ pub mod extrinsic_weights;
pub mod pallet_asset_manager;
pub mod pallet_assets;
pub mod pallet_balances;
#[cfg(not(feature = "tanssi"))]
pub mod pallet_collator_selection;
pub mod pallet_conviction_voting;
pub mod pallet_message_queue;
@@ -32,6 +33,7 @@ pub mod pallet_preimage;
pub mod pallet_proxy;
pub mod pallet_referenda;
pub mod pallet_scheduler;
#[cfg(not(feature = "tanssi"))]
pub mod pallet_session;
pub mod pallet_sudo;
pub mod pallet_timestamp;
@@ -1,4 +1,3 @@
//! Autogenerated weights for `pallet_collator_selection`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 42.0.0
@@ -21,242 +20,253 @@
// --chain=dev
// --output=benchmarking/new-benchmarks/pallet_collator_selection.rs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
// #![cfg_attr(rustfmt, rustfmt_skip)]
// #![allow(unused_parens)]
// #![allow(unused_imports)]
// #![allow(missing_docs)]
use core::marker::PhantomData;
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_collator_selection`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_collator_selection::WeightInfo for WeightInfo<T> {
/// Storage: `Session::NextKeys` (r:20 w:0)
/// Proof: `Session::NextKeys` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `CollatorSelection::Invulnerables` (r:0 w:1)
/// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
/// The range of component `b` is `[1, 20]`.
fn set_invulnerables(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `197 + b * (79 ±0)`
// Estimated: `1188 + b * (2555 ±0)`
// Minimum execution time: 15_225_000 picoseconds.
Weight::from_parts(11_571_267, 0)
.saturating_add(Weight::from_parts(0, 1188))
// Standard Error: 5_469
.saturating_add(Weight::from_parts(4_047_420, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into())))
.saturating_add(T::DbWeight::get().writes(1))
.saturating_add(Weight::from_parts(0, 2555).saturating_mul(b.into()))
}
/// Storage: `Session::NextKeys` (r:1 w:0)
/// Proof: `Session::NextKeys` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `CollatorSelection::Invulnerables` (r:1 w:1)
/// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::CandidateList` (r:1 w:1)
/// Proof: `CollatorSelection::CandidateList` (`max_values`: Some(1), `max_size`: Some(4802), added: 5297, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// The range of component `b` is `[1, 19]`.
/// The range of component `c` is `[1, 99]`.
fn add_invulnerable(b: u32, c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `828 + b * (32 ±0) + c * (53 ±0)`
// Estimated: `6287 + b * (37 ±0) + c * (53 ±0)`
// Minimum execution time: 51_115_000 picoseconds.
Weight::from_parts(46_321_661, 0)
.saturating_add(Weight::from_parts(0, 6287))
// Standard Error: 18_486
.saturating_add(Weight::from_parts(346_609, 0).saturating_mul(b.into()))
// Standard Error: 3_504
.saturating_add(Weight::from_parts(202_188, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
.saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into()))
.saturating_add(Weight::from_parts(0, 53).saturating_mul(c.into()))
}
/// Storage: `CollatorSelection::CandidateList` (r:1 w:0)
/// Proof: `CollatorSelection::CandidateList` (`max_values`: Some(1), `max_size`: Some(4802), added: 5297, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::Invulnerables` (r:1 w:1)
/// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
/// The range of component `b` is `[5, 20]`.
fn remove_invulnerable(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `153 + b * (32 ±0)`
// Estimated: `6287`
// Minimum execution time: 14_756_000 picoseconds.
Weight::from_parts(14_469_493, 0)
.saturating_add(Weight::from_parts(0, 6287))
// Standard Error: 2_837
.saturating_add(Weight::from_parts(214_011, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `CollatorSelection::DesiredCandidates` (r:0 w:1)
/// Proof: `CollatorSelection::DesiredCandidates` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn set_desired_candidates() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 6_561_000 picoseconds.
Weight::from_parts(6_777_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `CollatorSelection::CandidacyBond` (r:1 w:1)
/// Proof: `CollatorSelection::CandidacyBond` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::CandidateList` (r:1 w:1)
/// Proof: `CollatorSelection::CandidateList` (`max_values`: Some(1), `max_size`: Some(4802), added: 5297, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:100 w:100)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::LastAuthoredBlock` (r:0 w:100)
/// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
/// The range of component `c` is `[0, 100]`.
/// The range of component `k` is `[0, 100]`.
fn set_candidacy_bond(c: u32, k: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0 + c * (182 ±0) + k * (115 ±0)`
// Estimated: `6287 + c * (901 ±29) + k * (901 ±29)`
// Minimum execution time: 13_013_000 picoseconds.
Weight::from_parts(13_150_000, 0)
.saturating_add(Weight::from_parts(0, 6287))
// Standard Error: 212_739
.saturating_add(Weight::from_parts(7_127_589, 0).saturating_mul(c.into()))
// Standard Error: 212_739
.saturating_add(Weight::from_parts(6_784_046, 0).saturating_mul(k.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into())))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into())))
.saturating_add(Weight::from_parts(0, 901).saturating_mul(c.into()))
.saturating_add(Weight::from_parts(0, 901).saturating_mul(k.into()))
}
/// Storage: `CollatorSelection::CandidacyBond` (r:1 w:0)
/// Proof: `CollatorSelection::CandidacyBond` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::CandidateList` (r:1 w:1)
/// Proof: `CollatorSelection::CandidateList` (`max_values`: Some(1), `max_size`: Some(4802), added: 5297, mode: `MaxEncodedLen`)
/// The range of component `c` is `[3, 100]`.
fn update_bond(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `356 + c * (49 ±0)`
// Estimated: `6287`
// Minimum execution time: 34_412_000 picoseconds.
Weight::from_parts(37_538_467, 0)
.saturating_add(Weight::from_parts(0, 6287))
// Standard Error: 2_658
.saturating_add(Weight::from_parts(140_363, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `CollatorSelection::CandidateList` (r:1 w:1)
/// Proof: `CollatorSelection::CandidateList` (`max_values`: Some(1), `max_size`: Some(4802), added: 5297, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::Invulnerables` (r:1 w:0)
/// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
/// Storage: `Session::NextKeys` (r:1 w:0)
/// Proof: `Session::NextKeys` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `CollatorSelection::CandidacyBond` (r:1 w:0)
/// Proof: `CollatorSelection::CandidacyBond` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::LastAuthoredBlock` (r:0 w:1)
/// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
/// The range of component `c` is `[1, 99]`.
fn register_as_candidate(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `799 + c * (52 ±0)`
// Estimated: `6287 + c * (54 ±0)`
// Minimum execution time: 45_366_000 picoseconds.
Weight::from_parts(49_711_930, 0)
.saturating_add(Weight::from_parts(0, 6287))
// Standard Error: 3_239
.saturating_add(Weight::from_parts(180_195, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(2))
.saturating_add(Weight::from_parts(0, 54).saturating_mul(c.into()))
}
/// Storage: `CollatorSelection::Invulnerables` (r:1 w:0)
/// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::CandidacyBond` (r:1 w:0)
/// Proof: `CollatorSelection::CandidacyBond` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
/// Storage: `Session::NextKeys` (r:1 w:0)
/// Proof: `Session::NextKeys` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `CollatorSelection::CandidateList` (r:1 w:1)
/// Proof: `CollatorSelection::CandidateList` (`max_values`: Some(1), `max_size`: Some(4802), added: 5297, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::LastAuthoredBlock` (r:0 w:2)
/// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
/// The range of component `c` is `[3, 100]`.
fn take_candidate_slot(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `939 + c * (53 ±0)`
// Estimated: `6287 + c * (54 ±0)`
// Minimum execution time: 68_436_000 picoseconds.
Weight::from_parts(73_112_305, 0)
.saturating_add(Weight::from_parts(0, 6287))
// Standard Error: 4_118
.saturating_add(Weight::from_parts(214_419, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(4))
.saturating_add(Weight::from_parts(0, 54).saturating_mul(c.into()))
}
/// Storage: `CollatorSelection::CandidateList` (r:1 w:1)
/// Proof: `CollatorSelection::CandidateList` (`max_values`: Some(1), `max_size`: Some(4802), added: 5297, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::Invulnerables` (r:1 w:0)
/// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::LastAuthoredBlock` (r:0 w:1)
/// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
/// The range of component `c` is `[3, 100]`.
fn leave_intent(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `381 + c * (48 ±0)`
// Estimated: `6287`
// Minimum execution time: 37_349_000 picoseconds.
Weight::from_parts(41_362_337, 0)
.saturating_add(Weight::from_parts(0, 6287))
// Standard Error: 3_309
.saturating_add(Weight::from_parts(158_689, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `System::Account` (r:2 w:2)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::LastAuthoredBlock` (r:0 w:1)
/// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
fn note_author() -> Weight {
// Proof Size summary in bytes:
// Measured: `192`
// Estimated: `6196`
// Minimum execution time: 56_862_000 picoseconds.
Weight::from_parts(57_890_000, 0)
.saturating_add(Weight::from_parts(0, 6196))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `CollatorSelection::CandidateList` (r:1 w:0)
/// Proof: `CollatorSelection::CandidateList` (`max_values`: Some(1), `max_size`: Some(4802), added: 5297, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::LastAuthoredBlock` (r:100 w:0)
/// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::Invulnerables` (r:1 w:0)
/// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::DesiredCandidates` (r:1 w:0)
/// Proof: `CollatorSelection::DesiredCandidates` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:97 w:97)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// The range of component `r` is `[1, 100]`.
/// The range of component `c` is `[1, 100]`.
fn new_session(r: u32, c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `2369 + c * (97 ±0) + r * (114 ±0)`
// Estimated: `6287 + c * (2519 ±0) + r * (2603 ±0)`
// Minimum execution time: 23_061_000 picoseconds.
Weight::from_parts(23_816_000, 0)
.saturating_add(Weight::from_parts(0, 6287))
// Standard Error: 378_020
.saturating_add(Weight::from_parts(16_325_603, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into())))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into())))
.saturating_add(Weight::from_parts(0, 2519).saturating_mul(c.into()))
.saturating_add(Weight::from_parts(0, 2603).saturating_mul(r.into()))
}
/// Storage: `Session::NextKeys` (r:20 w:0)
/// Proof: `Session::NextKeys` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `CollatorSelection::Invulnerables` (r:0 w:1)
/// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
/// The range of component `b` is `[1, 20]`.
fn set_invulnerables(b: u32) -> Weight {
// Proof Size summary in bytes:
// Measured: `197 + b * (79 ±0)`
// Estimated: `1188 + b * (2555 ±0)`
// Minimum execution time: 15_225_000 picoseconds.
Weight::from_parts(11_571_267, 0)
.saturating_add(Weight::from_parts(0, 1188))
// Standard Error: 5_469
.saturating_add(Weight::from_parts(4_047_420, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into())))
.saturating_add(T::DbWeight::get().writes(1))
.saturating_add(Weight::from_parts(0, 2555).saturating_mul(b.into()))
}
/// Storage: `Session::NextKeys` (r:1 w:0)
/// Proof: `Session::NextKeys` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `CollatorSelection::Invulnerables` (r:1 w:1)
/// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::CandidateList` (r:1 w:1)
/// Proof: `CollatorSelection::CandidateList` (`max_values`: Some(1), `max_size`: Some(4802), added: 5297, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// The range of component `b` is `[1, 19]`.
/// The range of component `c` is `[1, 99]`.
fn add_invulnerable(b: u32, c: u32) -> Weight {
// Proof Size summary in bytes:
// Measured: `828 + b * (32 ±0) + c * (53 ±0)`
// Estimated: `6287 + b * (37 ±0) + c * (53 ±0)`
// Minimum execution time: 51_115_000 picoseconds.
Weight::from_parts(46_321_661, 0)
.saturating_add(Weight::from_parts(0, 6287))
// Standard Error: 18_486
.saturating_add(Weight::from_parts(346_609, 0).saturating_mul(b.into()))
// Standard Error: 3_504
.saturating_add(Weight::from_parts(202_188, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
.saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into()))
.saturating_add(Weight::from_parts(0, 53).saturating_mul(c.into()))
}
/// Storage: `CollatorSelection::CandidateList` (r:1 w:0)
/// Proof: `CollatorSelection::CandidateList` (`max_values`: Some(1), `max_size`: Some(4802), added: 5297, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::Invulnerables` (r:1 w:1)
/// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
/// The range of component `b` is `[5, 20]`.
fn remove_invulnerable(b: u32) -> Weight {
// Proof Size summary in bytes:
// Measured: `153 + b * (32 ±0)`
// Estimated: `6287`
// Minimum execution time: 14_756_000 picoseconds.
Weight::from_parts(14_469_493, 0)
.saturating_add(Weight::from_parts(0, 6287))
// Standard Error: 2_837
.saturating_add(Weight::from_parts(214_011, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `CollatorSelection::DesiredCandidates` (r:0 w:1)
/// Proof: `CollatorSelection::DesiredCandidates` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn set_desired_candidates() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 6_561_000 picoseconds.
Weight::from_parts(6_777_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `CollatorSelection::CandidacyBond` (r:1 w:1)
/// Proof: `CollatorSelection::CandidacyBond` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::CandidateList` (r:1 w:1)
/// Proof: `CollatorSelection::CandidateList` (`max_values`: Some(1), `max_size`: Some(4802), added: 5297, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:100 w:100)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::LastAuthoredBlock` (r:0 w:100)
/// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
/// The range of component `c` is `[0, 100]`.
/// The range of component `k` is `[0, 100]`.
fn set_candidacy_bond(c: u32, k: u32) -> Weight {
// Proof Size summary in bytes:
// Measured: `0 + c * (182 ±0) + k * (115 ±0)`
// Estimated: `6287 + c * (901 ±29) + k * (901 ±29)`
// Minimum execution time: 13_013_000 picoseconds.
Weight::from_parts(13_150_000, 0)
.saturating_add(Weight::from_parts(0, 6287))
// Standard Error: 212_739
.saturating_add(Weight::from_parts(7_127_589, 0).saturating_mul(c.into()))
// Standard Error: 212_739
.saturating_add(Weight::from_parts(6_784_046, 0).saturating_mul(k.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into())))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into())))
.saturating_add(Weight::from_parts(0, 901).saturating_mul(c.into()))
.saturating_add(Weight::from_parts(0, 901).saturating_mul(k.into()))
}
/// Storage: `CollatorSelection::CandidacyBond` (r:1 w:0)
/// Proof: `CollatorSelection::CandidacyBond` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::CandidateList` (r:1 w:1)
/// Proof: `CollatorSelection::CandidateList` (`max_values`: Some(1), `max_size`: Some(4802), added: 5297, mode: `MaxEncodedLen`)
/// The range of component `c` is `[3, 100]`.
fn update_bond(c: u32) -> Weight {
// Proof Size summary in bytes:
// Measured: `356 + c * (49 ±0)`
// Estimated: `6287`
// Minimum execution time: 34_412_000 picoseconds.
Weight::from_parts(37_538_467, 0)
.saturating_add(Weight::from_parts(0, 6287))
// Standard Error: 2_658
.saturating_add(Weight::from_parts(140_363, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `CollatorSelection::CandidateList` (r:1 w:1)
/// Proof: `CollatorSelection::CandidateList` (`max_values`: Some(1), `max_size`: Some(4802), added: 5297, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::Invulnerables` (r:1 w:0)
/// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
/// Storage: `Session::NextKeys` (r:1 w:0)
/// Proof: `Session::NextKeys` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `CollatorSelection::CandidacyBond` (r:1 w:0)
/// Proof: `CollatorSelection::CandidacyBond` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::LastAuthoredBlock` (r:0 w:1)
/// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
/// The range of component `c` is `[1, 99]`.
fn register_as_candidate(c: u32) -> Weight {
// Proof Size summary in bytes:
// Measured: `799 + c * (52 ±0)`
// Estimated: `6287 + c * (54 ±0)`
// Minimum execution time: 45_366_000 picoseconds.
Weight::from_parts(49_711_930, 0)
.saturating_add(Weight::from_parts(0, 6287))
// Standard Error: 3_239
.saturating_add(Weight::from_parts(180_195, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(2))
.saturating_add(Weight::from_parts(0, 54).saturating_mul(c.into()))
}
/// Storage: `CollatorSelection::Invulnerables` (r:1 w:0)
/// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::CandidacyBond` (r:1 w:0)
/// Proof: `CollatorSelection::CandidacyBond` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
/// Storage: `Session::NextKeys` (r:1 w:0)
/// Proof: `Session::NextKeys` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `CollatorSelection::CandidateList` (r:1 w:1)
/// Proof: `CollatorSelection::CandidateList` (`max_values`: Some(1), `max_size`: Some(4802), added: 5297, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::LastAuthoredBlock` (r:0 w:2)
/// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
/// The range of component `c` is `[3, 100]`.
fn take_candidate_slot(c: u32) -> Weight {
// Proof Size summary in bytes:
// Measured: `939 + c * (53 ±0)`
// Estimated: `6287 + c * (54 ±0)`
// Minimum execution time: 68_436_000 picoseconds.
Weight::from_parts(73_112_305, 0)
.saturating_add(Weight::from_parts(0, 6287))
// Standard Error: 4_118
.saturating_add(Weight::from_parts(214_419, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(4))
.saturating_add(Weight::from_parts(0, 54).saturating_mul(c.into()))
}
/// Storage: `CollatorSelection::CandidateList` (r:1 w:1)
/// Proof: `CollatorSelection::CandidateList` (`max_values`: Some(1), `max_size`: Some(4802), added: 5297, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::Invulnerables` (r:1 w:0)
/// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::LastAuthoredBlock` (r:0 w:1)
/// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
/// The range of component `c` is `[3, 100]`.
fn leave_intent(c: u32) -> Weight {
// Proof Size summary in bytes:
// Measured: `381 + c * (48 ±0)`
// Estimated: `6287`
// Minimum execution time: 37_349_000 picoseconds.
Weight::from_parts(41_362_337, 0)
.saturating_add(Weight::from_parts(0, 6287))
// Standard Error: 3_309
.saturating_add(Weight::from_parts(158_689, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `System::Account` (r:2 w:2)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::LastAuthoredBlock` (r:0 w:1)
/// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
fn note_author() -> Weight {
// Proof Size summary in bytes:
// Measured: `192`
// Estimated: `6196`
// Minimum execution time: 56_862_000 picoseconds.
Weight::from_parts(57_890_000, 0)
.saturating_add(Weight::from_parts(0, 6196))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `CollatorSelection::CandidateList` (r:1 w:0)
/// Proof: `CollatorSelection::CandidateList` (`max_values`: Some(1), `max_size`: Some(4802), added: 5297, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::LastAuthoredBlock` (r:100 w:0)
/// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::Invulnerables` (r:1 w:0)
/// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`)
/// Storage: `CollatorSelection::DesiredCandidates` (r:1 w:0)
/// Proof: `CollatorSelection::DesiredCandidates` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:97 w:97)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// The range of component `r` is `[1, 100]`.
/// The range of component `c` is `[1, 100]`.
fn new_session(r: u32, c: u32) -> Weight {
// Proof Size summary in bytes:
// Measured: `2369 + c * (97 ±0) + r * (114 ±0)`
// Estimated: `6287 + c * (2519 ±0) + r * (2603 ±0)`
// Minimum execution time: 23_061_000 picoseconds.
Weight::from_parts(23_816_000, 0)
.saturating_add(Weight::from_parts(0, 6287))
// Standard Error: 378_020
.saturating_add(Weight::from_parts(16_325_603, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into())))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into())))
.saturating_add(Weight::from_parts(0, 2519).saturating_mul(c.into()))
.saturating_add(Weight::from_parts(0, 2603).saturating_mul(r.into()))
}
}
@@ -1,4 +1,3 @@
//! Autogenerated weights for `pallet_session`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 42.0.0
@@ -21,43 +20,45 @@
// --chain=dev
// --output=benchmarking/new-benchmarks/pallet_session.rs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
// #![cfg_attr(rustfmt, rustfmt_skip)]
// #![allow(unused_parens)]
// #![allow(unused_imports)]
// #![allow(missing_docs)]
use core::marker::PhantomData;
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_session`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_session::WeightInfo for WeightInfo<T> {
/// Storage: `Session::NextKeys` (r:1 w:1)
/// Proof: `Session::NextKeys` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Session::KeyOwner` (r:1 w:1)
/// Proof: `Session::KeyOwner` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn set_keys() -> Weight {
// Proof Size summary in bytes:
// Measured: `298`
// Estimated: `3763`
// Minimum execution time: 21_646_000 picoseconds.
Weight::from_parts(21_946_000, 0)
.saturating_add(Weight::from_parts(0, 3763))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Session::NextKeys` (r:1 w:1)
/// Proof: `Session::NextKeys` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Session::KeyOwner` (r:0 w:1)
/// Proof: `Session::KeyOwner` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn purge_keys() -> Weight {
// Proof Size summary in bytes:
// Measured: `280`
// Estimated: `3745`
// Minimum execution time: 15_321_000 picoseconds.
Weight::from_parts(15_898_000, 0)
.saturating_add(Weight::from_parts(0, 3745))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Session::NextKeys` (r:1 w:1)
/// Proof: `Session::NextKeys` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Session::KeyOwner` (r:1 w:1)
/// Proof: `Session::KeyOwner` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn set_keys() -> Weight {
// Proof Size summary in bytes:
// Measured: `298`
// Estimated: `3763`
// Minimum execution time: 21_646_000 picoseconds.
Weight::from_parts(21_946_000, 0)
.saturating_add(Weight::from_parts(0, 3763))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Session::NextKeys` (r:1 w:1)
/// Proof: `Session::NextKeys` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Session::KeyOwner` (r:0 w:1)
/// Proof: `Session::KeyOwner` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn purge_keys() -> Weight {
// Proof Size summary in bytes:
// Measured: `280`
// Estimated: `3745`
// Minimum execution time: 15_321_000 picoseconds.
Weight::from_parts(15_898_000, 0)
.saturating_add(Weight::from_parts(0, 3745))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
}
}
@@ -141,12 +141,7 @@ mod runtime_tests {
fn assets_constants() {
assert_eq!(<Runtime as pallet_assets::Config>::AssetDeposit::get(), 10 * CENTS);
// TODO: uncomment once patch is merged and updated RC is released and pointed to in deps
//assert_eq!(<Runtime as pallet_assets::Config>::AssetAccountDeposit::get(), deposit(1, 16));
assert_eq!(
<Runtime as pallet_assets::Config>::AssetAccountDeposit::get(),
EXISTENTIAL_DEPOSIT
);
assert_eq!(<Runtime as pallet_assets::Config>::AssetAccountDeposit::get(), deposit(1, 16));
assert_eq!(<Runtime as pallet_assets::Config>::ApprovalDeposit::get(), EXISTENTIAL_DEPOSIT);
@@ -237,7 +232,7 @@ mod runtime_tests {
pallet_id_to_string(PalletId(*b"PotStake"))
);
assert_eq!(configs::Period::get(), 6 * HOURS);
assert_eq!(configs::SessionLength::get(), 6 * HOURS);
assert_eq!(configs::StakingAdminBodyId::get(), BodyId::Defense);
@@ -60,6 +60,7 @@ std = [
"sp-runtime/std",
]
fuzzing = []
tanssi = []
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
+16 -7
View File
@@ -3,9 +3,11 @@ use std::{
time::{Duration, Instant},
};
#[cfg(not(feature = "tanssi"))]
use frame_support::traits::Get;
use frame_support::{
dispatch::GetDispatchInfo,
traits::{Get, IntegrityTest, TryState, TryStateSelect},
traits::{IntegrityTest, TryState, TryStateSelect},
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
};
use frame_system::Account;
@@ -26,15 +28,21 @@ use sp_runtime::{
use sp_state_machine::BasicExternalities;
fn generate_genesis(accounts: &[AccountId]) -> Storage {
use generic_runtime_template::{
BalancesConfig, CollatorSelectionConfig, RuntimeGenesisConfig, SessionConfig, SessionKeys,
};
use generic_runtime_template::{BalancesConfig, RuntimeGenesisConfig};
#[cfg(not(feature = "tanssi"))]
use generic_runtime_template::{CollatorSelectionConfig, SessionConfig, SessionKeys};
#[cfg(not(feature = "tanssi"))]
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_runtime::{app_crypto::ByteArray, BuildStorage};
#[cfg(not(feature = "tanssi"))]
use sp_runtime::app_crypto::ByteArray;
use sp_runtime::BuildStorage;
// Configure endowed accounts with initial balance of 1 << 60.
let balances = accounts.iter().cloned().map(|k| (k, 1 << 60)).collect();
#[cfg(not(feature = "tanssi"))]
let invulnerables: Vec<AccountId> = vec![[0; 32].into()];
#[cfg(not(feature = "tanssi"))]
let session_keys = vec![(
[0; 32].into(),
[0; 32].into(),
@@ -45,14 +53,14 @@ fn generate_genesis(accounts: &[AccountId]) -> Storage {
RuntimeGenesisConfig {
system: Default::default(),
balances: BalancesConfig { balances },
aura: Default::default(),
#[cfg(not(feature = "tanssi"))]
session: SessionConfig { keys: session_keys },
#[cfg(not(feature = "tanssi"))]
collator_selection: CollatorSelectionConfig {
invulnerables,
candidacy_bond: 1 << 57,
desired_candidates: 1,
},
aura_ext: Default::default(),
parachain_info: Default::default(),
parachain_system: Default::default(),
polkadot_xcm: Default::default(),
@@ -294,6 +302,7 @@ fn recursive_call_filter(call: &RuntimeCall, origin: usize) -> bool {
RuntimeCall::System(
frame_system::Call::set_code { .. } | frame_system::Call::kill_prefix { .. },
) => false,
#[cfg(not(feature = "tanssi"))]
RuntimeCall::CollatorSelection(
pallet_collator_selection::Call::set_desired_candidates { max },
) => *max < <Runtime as pallet_collator_selection::Config>::MaxCandidates::get(),