mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 07:41:08 +00:00
Remove v0 parachains runtime (#1501)
* remove v0 parachains modules and switch to v1 primitives * get tests compiling for runtime-common * remove registrar module * Add a dummy module * remove runtime-parachains * mostly remove old parachains code from polkadot-runtime * remove slots::Trait implementation * remove sp_std prelude import * add a ZeroSizedTypeDifferentiator to dummy * finish porting over polkadot runtime * ZeroSizedTypeDifferentiator was actually unnecessary * westend * kusama * test-runtime (no dummy modules) * fix warning * fix chain-specs * fix test-service * test-client * remove dead import * remove unused needed_extrinsics parameter * runtimes compile * remove rococo-v0 * remove remaining references to Rococo * bump versions
This commit is contained in:
committed by
GitHub
parent
e6688620b5
commit
57aef8eef5
Generated
-76
@@ -5182,7 +5182,6 @@ dependencies = [
|
||||
"polkadot-runtime",
|
||||
"polkadot-test-runtime-client",
|
||||
"polkadot-validation",
|
||||
"rococo-runtime",
|
||||
"sc-authority-discovery",
|
||||
"sc-block-builder",
|
||||
"sc-chain-spec",
|
||||
@@ -6138,81 +6137,6 @@ dependencies = [
|
||||
"librocksdb-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rococo-runtime"
|
||||
version = "0.8.22"
|
||||
dependencies = [
|
||||
"bitvec",
|
||||
"frame-benchmarking",
|
||||
"frame-executive",
|
||||
"frame-support",
|
||||
"frame-system",
|
||||
"frame-system-benchmarking",
|
||||
"frame-system-rpc-runtime-api",
|
||||
"hex-literal",
|
||||
"libsecp256k1",
|
||||
"log 0.3.9",
|
||||
"pallet-authority-discovery",
|
||||
"pallet-authorship",
|
||||
"pallet-babe",
|
||||
"pallet-balances",
|
||||
"pallet-collective",
|
||||
"pallet-democracy",
|
||||
"pallet-elections-phragmen",
|
||||
"pallet-finality-tracker",
|
||||
"pallet-grandpa",
|
||||
"pallet-identity",
|
||||
"pallet-im-online",
|
||||
"pallet-indices",
|
||||
"pallet-membership",
|
||||
"pallet-multisig",
|
||||
"pallet-nicks",
|
||||
"pallet-offences",
|
||||
"pallet-offences-benchmarking",
|
||||
"pallet-proxy",
|
||||
"pallet-randomness-collective-flip",
|
||||
"pallet-recovery",
|
||||
"pallet-scheduler",
|
||||
"pallet-session",
|
||||
"pallet-session-benchmarking",
|
||||
"pallet-staking",
|
||||
"pallet-staking-reward-curve",
|
||||
"pallet-sudo",
|
||||
"pallet-timestamp",
|
||||
"pallet-transaction-payment",
|
||||
"pallet-transaction-payment-rpc-runtime-api",
|
||||
"pallet-treasury",
|
||||
"pallet-utility",
|
||||
"pallet-vesting",
|
||||
"parity-scale-codec",
|
||||
"polkadot-parachain",
|
||||
"polkadot-primitives",
|
||||
"polkadot-runtime-common",
|
||||
"rustc-hex",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"smallvec 1.4.1",
|
||||
"sp-api",
|
||||
"sp-authority-discovery",
|
||||
"sp-block-builder",
|
||||
"sp-consensus-babe",
|
||||
"sp-core",
|
||||
"sp-inherents",
|
||||
"sp-io",
|
||||
"sp-keyring",
|
||||
"sp-offchain",
|
||||
"sp-runtime",
|
||||
"sp-session",
|
||||
"sp-std",
|
||||
"sp-transaction-pool",
|
||||
"sp-trie",
|
||||
"sp-version",
|
||||
"static_assertions",
|
||||
"substrate-wasm-builder-runner 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tiny-keccak 1.5.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rococo-v1-runtime"
|
||||
version = "0.8.22"
|
||||
|
||||
@@ -37,7 +37,6 @@ members = [
|
||||
"runtime/kusama",
|
||||
"runtime/rococo-v1",
|
||||
"runtime/westend",
|
||||
"runtime/rococo",
|
||||
"runtime/test-runtime",
|
||||
"runtime/test-runtime/client",
|
||||
"service",
|
||||
|
||||
@@ -59,10 +59,6 @@ pub struct RunCmd {
|
||||
#[structopt(long = "force-westend")]
|
||||
pub force_westend: bool,
|
||||
|
||||
/// Force using Rococo native runtime.
|
||||
#[structopt(long)]
|
||||
pub force_rococo: bool,
|
||||
|
||||
/// Enable the authority discovery module on validator or sentry nodes.
|
||||
///
|
||||
/// When enabled:
|
||||
|
||||
@@ -47,7 +47,7 @@ impl SubstrateCli for Cli {
|
||||
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
|
||||
let id = if id == "" {
|
||||
let n = get_exec_name().unwrap_or_default();
|
||||
["polkadot", "kusama", "westend", "rococo"].iter()
|
||||
["polkadot", "kusama", "westend"].iter()
|
||||
.cloned()
|
||||
.find(|&chain| n.starts_with(chain))
|
||||
.unwrap_or("polkadot")
|
||||
@@ -65,9 +65,6 @@ impl SubstrateCli for Cli {
|
||||
"westend-dev" => Box::new(service::chain_spec::westend_development_config()?),
|
||||
"westend-local" => Box::new(service::chain_spec::westend_local_testnet_config()?),
|
||||
"westend-staging" => Box::new(service::chain_spec::westend_staging_testnet_config()?),
|
||||
"rococo-staging" => Box::new(service::chain_spec::rococo_staging_testnet_config()?),
|
||||
"rococo-local" => Box::new(service::chain_spec::rococo_local_testnet_config()?),
|
||||
"rococo" => Box::new(service::chain_spec::rococo_config()?),
|
||||
path => {
|
||||
let path = std::path::PathBuf::from(path);
|
||||
|
||||
@@ -77,9 +74,7 @@ impl SubstrateCli for Cli {
|
||||
|
||||
// When `force_*` is given or the file name starts with the name of one of the known chains,
|
||||
// we use the chain spec for the specific chain.
|
||||
if self.run.force_rococo || starts_with("rococo") {
|
||||
Box::new(service::RococoChainSpec::from_json_file(path)?)
|
||||
} else if self.run.force_kusama || starts_with("kusama") {
|
||||
if self.run.force_kusama || starts_with("kusama") {
|
||||
Box::new(service::KusamaChainSpec::from_json_file(path)?)
|
||||
} else if self.run.force_westend || starts_with("westend") {
|
||||
Box::new(service::WestendChainSpec::from_json_file(path)?)
|
||||
@@ -95,8 +90,6 @@ impl SubstrateCli for Cli {
|
||||
&service::kusama_runtime::VERSION
|
||||
} else if spec.is_westend() {
|
||||
&service::westend_runtime::VERSION
|
||||
} else if spec.is_rococo() {
|
||||
&service::rococo_runtime::VERSION
|
||||
} else {
|
||||
&service::polkadot_runtime::VERSION
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ fn prepare_good_block() -> (TestClient, Hash, u64, PeerId, IncomingBlock<Block>)
|
||||
let mut client = polkadot_test_runtime_client::new();
|
||||
let mut builder = client.new_block(Default::default()).unwrap();
|
||||
|
||||
let extrinsics = polkadot_test_runtime_client::needed_extrinsics(vec![], 0);
|
||||
let extrinsics = polkadot_test_runtime_client::needed_extrinsics(0);
|
||||
|
||||
for extrinsic in &extrinsics {
|
||||
builder.push(extrinsic.clone()).unwrap();
|
||||
|
||||
@@ -180,13 +180,6 @@ fn polkadot_staging_testnet_config_genesis(wasm_binary: &[u8]) -> polkadot::Gene
|
||||
pallet_authority_discovery: Some(polkadot::AuthorityDiscoveryConfig {
|
||||
keys: vec![],
|
||||
}),
|
||||
parachains: Some(polkadot::ParachainsConfig {
|
||||
authorities: vec![],
|
||||
}),
|
||||
registrar: Some(polkadot::RegistrarConfig {
|
||||
parachains: vec![],
|
||||
_phdata: Default::default(),
|
||||
}),
|
||||
claims: Some(polkadot::ClaimsConfig {
|
||||
claims: vec![],
|
||||
vesting: vec![],
|
||||
@@ -321,13 +314,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
|
||||
pallet_authority_discovery: Some(westend::AuthorityDiscoveryConfig {
|
||||
keys: vec![],
|
||||
}),
|
||||
parachains: Some(westend::ParachainsConfig {
|
||||
authorities: vec![],
|
||||
}),
|
||||
registrar: Some(westend::RegistrarConfig {
|
||||
parachains: vec![],
|
||||
_phdata: Default::default(),
|
||||
}),
|
||||
pallet_vesting: Some(westend::VestingConfig {
|
||||
vesting: vec![],
|
||||
}),
|
||||
@@ -472,13 +458,6 @@ fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisC
|
||||
pallet_authority_discovery: Some(kusama::AuthorityDiscoveryConfig {
|
||||
keys: vec![],
|
||||
}),
|
||||
parachains: Some(kusama::ParachainsConfig {
|
||||
authorities: vec![],
|
||||
}),
|
||||
registrar: Some(kusama::RegistrarConfig {
|
||||
parachains: vec![],
|
||||
_phdata: Default::default(),
|
||||
}),
|
||||
claims: Some(kusama::ClaimsConfig {
|
||||
claims: vec![],
|
||||
vesting: vec![],
|
||||
@@ -657,13 +636,6 @@ pub fn polkadot_testnet_genesis(
|
||||
pallet_authority_discovery: Some(polkadot::AuthorityDiscoveryConfig {
|
||||
keys: vec![],
|
||||
}),
|
||||
parachains: Some(polkadot::ParachainsConfig {
|
||||
authorities: vec![],
|
||||
}),
|
||||
registrar: Some(polkadot::RegistrarConfig{
|
||||
parachains: vec![],
|
||||
_phdata: Default::default(),
|
||||
}),
|
||||
claims: Some(polkadot::ClaimsConfig {
|
||||
claims: vec![],
|
||||
vesting: vec![],
|
||||
@@ -732,13 +704,6 @@ pub fn kusama_testnet_genesis(
|
||||
pallet_authority_discovery: Some(kusama::AuthorityDiscoveryConfig {
|
||||
keys: vec![],
|
||||
}),
|
||||
parachains: Some(kusama::ParachainsConfig {
|
||||
authorities: vec![],
|
||||
}),
|
||||
registrar: Some(kusama::RegistrarConfig{
|
||||
parachains: vec![],
|
||||
_phdata: Default::default(),
|
||||
}),
|
||||
claims: Some(kusama::ClaimsConfig {
|
||||
claims: vec![],
|
||||
vesting: vec![],
|
||||
@@ -796,13 +761,6 @@ pub fn westend_testnet_genesis(
|
||||
pallet_authority_discovery: Some(westend::AuthorityDiscoveryConfig {
|
||||
keys: vec![],
|
||||
}),
|
||||
parachains: Some(westend::ParachainsConfig {
|
||||
authorities: vec![],
|
||||
}),
|
||||
registrar: Some(westend::RegistrarConfig{
|
||||
parachains: vec![],
|
||||
_phdata: Default::default(),
|
||||
}),
|
||||
pallet_vesting: Some(westend::VestingConfig {
|
||||
vesting: vec![],
|
||||
}),
|
||||
|
||||
@@ -256,7 +256,7 @@ mod tests {
|
||||
for i in 0..n {
|
||||
let mut builder = client.new_block(Default::default()).unwrap();
|
||||
|
||||
for extrinsic in polkadot_test_runtime_client::needed_extrinsics(vec![], base + i) {
|
||||
for extrinsic in polkadot_test_runtime_client::needed_extrinsics(base + i) {
|
||||
builder.push(extrinsic).unwrap()
|
||||
}
|
||||
|
||||
|
||||
@@ -155,13 +155,6 @@ fn polkadot_testnet_genesis(
|
||||
pallet_babe: Some(Default::default()),
|
||||
pallet_grandpa: Some(Default::default()),
|
||||
pallet_authority_discovery: Some(polkadot::AuthorityDiscoveryConfig { keys: vec![] }),
|
||||
parachains: Some(polkadot::ParachainsConfig {
|
||||
authorities: vec![],
|
||||
}),
|
||||
registrar: Some(polkadot::RegistrarConfig {
|
||||
parachains: vec![],
|
||||
_phdata: Default::default(),
|
||||
}),
|
||||
claims: Some(polkadot::ClaimsConfig {
|
||||
claims: vec![],
|
||||
vesting: vec![],
|
||||
|
||||
@@ -25,9 +25,11 @@ use futures::future::Future;
|
||||
use polkadot_primitives::v0::{
|
||||
Block, Hash, CollatorId, Id as ParaId,
|
||||
};
|
||||
use polkadot_runtime_common::{parachains, registrar, BlockHashCount};
|
||||
use polkadot_service::{new_full, FullNodeHandles, AbstractClient, ClientHandle, ExecuteWithClient};
|
||||
use polkadot_test_runtime::{RestrictFunctionality, Runtime, SignedExtra, SignedPayload, VERSION};
|
||||
use polkadot_runtime_common::BlockHashCount;
|
||||
use polkadot_service::{
|
||||
new_full, FullNodeHandles, AbstractClient, ClientHandle, ExecuteWithClient,
|
||||
};
|
||||
use polkadot_test_runtime::{Runtime, SignedExtra, SignedPayload, VERSION};
|
||||
use sc_chain_spec::ChainSpec;
|
||||
use sc_client_api::{execution_extensions::ExecutionStrategies, BlockchainEvents};
|
||||
use sc_executor::native_executor_instance;
|
||||
@@ -258,7 +260,6 @@ where
|
||||
.unwrap_or(2) as u64;
|
||||
let tip = 0;
|
||||
let extra: SignedExtra = (
|
||||
RestrictFunctionality,
|
||||
frame_system::CheckSpecVersion::<Runtime>::new(),
|
||||
frame_system::CheckTxVersion::<Runtime>::new(),
|
||||
frame_system::CheckGenesis::<Runtime>::new(),
|
||||
@@ -266,14 +267,11 @@ where
|
||||
frame_system::CheckNonce::<Runtime>::from(nonce),
|
||||
frame_system::CheckWeight::<Runtime>::new(),
|
||||
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
|
||||
registrar::LimitParathreadCommits::<Runtime>::new(),
|
||||
parachains::ValidateDoubleVoteReports::<Runtime>::new(),
|
||||
);
|
||||
let raw_payload = SignedPayload::from_raw(
|
||||
function.clone(),
|
||||
extra.clone(),
|
||||
(
|
||||
(),
|
||||
VERSION.spec_version,
|
||||
VERSION.transaction_version,
|
||||
genesis_block,
|
||||
@@ -281,8 +279,6 @@ where
|
||||
(),
|
||||
(),
|
||||
(),
|
||||
(),
|
||||
(),
|
||||
),
|
||||
);
|
||||
let signature = raw_payload.using_encoded(|e| caller.sign(e));
|
||||
|
||||
@@ -705,6 +705,25 @@ sp_api::decl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
/// Custom validity errors used in Polkadot while validating transactions.
|
||||
#[repr(u8)]
|
||||
pub enum ValidityError {
|
||||
/// The Ethereum signature is invalid.
|
||||
InvalidEthereumSignature = 0,
|
||||
/// The signer has no claim.
|
||||
SignerHasNoClaim = 1,
|
||||
/// No permission to execute the call.
|
||||
NoPermission = 2,
|
||||
/// An invalid statement was made for a claim.
|
||||
InvalidStatement = 3,
|
||||
}
|
||||
|
||||
impl From<ValidityError> for u8 {
|
||||
fn from(err: ValidityError) -> Self {
|
||||
err as u8
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -1,214 +0,0 @@
|
||||
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! A module for tracking all attestations that fell on a given candidate receipt.
|
||||
//!
|
||||
//! In the future, it is planned that this module will handle dispute resolution
|
||||
//! as well.
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use codec::{Encode, Decode};
|
||||
use frame_support::{
|
||||
decl_storage, decl_module, decl_error, ensure,
|
||||
dispatch::DispatchResult,
|
||||
traits::Get,
|
||||
weights::DispatchClass,
|
||||
};
|
||||
|
||||
use primitives::v0::{Hash, AttestedCandidate, AbridgedCandidateReceipt, Id as ParaId};
|
||||
use sp_runtime::RuntimeDebug;
|
||||
use sp_staking::SessionIndex;
|
||||
|
||||
use inherents::{ProvideInherent, InherentData, MakeFatalError, InherentIdentifier};
|
||||
use frame_system::ensure_none;
|
||||
|
||||
/// Parachain blocks included in a recent relay-chain block.
|
||||
#[derive(Encode, Decode)]
|
||||
pub struct IncludedBlocks<T: Trait> {
|
||||
/// The actual relay chain block number where blocks were included.
|
||||
pub actual_number: T::BlockNumber,
|
||||
/// The session index at this block.
|
||||
pub session: SessionIndex,
|
||||
/// The randomness seed at this block.
|
||||
pub random_seed: [u8; 32],
|
||||
/// All parachain IDs active at this block.
|
||||
pub active_parachains: Vec<ParaId>,
|
||||
/// Hashes of the parachain candidates included at this block.
|
||||
pub para_blocks: Vec<Hash>,
|
||||
}
|
||||
|
||||
/// Attestations kept over time on a parachain block.
|
||||
#[derive(Encode, Decode)]
|
||||
pub struct BlockAttestations<T: Trait> {
|
||||
receipt: AbridgedCandidateReceipt,
|
||||
valid: Vec<T::AccountId>, // stash account ID of voter.
|
||||
invalid: Vec<T::AccountId>, // stash account ID of voter.
|
||||
}
|
||||
|
||||
/// Additional attestations on a parachain block, after it was included.
|
||||
#[derive(Encode, Decode, Clone, PartialEq, RuntimeDebug)]
|
||||
pub struct MoreAttestations;
|
||||
|
||||
/// Something which processes rewards for received attestations.
|
||||
pub trait RewardAttestation {
|
||||
/// Reward immediate attestations on parachain blocks. The argument is an iterable of
|
||||
/// validator indices of the attesting validators.
|
||||
fn reward_immediate(validator_indices: impl IntoIterator<Item=u32>);
|
||||
}
|
||||
|
||||
impl RewardAttestation for () {
|
||||
fn reward_immediate(validator_indices: impl IntoIterator<Item=u32>) {
|
||||
// ensure side-effecting iterators do work.
|
||||
for _ in validator_indices {}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: pallet_staking::Trait> RewardAttestation for pallet_staking::Module<T> {
|
||||
fn reward_immediate(validator_indices: impl IntoIterator<Item=u32>) {
|
||||
use pallet_staking::SessionInterface;
|
||||
|
||||
// The number of points to reward for a validity statement.
|
||||
// https://research.web3.foundation/en/latest/polkadot/Token%20Economics/#payment-details
|
||||
const STAKING_REWARD_POINTS: u32 = 20;
|
||||
|
||||
let validators = T::SessionInterface::validators();
|
||||
|
||||
let validator_rewards = validator_indices.into_iter()
|
||||
.filter_map(|i| validators.get(i as usize).cloned())
|
||||
.map(|v| (v, STAKING_REWARD_POINTS));
|
||||
|
||||
Self::reward_by_ids(validator_rewards);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Trait: pallet_session::Trait {
|
||||
/// How many blocks ago we're willing to accept attestations for.
|
||||
type AttestationPeriod: Get<Self::BlockNumber>;
|
||||
|
||||
/// Get a list of the validators' underlying identities.
|
||||
type ValidatorIdentities: Get<Vec<Self::AccountId>>;
|
||||
|
||||
/// Hook for rewarding validators upon attesting.
|
||||
type RewardAttestation: RewardAttestation;
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait> as Attestations {
|
||||
/// A mapping from modular block number (n % AttestationPeriod)
|
||||
/// to session index and the list of candidate hashes.
|
||||
pub RecentParaBlocks: map hasher(twox_64_concat) T::BlockNumber => Option<IncludedBlocks<T>>;
|
||||
|
||||
/// Attestations on a recent parachain block.
|
||||
pub ParaBlockAttestations:
|
||||
double_map hasher(twox_64_concat) T::BlockNumber, hasher(identity) Hash
|
||||
=> Option<BlockAttestations<T>>;
|
||||
|
||||
// Did we already have more attestations included in this block?
|
||||
DidUpdate: bool;
|
||||
}
|
||||
}
|
||||
|
||||
decl_error! {
|
||||
pub enum Error for Module<T: Trait> {
|
||||
/// More attestations can be added only once in a block.
|
||||
TooManyAttestations,
|
||||
}
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
/// Parachain-attestations module.
|
||||
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
|
||||
type Error = Error<T>;
|
||||
|
||||
/// Provide candidate receipts for parachains, in ascending order by id.
|
||||
#[weight = (0, DispatchClass::Mandatory)]
|
||||
fn more_attestations(origin, _more: MoreAttestations) -> DispatchResult {
|
||||
ensure_none(origin)?;
|
||||
ensure!(!DidUpdate::exists(), Error::<T>::TooManyAttestations);
|
||||
DidUpdate::put(true);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn on_finalize(_n: T::BlockNumber) {
|
||||
DidUpdate::kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> Module<T> {
|
||||
/// Update recent candidates to contain the already-checked parachain candidates.
|
||||
pub(crate) fn note_included(heads: &[AttestedCandidate], para_blocks: IncludedBlocks<T>) {
|
||||
let attestation_period = T::AttestationPeriod::get();
|
||||
let mod_num = para_blocks.actual_number % attestation_period;
|
||||
|
||||
// clear old entry that was in this place.
|
||||
if let Some(old_entry) = <RecentParaBlocks<T>>::take(&mod_num) {
|
||||
<ParaBlockAttestations<T>>::remove_prefix(&old_entry.actual_number);
|
||||
}
|
||||
|
||||
let validators = T::ValidatorIdentities::get();
|
||||
|
||||
// make new entry.
|
||||
for (head, hash) in heads.iter().zip(¶_blocks.para_blocks) {
|
||||
let mut valid = Vec::new();
|
||||
let invalid = Vec::new();
|
||||
|
||||
{
|
||||
let attesting_indices = head.validator_indices
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, bit)| **bit)
|
||||
.inspect(|&(auth_index, _)| {
|
||||
if let Some(stash_id) = validators.get(auth_index) {
|
||||
valid.push(stash_id.clone());
|
||||
}
|
||||
})
|
||||
.map(|(i, _)| i as u32);
|
||||
|
||||
T::RewardAttestation::reward_immediate(attesting_indices);
|
||||
}
|
||||
|
||||
let summary = BlockAttestations {
|
||||
receipt: head.candidate().clone(),
|
||||
valid,
|
||||
invalid,
|
||||
};
|
||||
|
||||
<ParaBlockAttestations<T>>::insert(¶_blocks.actual_number, hash, &summary);
|
||||
}
|
||||
|
||||
<RecentParaBlocks<T>>::insert(&mod_num, ¶_blocks);
|
||||
}
|
||||
}
|
||||
|
||||
/// An identifier for inherent data that provides after-the-fact attestations
|
||||
/// on already included parachain blocks.
|
||||
pub const MORE_ATTESTATIONS_IDENTIFIER: InherentIdentifier = *b"par-atts";
|
||||
|
||||
pub type InherentType = MoreAttestations;
|
||||
|
||||
impl<T: Trait> ProvideInherent for Module<T> {
|
||||
type Call = Call<T>;
|
||||
type Error = MakeFatalError<inherents::Error>;
|
||||
const INHERENT_IDENTIFIER: InherentIdentifier = MORE_ATTESTATIONS_IDENTIFIER;
|
||||
|
||||
fn create_inherent(data: &InherentData) -> Option<Self::Call> {
|
||||
data.get_data::<InherentType>(&MORE_ATTESTATIONS_IDENTIFIER)
|
||||
.ok()
|
||||
.and_then(|x| x.map(Call::more_attestations))
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ use sp_runtime::{
|
||||
TransactionSource, TransactionValidityError,
|
||||
},
|
||||
};
|
||||
use primitives::v0::ValidityError;
|
||||
use primitives::v1::ValidityError;
|
||||
|
||||
type CurrencyOf<T> = <<T as Trait>::VestingSchedule as VestingSchedule<<T as frame_system::Trait>::AccountId>>::Currency;
|
||||
type BalanceOf<T> = <CurrencyOf<T> as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||
|
||||
@@ -79,7 +79,7 @@ use sp_runtime::{ModuleId,
|
||||
use crate::slots;
|
||||
use codec::{Encode, Decode};
|
||||
use sp_std::vec::Vec;
|
||||
use primitives::v0::{Id as ParaId, HeadData};
|
||||
use primitives::v1::{Id as ParaId, HeadData};
|
||||
|
||||
pub type BalanceOf<T> =
|
||||
<<T as slots::Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||
@@ -568,14 +568,14 @@ mod tests {
|
||||
};
|
||||
use frame_support::traits::{Contains, ContainsLengthBound};
|
||||
use sp_core::H256;
|
||||
use primitives::v0::{Info as ParaInfo, Id as ParaId, Scheduling, ValidationCode};
|
||||
use primitives::v1::{Id as ParaId, ValidationCode};
|
||||
// The testing primitives are very useful for avoiding having to work with signatures
|
||||
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are requried.
|
||||
use sp_runtime::{
|
||||
Perbill, Permill, Percent, testing::Header, DispatchResult,
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
};
|
||||
use crate::registrar::Registrar;
|
||||
use crate::slots::Registrar;
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
@@ -699,13 +699,9 @@ mod tests {
|
||||
code_size <= MAX_CODE_SIZE
|
||||
}
|
||||
|
||||
fn para_info(_id: ParaId) -> Option<ParaInfo> {
|
||||
Some(ParaInfo { scheduling: Scheduling::Always })
|
||||
}
|
||||
|
||||
fn register_para(
|
||||
id: ParaId,
|
||||
_info: ParaInfo,
|
||||
_parachain: bool,
|
||||
code: ValidationCode,
|
||||
initial_head_data: HeadData,
|
||||
) -> DispatchResult {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! A dummy module for holding place of modules in a runtime.
|
||||
|
||||
use frame_support::{decl_module, decl_storage};
|
||||
|
||||
pub trait Trait<I: Instance = DefaultInstance>: frame_system::Trait { }
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait<I>, I: Instance = DefaultInstance> for enum Call where origin: T::Origin {
|
||||
}
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait<I>, I: Instance = DefaultInstance> as Dummy { }
|
||||
}
|
||||
@@ -26,8 +26,8 @@ pub struct ToAuthor<R>(sp_std::marker::PhantomData<R>);
|
||||
impl<R> OnUnbalanced<NegativeImbalance<R>> for ToAuthor<R>
|
||||
where
|
||||
R: pallet_balances::Trait + pallet_authorship::Trait,
|
||||
<R as frame_system::Trait>::AccountId: From<primitives::v0::AccountId>,
|
||||
<R as frame_system::Trait>::AccountId: Into<primitives::v0::AccountId>,
|
||||
<R as frame_system::Trait>::AccountId: From<primitives::v1::AccountId>,
|
||||
<R as frame_system::Trait>::AccountId: Into<primitives::v1::AccountId>,
|
||||
<R as frame_system::Trait>::Event: From<pallet_balances::RawEvent<
|
||||
<R as frame_system::Trait>::AccountId,
|
||||
<R as pallet_balances::Trait>::Balance,
|
||||
|
||||
@@ -18,18 +18,17 @@
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
pub mod attestations;
|
||||
pub mod claims;
|
||||
pub mod parachains;
|
||||
pub mod slot_range;
|
||||
pub mod registrar;
|
||||
pub mod slots;
|
||||
pub mod crowdfund;
|
||||
pub mod purchase;
|
||||
pub mod impls;
|
||||
pub mod paras_sudo_wrapper;
|
||||
|
||||
use primitives::v0::BlockNumber;
|
||||
pub mod dummy;
|
||||
|
||||
use primitives::v1::{BlockNumber, ValidatorId};
|
||||
use sp_runtime::{Perquintill, Perbill, FixedPointNumber, traits::Saturating};
|
||||
use frame_support::{
|
||||
parameter_types, traits::{Currency},
|
||||
@@ -45,8 +44,6 @@ pub use pallet_staking::StakerStatus;
|
||||
pub use sp_runtime::BuildStorage;
|
||||
pub use pallet_timestamp::Call as TimestampCall;
|
||||
pub use pallet_balances::Call as BalancesCall;
|
||||
pub use attestations::{Call as AttestationsCall, MORE_ATTESTATIONS_IDENTIFIER};
|
||||
pub use parachains::Call as ParachainsCall;
|
||||
|
||||
/// Implementations of some helper traits passed into runtime modules as associated types.
|
||||
pub use impls::{CurrencyToVoteHandler, ToAuthor};
|
||||
@@ -92,6 +89,35 @@ pub type SlowAdjustingFeeUpdate<R> = TargetedFeeAdjustment<
|
||||
MinimumMultiplier
|
||||
>;
|
||||
|
||||
/// A placeholder since there is currently no provided session key handler for parachain validator
|
||||
/// keys.
|
||||
pub struct ParachainSessionKeyPlaceholder<T>(sp_std::marker::PhantomData<T>);
|
||||
impl<T> sp_runtime::BoundToRuntimeAppPublic for ParachainSessionKeyPlaceholder<T> {
|
||||
type Public = ValidatorId;
|
||||
}
|
||||
|
||||
impl<T: pallet_session::Trait>
|
||||
pallet_session::OneSessionHandler<T::AccountId> for ParachainSessionKeyPlaceholder<T>
|
||||
{
|
||||
type Key = ValidatorId;
|
||||
|
||||
fn on_genesis_session<'a, I: 'a>(_validators: I) where
|
||||
I: Iterator<Item = (&'a T::AccountId, ValidatorId)>,
|
||||
T::AccountId: 'a
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
fn on_new_session<'a, I: 'a>(_changed: bool, _v: I, _q: I) where
|
||||
I: Iterator<Item = (&'a T::AccountId, ValidatorId)>,
|
||||
T::AccountId: 'a
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
fn on_disabled(_: usize) { }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod multiplier_tests {
|
||||
use super::*;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -28,11 +28,10 @@ use frame_support::{
|
||||
traits::{Currency, ReservableCurrency, WithdrawReason, ExistenceRequirement, Get, Randomness},
|
||||
weights::{DispatchClass, Weight},
|
||||
};
|
||||
use primitives::v0::{
|
||||
SwapAux, PARACHAIN_INFO, Id as ParaId, ValidationCode, HeadData,
|
||||
use primitives::v1::{
|
||||
Id as ParaId, ValidationCode, HeadData,
|
||||
};
|
||||
use frame_system::{ensure_signed, ensure_root};
|
||||
use crate::registrar::{Registrar, swap_ordered_existence};
|
||||
use crate::slot_range::{SlotRange, SLOT_RANGE_COUNT};
|
||||
|
||||
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||
@@ -58,6 +57,50 @@ pub trait Trait: frame_system::Trait {
|
||||
type Randomness: Randomness<Self::Hash>;
|
||||
}
|
||||
|
||||
/// Parachain registration API.
|
||||
pub trait Registrar<AccountId> {
|
||||
/// Create a new unique parachain identity for later registration.
|
||||
fn new_id() -> ParaId;
|
||||
|
||||
/// Checks whether the given initial head data size falls within the limit.
|
||||
fn head_data_size_allowed(head_data_size: u32) -> bool;
|
||||
|
||||
/// Checks whether the given validation code falls within the limit.
|
||||
fn code_size_allowed(code_size: u32) -> bool;
|
||||
|
||||
/// Register a parachain with given `code` and `initial_head_data`. `id` must not yet be registered or it will
|
||||
/// result in a error.
|
||||
///
|
||||
/// This does not enforce any code size or initial head data limits, as these
|
||||
/// are governable and parameters for parachain initialization are often
|
||||
/// determined long ahead-of-time. Not checking these values ensures that changes to limits
|
||||
/// do not invalidate in-progress auction winners.
|
||||
fn register_para(
|
||||
id: ParaId,
|
||||
_parachain: bool,
|
||||
code: ValidationCode,
|
||||
initial_head_data: HeadData,
|
||||
) -> DispatchResult;
|
||||
|
||||
/// Deregister a parachain with given `id`. If `id` is not currently registered, an error is returned.
|
||||
fn deregister_para(id: ParaId) -> DispatchResult;
|
||||
}
|
||||
|
||||
/// Auxilliary for when there's an attempt to swap two parachains/parathreads.
|
||||
pub trait SwapAux {
|
||||
/// Result describing whether it is possible to swap two parachains. Doesn't mutate state.
|
||||
fn ensure_can_swap(one: ParaId, other: ParaId) -> Result<(), &'static str>;
|
||||
|
||||
/// Updates any needed state/references to enact a logical swap of two parachains. Identity,
|
||||
/// code and `head_data` remain equivalent for all parachains/threads, however other properties
|
||||
/// such as leases, deposits held and thread/chain nature are swapped.
|
||||
///
|
||||
/// May only be called on a state that `ensure_can_swap` has previously returned `Ok` for: if this is
|
||||
/// not the case, the result is undefined. May only return an error if `ensure_can_swap` also returns
|
||||
/// an error.
|
||||
fn on_swap(one: ParaId, other: ParaId) -> Result<(), &'static str>;
|
||||
}
|
||||
|
||||
/// A sub-bidder identifier. Used to distinguish between different logical bidders coming from the
|
||||
/// same account ID.
|
||||
pub type SubId = u32;
|
||||
@@ -187,6 +230,21 @@ decl_storage! {
|
||||
}
|
||||
}
|
||||
|
||||
/// Swap the existence of two items, provided by value, within an ordered list.
|
||||
///
|
||||
/// If neither item exists, or if both items exist this will do nothing. If exactly one of the
|
||||
/// items exists, then it will be removed and the other inserted.
|
||||
fn swap_ordered_existence<T: PartialOrd + Ord + Copy>(ids: &mut [T], one: T, other: T) {
|
||||
let maybe_one_pos = ids.binary_search(&one);
|
||||
let maybe_other_pos = ids.binary_search(&other);
|
||||
match (maybe_one_pos, maybe_other_pos) {
|
||||
(Ok(one_pos), Err(_)) => ids[one_pos] = other,
|
||||
(Err(_), Ok(other_pos)) => ids[other_pos] = one,
|
||||
_ => return,
|
||||
};
|
||||
ids.sort();
|
||||
}
|
||||
|
||||
impl<T: Trait> SwapAux for Module<T> {
|
||||
fn ensure_can_swap(one: ParaId, other: ParaId) -> Result<(), &'static str> {
|
||||
if <Onboarding<T>>::contains_key(one) || <Onboarding<T>>::contains_key(other) {
|
||||
@@ -470,7 +528,7 @@ decl_module! {
|
||||
// parachain for its immediate start.
|
||||
<Onboarding<T>>::remove(¶_id);
|
||||
let _ = T::Parachains::
|
||||
register_para(para_id, PARACHAIN_INFO, code, initial_head_data);
|
||||
register_para(para_id, true, code, initial_head_data);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -719,7 +777,7 @@ impl<T: Trait> Module<T> {
|
||||
// The chain's deployment data is set; go ahead and register it, and remove the
|
||||
// now-redundant on-boarding entry.
|
||||
let _ = T::Parachains::
|
||||
register_para(para_id.clone(), PARACHAIN_INFO, code, initial_head_data);
|
||||
register_para(para_id.clone(), true, code, initial_head_data);
|
||||
// ^^ not much we can do if it fails for some reason.
|
||||
<Onboarding<T>>::remove(para_id)
|
||||
}
|
||||
@@ -890,7 +948,7 @@ mod tests {
|
||||
traits::{OnInitialize, OnFinalize}
|
||||
};
|
||||
use pallet_balances;
|
||||
use primitives::v0::{BlockNumber, Header, Id as ParaId, Info as ParaInfo, Scheduling};
|
||||
use primitives::v1::{BlockNumber, Header, Id as ParaId};
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
@@ -974,13 +1032,9 @@ mod tests {
|
||||
code_size <= MAX_CODE_SIZE
|
||||
}
|
||||
|
||||
fn para_info(_id: ParaId) -> Option<ParaInfo> {
|
||||
Some(ParaInfo { scheduling: Scheduling::Always })
|
||||
}
|
||||
|
||||
fn register_para(
|
||||
id: ParaId,
|
||||
_info: ParaInfo,
|
||||
_parachain: bool,
|
||||
code: ValidationCode,
|
||||
initial_head_data: HeadData,
|
||||
) -> DispatchResult {
|
||||
|
||||
@@ -23,17 +23,16 @@
|
||||
use sp_std::prelude::*;
|
||||
use sp_core::u32_trait::{_1, _2, _3, _4, _5};
|
||||
use codec::{Encode, Decode};
|
||||
use primitives::v0::{
|
||||
self as parachain,
|
||||
use primitives::v1::{
|
||||
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, Signature, Moment,
|
||||
ActiveParas, AbridgedCandidateReceipt, SigningContext,
|
||||
};
|
||||
use primitives::v0 as p_v0;
|
||||
use runtime_common::{
|
||||
attestations, claims, parachains, registrar, slots, SlowAdjustingFeeUpdate,
|
||||
dummy, claims, SlowAdjustingFeeUpdate,
|
||||
impls::{CurrencyToVoteHandler, ToAuthor},
|
||||
NegativeImbalance, BlockHashCount, MaximumBlockWeight, AvailableBlockRatio,
|
||||
MaximumBlockLength, BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight,
|
||||
MaximumExtrinsicWeight,
|
||||
MaximumExtrinsicWeight, ParachainSessionKeyPlaceholder,
|
||||
};
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic, impl_opaque_keys, ModuleId,
|
||||
@@ -71,8 +70,6 @@ pub use pallet_staking::StakerStatus;
|
||||
pub use sp_runtime::BuildStorage;
|
||||
pub use pallet_timestamp::Call as TimestampCall;
|
||||
pub use pallet_balances::Call as BalancesCall;
|
||||
pub use attestations::{Call as AttestationsCall, MORE_ATTESTATIONS_IDENTIFIER};
|
||||
pub use parachains::Call as ParachainsCall;
|
||||
|
||||
/// Constant values used within the runtime.
|
||||
pub mod constants;
|
||||
@@ -90,7 +87,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("kusama"),
|
||||
impl_name: create_runtime_str!("parity-kusama"),
|
||||
authoring_version: 2,
|
||||
spec_version: 2022,
|
||||
spec_version: 2023,
|
||||
impl_version: 0,
|
||||
#[cfg(not(feature = "disable-runtime-api"))]
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
@@ -111,8 +108,8 @@ pub fn native_version() -> NativeVersion {
|
||||
/// Avoid processing transactions from slots and parachain registrar.
|
||||
pub struct BaseFilter;
|
||||
impl Filter<Call> for BaseFilter {
|
||||
fn filter(call: &Call) -> bool {
|
||||
!matches!(call, Call::Slots(_) | Call::Registrar(_))
|
||||
fn filter(_: &Call) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +266,7 @@ impl_opaque_keys! {
|
||||
pub grandpa: Grandpa,
|
||||
pub babe: Babe,
|
||||
pub im_online: ImOnline,
|
||||
pub parachain_validator: Parachains,
|
||||
pub parachain_validator: ParachainSessionKeyPlaceholder<Runtime>,
|
||||
pub authority_discovery: AuthorityDiscovery,
|
||||
}
|
||||
}
|
||||
@@ -577,47 +574,6 @@ impl pallet_finality_tracker::Trait for Runtime {
|
||||
type ReportLatency = ReportLatency;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const AttestationPeriod: BlockNumber = 50;
|
||||
}
|
||||
|
||||
impl attestations::Trait for Runtime {
|
||||
type AttestationPeriod = AttestationPeriod;
|
||||
type ValidatorIdentities = parachains::ValidatorIdentities<Runtime>;
|
||||
type RewardAttestation = Staking;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const MaxCodeSize: u32 = 10 * 1024 * 1024; // 10 MB
|
||||
pub const MaxHeadDataSize: u32 = 20 * 1024; // 20 KB
|
||||
pub const ValidationUpgradeFrequency: BlockNumber = 2 * DAYS;
|
||||
pub const ValidationUpgradeDelay: BlockNumber = 8 * HOURS;
|
||||
pub const SlashPeriod: BlockNumber = 7 * DAYS;
|
||||
}
|
||||
|
||||
impl parachains::Trait for Runtime {
|
||||
type AuthorityId = primitives::v0::fisherman::FishermanAppCrypto;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
type ParachainCurrency = Balances;
|
||||
type BlockNumberConversion = sp_runtime::traits::Identity;
|
||||
type Randomness = RandomnessCollectiveFlip;
|
||||
type ActiveParachains = Registrar;
|
||||
type Registrar = Registrar;
|
||||
type MaxCodeSize = MaxCodeSize;
|
||||
type MaxHeadDataSize = MaxHeadDataSize;
|
||||
|
||||
type ValidationUpgradeFrequency = ValidationUpgradeFrequency;
|
||||
type ValidationUpgradeDelay = ValidationUpgradeDelay;
|
||||
type SlashPeriod = SlashPeriod;
|
||||
|
||||
type Proof = sp_session::MembershipProof;
|
||||
type KeyOwnerProofSystem = pallet_session::historical::Module<Self>;
|
||||
type IdentificationTuple = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, Vec<u8>)>>::IdentificationTuple;
|
||||
type ReportOffence = Offences;
|
||||
type BlockHashConversion = sp_runtime::traits::Identity;
|
||||
}
|
||||
|
||||
/// Submits transaction with the node's public and signature type. Adheres to the signed extension
|
||||
/// format of the chain.
|
||||
impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime where
|
||||
@@ -649,8 +605,6 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
|
||||
frame_system::CheckNonce::<Runtime>::from(nonce),
|
||||
frame_system::CheckWeight::<Runtime>::new(),
|
||||
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
|
||||
registrar::LimitParathreadCommits::<Runtime>::new(),
|
||||
parachains::ValidateDoubleVoteReports::<Runtime>::new(),
|
||||
);
|
||||
let raw_payload = SignedPayload::new(call, extra).map_err(|e| {
|
||||
debug::warn!("Unable to create signed payload: {:?}", e);
|
||||
@@ -675,36 +629,6 @@ impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime where
|
||||
type Extrinsic = UncheckedExtrinsic;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ParathreadDeposit: Balance = 5 * DOLLARS;
|
||||
pub const QueueSize: usize = 2;
|
||||
pub const MaxRetries: u32 = 3;
|
||||
}
|
||||
|
||||
impl registrar::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type Origin = Origin;
|
||||
type Currency = Balances;
|
||||
type ParathreadDeposit = ParathreadDeposit;
|
||||
type SwapAux = Slots;
|
||||
type QueueSize = QueueSize;
|
||||
type MaxRetries = MaxRetries;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const LeasePeriod: BlockNumber = 100_000;
|
||||
pub const EndingPeriod: BlockNumber = 1000;
|
||||
}
|
||||
|
||||
impl slots::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type Currency = Balances;
|
||||
type Parachains = Registrar;
|
||||
type LeasePeriod = LeasePeriod;
|
||||
type EndingPeriod = EndingPeriod;
|
||||
type Randomness = RandomnessCollectiveFlip;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub Prefix: &'static [u8] = b"Pay KSMs to the Kusama account:";
|
||||
}
|
||||
@@ -830,6 +754,8 @@ parameter_types! {
|
||||
pub const MaxProxies: u16 = 32;
|
||||
}
|
||||
|
||||
impl<I: frame_support::traits::Instance> dummy::Trait<I> for Runtime { }
|
||||
|
||||
/// The type used to represent the kinds of proxying allowed.
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug)]
|
||||
pub enum ProxyType {
|
||||
@@ -868,10 +794,10 @@ impl InstanceFilter<Call> for ProxyType {
|
||||
Call::TechnicalMembership(..) |
|
||||
Call::Treasury(..) |
|
||||
Call::Claims(..) |
|
||||
Call::Parachains(..) |
|
||||
Call::Attestations(..) |
|
||||
Call::Slots(..) |
|
||||
Call::Registrar(..) |
|
||||
Call::DummyParachains(..) |
|
||||
Call::DummyAttestations(..) |
|
||||
Call::DummySlots(..) |
|
||||
Call::DummyRegistrar(..) |
|
||||
Call::Utility(..) |
|
||||
Call::Identity(..) |
|
||||
Call::Society(..) |
|
||||
@@ -938,7 +864,7 @@ impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
|
||||
construct_runtime! {
|
||||
pub enum Runtime where
|
||||
Block = Block,
|
||||
NodeBlock = primitives::v0::Block,
|
||||
NodeBlock = primitives::v1::Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic
|
||||
{
|
||||
// Basic stuff; balances is uncallable initially.
|
||||
@@ -975,12 +901,11 @@ construct_runtime! {
|
||||
// Claims. Usable initially.
|
||||
Claims: claims::{Module, Call, Storage, Event<T>, Config<T>, ValidateUnsigned},
|
||||
|
||||
// Parachains stuff; slots are disabled (no auctions initially). The rest are safe as they
|
||||
// have no public dispatchables.
|
||||
Parachains: parachains::{Module, Call, Storage, Config, Inherent, Origin},
|
||||
Attestations: attestations::{Module, Call, Storage},
|
||||
Slots: slots::{Module, Call, Storage, Event<T>},
|
||||
Registrar: registrar::{Module, Call, Storage, Event, Config<T>},
|
||||
// Old parachains stuff. All dummies to avoid messing up the transaction indices.
|
||||
DummyParachains: dummy::<Instance0>::{Module, Call},
|
||||
DummyAttestations: dummy::<Instance1>::{Module, Call},
|
||||
DummySlots: dummy::<Instance2>::{Module, Call},
|
||||
DummyRegistrar: dummy::<Instance3>::{Module, Call},
|
||||
|
||||
// Utility module.
|
||||
Utility: pallet_utility::{Module, Call, Event},
|
||||
@@ -1027,8 +952,6 @@ pub type SignedExtra = (
|
||||
frame_system::CheckNonce<Runtime>,
|
||||
frame_system::CheckWeight<Runtime>,
|
||||
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
|
||||
registrar::LimitParathreadCommits<Runtime>,
|
||||
parachains::ValidateDoubleVoteReports<Runtime>,
|
||||
);
|
||||
/// Unchecked extrinsic type as expected by this runtime.
|
||||
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
|
||||
@@ -1108,45 +1031,55 @@ sp_api::impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl parachain::ParachainHost<Block> for Runtime {
|
||||
fn validators() -> Vec<parachain::ValidatorId> {
|
||||
Parachains::authorities()
|
||||
}
|
||||
fn duty_roster() -> parachain::DutyRoster {
|
||||
Parachains::calculate_duty_roster().0
|
||||
}
|
||||
fn active_parachains() -> Vec<(parachain::Id, Option<(parachain::CollatorId, parachain::Retriable)>)> {
|
||||
Registrar::active_paras()
|
||||
}
|
||||
fn global_validation_data() -> parachain::GlobalValidationData {
|
||||
Parachains::global_validation_data()
|
||||
}
|
||||
fn local_validation_data(id: parachain::Id) -> Option<parachain::LocalValidationData> {
|
||||
Parachains::current_local_validation_data(&id)
|
||||
}
|
||||
fn parachain_code(id: parachain::Id) -> Option<parachain::ValidationCode> {
|
||||
Parachains::parachain_code(&id)
|
||||
}
|
||||
fn get_heads(extrinsics: Vec<<Block as BlockT>::Extrinsic>)
|
||||
-> Option<Vec<AbridgedCandidateReceipt>>
|
||||
{
|
||||
extrinsics
|
||||
// Dummy implementation to continue supporting old parachains runtime temporarily.
|
||||
impl p_v0::ParachainHost<Block> for Runtime {
|
||||
fn validators() -> Vec<p_v0::ValidatorId> {
|
||||
// this is a compile-time check of size equality. note that we don't invoke
|
||||
// the function and nothing here is unsafe.
|
||||
let _ = core::mem::transmute::<p_v0::ValidatorId, AccountId>;
|
||||
|
||||
// Yes, these aren't actually the parachain session keys.
|
||||
// It doesn't matter, but we shouldn't return a zero-sized vector here.
|
||||
// As there are no parachains
|
||||
Session::validators()
|
||||
.into_iter()
|
||||
.find_map(|ex| match UncheckedExtrinsic::decode(&mut ex.encode().as_slice()) {
|
||||
Ok(ex) => match ex.function {
|
||||
Call::Parachains(ParachainsCall::set_heads(heads)) => {
|
||||
Some(heads.into_iter().map(|c| c.candidate).collect())
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
Err(_) => None,
|
||||
})
|
||||
.map(|k| k.using_encoded(|s| Decode::decode(&mut &s[..]))
|
||||
.expect("correct size and raw-bytes; qed"))
|
||||
.collect()
|
||||
}
|
||||
fn signing_context() -> SigningContext {
|
||||
Parachains::signing_context()
|
||||
fn duty_roster() -> p_v0::DutyRoster {
|
||||
let v = Session::validators();
|
||||
p_v0::DutyRoster { validator_duty: (0..v.len()).map(|_| p_v0::Chain::Relay).collect() }
|
||||
}
|
||||
fn downward_messages(id: parachain::Id) -> Vec<primitives::v0::DownwardMessage> {
|
||||
Parachains::downward_messages(id)
|
||||
fn active_parachains() -> Vec<(p_v0::Id, Option<(p_v0::CollatorId, p_v0::Retriable)>)> {
|
||||
Vec::new()
|
||||
}
|
||||
fn global_validation_data() -> p_v0::GlobalValidationData {
|
||||
p_v0::GlobalValidationData {
|
||||
max_code_size: 1,
|
||||
max_head_data_size: 1,
|
||||
block_number: System::block_number().saturating_sub(1),
|
||||
}
|
||||
}
|
||||
fn local_validation_data(_id: p_v0::Id) -> Option<p_v0::LocalValidationData> {
|
||||
None
|
||||
}
|
||||
fn parachain_code(_id: p_v0::Id) -> Option<p_v0::ValidationCode> {
|
||||
None
|
||||
}
|
||||
fn get_heads(_extrinsics: Vec<<Block as BlockT>::Extrinsic>)
|
||||
-> Option<Vec<p_v0::AbridgedCandidateReceipt>>
|
||||
{
|
||||
None
|
||||
}
|
||||
fn signing_context() -> p_v0::SigningContext {
|
||||
p_v0::SigningContext {
|
||||
parent_hash: System::parent_hash(),
|
||||
session_index: Session::current_index(),
|
||||
}
|
||||
}
|
||||
fn downward_messages(_id: p_v0::Id) -> Vec<p_v0::DownwardMessage> {
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,21 +21,20 @@
|
||||
#![recursion_limit="256"]
|
||||
|
||||
use runtime_common::{
|
||||
attestations, claims, parachains, registrar, slots, SlowAdjustingFeeUpdate,
|
||||
dummy, claims, SlowAdjustingFeeUpdate,
|
||||
impls::{CurrencyToVoteHandler, ToAuthor},
|
||||
NegativeImbalance, BlockHashCount, MaximumBlockWeight, AvailableBlockRatio,
|
||||
MaximumBlockLength, BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight,
|
||||
MaximumExtrinsicWeight, purchase,
|
||||
MaximumExtrinsicWeight, purchase, ParachainSessionKeyPlaceholder,
|
||||
};
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use sp_core::u32_trait::{_1, _2, _3, _4, _5};
|
||||
use codec::{Encode, Decode};
|
||||
use primitives::v0::{
|
||||
self as parachain,
|
||||
use primitives::v1::{
|
||||
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, Signature, Moment,
|
||||
ActiveParas, AbridgedCandidateReceipt, SigningContext,
|
||||
};
|
||||
use primitives::v0 as p_v0;
|
||||
use sp_runtime::{create_runtime_str, generic, impl_opaque_keys, ModuleId, ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, transaction_validity::{
|
||||
TransactionValidity, TransactionSource, TransactionPriority,
|
||||
}, curve::PiecewiseLinear, traits::{
|
||||
@@ -68,8 +67,6 @@ pub use pallet_staking::StakerStatus;
|
||||
pub use sp_runtime::BuildStorage;
|
||||
pub use pallet_timestamp::Call as TimestampCall;
|
||||
pub use pallet_balances::Call as BalancesCall;
|
||||
pub use attestations::{Call as AttestationsCall, MORE_ATTESTATIONS_IDENTIFIER};
|
||||
pub use parachains::Call as ParachainsCall;
|
||||
|
||||
/// Constant values used within the runtime.
|
||||
pub mod constants;
|
||||
@@ -89,7 +86,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("polkadot"),
|
||||
impl_name: create_runtime_str!("parity-polkadot"),
|
||||
authoring_version: 0,
|
||||
spec_version: 22,
|
||||
spec_version: 23,
|
||||
impl_version: 0,
|
||||
#[cfg(not(feature = "disable-runtime-api"))]
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
@@ -111,10 +108,8 @@ pub struct BaseFilter;
|
||||
impl Filter<Call> for BaseFilter {
|
||||
fn filter(call: &Call) -> bool {
|
||||
match call {
|
||||
Call::Parachains(parachains::Call::set_heads(..)) => true,
|
||||
|
||||
// Parachains stuff
|
||||
Call::Parachains(_) | Call::Attestations(_) | Call::Slots(_) | Call::Registrar(_) =>
|
||||
Call::DummyParachains(_) | Call::DummyAttestations(_) | Call::DummySlots(_) | Call::DummyRegistrar(_) =>
|
||||
false,
|
||||
|
||||
// These modules are all allowed to be called by transactions:
|
||||
@@ -281,7 +276,7 @@ impl_opaque_keys! {
|
||||
pub grandpa: Grandpa,
|
||||
pub babe: Babe,
|
||||
pub im_online: ImOnline,
|
||||
pub parachain_validator: Parachains,
|
||||
pub parachain_validator: ParachainSessionKeyPlaceholder<Runtime>,
|
||||
pub authority_discovery: AuthorityDiscovery,
|
||||
}
|
||||
}
|
||||
@@ -632,48 +627,6 @@ impl pallet_finality_tracker::Trait for Runtime {
|
||||
type ReportLatency = ReportLatency;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const AttestationPeriod: BlockNumber = 50;
|
||||
}
|
||||
|
||||
impl attestations::Trait for Runtime {
|
||||
type AttestationPeriod = AttestationPeriod;
|
||||
type ValidatorIdentities = parachains::ValidatorIdentities<Runtime>;
|
||||
type RewardAttestation = Staking;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const MaxCodeSize: u32 = 10 * 1024 * 1024; // 10 MB
|
||||
pub const MaxHeadDataSize: u32 = 20 * 1024; // 20 KB
|
||||
|
||||
pub const ValidationUpgradeFrequency: BlockNumber = 7 * DAYS;
|
||||
pub const ValidationUpgradeDelay: BlockNumber = 1 * DAYS;
|
||||
pub const SlashPeriod: BlockNumber = 28 * DAYS;
|
||||
}
|
||||
|
||||
impl parachains::Trait for Runtime {
|
||||
type AuthorityId = primitives::v0::fisherman::FishermanAppCrypto;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
type ParachainCurrency = Balances;
|
||||
type BlockNumberConversion = sp_runtime::traits::Identity;
|
||||
type Randomness = RandomnessCollectiveFlip;
|
||||
type ActiveParachains = Registrar;
|
||||
type Registrar = Registrar;
|
||||
type MaxCodeSize = MaxCodeSize;
|
||||
type MaxHeadDataSize = MaxHeadDataSize;
|
||||
|
||||
type ValidationUpgradeFrequency = ValidationUpgradeFrequency;
|
||||
type ValidationUpgradeDelay = ValidationUpgradeDelay;
|
||||
type SlashPeriod = SlashPeriod;
|
||||
|
||||
type Proof = sp_session::MembershipProof;
|
||||
type KeyOwnerProofSystem = pallet_session::historical::Module<Self>;
|
||||
type IdentificationTuple = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, Vec<u8>)>>::IdentificationTuple;
|
||||
type ReportOffence = Offences;
|
||||
type BlockHashConversion = sp_runtime::traits::Identity;
|
||||
}
|
||||
|
||||
/// Submits a transaction with the node's public and signature type. Adheres to the signed extension
|
||||
/// format of the chain.
|
||||
impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime where
|
||||
@@ -705,8 +658,6 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
|
||||
frame_system::CheckNonce::<Runtime>::from(nonce),
|
||||
frame_system::CheckWeight::<Runtime>::new(),
|
||||
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
|
||||
registrar::LimitParathreadCommits::<Runtime>::new(),
|
||||
parachains::ValidateDoubleVoteReports::<Runtime>::new(),
|
||||
claims::PrevalidateAttests::<Runtime>::new(),
|
||||
);
|
||||
let raw_payload = SignedPayload::new(call, extra).map_err(|e| {
|
||||
@@ -736,30 +687,6 @@ parameter_types! {
|
||||
pub const MaxRetries: u32 = 3;
|
||||
}
|
||||
|
||||
impl registrar::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type Origin = Origin;
|
||||
type Currency = Balances;
|
||||
type ParathreadDeposit = ParathreadDeposit;
|
||||
type SwapAux = Slots;
|
||||
type QueueSize = QueueSize;
|
||||
type MaxRetries = MaxRetries;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const LeasePeriod: BlockNumber = 100_000;
|
||||
pub const EndingPeriod: BlockNumber = 1000;
|
||||
}
|
||||
|
||||
impl slots::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type Currency = Balances;
|
||||
type Parachains = Registrar;
|
||||
type EndingPeriod = EndingPeriod;
|
||||
type LeasePeriod = LeasePeriod;
|
||||
type Randomness = RandomnessCollectiveFlip;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub Prefix: &'static [u8] = b"Pay DOTs to the Polkadot account:";
|
||||
}
|
||||
@@ -816,6 +743,8 @@ parameter_types! {
|
||||
pub const MaxProxies: u16 = 32;
|
||||
}
|
||||
|
||||
impl<I: frame_support::traits::Instance> dummy::Trait<I> for Runtime { }
|
||||
|
||||
/// The type used to represent the kinds of proxying allowed.
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug)]
|
||||
pub enum ProxyType {
|
||||
@@ -885,10 +814,10 @@ impl InstanceFilter<Call> for ProxyType {
|
||||
Call::ElectionsPhragmen(..) |
|
||||
Call::TechnicalMembership(..) |
|
||||
Call::Treasury(..) |
|
||||
Call::Parachains(..) |
|
||||
Call::Attestations(..) |
|
||||
Call::Slots(..) |
|
||||
Call::Registrar(..) |
|
||||
Call::DummyParachains(..) |
|
||||
Call::DummyAttestations(..) |
|
||||
Call::DummySlots(..) |
|
||||
Call::DummyRegistrar(..) |
|
||||
Call::Claims(..) |
|
||||
Call::Vesting(pallet_vesting::Call::vest(..)) |
|
||||
Call::Vesting(pallet_vesting::Call::vest_other(..)) |
|
||||
@@ -1083,7 +1012,7 @@ impl purchase::Trait for Runtime {
|
||||
construct_runtime! {
|
||||
pub enum Runtime where
|
||||
Block = Block,
|
||||
NodeBlock = primitives::v0::Block,
|
||||
NodeBlock = primitives::v1::Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic
|
||||
{
|
||||
// Basic stuff; balances is uncallable initially.
|
||||
@@ -1118,13 +1047,11 @@ construct_runtime! {
|
||||
TechnicalMembership: pallet_membership::<Instance1>::{Module, Call, Storage, Event<T>, Config<T>},
|
||||
Treasury: pallet_treasury::{Module, Call, Storage, Event<T>},
|
||||
|
||||
// Parachains stuff; slots are disabled (no auctions initially). The rest are safe as they
|
||||
// have no public dispatchables. Disabled `Call` on all of them, but this should be
|
||||
// uncommented once we're ready to start parachains.
|
||||
Parachains: parachains::{Module, Call, Storage, Config, Inherent, Origin},
|
||||
Attestations: attestations::{Module, Call, Storage},
|
||||
Slots: slots::{Module, Call, Storage, Event<T>},
|
||||
Registrar: registrar::{Module, Call, Storage, Event, Config<T>},
|
||||
// Old parachains stuff. All dummies to avoid messing up the transaction indices.
|
||||
DummyParachains: dummy::<Instance0>::{Module, Call},
|
||||
DummyAttestations: dummy::<Instance1>::{Module, Call},
|
||||
DummySlots: dummy::<Instance2>::{Module, Call},
|
||||
DummyRegistrar: dummy::<Instance3>::{Module, Call},
|
||||
|
||||
// Claims. Usable initially.
|
||||
Claims: claims::{Module, Call, Storage, Event<T>, Config<T>, ValidateUnsigned},
|
||||
@@ -1166,8 +1093,6 @@ pub type SignedExtra = (
|
||||
frame_system::CheckNonce<Runtime>,
|
||||
frame_system::CheckWeight<Runtime>,
|
||||
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
|
||||
registrar::LimitParathreadCommits<Runtime>,
|
||||
parachains::ValidateDoubleVoteReports<Runtime>,
|
||||
claims::PrevalidateAttests<Runtime>,
|
||||
);
|
||||
/// Unchecked extrinsic type as expected by this runtime.
|
||||
@@ -1247,46 +1172,55 @@ sp_api::impl_runtime_apis! {
|
||||
Executive::offchain_worker(header)
|
||||
}
|
||||
}
|
||||
// Dummy implementation to continue supporting old parachains runtime temporarily.
|
||||
impl p_v0::ParachainHost<Block> for Runtime {
|
||||
fn validators() -> Vec<p_v0::ValidatorId> {
|
||||
// this is a compile-time check of size equality. note that we don't invoke
|
||||
// the function and nothing here is unsafe.
|
||||
let _ = core::mem::transmute::<p_v0::ValidatorId, AccountId>;
|
||||
|
||||
impl parachain::ParachainHost<Block> for Runtime {
|
||||
fn validators() -> Vec<parachain::ValidatorId> {
|
||||
Parachains::authorities()
|
||||
}
|
||||
fn duty_roster() -> parachain::DutyRoster {
|
||||
Parachains::calculate_duty_roster().0
|
||||
}
|
||||
fn active_parachains() -> Vec<(parachain::Id, Option<(parachain::CollatorId, parachain::Retriable)>)> {
|
||||
Registrar::active_paras()
|
||||
}
|
||||
fn global_validation_data() -> parachain::GlobalValidationData {
|
||||
Parachains::global_validation_data()
|
||||
}
|
||||
fn local_validation_data(id: parachain::Id) -> Option<parachain::LocalValidationData> {
|
||||
Parachains::current_local_validation_data(&id)
|
||||
}
|
||||
fn parachain_code(id: parachain::Id) -> Option<parachain::ValidationCode> {
|
||||
Parachains::parachain_code(&id)
|
||||
}
|
||||
fn get_heads(extrinsics: Vec<<Block as BlockT>::Extrinsic>)
|
||||
-> Option<Vec<AbridgedCandidateReceipt>>
|
||||
{
|
||||
extrinsics
|
||||
// Yes, these aren't actually the parachain session keys.
|
||||
// It doesn't matter, but we shouldn't return a zero-sized vector here.
|
||||
// As there are no parachains
|
||||
Session::validators()
|
||||
.into_iter()
|
||||
.find_map(|ex| match UncheckedExtrinsic::decode(&mut ex.encode().as_slice()) {
|
||||
Ok(ex) => match ex.function {
|
||||
Call::Parachains(ParachainsCall::set_heads(heads)) => {
|
||||
Some(heads.into_iter().map(|c| c.candidate).collect())
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
Err(_) => None,
|
||||
})
|
||||
.map(|k| k.using_encoded(|s| Decode::decode(&mut &s[..]))
|
||||
.expect("correct size and raw-bytes; qed"))
|
||||
.collect()
|
||||
}
|
||||
fn signing_context() -> SigningContext {
|
||||
Parachains::signing_context()
|
||||
fn duty_roster() -> p_v0::DutyRoster {
|
||||
let v = Session::validators();
|
||||
p_v0::DutyRoster { validator_duty: (0..v.len()).map(|_| p_v0::Chain::Relay).collect() }
|
||||
}
|
||||
fn downward_messages(id: parachain::Id) -> Vec<primitives::v0::DownwardMessage> {
|
||||
Parachains::downward_messages(id)
|
||||
fn active_parachains() -> Vec<(p_v0::Id, Option<(p_v0::CollatorId, p_v0::Retriable)>)> {
|
||||
Vec::new()
|
||||
}
|
||||
fn global_validation_data() -> p_v0::GlobalValidationData {
|
||||
p_v0::GlobalValidationData {
|
||||
max_code_size: 1,
|
||||
max_head_data_size: 1,
|
||||
block_number: System::block_number().saturating_sub(1),
|
||||
}
|
||||
}
|
||||
fn local_validation_data(_id: p_v0::Id) -> Option<p_v0::LocalValidationData> {
|
||||
None
|
||||
}
|
||||
fn parachain_code(_id: p_v0::Id) -> Option<p_v0::ValidationCode> {
|
||||
None
|
||||
}
|
||||
fn get_heads(_extrinsics: Vec<<Block as BlockT>::Extrinsic>)
|
||||
-> Option<Vec<p_v0::AbridgedCandidateReceipt>>
|
||||
{
|
||||
None
|
||||
}
|
||||
fn signing_context() -> p_v0::SigningContext {
|
||||
p_v0::SigningContext {
|
||||
parent_hash: System::parent_hash(),
|
||||
session_index: Session::current_index(),
|
||||
}
|
||||
}
|
||||
fn downward_messages(_id: p_v0::Id) -> Vec<p_v0::DownwardMessage> {
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,176 +0,0 @@
|
||||
[package]
|
||||
name = "rococo-runtime"
|
||||
version = "0.8.22"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
bitvec = { version = "0.17.4", default-features = false, features = ["alloc"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false, features = ["derive"] }
|
||||
log = { version = "0.3.9", optional = true }
|
||||
rustc-hex = { version = "2.0.1", default-features = false }
|
||||
serde = { version = "1.0.102", default-features = false }
|
||||
serde_derive = { version = "1.0.102", optional = true }
|
||||
static_assertions = "1.1.0"
|
||||
smallvec = "1.4.1"
|
||||
|
||||
authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
sp-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
tx-pool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
block-builder-api = { package = "sp-block-builder", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
|
||||
pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-collective = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-democracy = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
frame-executive = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-finality-tracker = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-identity = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-membership = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-multisig = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-nicks = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-offences = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-proxy = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-recovery = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-scheduler = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-staking-reward-curve = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
frame-system = {git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
|
||||
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
|
||||
frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
|
||||
pallet-offences-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
|
||||
pallet-session-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
|
||||
hex-literal = { version = "0.2.1" }
|
||||
|
||||
runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false }
|
||||
primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false }
|
||||
polkadot-parachain = { path = "../../parachain", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
hex-literal = "0.2.1"
|
||||
libsecp256k1 = "0.3.2"
|
||||
tiny-keccak = "1.5.0"
|
||||
keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
serde_json = "1.0.41"
|
||||
|
||||
[build-dependencies]
|
||||
wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.6" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
no_std = []
|
||||
only-staking = []
|
||||
std = [
|
||||
"authority-discovery-primitives/std",
|
||||
"pallet-authority-discovery/std",
|
||||
"bitvec/std",
|
||||
"primitives/std",
|
||||
"rustc-hex/std",
|
||||
"codec/std",
|
||||
"inherents/std",
|
||||
"sp-core/std",
|
||||
"polkadot-parachain/std",
|
||||
"sp-api/std",
|
||||
"tx-pool-api/std",
|
||||
"block-builder-api/std",
|
||||
"offchain-primitives/std",
|
||||
"sp-std/std",
|
||||
"sp-io/std",
|
||||
"frame-support/std",
|
||||
"pallet-authorship/std",
|
||||
"pallet-balances/std",
|
||||
"pallet-transaction-payment/std",
|
||||
"pallet-transaction-payment-rpc-runtime-api/std",
|
||||
"pallet-collective/std",
|
||||
"pallet-elections-phragmen/std",
|
||||
"pallet-democracy/std",
|
||||
"frame-executive/std",
|
||||
"pallet-finality-tracker/std",
|
||||
"pallet-grandpa/std",
|
||||
"pallet-identity/std",
|
||||
"pallet-im-online/std",
|
||||
"pallet-indices/std",
|
||||
"pallet-membership/std",
|
||||
"pallet-multisig/std",
|
||||
"pallet-nicks/std",
|
||||
"pallet-offences/std",
|
||||
"pallet-proxy/std",
|
||||
"pallet-recovery/std",
|
||||
"sp-runtime/std",
|
||||
"pallet-scheduler/std",
|
||||
"pallet-session/std",
|
||||
"pallet-staking/std",
|
||||
"pallet-sudo/std",
|
||||
"frame-system/std",
|
||||
"frame-system-rpc-runtime-api/std",
|
||||
"pallet-timestamp/std",
|
||||
"pallet-treasury/std",
|
||||
"sp-version/std",
|
||||
"serde_derive",
|
||||
"serde/std",
|
||||
"log",
|
||||
"pallet-babe/std",
|
||||
"babe-primitives/std",
|
||||
"sp-session/std",
|
||||
"pallet-randomness-collective-flip/std",
|
||||
"runtime-common/std",
|
||||
"pallet-vesting/std",
|
||||
"pallet-utility/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"runtime-common/runtime-benchmarks",
|
||||
"frame-benchmarking",
|
||||
"frame-support/runtime-benchmarks",
|
||||
"frame-system-benchmarking",
|
||||
"frame-system/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"pallet-balances/runtime-benchmarks",
|
||||
"pallet-collective/runtime-benchmarks",
|
||||
"pallet-democracy/runtime-benchmarks",
|
||||
"pallet-elections-phragmen/runtime-benchmarks",
|
||||
"pallet-im-online/runtime-benchmarks",
|
||||
"pallet-scheduler/runtime-benchmarks",
|
||||
"pallet-staking/runtime-benchmarks",
|
||||
"pallet-timestamp/runtime-benchmarks",
|
||||
"pallet-treasury/runtime-benchmarks",
|
||||
"pallet-vesting/runtime-benchmarks",
|
||||
"pallet-offences-benchmarking",
|
||||
"pallet-session-benchmarking",
|
||||
# uncomment when it is made optional again
|
||||
# "hex-literal",
|
||||
]
|
||||
# When enabled, the runtime api will not be build.
|
||||
#
|
||||
# This is required by Cumulus to access certain types of the
|
||||
# runtime without clashing with the runtime api exported functions
|
||||
# in WASM.
|
||||
disable-runtime-api = []
|
||||
@@ -1,26 +0,0 @@
|
||||
// Copyright 2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Substrate is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Substrate is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use wasm_builder_runner::WasmBuilder;
|
||||
|
||||
fn main() {
|
||||
WasmBuilder::new()
|
||||
.with_current_project()
|
||||
.with_wasm_builder_from_crates("2.0.0")
|
||||
.import_memory()
|
||||
.export_heap_base()
|
||||
.build()
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
// Copyright 2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/// Money matters.
|
||||
pub mod currency {
|
||||
use primitives::v0::Balance;
|
||||
|
||||
pub const DOTS: Balance = 1_000_000_000_000;
|
||||
pub const DOLLARS: Balance = DOTS;
|
||||
pub const CENTS: Balance = DOLLARS / 100;
|
||||
pub const MILLICENTS: Balance = CENTS / 1_000;
|
||||
|
||||
pub const fn deposit(items: u32, bytes: u32) -> Balance {
|
||||
items as Balance * 1 * DOLLARS + (bytes as Balance) * 5 * MILLICENTS
|
||||
}
|
||||
}
|
||||
|
||||
/// Time and blocks.
|
||||
pub mod time {
|
||||
use primitives::v0::{Moment, BlockNumber};
|
||||
pub const MILLISECS_PER_BLOCK: Moment = 6000;
|
||||
pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK;
|
||||
pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 1 * HOURS;
|
||||
|
||||
// These time units are defined in number of blocks.
|
||||
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
|
||||
pub const HOURS: BlockNumber = MINUTES * 60;
|
||||
pub const DAYS: BlockNumber = HOURS * 24;
|
||||
|
||||
// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks.
|
||||
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
|
||||
}
|
||||
|
||||
/// Fee-related.
|
||||
pub mod fee {
|
||||
pub use sp_runtime::Perbill;
|
||||
use primitives::v0::Balance;
|
||||
use runtime_common::ExtrinsicBaseWeight;
|
||||
use frame_support::weights::{
|
||||
WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,
|
||||
};
|
||||
use smallvec::smallvec;
|
||||
|
||||
/// The block saturation level. Fees will be updates based on this value.
|
||||
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
|
||||
|
||||
/// Handles converting a weight scalar to a fee value, based on the scale and granularity of the
|
||||
/// node's balance type.
|
||||
///
|
||||
/// This should typically create a mapping between the following ranges:
|
||||
/// - [0, frame_system::MaximumBlockWeight]
|
||||
/// - [Balance::min, Balance::max]
|
||||
///
|
||||
/// Yet, it can be used for any other sort of change to weight-fee. Some examples being:
|
||||
/// - Setting it to `0` will essentially disable the weight fee.
|
||||
/// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged.
|
||||
pub struct WeightToFee;
|
||||
impl WeightToFeePolynomial for WeightToFee {
|
||||
type Balance = Balance;
|
||||
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
|
||||
// in Westend, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT:
|
||||
let p = super::currency::CENTS;
|
||||
let q = 10 * Balance::from(ExtrinsicBaseWeight::get());
|
||||
smallvec![WeightToFeeCoefficient {
|
||||
degree: 1,
|
||||
negative: false,
|
||||
coeff_frac: Perbill::from_rational_approximation(p % q, q),
|
||||
coeff_integer: p / q,
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use frame_support::weights::WeightToFeePolynomial;
|
||||
use runtime_common::{MaximumBlockWeight, ExtrinsicBaseWeight};
|
||||
use super::fee::WeightToFee;
|
||||
use super::currency::{CENTS, DOLLARS, MILLICENTS};
|
||||
|
||||
#[test]
|
||||
// This function tests that the fee for `MaximumBlockWeight` of weight is correct
|
||||
fn full_block_fee_is_correct() {
|
||||
// A full block should cost 16 DOLLARS
|
||||
println!("Base: {}", ExtrinsicBaseWeight::get());
|
||||
let x = WeightToFee::calc(&MaximumBlockWeight::get());
|
||||
let y = 16 * DOLLARS;
|
||||
assert!(x.max(y) - x.min(y) < MILLICENTS);
|
||||
}
|
||||
|
||||
#[test]
|
||||
// This function tests that the fee for `ExtrinsicBaseWeight` of weight is correct
|
||||
fn extrinsic_base_fee_is_correct() {
|
||||
// `ExtrinsicBaseWeight` should cost 1/10 of a CENT
|
||||
println!("Base: {}", ExtrinsicBaseWeight::get());
|
||||
let x = WeightToFee::calc(&ExtrinsicBaseWeight::get());
|
||||
let y = CENTS / 10;
|
||||
assert!(x.max(y) - x.min(y) < MILLICENTS);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -326,20 +326,13 @@ pub fn new_native_executor() -> sc_executor::NativeExecutor<LocalExecutor> {
|
||||
/// The index of the block must be provided to calculate a valid timestamp for the block. The value starts at 0 and
|
||||
/// should be incremented by one for every block produced.
|
||||
pub fn needed_extrinsics(
|
||||
heads: Vec<polkadot_primitives::v0::AttestedCandidate>,
|
||||
i: u64,
|
||||
) -> Vec<polkadot_test_runtime::UncheckedExtrinsic> {
|
||||
use polkadot_runtime_common::parachains;
|
||||
|
||||
let timestamp = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH)
|
||||
.expect("now always later than unix epoch; qed")
|
||||
.as_millis() + (i * polkadot_test_runtime::constants::time::SLOT_DURATION / 2) as u128;
|
||||
|
||||
vec![
|
||||
polkadot_test_runtime::UncheckedExtrinsic {
|
||||
function: polkadot_test_runtime::Call::Parachains(parachains::Call::set_heads(heads)),
|
||||
signature: None,
|
||||
},
|
||||
polkadot_test_runtime::UncheckedExtrinsic {
|
||||
function: polkadot_test_runtime::Call::Timestamp(pallet_timestamp::Call::set(
|
||||
u64::try_from(timestamp).expect("unexpected big timestamp"),
|
||||
|
||||
@@ -22,27 +22,25 @@
|
||||
|
||||
use rstd::prelude::*;
|
||||
use codec::{Encode, Decode};
|
||||
use primitives::v0::{
|
||||
self as parachain,
|
||||
use primitives::v0 as p_v0;
|
||||
use primitives::v1::{
|
||||
AccountId, AccountIndex, Balance, BlockNumber, Hash as HashT, Nonce, Signature, Moment,
|
||||
ActiveParas, AbridgedCandidateReceipt, SigningContext, ValidityError,
|
||||
};
|
||||
use runtime_common::{
|
||||
attestations, claims, parachains, registrar, slots, SlowAdjustingFeeUpdate,
|
||||
impls::CurrencyToVoteHandler,
|
||||
claims, SlowAdjustingFeeUpdate, impls::CurrencyToVoteHandler,
|
||||
BlockHashCount, MaximumBlockWeight, AvailableBlockRatio,
|
||||
MaximumBlockLength, BlockExecutionWeight, ExtrinsicBaseWeight,
|
||||
MaximumBlockLength, BlockExecutionWeight, ExtrinsicBaseWeight, ParachainSessionKeyPlaceholder,
|
||||
};
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic, impl_opaque_keys,
|
||||
ApplyExtrinsicResult, Perbill, RuntimeDebug, KeyTypeId,
|
||||
ApplyExtrinsicResult, Perbill, KeyTypeId,
|
||||
transaction_validity::{
|
||||
TransactionValidity, InvalidTransaction, TransactionValidityError, TransactionSource, TransactionPriority,
|
||||
TransactionValidity, TransactionSource, TransactionPriority,
|
||||
},
|
||||
curve::PiecewiseLinear,
|
||||
traits::{
|
||||
BlakeTwo256, Block as BlockT, StaticLookup, SignedExtension, OpaqueKeys, ConvertInto,
|
||||
DispatchInfoOf, Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
|
||||
BlakeTwo256, Block as BlockT, StaticLookup, OpaqueKeys, ConvertInto,
|
||||
Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
|
||||
},
|
||||
};
|
||||
use sp_version::RuntimeVersion;
|
||||
@@ -66,8 +64,6 @@ pub use pallet_staking::StakerStatus;
|
||||
pub use sp_runtime::BuildStorage;
|
||||
pub use pallet_timestamp::Call as TimestampCall;
|
||||
pub use pallet_balances::Call as BalancesCall;
|
||||
pub use attestations::{Call as AttestationsCall, MORE_ATTESTATIONS_IDENTIFIER};
|
||||
pub use parachains::Call as ParachainsCall;
|
||||
|
||||
/// Constant values used within the runtime.
|
||||
pub mod constants;
|
||||
@@ -97,35 +93,6 @@ pub fn native_version() -> NativeVersion {
|
||||
}
|
||||
}
|
||||
|
||||
/// Avoid processing transactions from slots and parachain registrar.
|
||||
#[derive(Default, Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug)]
|
||||
pub struct RestrictFunctionality;
|
||||
impl SignedExtension for RestrictFunctionality {
|
||||
const IDENTIFIER: &'static str = "RestrictFunctionality";
|
||||
type AccountId = AccountId;
|
||||
type Call = Call;
|
||||
type AdditionalSigned = ();
|
||||
type Pre = ();
|
||||
|
||||
fn additional_signed(&self) -> rstd::result::Result<(), TransactionValidityError> { Ok(()) }
|
||||
|
||||
fn validate(
|
||||
&self,
|
||||
_: &Self::AccountId,
|
||||
call: &Self::Call,
|
||||
_: &DispatchInfoOf<Self::Call>,
|
||||
_: usize
|
||||
)
|
||||
-> TransactionValidity
|
||||
{
|
||||
match call {
|
||||
Call::Slots(_) | Call::Registrar(_)
|
||||
=> Err(InvalidTransaction::Custom(ValidityError::NoPermission.into()).into()),
|
||||
_ => Ok(Default::default()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const Version: RuntimeVersion = VERSION;
|
||||
}
|
||||
@@ -261,7 +228,7 @@ impl_opaque_keys! {
|
||||
pub struct SessionKeys {
|
||||
pub grandpa: Grandpa,
|
||||
pub babe: Babe,
|
||||
pub parachain_validator: Parachains,
|
||||
pub parachain_validator: ParachainSessionKeyPlaceholder<Runtime>,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,50 +323,6 @@ impl pallet_grandpa::Trait for Runtime {
|
||||
type HandleEquivocation = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const AttestationPeriod: BlockNumber = 50;
|
||||
}
|
||||
|
||||
impl attestations::Trait for Runtime {
|
||||
type AttestationPeriod = AttestationPeriod;
|
||||
type ValidatorIdentities = parachains::ValidatorIdentities<Runtime>;
|
||||
type RewardAttestation = Staking;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub storage MaxCodeSize: u32 = 10 * 1024 * 1024; // 10 MB
|
||||
pub storage MaxHeadDataSize: u32 = 20 * 1024; // 20 KB
|
||||
|
||||
pub storage ValidationUpgradeFrequency: BlockNumber = 2;
|
||||
pub storage ValidationUpgradeDelay: BlockNumber = 1;
|
||||
pub storage SlashPeriod: BlockNumber = 1 * MINUTES;
|
||||
}
|
||||
|
||||
impl parachains::Trait for Runtime {
|
||||
type AuthorityId = primitives::v0::fisherman::FishermanAppCrypto;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
type ParachainCurrency = Balances;
|
||||
type BlockNumberConversion = sp_runtime::traits::Identity;
|
||||
type Randomness = RandomnessCollectiveFlip;
|
||||
type ActiveParachains = Registrar;
|
||||
type Registrar = Registrar;
|
||||
type MaxCodeSize = MaxCodeSize;
|
||||
type MaxHeadDataSize = MaxHeadDataSize;
|
||||
|
||||
type ValidationUpgradeFrequency = ValidationUpgradeFrequency;
|
||||
type ValidationUpgradeDelay = ValidationUpgradeDelay;
|
||||
type SlashPeriod = SlashPeriod;
|
||||
|
||||
type Proof = sp_session::MembershipProof;
|
||||
type KeyOwnerProofSystem = pallet_session::historical::Module<Self>;
|
||||
type IdentificationTuple = <
|
||||
Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, Vec<u8>)>
|
||||
>::IdentificationTuple;
|
||||
type ReportOffence = Offences;
|
||||
type BlockHashConversion = sp_runtime::traits::Identity;
|
||||
}
|
||||
|
||||
impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime where
|
||||
Call: From<LocalCall>,
|
||||
{
|
||||
@@ -419,7 +342,6 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
|
||||
.saturating_sub(1);
|
||||
let tip = 0;
|
||||
let extra: SignedExtra = (
|
||||
RestrictFunctionality,
|
||||
frame_system::CheckSpecVersion::<Runtime>::new(),
|
||||
frame_system::CheckTxVersion::<Runtime>::new(),
|
||||
frame_system::CheckGenesis::<Runtime>::new(),
|
||||
@@ -427,8 +349,6 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
|
||||
frame_system::CheckNonce::<Runtime>::from(nonce),
|
||||
frame_system::CheckWeight::<Runtime>::new(),
|
||||
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
|
||||
registrar::LimitParathreadCommits::<Runtime>::new(),
|
||||
parachains::ValidateDoubleVoteReports::<Runtime>::new(),
|
||||
);
|
||||
let raw_payload = SignedPayload::new(call, extra).map_err(|e| {
|
||||
debug::warn!("Unable to create signed payload: {:?}", e);
|
||||
@@ -461,36 +381,11 @@ impl pallet_offences::Trait for Runtime {
|
||||
|
||||
impl pallet_authority_discovery::Trait for Runtime {}
|
||||
|
||||
parameter_types! {
|
||||
pub storage ParathreadDeposit: Balance = 5 * DOLLARS;
|
||||
pub const QueueSize: usize = 2;
|
||||
pub storage MaxRetries: u32 = 3;
|
||||
}
|
||||
|
||||
impl registrar::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type Origin = Origin;
|
||||
type Currency = Balances;
|
||||
type ParathreadDeposit = ParathreadDeposit;
|
||||
type SwapAux = Slots;
|
||||
type QueueSize = QueueSize;
|
||||
type MaxRetries = MaxRetries;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub storage LeasePeriod: BlockNumber = 100_000;
|
||||
pub storage EndingPeriod: BlockNumber = 1000;
|
||||
}
|
||||
|
||||
impl slots::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type Currency = Balances;
|
||||
type Parachains = Registrar;
|
||||
type LeasePeriod = LeasePeriod;
|
||||
type EndingPeriod = EndingPeriod;
|
||||
type Randomness = RandomnessCollectiveFlip;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub Prefix: &'static [u8] = b"Pay KSMs to the Kusama account:";
|
||||
}
|
||||
@@ -522,7 +417,7 @@ impl pallet_sudo::Trait for Runtime {
|
||||
construct_runtime! {
|
||||
pub enum Runtime where
|
||||
Block = Block,
|
||||
NodeBlock = primitives::v0::Block,
|
||||
NodeBlock = primitives::v1::Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic
|
||||
{
|
||||
// Basic stuff; balances is uncallable initially.
|
||||
@@ -549,13 +444,6 @@ construct_runtime! {
|
||||
// Claims. Usable initially.
|
||||
Claims: claims::{Module, Call, Storage, Event<T>, Config<T>, ValidateUnsigned},
|
||||
|
||||
// Parachains stuff; slots are disabled (no auctions initially). The rest are safe as they
|
||||
// have no public dispatchables.
|
||||
Parachains: parachains::{Module, Call, Storage, Config, Inherent, Origin},
|
||||
Attestations: attestations::{Module, Call, Storage},
|
||||
Slots: slots::{Module, Call, Storage, Event<T>},
|
||||
Registrar: registrar::{Module, Call, Storage, Event, Config<T>},
|
||||
|
||||
// Vesting. Usable initially, but removed once all vesting is finished.
|
||||
Vesting: pallet_vesting::{Module, Call, Storage, Event<T>, Config<T>},
|
||||
|
||||
@@ -576,7 +464,6 @@ pub type SignedBlock = generic::SignedBlock<Block>;
|
||||
pub type BlockId = generic::BlockId<Block>;
|
||||
/// The SignedExtension to the basic transaction logic.
|
||||
pub type SignedExtra = (
|
||||
RestrictFunctionality,
|
||||
frame_system::CheckSpecVersion<Runtime>,
|
||||
frame_system::CheckTxVersion<Runtime>,
|
||||
frame_system::CheckGenesis<Runtime>,
|
||||
@@ -584,8 +471,6 @@ pub type SignedExtra = (
|
||||
frame_system::CheckNonce<Runtime>,
|
||||
frame_system::CheckWeight<Runtime>,
|
||||
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>,
|
||||
registrar::LimitParathreadCommits<Runtime>,
|
||||
parachains::ValidateDoubleVoteReports<Runtime>,
|
||||
);
|
||||
/// Unchecked extrinsic type as expected by this runtime.
|
||||
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
|
||||
@@ -666,45 +551,55 @@ sp_api::impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl parachain::ParachainHost<Block> for Runtime {
|
||||
fn validators() -> Vec<parachain::ValidatorId> {
|
||||
Parachains::authorities()
|
||||
}
|
||||
fn duty_roster() -> parachain::DutyRoster {
|
||||
Parachains::calculate_duty_roster().0
|
||||
}
|
||||
fn active_parachains() -> Vec<(parachain::Id, Option<(parachain::CollatorId, parachain::Retriable)>)> {
|
||||
Registrar::active_paras()
|
||||
}
|
||||
fn global_validation_data() -> parachain::GlobalValidationData {
|
||||
Parachains::global_validation_data()
|
||||
}
|
||||
fn local_validation_data(id: parachain::Id) -> Option<parachain::LocalValidationData> {
|
||||
Parachains::current_local_validation_data(&id)
|
||||
}
|
||||
fn parachain_code(id: parachain::Id) -> Option<parachain::ValidationCode> {
|
||||
Parachains::parachain_code(&id)
|
||||
}
|
||||
fn get_heads(extrinsics: Vec<<Block as BlockT>::Extrinsic>)
|
||||
-> Option<Vec<AbridgedCandidateReceipt>>
|
||||
{
|
||||
extrinsics
|
||||
// Dummy implementation to continue supporting old parachains runtime temporarily.
|
||||
impl p_v0::ParachainHost<Block> for Runtime {
|
||||
fn validators() -> Vec<p_v0::ValidatorId> {
|
||||
// this is a compile-time check of size equality. note that we don't invoke
|
||||
// the function and nothing here is unsafe.
|
||||
let _ = core::mem::transmute::<p_v0::ValidatorId, AccountId>;
|
||||
|
||||
// Yes, these aren't actually the parachain session keys.
|
||||
// It doesn't matter, but we shouldn't return a zero-sized vector here.
|
||||
// As there are no parachains
|
||||
Session::validators()
|
||||
.into_iter()
|
||||
.find_map(|ex| match UncheckedExtrinsic::decode(&mut ex.encode().as_slice()) {
|
||||
Ok(ex) => match ex.function {
|
||||
Call::Parachains(ParachainsCall::set_heads(heads)) => {
|
||||
Some(heads.into_iter().map(|c| c.candidate).collect())
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
Err(_) => None,
|
||||
})
|
||||
.map(|k| k.using_encoded(|s| Decode::decode(&mut &s[..]))
|
||||
.expect("correct size and raw-bytes; qed"))
|
||||
.collect()
|
||||
}
|
||||
fn signing_context() -> SigningContext {
|
||||
Parachains::signing_context()
|
||||
fn duty_roster() -> p_v0::DutyRoster {
|
||||
let v = Session::validators();
|
||||
p_v0::DutyRoster { validator_duty: (0..v.len()).map(|_| p_v0::Chain::Relay).collect() }
|
||||
}
|
||||
fn downward_messages(id: parachain::Id) -> Vec<primitives::v0::DownwardMessage> {
|
||||
Parachains::downward_messages(id)
|
||||
fn active_parachains() -> Vec<(p_v0::Id, Option<(p_v0::CollatorId, p_v0::Retriable)>)> {
|
||||
Vec::new()
|
||||
}
|
||||
fn global_validation_data() -> p_v0::GlobalValidationData {
|
||||
p_v0::GlobalValidationData {
|
||||
max_code_size: 1,
|
||||
max_head_data_size: 1,
|
||||
block_number: System::block_number().saturating_sub(1),
|
||||
}
|
||||
}
|
||||
fn local_validation_data(_id: p_v0::Id) -> Option<p_v0::LocalValidationData> {
|
||||
None
|
||||
}
|
||||
fn parachain_code(_id: p_v0::Id) -> Option<p_v0::ValidationCode> {
|
||||
None
|
||||
}
|
||||
fn get_heads(_extrinsics: Vec<<Block as BlockT>::Extrinsic>)
|
||||
-> Option<Vec<p_v0::AbridgedCandidateReceipt>>
|
||||
{
|
||||
None
|
||||
}
|
||||
fn signing_context() -> p_v0::SigningContext {
|
||||
p_v0::SigningContext {
|
||||
parent_hash: System::parent_hash(),
|
||||
session_index: Session::current_index(),
|
||||
}
|
||||
}
|
||||
fn downward_messages(_id: p_v0::Id) -> Vec<p_v0::DownwardMessage> {
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,16 +22,16 @@
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use codec::{Encode, Decode};
|
||||
use primitives::v0::{
|
||||
self as parachain,
|
||||
use primitives::v1::{
|
||||
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, Signature, Moment,
|
||||
ActiveParas, AbridgedCandidateReceipt, SigningContext,
|
||||
};
|
||||
use primitives::v0 as p_v0;
|
||||
use runtime_common::{
|
||||
attestations, parachains, registrar, purchase, SlowAdjustingFeeUpdate,
|
||||
dummy, purchase, SlowAdjustingFeeUpdate,
|
||||
impls::{CurrencyToVoteHandler, ToAuthor},
|
||||
BlockHashCount, MaximumBlockWeight, AvailableBlockRatio, MaximumBlockLength,
|
||||
BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, MaximumExtrinsicWeight,
|
||||
ParachainSessionKeyPlaceholder,
|
||||
};
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic, impl_opaque_keys,
|
||||
@@ -67,8 +67,6 @@ pub use pallet_staking::StakerStatus;
|
||||
pub use sp_runtime::BuildStorage;
|
||||
pub use pallet_timestamp::Call as TimestampCall;
|
||||
pub use pallet_balances::Call as BalancesCall;
|
||||
pub use attestations::{Call as AttestationsCall, MORE_ATTESTATIONS_IDENTIFIER};
|
||||
pub use parachains::Call as ParachainsCall;
|
||||
|
||||
/// Constant values used within the runtime.
|
||||
pub mod constants;
|
||||
@@ -86,7 +84,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("westend"),
|
||||
impl_name: create_runtime_str!("parity-westend"),
|
||||
authoring_version: 2,
|
||||
spec_version: 42,
|
||||
spec_version: 43,
|
||||
impl_version: 0,
|
||||
#[cfg(not(feature = "disable-runtime-api"))]
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
@@ -104,11 +102,11 @@ pub fn native_version() -> NativeVersion {
|
||||
}
|
||||
}
|
||||
|
||||
/// Avoid processing transactions from slots and parachain registrar.
|
||||
/// Accept all transactions.
|
||||
pub struct BaseFilter;
|
||||
impl Filter<Call> for BaseFilter {
|
||||
fn filter(call: &Call) -> bool {
|
||||
!matches!(call, Call::Registrar(_))
|
||||
fn filter(_: &Call) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +249,7 @@ impl_opaque_keys! {
|
||||
pub grandpa: Grandpa,
|
||||
pub babe: Babe,
|
||||
pub im_online: ImOnline,
|
||||
pub parachain_validator: Parachains,
|
||||
pub parachain_validator: ParachainSessionKeyPlaceholder<Runtime>,
|
||||
pub authority_discovery: AuthorityDiscovery,
|
||||
}
|
||||
}
|
||||
@@ -401,47 +399,6 @@ impl pallet_finality_tracker::Trait for Runtime {
|
||||
type ReportLatency = ReportLatency;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const AttestationPeriod: BlockNumber = 50;
|
||||
}
|
||||
|
||||
impl attestations::Trait for Runtime {
|
||||
type AttestationPeriod = AttestationPeriod;
|
||||
type ValidatorIdentities = parachains::ValidatorIdentities<Runtime>;
|
||||
type RewardAttestation = Staking;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const MaxCodeSize: u32 = 10 * 1024 * 1024; // 10 MB
|
||||
pub const MaxHeadDataSize: u32 = 20 * 1024; // 20 KB
|
||||
pub const ValidationUpgradeFrequency: BlockNumber = 2 * DAYS;
|
||||
pub const ValidationUpgradeDelay: BlockNumber = 8 * HOURS;
|
||||
pub const SlashPeriod: BlockNumber = 7 * DAYS;
|
||||
}
|
||||
|
||||
impl parachains::Trait for Runtime {
|
||||
type AuthorityId = primitives::v0::fisherman::FishermanAppCrypto;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
type ParachainCurrency = Balances;
|
||||
type BlockNumberConversion = sp_runtime::traits::Identity;
|
||||
type Randomness = RandomnessCollectiveFlip;
|
||||
type ActiveParachains = Registrar;
|
||||
type Registrar = Registrar;
|
||||
type MaxCodeSize = MaxCodeSize;
|
||||
type MaxHeadDataSize = MaxHeadDataSize;
|
||||
|
||||
type ValidationUpgradeFrequency = ValidationUpgradeFrequency;
|
||||
type ValidationUpgradeDelay = ValidationUpgradeDelay;
|
||||
type SlashPeriod = SlashPeriod;
|
||||
|
||||
type Proof = sp_session::MembershipProof;
|
||||
type KeyOwnerProofSystem = pallet_session::historical::Module<Self>;
|
||||
type IdentificationTuple = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, Vec<u8>)>>::IdentificationTuple;
|
||||
type ReportOffence = Offences;
|
||||
type BlockHashConversion = sp_runtime::traits::Identity;
|
||||
}
|
||||
|
||||
/// Submits a transaction with the node's public and signature type. Adheres to the signed extension
|
||||
/// format of the chain.
|
||||
impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime where
|
||||
@@ -473,8 +430,6 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
|
||||
frame_system::CheckNonce::<Runtime>::from(nonce),
|
||||
frame_system::CheckWeight::<Runtime>::new(),
|
||||
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
|
||||
registrar::LimitParathreadCommits::<Runtime>::new(),
|
||||
parachains::ValidateDoubleVoteReports::<Runtime>::new(),
|
||||
);
|
||||
let raw_payload = SignedPayload::new(call, extra).map_err(|e| {
|
||||
debug::warn!("Unable to create signed payload: {:?}", e);
|
||||
@@ -499,22 +454,6 @@ impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime where
|
||||
type Extrinsic = UncheckedExtrinsic;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ParathreadDeposit: Balance = 5 * DOLLARS;
|
||||
pub const QueueSize: usize = 2;
|
||||
pub const MaxRetries: u32 = 3;
|
||||
}
|
||||
|
||||
impl registrar::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type Origin = Origin;
|
||||
type Currency = Balances;
|
||||
type ParathreadDeposit = ParathreadDeposit;
|
||||
type SwapAux = ();
|
||||
type QueueSize = QueueSize;
|
||||
type MaxRetries = MaxRetries;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
// Minimum 100 bytes/KSM deposited (1 CENT/byte)
|
||||
pub const BasicDeposit: Balance = 10 * DOLLARS; // 258 bytes on-chain
|
||||
@@ -637,9 +576,9 @@ impl InstanceFilter<Call> for ProxyType {
|
||||
Call::Grandpa(..) |
|
||||
Call::ImOnline(..) |
|
||||
Call::AuthorityDiscovery(..) |
|
||||
Call::Parachains(..) |
|
||||
Call::Attestations(..) |
|
||||
Call::Registrar(..) |
|
||||
Call::DummyParachains(..) |
|
||||
Call::DummyAttestations(..) |
|
||||
Call::DummyRegistrar(..) |
|
||||
Call::Utility(..) |
|
||||
Call::Identity(..) |
|
||||
Call::Recovery(pallet_recovery::Call::as_recovered(..)) |
|
||||
@@ -733,10 +672,12 @@ impl purchase::Trait for Runtime {
|
||||
type MaxUnlocked = MaxUnlocked;
|
||||
}
|
||||
|
||||
impl<I: frame_support::traits::Instance> dummy::Trait<I> for Runtime { }
|
||||
|
||||
construct_runtime! {
|
||||
pub enum Runtime where
|
||||
Block = Block,
|
||||
NodeBlock = primitives::v0::Block,
|
||||
NodeBlock = primitives::v1::Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic
|
||||
{
|
||||
// Basic stuff; balances is uncallable initially.
|
||||
@@ -762,11 +703,10 @@ construct_runtime! {
|
||||
ImOnline: pallet_im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
|
||||
AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config},
|
||||
|
||||
// Parachains stuff; slots are disabled (no auctions initially). The rest are safe as they
|
||||
// have no public dispatchables.
|
||||
Parachains: parachains::{Module, Call, Storage, Config, Inherent, Origin},
|
||||
Attestations: attestations::{Module, Call, Storage},
|
||||
Registrar: registrar::{Module, Call, Storage, Event, Config<T>},
|
||||
// Old Parachains stuff. All dummies to avoid messing up the transaction indices.
|
||||
DummyParachains: dummy::<Instance0>::{Module, Call},
|
||||
DummyAttestations: dummy::<Instance1>::{Module, Call},
|
||||
DummyRegistrar: dummy::<Instance2>::{Module, Call},
|
||||
|
||||
// Utility module.
|
||||
Utility: pallet_utility::{Module, Call, Event},
|
||||
@@ -816,8 +756,6 @@ pub type SignedExtra = (
|
||||
frame_system::CheckNonce<Runtime>,
|
||||
frame_system::CheckWeight<Runtime>,
|
||||
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
|
||||
registrar::LimitParathreadCommits<Runtime>,
|
||||
parachains::ValidateDoubleVoteReports<Runtime>,
|
||||
);
|
||||
/// Unchecked extrinsic type as expected by this runtime.
|
||||
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
|
||||
@@ -890,45 +828,55 @@ sp_api::impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl parachain::ParachainHost<Block> for Runtime {
|
||||
fn validators() -> Vec<parachain::ValidatorId> {
|
||||
Parachains::authorities()
|
||||
}
|
||||
fn duty_roster() -> parachain::DutyRoster {
|
||||
Parachains::calculate_duty_roster().0
|
||||
}
|
||||
fn active_parachains() -> Vec<(parachain::Id, Option<(parachain::CollatorId, parachain::Retriable)>)> {
|
||||
Registrar::active_paras()
|
||||
}
|
||||
fn global_validation_data() -> parachain::GlobalValidationData {
|
||||
Parachains::global_validation_data()
|
||||
}
|
||||
fn local_validation_data(id: parachain::Id) -> Option<parachain::LocalValidationData> {
|
||||
Parachains::current_local_validation_data(&id)
|
||||
}
|
||||
fn parachain_code(id: parachain::Id) -> Option<parachain::ValidationCode> {
|
||||
Parachains::parachain_code(&id)
|
||||
}
|
||||
fn get_heads(extrinsics: Vec<<Block as BlockT>::Extrinsic>)
|
||||
-> Option<Vec<AbridgedCandidateReceipt>>
|
||||
{
|
||||
extrinsics
|
||||
// Dummy implementation to continue supporting old parachains runtime temporarily.
|
||||
impl p_v0::ParachainHost<Block> for Runtime {
|
||||
fn validators() -> Vec<p_v0::ValidatorId> {
|
||||
// this is a compile-time check of size equality. note that we don't invoke
|
||||
// the function and nothing here is unsafe.
|
||||
let _ = core::mem::transmute::<p_v0::ValidatorId, AccountId>;
|
||||
|
||||
// Yes, these aren't actually the parachain session keys.
|
||||
// It doesn't matter, but we shouldn't return a zero-sized vector here.
|
||||
// As there are no parachains
|
||||
Session::validators()
|
||||
.into_iter()
|
||||
.find_map(|ex| match UncheckedExtrinsic::decode(&mut ex.encode().as_slice()) {
|
||||
Ok(ex) => match ex.function {
|
||||
Call::Parachains(ParachainsCall::set_heads(heads)) => {
|
||||
Some(heads.into_iter().map(|c| c.candidate).collect())
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
Err(_) => None,
|
||||
})
|
||||
.map(|k| k.using_encoded(|s| Decode::decode(&mut &s[..]))
|
||||
.expect("correct size and raw-bytes; qed"))
|
||||
.collect()
|
||||
}
|
||||
fn signing_context() -> SigningContext {
|
||||
Parachains::signing_context()
|
||||
fn duty_roster() -> p_v0::DutyRoster {
|
||||
let v = Session::validators();
|
||||
p_v0::DutyRoster { validator_duty: (0..v.len()).map(|_| p_v0::Chain::Relay).collect() }
|
||||
}
|
||||
fn downward_messages(id: parachain::Id) -> Vec<primitives::v0::DownwardMessage> {
|
||||
Parachains::downward_messages(id)
|
||||
fn active_parachains() -> Vec<(p_v0::Id, Option<(p_v0::CollatorId, p_v0::Retriable)>)> {
|
||||
Vec::new()
|
||||
}
|
||||
fn global_validation_data() -> p_v0::GlobalValidationData {
|
||||
p_v0::GlobalValidationData {
|
||||
max_code_size: 1,
|
||||
max_head_data_size: 1,
|
||||
block_number: System::block_number().saturating_sub(1),
|
||||
}
|
||||
}
|
||||
fn local_validation_data(_id: p_v0::Id) -> Option<p_v0::LocalValidationData> {
|
||||
None
|
||||
}
|
||||
fn parachain_code(_id: p_v0::Id) -> Option<p_v0::ValidationCode> {
|
||||
None
|
||||
}
|
||||
fn get_heads(_extrinsics: Vec<<Block as BlockT>::Extrinsic>)
|
||||
-> Option<Vec<p_v0::AbridgedCandidateReceipt>>
|
||||
{
|
||||
None
|
||||
}
|
||||
fn signing_context() -> p_v0::SigningContext {
|
||||
p_v0::SigningContext {
|
||||
parent_hash: System::parent_hash(),
|
||||
session_index: Session::current_index(),
|
||||
}
|
||||
}
|
||||
fn downward_messages(_id: p_v0::Id) -> Vec<p_v0::DownwardMessage> {
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ polkadot-primitives = { path = "../primitives" }
|
||||
polkadot-runtime = { path = "../runtime/polkadot" }
|
||||
kusama-runtime = { path = "../runtime/kusama" }
|
||||
westend-runtime = { path = "../runtime/westend" }
|
||||
rococo-runtime = { path = "../runtime/rococo" }
|
||||
polkadot-network = { path = "../network", optional = true }
|
||||
polkadot-rpc = { path = "../rpc" }
|
||||
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -21,11 +21,9 @@ use polkadot_primitives::v0::{AccountId, AccountPublic, ValidatorId};
|
||||
use polkadot_runtime as polkadot;
|
||||
use kusama_runtime as kusama;
|
||||
use westend_runtime as westend;
|
||||
use rococo_runtime as rococo;
|
||||
use polkadot::constants::currency::DOTS;
|
||||
use kusama::constants::currency::DOTS as KSM;
|
||||
use westend::constants::currency::DOTS as WND;
|
||||
use rococo_runtime::constants::currency::DOTS as ROC;
|
||||
use sc_chain_spec::{ChainSpecExtension, ChainType};
|
||||
use sp_runtime::{traits::IdentifyAccount, Perbill};
|
||||
use serde::{Serialize, Deserialize};
|
||||
@@ -73,12 +71,6 @@ pub type WestendChainSpec = service::GenericChainSpec<
|
||||
Extensions,
|
||||
>;
|
||||
|
||||
/// The `ChainSpec parametrised for rococo runtime`.
|
||||
pub type RococoChainSpec = service::GenericChainSpec<
|
||||
rococo_runtime::GenesisConfig,
|
||||
Extensions,
|
||||
>;
|
||||
|
||||
pub fn polkadot_config() -> Result<PolkadotChainSpec, String> {
|
||||
PolkadotChainSpec::from_json_bytes(&include_bytes!("../res/polkadot.json")[..])
|
||||
}
|
||||
@@ -91,10 +83,6 @@ pub fn westend_config() -> Result<WestendChainSpec, String> {
|
||||
WestendChainSpec::from_json_bytes(&include_bytes!("../res/westend.json")[..])
|
||||
}
|
||||
|
||||
pub fn rococo_config() -> Result<RococoChainSpec, String> {
|
||||
RococoChainSpec::from_json_bytes(&include_bytes!("../res/rococo.json")[..])
|
||||
}
|
||||
|
||||
fn polkadot_session_keys(
|
||||
babe: BabeId,
|
||||
grandpa: GrandpaId,
|
||||
@@ -125,16 +113,6 @@ fn westend_session_keys(
|
||||
westend::SessionKeys { babe, grandpa, im_online, parachain_validator, authority_discovery }
|
||||
}
|
||||
|
||||
fn rococo_session_keys(
|
||||
babe: BabeId,
|
||||
grandpa: GrandpaId,
|
||||
im_online: ImOnlineId,
|
||||
parachain_validator: ValidatorId,
|
||||
authority_discovery: AuthorityDiscoveryId
|
||||
) -> rococo_runtime::SessionKeys {
|
||||
rococo_runtime::SessionKeys { babe, grandpa, im_online, parachain_validator, authority_discovery }
|
||||
}
|
||||
|
||||
fn polkadot_staging_testnet_config_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig {
|
||||
// subkey inspect "$SECRET"
|
||||
let endowed_accounts = vec![];
|
||||
@@ -202,13 +180,6 @@ fn polkadot_staging_testnet_config_genesis(wasm_binary: &[u8]) -> polkadot::Gene
|
||||
pallet_authority_discovery: Some(polkadot::AuthorityDiscoveryConfig {
|
||||
keys: vec![],
|
||||
}),
|
||||
parachains: Some(polkadot::ParachainsConfig {
|
||||
authorities: vec![],
|
||||
}),
|
||||
registrar: Some(polkadot::RegistrarConfig {
|
||||
parachains: vec![],
|
||||
_phdata: Default::default(),
|
||||
}),
|
||||
claims: Some(polkadot::ClaimsConfig {
|
||||
claims: vec![],
|
||||
vesting: vec![],
|
||||
@@ -343,13 +314,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
|
||||
pallet_authority_discovery: Some(westend::AuthorityDiscoveryConfig {
|
||||
keys: vec![],
|
||||
}),
|
||||
parachains: Some(westend::ParachainsConfig {
|
||||
authorities: vec![],
|
||||
}),
|
||||
registrar: Some(westend::RegistrarConfig {
|
||||
parachains: vec![],
|
||||
_phdata: Default::default(),
|
||||
}),
|
||||
pallet_vesting: Some(westend::VestingConfig {
|
||||
vesting: vec![],
|
||||
}),
|
||||
@@ -359,197 +323,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
|
||||
}
|
||||
}
|
||||
|
||||
fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::GenesisConfig {
|
||||
// subkey inspect "$SECRET"
|
||||
let endowed_accounts = vec![
|
||||
// 5FeyRQmjtdHoPH56ASFW76AJEP1yaQC1K9aEMvJTF9nzt9S9
|
||||
hex!["9ed7705e3c7da027ba0583a22a3212042f7e715d3c168ba14f1424e2bc111d00"].into(),
|
||||
];
|
||||
|
||||
// ./scripts/prepare-test-net.sh 8
|
||||
let initial_authorities: Vec<(
|
||||
AccountId,
|
||||
AccountId,
|
||||
BabeId,
|
||||
GrandpaId,
|
||||
ImOnlineId,
|
||||
ValidatorId,
|
||||
AuthorityDiscoveryId
|
||||
)> = vec![(
|
||||
//5EHZkbp22djdbuMFH9qt1DVzSCvqi3zWpj6DAYfANa828oei
|
||||
hex!["62475fe5406a7cb6a64c51d0af9d3ab5c2151bcae982fb812f7a76b706914d6a"].into(),
|
||||
//5FeSEpi9UYYaWwXXb3tV88qtZkmSdB3mvgj3pXkxKyYLGhcd
|
||||
hex!["9e6e781a76810fe93187af44c79272c290c2b9e2b8b92ee11466cd79d8023f50"].into(),
|
||||
//5Fh6rDpMDhM363o1Z3Y9twtaCPfizGQWCi55BSykTQjGbP7H
|
||||
hex!["a076ef1280d768051f21d060623da3ab5b56944d681d303ed2d4bf658c5bed35"].unchecked_into(),
|
||||
//5CPd3zoV9Aaah4xWucuDivMHJ2nEEmpdi864nPTiyRZp4t87
|
||||
hex!["0e6d7d1afbcc6547b92995a394ba0daed07a2420be08220a5a1336c6731f0bfa"].unchecked_into(),
|
||||
//5F7BEa1LGFksUihyatf3dCDYneB8pWzVyavnByCsm5nBgezi
|
||||
hex!["86975a37211f8704e947a365b720f7a3e2757988eaa7d0f197e83dba355ef743"].unchecked_into(),
|
||||
//5CDS33qmzmrBHWxVx5Vcz2Wim5b4aVS5C9yh3HpxqwmkrFwt
|
||||
hex!["06a7f34a2ae69cc0cca633c7a82b37cfba821707eb62ffe065b242e1230e4661"].unchecked_into(),
|
||||
//5HbSgM72xVuscsopsdeG3sCSCYdAeM1Tay9p79N6ky6vwDGq
|
||||
hex!["f49eae66a0ac9f610316906ec8f1a0928e20d7059d76a5ca53cbcb5a9b50dd3c"].unchecked_into(),
|
||||
),
|
||||
(
|
||||
//5DvH8oEjQPYhzCoQVo7WDU91qmQfLZvxe9wJcrojmJKebCmG
|
||||
hex!["520b48452969f6ddf263b664de0adb0c729d0e0ad3b0e5f3cb636c541bc9022a"].into(),
|
||||
//5ENZvCRzyXJJYup8bM6yEzb2kQHEb1NDpY2ZEyVGBkCfRdj3
|
||||
hex!["6618289af7ae8621981ffab34591e7a6486e12745dfa3fd3b0f7e6a3994c7b5b"].into(),
|
||||
//5DLjSUfqZVNAADbwYLgRvHvdzXypiV1DAEaDMjcESKTcqMoM
|
||||
hex!["38757d0de00a0c739e7d7984ef4bc01161bd61e198b7c01b618425c16bb5bd5f"].unchecked_into(),
|
||||
//5HnDVBN9mD6mXyx8oryhDbJtezwNSj1VRXgLoYCBA6uEkiao
|
||||
hex!["fcd5f87a6fd5707a25122a01b4dac0a8482259df7d42a9a096606df1320df08d"].unchecked_into(),
|
||||
//5DhyXZiuB1LvqYKFgT5tRpgGsN3is2cM9QxgW7FikvakbAZP
|
||||
hex!["48a910c0af90898f11bd57d37ceaea53c78994f8e1833a7ade483c9a84bde055"].unchecked_into(),
|
||||
//5FxYBi73N4C9HQphtjCRDthxT2XLhd8e6BuYnxERQ7UJtAx6
|
||||
hex!["ac3ce74c09d1bb387d3f79dc8df88d661da689d5364eb8131c83fcc8ecb2fc5b"].unchecked_into(),
|
||||
//5HeXbwb5PxtcRoopPZTp5CQun38atn2UudQ8p2AxR5BzoaXw
|
||||
hex!["f6f8fe475130d21165446a02fb1dbce3a7bf36412e5d98f4f0473aed9252f349"].unchecked_into(),
|
||||
),
|
||||
(
|
||||
//5FPMzsezo1PRxYbVpJMWK7HNbR2kUxidsAAxH4BosHa4wd6S
|
||||
hex!["92ef83665b39d7a565e11bf8d18d41d45a8011601c339e57a8ea88c8ff7bba6f"].into(),
|
||||
//5G6NQidFG7YiXsvV7hQTLGArir9tsYqD4JDxByhgxKvSKwRx
|
||||
hex!["b235f57244230589523271c27b8a490922ffd7dccc83b044feaf22273c1dc735"].into(),
|
||||
//5GpZhzAVg7SAtzLvaAC777pjquPEcNy1FbNUAG2nZvhmd6eY
|
||||
hex!["d2644c1ab2c63a3ad8d40ad70d4b260969e3abfe6d7e6665f50dc9f6365c9d2a"].unchecked_into(),
|
||||
//5HAes2RQYPbYKbLBfKb88f4zoXv6pPA6Ke8CjN7dob3GpmSP
|
||||
hex!["e1b68fbd84333e31486c08e6153d9a1415b2e7e71b413702b7d64e9b631184a1"].unchecked_into(),
|
||||
//5HTXBf36LXmkFWJLokNUK6fPxVpkr2ToUnB1pvaagdGu4c1T
|
||||
hex!["ee93e26259decb89afcf17ef2aa0fa2db2e1042fb8f56ecfb24d19eae8629878"].unchecked_into(),
|
||||
//5EXD52Bdz24J1N6i8hss7a5pfAARYmURgESatGXgjsV274Rk
|
||||
hex!["6caf2fe2cf01fc3f07e113a2940a1d6c7bc1ab9d8974f152c2ee201d4f16f67a"].unchecked_into(),
|
||||
//5D4r6YaB6F7A7nvMRHNFNF6zrR9g39bqDJFenrcaFmTCRwfa
|
||||
hex!["2c57f81fd311c1ab53813c6817fe67f8947f8d39258252663b3384ab4195494d"].unchecked_into(),
|
||||
),
|
||||
(
|
||||
//5DMNx7RoX6d7JQ38NEM7DWRcW2THu92LBYZEWvBRhJeqcWgR
|
||||
hex!["38f3c2f38f6d47f161e98c697bbe3ca0e47c033460afda0dda314ab4222a0404"].into(),
|
||||
//5GGdKNDr9P47dpVnmtq3m8Tvowwf1ot1abw6tPsTYYFoKm2v
|
||||
hex!["ba0898c1964196474c0be08d364cdf4e9e1d47088287f5235f70b0590dfe1704"].into(),
|
||||
//5EjkyPCzR2SjhDZq8f7ufsw6TfkvgNRepjCRQFc4TcdXdaB1
|
||||
hex!["764186bc30fd5a02477f19948dc723d6d57ab174debd4f80ed6038ec960bfe21"].unchecked_into(),
|
||||
//5DJV3zCBTJBLGNDCcdWrYxWDacSz84goGTa4pFeKVvehEBte
|
||||
hex!["36be9069cdb4a8a07ecd51f257875150f0a8a1be44a10d9d98dabf10a030aef4"].unchecked_into(),
|
||||
//5FHf8kpK4fPjEJeYcYon2gAPwEBubRvtwpzkUbhMWSweKPUY
|
||||
hex!["8e95b9b5b4dc69790b67b566567ca8bf8cdef3a3a8bb65393c0d1d1c87cd2d2c"].unchecked_into(),
|
||||
//5HZ5hm2WTQEXaYAeH24h5kh2Q2rCbnJeiXNm9nhkxNXwwn8M
|
||||
hex!["f2d19482d1da872af925e84478787e0719f637bd1f88c0c99316bdf2658d5478"].unchecked_into(),
|
||||
//5CtgRR74VypK4h154s369abs78hDUxZSJqcbWsfXvsjcHJNA
|
||||
hex!["2496f28d887d84705c6dae98aee8bf90fc5ad10bb5545eca1de6b68425b70f7c"].unchecked_into(),
|
||||
),
|
||||
(
|
||||
//5C8AL1Zb4bVazgT3EgDxFgcow1L4SJjVu44XcLC9CrYqFN4N
|
||||
hex!["02a2d8cfcf75dda85fafc04ace3bcb73160034ed1964c43098fb1fe831de1b16"].into(),
|
||||
//5FLYy3YKsAnooqE4hCudttAsoGKbVG3hYYBtVzwMjJQrevPa
|
||||
hex!["90cab33f0bb501727faa8319f0845faef7d31008f178b65054b6629fe531b772"].into(),
|
||||
//5Et3tfbVf1ByFThNAuUq5pBssdaPPskip5yob5GNyUFojXC7
|
||||
hex!["7c94715e5dd8ab54221b1b6b2bfa5666f593f28a92a18e28052531de1bd80813"].unchecked_into(),
|
||||
//5EX1JBghGbQqWohTPU6msR9qZ2nYPhK9r3RTQ2oD1K8TCxaG
|
||||
hex!["6c878e33b83c20324238d22240f735457b6fba544b383e70bb62a27b57380c81"].unchecked_into(),
|
||||
//5GqL8RbVAuNXpDhjQi1KrS1MyNuKhvus2AbmQwRGjpuGZmFu
|
||||
hex!["d2f9d537ffa59919a4028afdb627c14c14c97a1547e13e8e82203d2049b15b1a"].unchecked_into(),
|
||||
//5DfapfASpVBDsVxgM2FctoQXRX6oa9AbXY5uH7VxWu9esQFy
|
||||
hex!["46d6245026e0e4f4a120cfdfbc9f36a37de202489c4c7ff05b6c54d1811aee2c"].unchecked_into(),
|
||||
//5DABsdQCDUGuhzVGWe5xXzYQ9rtrVxRygW7RXf9Tsjsw1aGJ
|
||||
hex!["306ac5c772fe858942f92b6e28bd82fb7dd8cdd25f9a4626c1b0eee075fcb531"].unchecked_into(),
|
||||
),
|
||||
(
|
||||
//5C8XbDXdMNKJrZSrQURwVCxdNdk8AzG6xgLggbzuA399bBBF
|
||||
hex!["02ea6bfa8b23b92fe4b5db1063a1f9475e3acd0ab61e6b4f454ed6ba00b5f864"].into(),
|
||||
//5GsyzFP8qtF8tXPSsjhjxAeU1v7D1PZofuQKN9TdCc7Dp1JM
|
||||
hex!["d4ffc4c05b47d1115ad200f7f86e307b20b46c50e1b72a912ec4f6f7db46b616"].into(),
|
||||
//5GHWB8ZDzegLcMW7Gdd1BS6WHVwDdStfkkE4G7KjPjZNJBtD
|
||||
hex!["bab3cccdcc34401e9b3971b96a662686cf755aa869a5c4b762199ce531b12c5b"].unchecked_into(),
|
||||
//5GzDPGbUM9uH52ZEwydasTj8edokGUJ7vEpoFWp9FE1YNuFB
|
||||
hex!["d9c056c98ca0e6b4eb7f5c58c007c1db7be0fe1f3776108f797dd4990d1ccc33"].unchecked_into(),
|
||||
//5GWZbVkJEfWZ7fRca39YAQeqri2Z7pkeHyd7rUctUHyQifLp
|
||||
hex!["c4a980da30939d5bb9e4a734d12bf81259ae286aa21fa4b65405347fa40eff35"].unchecked_into(),
|
||||
//5C5DAKUwKcxU2eT9fZU23HPEJcJLPQRt7YX5sAyifKKsnBNd
|
||||
hex!["0062a5ab339962d84b6711b86fa67b457483fcd3d75dafb7bd15f182b7434227"].unchecked_into(),
|
||||
//5CZdFnyzZvKetZTeUwj5APAYskVJe4QFiTezo5dQNsrnehGd
|
||||
hex!["160ea09c5717270e958a3da42673fa011613a9539b2e4ebcad8626bc117ca04a"].unchecked_into(),
|
||||
),
|
||||
(
|
||||
//5HinEonzr8MywkqedcpsmwpxKje2jqr9miEwuzyFXEBCvVXM
|
||||
hex!["fa373e25a1c4fe19c7148acde13bc3db1811cf656dc086820f3dda736b9c4a00"].into(),
|
||||
//5EHJbj6Td6ks5HDnyfN4ttTSi57osxcQsQexm7XpazdeqtV7
|
||||
hex!["62145d721967bd88622d08625f0f5681463c0f1b8bcd97eb3c2c53f7660fd513"].into(),
|
||||
//5EeCsC58XgJ1DFaoYA1WktEpP27jvwGpKdxPMFjicpLeYu96
|
||||
hex!["720537e2c1c554654d73b3889c3ef4c3c2f95a65dd3f7c185ebe4afebed78372"].unchecked_into(),
|
||||
//5DnEySxbnppWEyN8cCLqvGjAorGdLRg2VmkY96dbJ1LHFK8N
|
||||
hex!["4bea0b37e0cce9bddd80835fa2bfd5606f5dcfb8388bbb10b10c483f0856cf14"].unchecked_into(),
|
||||
//5E1Y1FJ7dVP7qtE3wm241pTm72rTMcDT5Jd8Czv7Pwp7N3AH
|
||||
hex!["560d90ca51e9c9481b8a9810060e04d0708d246714960439f804e5c6f40ca651"].unchecked_into(),
|
||||
//5Fs2mowfPb93ByRTKtzTE5evCh2SfVLJfpBBM5SmpYGdG6yK
|
||||
hex!["a809aaaaebc04051536c99166c99f0cba19c7b5950cd8a37882dd56220f2e84f"].unchecked_into(),
|
||||
//5ELv74v7QcsS6FdzvG4vL2NnYDGWmRnJUSMKYwdyJD7Xcdi7
|
||||
hex!["64d59feddb3d00316a55906953fb3db8985797472bd2e6c7ea1ab730cc339d7f"].unchecked_into(),
|
||||
),
|
||||
(
|
||||
//5Ey3NQ3dfabaDc16NUv7wRLsFCMDFJSqZFzKVycAsWuUC6Di
|
||||
hex!["8062e9c21f1d92926103119f7e8153cebdb1e5ab3e52d6f395be80bb193eab47"].into(),
|
||||
//5HiWsuSBqt8nS9pnggexXuHageUifVPKPHDE2arTKqhTp1dV
|
||||
hex!["fa0388fa88f3f0cb43d583e2571fbc0edad57dff3a6fd89775451dd2c2b8ea00"].into(),
|
||||
//5H168nKX2Yrfo3bxj7rkcg25326Uv3CCCnKUGK6uHdKMdPt8
|
||||
hex!["da6b2df18f0f9001a6dcf1d301b92534fe9b1f3ccfa10c49449fee93adaa8349"].unchecked_into(),
|
||||
//5DrA2fZdzmNqT5j6DXNwVxPBjDV9jhkAqvjt6Us3bQHKy3cF
|
||||
hex!["4ee66173993dd0db5d628c4c9cb61a27b76611ad3c3925947f0d0011ee2c5dcc"].unchecked_into(),
|
||||
//5FNFDUGNLUtqg5LgrwYLNmBiGoP8KRxsvQpBkc7GQP6qaBUG
|
||||
hex!["92156f54a114ee191415898f2da013d9db6a5362d6b36330d5fc23e27360ab66"].unchecked_into(),
|
||||
//5Ea4of4L3i5Nc8QcPE648cN8CL8iuo9v4xc2LpKAtr6oShFU
|
||||
hex!["6edd19e3c5230998e533e165a26438afe663368d0eab37fabff734a36119ce0e"].unchecked_into(),
|
||||
//5DqAvikdpfRdk5rR35ZobZhqaC5bJXZcEuvzGtexAZP1hU3T
|
||||
hex!["4e262811acdfe94528bfc3c65036080426a0e1301b9ada8d687a70ffcae99c26"].unchecked_into(),
|
||||
)];
|
||||
|
||||
const ENDOWMENT: u128 = 1_000_000 * ROC;
|
||||
const STASH: u128 = 100 * ROC;
|
||||
|
||||
rococo_runtime::GenesisConfig {
|
||||
frame_system: Some(rococo_runtime::SystemConfig {
|
||||
code: wasm_binary.to_vec(),
|
||||
changes_trie_config: Default::default(),
|
||||
}),
|
||||
pallet_balances: Some(rococo_runtime::BalancesConfig {
|
||||
balances: endowed_accounts.iter()
|
||||
.map(|k: &AccountId| (k.clone(), ENDOWMENT))
|
||||
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
|
||||
.collect(),
|
||||
}),
|
||||
pallet_indices: Some(rococo_runtime::IndicesConfig {
|
||||
indices: vec![],
|
||||
}),
|
||||
pallet_session: Some(rococo_runtime::SessionConfig {
|
||||
keys: initial_authorities.iter().map(|x| (
|
||||
x.0.clone(),
|
||||
x.0.clone(),
|
||||
rococo_session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone(), x.6.clone()),
|
||||
)).collect::<Vec<_>>(),
|
||||
}),
|
||||
pallet_babe: Some(Default::default()),
|
||||
pallet_grandpa: Some(Default::default()),
|
||||
pallet_im_online: Some(Default::default()),
|
||||
pallet_authority_discovery: Some(rococo_runtime::AuthorityDiscoveryConfig {
|
||||
keys: vec![],
|
||||
}),
|
||||
parachains: Some(rococo_runtime::ParachainsConfig {
|
||||
authorities: vec![],
|
||||
}),
|
||||
registrar: Some(rococo_runtime::RegistrarConfig {
|
||||
parachains: vec![],
|
||||
_phdata: Default::default(),
|
||||
}),
|
||||
pallet_vesting: Some(rococo_runtime::VestingConfig {
|
||||
vesting: vec![],
|
||||
}),
|
||||
pallet_sudo: Some(rococo_runtime::SudoConfig {
|
||||
key: endowed_accounts[0].clone(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfig {
|
||||
// subkey inspect "$SECRET"
|
||||
let endowed_accounts = vec![
|
||||
@@ -685,13 +458,6 @@ fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisC
|
||||
pallet_authority_discovery: Some(kusama::AuthorityDiscoveryConfig {
|
||||
keys: vec![],
|
||||
}),
|
||||
parachains: Some(kusama::ParachainsConfig {
|
||||
authorities: vec![],
|
||||
}),
|
||||
registrar: Some(kusama::RegistrarConfig {
|
||||
parachains: vec![],
|
||||
_phdata: Default::default(),
|
||||
}),
|
||||
claims: Some(kusama::ClaimsConfig {
|
||||
claims: vec![],
|
||||
vesting: vec![],
|
||||
@@ -759,25 +525,6 @@ pub fn westend_staging_testnet_config() -> Result<WestendChainSpec, String> {
|
||||
))
|
||||
}
|
||||
|
||||
/// Rococo staging testnet config.
|
||||
pub fn rococo_staging_testnet_config() -> Result<RococoChainSpec, String> {
|
||||
let wasm_binary = rococo::WASM_BINARY.ok_or("Rococo development wasm not available")?;
|
||||
let boot_nodes = vec![];
|
||||
|
||||
Ok(RococoChainSpec::from_genesis(
|
||||
"Rococo Staging Testnet",
|
||||
"rococo_staging_testnet",
|
||||
ChainType::Live,
|
||||
move || rococo_staging_testnet_config_genesis(wasm_binary),
|
||||
boot_nodes,
|
||||
Some(TelemetryEndpoints::new(vec![(WESTEND_STAGING_TELEMETRY_URL.to_string(), 0)])
|
||||
.expect("Rococo Staging telemetry url is valid; qed")),
|
||||
Some(DEFAULT_PROTOCOL_ID),
|
||||
None,
|
||||
Default::default(),
|
||||
))
|
||||
}
|
||||
|
||||
/// Helper function to generate a crypto pair from seed
|
||||
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
|
||||
TPublic::Pair::from_string(&format!("//{}", seed), None)
|
||||
@@ -889,13 +636,6 @@ pub fn polkadot_testnet_genesis(
|
||||
pallet_authority_discovery: Some(polkadot::AuthorityDiscoveryConfig {
|
||||
keys: vec![],
|
||||
}),
|
||||
parachains: Some(polkadot::ParachainsConfig {
|
||||
authorities: vec![],
|
||||
}),
|
||||
registrar: Some(polkadot::RegistrarConfig{
|
||||
parachains: vec![],
|
||||
_phdata: Default::default(),
|
||||
}),
|
||||
claims: Some(polkadot::ClaimsConfig {
|
||||
claims: vec![],
|
||||
vesting: vec![],
|
||||
@@ -964,13 +704,6 @@ pub fn kusama_testnet_genesis(
|
||||
pallet_authority_discovery: Some(kusama::AuthorityDiscoveryConfig {
|
||||
keys: vec![],
|
||||
}),
|
||||
parachains: Some(kusama::ParachainsConfig {
|
||||
authorities: vec![],
|
||||
}),
|
||||
registrar: Some(kusama::RegistrarConfig{
|
||||
parachains: vec![],
|
||||
_phdata: Default::default(),
|
||||
}),
|
||||
claims: Some(kusama::ClaimsConfig {
|
||||
claims: vec![],
|
||||
vesting: vec![],
|
||||
@@ -1028,13 +761,6 @@ pub fn westend_testnet_genesis(
|
||||
pallet_authority_discovery: Some(westend::AuthorityDiscoveryConfig {
|
||||
keys: vec![],
|
||||
}),
|
||||
parachains: Some(westend::ParachainsConfig {
|
||||
authorities: vec![],
|
||||
}),
|
||||
registrar: Some(westend::RegistrarConfig{
|
||||
parachains: vec![],
|
||||
_phdata: Default::default(),
|
||||
}),
|
||||
pallet_vesting: Some(westend::VestingConfig {
|
||||
vesting: vec![],
|
||||
}),
|
||||
@@ -1044,57 +770,6 @@ pub fn westend_testnet_genesis(
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper function to create rococo GenesisConfig for testing
|
||||
pub fn rococo_testnet_genesis(
|
||||
wasm_binary: &[u8],
|
||||
initial_authorities: Vec<(AccountId, AccountId, BabeId, GrandpaId, ImOnlineId, ValidatorId, AuthorityDiscoveryId)>,
|
||||
root_key: AccountId,
|
||||
endowed_accounts: Option<Vec<AccountId>>,
|
||||
) -> rococo_runtime::GenesisConfig {
|
||||
let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(testnet_accounts);
|
||||
|
||||
const ENDOWMENT: u128 = 1_000_000 * DOTS;
|
||||
|
||||
rococo_runtime::GenesisConfig {
|
||||
frame_system: Some(rococo_runtime::SystemConfig {
|
||||
code: wasm_binary.to_vec(),
|
||||
changes_trie_config: Default::default(),
|
||||
}),
|
||||
pallet_indices: Some(rococo_runtime::IndicesConfig {
|
||||
indices: vec![],
|
||||
}),
|
||||
pallet_balances: Some(rococo_runtime::BalancesConfig {
|
||||
balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
|
||||
}),
|
||||
pallet_session: Some(rococo_runtime::SessionConfig {
|
||||
keys: initial_authorities.iter().map(|x| (
|
||||
x.0.clone(),
|
||||
x.0.clone(),
|
||||
rococo_session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone(), x.6.clone()),
|
||||
)).collect::<Vec<_>>(),
|
||||
}),
|
||||
pallet_babe: Some(Default::default()),
|
||||
pallet_grandpa: Some(Default::default()),
|
||||
pallet_im_online: Some(Default::default()),
|
||||
pallet_authority_discovery: Some(rococo_runtime::AuthorityDiscoveryConfig {
|
||||
keys: vec![],
|
||||
}),
|
||||
parachains: Some(rococo_runtime::ParachainsConfig {
|
||||
authorities: vec![],
|
||||
}),
|
||||
registrar: Some(rococo_runtime::RegistrarConfig{
|
||||
parachains: vec![],
|
||||
_phdata: Default::default(),
|
||||
}),
|
||||
pallet_vesting: Some(rococo_runtime::VestingConfig {
|
||||
vesting: vec![],
|
||||
}),
|
||||
pallet_sudo: Some(rococo_runtime::SudoConfig {
|
||||
key: root_key,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
fn polkadot_development_config_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig {
|
||||
polkadot_testnet_genesis(
|
||||
wasm_binary,
|
||||
@@ -1249,18 +924,6 @@ fn westend_local_testnet_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig {
|
||||
)
|
||||
}
|
||||
|
||||
fn rococo_local_testnet_genesis(wasm_binary: &[u8]) -> rococo_runtime::GenesisConfig {
|
||||
rococo_testnet_genesis(
|
||||
wasm_binary,
|
||||
vec![
|
||||
get_authority_keys_from_seed("Alice"),
|
||||
get_authority_keys_from_seed("Bob"),
|
||||
],
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
None,
|
||||
)
|
||||
}
|
||||
|
||||
/// Westend local testnet config (multivalidator Alice + Bob)
|
||||
pub fn westend_local_testnet_config() -> Result<WestendChainSpec, String> {
|
||||
let wasm_binary = westend::WASM_BINARY.ok_or("Westend development wasm not available")?;
|
||||
@@ -1277,20 +940,3 @@ pub fn westend_local_testnet_config() -> Result<WestendChainSpec, String> {
|
||||
Default::default(),
|
||||
))
|
||||
}
|
||||
|
||||
/// Rococo local testnet config (multivalidator Alice + Bob)
|
||||
pub fn rococo_local_testnet_config() -> Result<RococoChainSpec, String> {
|
||||
let wasm_binary = rococo::WASM_BINARY.ok_or("Rococo development wasm not available")?;
|
||||
|
||||
Ok(RococoChainSpec::from_genesis(
|
||||
"Rococo Local Testnet",
|
||||
"rococo_local_testnet",
|
||||
ChainType::Local,
|
||||
move || rococo_local_testnet_genesis(wasm_binary),
|
||||
vec![],
|
||||
None,
|
||||
Some(DEFAULT_PROTOCOL_ID),
|
||||
None,
|
||||
Default::default(),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -139,7 +139,6 @@ pub enum Client {
|
||||
Polkadot(Arc<crate::FullClient<polkadot_runtime::RuntimeApi, crate::PolkadotExecutor>>),
|
||||
Westend(Arc<crate::FullClient<westend_runtime::RuntimeApi, crate::WestendExecutor>>),
|
||||
Kusama(Arc<crate::FullClient<kusama_runtime::RuntimeApi, crate::KusamaExecutor>>),
|
||||
Rococo(Arc<crate::FullClient<rococo_runtime::RuntimeApi, crate::RococoExecutor>>),
|
||||
}
|
||||
|
||||
impl ClientHandle for Client {
|
||||
@@ -154,9 +153,6 @@ impl ClientHandle for Client {
|
||||
Self::Kusama(client) => {
|
||||
T::execute_with_client::<_, _, crate::FullBackend>(t, client.clone())
|
||||
},
|
||||
Self::Rococo(client) => {
|
||||
T::execute_with_client::<_, _, crate::FullBackend>(t, client.clone())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ mod tests {
|
||||
for i in 0..n {
|
||||
let mut builder = client.new_block(Default::default()).unwrap();
|
||||
|
||||
for extrinsic in polkadot_test_runtime_client::needed_extrinsics(vec![], base + i) {
|
||||
for extrinsic in polkadot_test_runtime_client::needed_extrinsics(base + i) {
|
||||
builder.push(extrinsic).unwrap()
|
||||
}
|
||||
|
||||
|
||||
@@ -45,14 +45,13 @@ pub use sp_runtime::traits::{HashFor, NumberFor};
|
||||
pub use consensus_common::{SelectChain, BlockImport, block_validation::Chain};
|
||||
pub use polkadot_primitives::v0::{Block, CollatorId, ParachainHost};
|
||||
pub use sp_runtime::traits::{Block as BlockT, self as runtime_traits, BlakeTwo256};
|
||||
pub use chain_spec::{PolkadotChainSpec, KusamaChainSpec, WestendChainSpec, RococoChainSpec};
|
||||
pub use chain_spec::{PolkadotChainSpec, KusamaChainSpec, WestendChainSpec};
|
||||
#[cfg(feature = "full-node")]
|
||||
pub use consensus::run_validation_worker;
|
||||
pub use codec::Codec;
|
||||
pub use polkadot_runtime;
|
||||
pub use kusama_runtime;
|
||||
pub use westend_runtime;
|
||||
pub use rococo_runtime;
|
||||
pub use self::client::*;
|
||||
|
||||
native_executor_instance!(
|
||||
@@ -76,13 +75,6 @@ native_executor_instance!(
|
||||
frame_benchmarking::benchmarking::HostFunctions,
|
||||
);
|
||||
|
||||
native_executor_instance!(
|
||||
pub RococoExecutor,
|
||||
rococo_runtime::api::dispatch,
|
||||
rococo_runtime::native_version,
|
||||
frame_benchmarking::benchmarking::HostFunctions,
|
||||
);
|
||||
|
||||
/// Can be called for a `Configuration` to check if it is a configuration for the `Kusama` network.
|
||||
pub trait IdentifyVariant {
|
||||
/// Returns if this is a configuration for the `Kusama` network.
|
||||
@@ -90,9 +82,6 @@ pub trait IdentifyVariant {
|
||||
|
||||
/// Returns if this is a configuration for the `Westend` network.
|
||||
fn is_westend(&self) -> bool;
|
||||
|
||||
/// Returns if this is a configuration for the `Rococo` network.
|
||||
fn is_rococo(&self) -> bool;
|
||||
}
|
||||
|
||||
impl IdentifyVariant for Box<dyn ChainSpec> {
|
||||
@@ -103,10 +92,6 @@ impl IdentifyVariant for Box<dyn ChainSpec> {
|
||||
fn is_westend(&self) -> bool {
|
||||
self.id().starts_with("westend") || self.id().starts_with("wnd")
|
||||
}
|
||||
|
||||
fn is_rococo(&self) -> bool {
|
||||
self.id().starts_with("rococo") || self.id().starts_with("roc")
|
||||
}
|
||||
}
|
||||
|
||||
/// Polkadot's full backend.
|
||||
@@ -787,35 +772,6 @@ pub fn westend_new_full(
|
||||
Ok((service, client, handles))
|
||||
}
|
||||
|
||||
/// Create a new Rococo service for a full node.
|
||||
#[cfg(feature = "full-node")]
|
||||
pub fn rococo_new_full(
|
||||
config: Configuration,
|
||||
collating_for: Option<(CollatorId, parachain::Id)>,
|
||||
max_block_data_size: Option<u64>,
|
||||
authority_discovery_enabled: bool,
|
||||
slot_duration: u64,
|
||||
grandpa_pause: Option<(u32, u32)>,
|
||||
)
|
||||
-> Result<(
|
||||
TaskManager,
|
||||
Arc<impl AbstractClient<Block, TFullBackend<Block>>>,
|
||||
FullNodeHandles,
|
||||
), ServiceError>
|
||||
{
|
||||
let (service, client, handles, _, _) = new_full::<rococo_runtime::RuntimeApi, RococoExecutor>(
|
||||
config,
|
||||
collating_for,
|
||||
max_block_data_size,
|
||||
authority_discovery_enabled,
|
||||
slot_duration,
|
||||
grandpa_pause,
|
||||
false,
|
||||
)?;
|
||||
|
||||
Ok((service, client, handles))
|
||||
}
|
||||
|
||||
/// Handles to other sub-services that full nodes instantiate, which consumers
|
||||
/// of the node may use.
|
||||
#[cfg(feature = "full-node")]
|
||||
@@ -833,8 +789,6 @@ pub fn build_light(config: Configuration) -> Result<(TaskManager, Arc<RpcHandler
|
||||
new_light::<kusama_runtime::RuntimeApi, KusamaExecutor>(config)
|
||||
} else if config.chain_spec.is_westend() {
|
||||
new_light::<westend_runtime::RuntimeApi, WestendExecutor>(config)
|
||||
} else if config.chain_spec.is_rococo() {
|
||||
new_light::<rococo_runtime::RuntimeApi, RococoExecutor>(config)
|
||||
} else {
|
||||
new_light::<polkadot_runtime::RuntimeApi, PolkadotExecutor>(config)
|
||||
}
|
||||
@@ -870,16 +824,6 @@ pub fn build_full(
|
||||
grandpa_pause,
|
||||
false,
|
||||
).map(|(task_manager, client, handles, _, _)| (task_manager, Client::Westend(client), handles))
|
||||
} else if config.chain_spec.is_rococo() {
|
||||
new_full::<rococo_runtime::RuntimeApi, RococoExecutor>(
|
||||
config,
|
||||
collating_for,
|
||||
max_block_data_size,
|
||||
authority_discovery_enabled,
|
||||
slot_duration,
|
||||
grandpa_pause,
|
||||
false,
|
||||
).map(|(task_manager, client, handles, _, _)| (task_manager, Client::Rococo(client), handles))
|
||||
} else {
|
||||
new_full::<polkadot_runtime::RuntimeApi, PolkadotExecutor>(
|
||||
config,
|
||||
|
||||
Reference in New Issue
Block a user