mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 02:51:08 +00:00
Bump Substrate/Polkadot/Cumulus refs (#1295)
Substrate: 31d90c202d6df9ce3837ee55587b604619a912ba
Polkadot: 60df3c55c711c2872872d6220f98b2611340e051
Cumulus: a9630551c2
This commit is contained in:
committed by
Bastian Köcher
parent
fe34a526bb
commit
ea2d6f898d
@@ -10,8 +10,8 @@ repository = "https://github.com/paritytech/parity-bridges-common/"
|
|||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
clap = { version = "3.0", features = ["derive"] }
|
||||||
jsonrpc-core = "18.0"
|
jsonrpc-core = "18.0"
|
||||||
structopt = "0.3.21"
|
|
||||||
serde_json = "1.0.59"
|
serde_json = "1.0.59"
|
||||||
|
|
||||||
# Bridge dependencies
|
# Bridge dependencies
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ impl Alternative {
|
|||||||
vec![],
|
vec![],
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
properties,
|
properties,
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
@@ -119,6 +120,7 @@ impl Alternative {
|
|||||||
vec![],
|
vec![],
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
properties,
|
properties,
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
@@ -195,7 +197,7 @@ fn testnet_genesis(
|
|||||||
aura: AuraConfig { authorities: Vec::new() },
|
aura: AuraConfig { authorities: Vec::new() },
|
||||||
beefy: BeefyConfig { authorities: Vec::new() },
|
beefy: BeefyConfig { authorities: Vec::new() },
|
||||||
grandpa: GrandpaConfig { authorities: Vec::new() },
|
grandpa: GrandpaConfig { authorities: Vec::new() },
|
||||||
sudo: SudoConfig { key: root_key },
|
sudo: SudoConfig { key: Some(root_key) },
|
||||||
session: SessionConfig {
|
session: SessionConfig {
|
||||||
keys: initial_authorities
|
keys: initial_authorities
|
||||||
.iter()
|
.iter()
|
||||||
|
|||||||
@@ -14,10 +14,10 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
use clap::Parser;
|
||||||
use sc_cli::RunCmd;
|
use sc_cli::RunCmd;
|
||||||
use structopt::StructOpt;
|
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct Cli {
|
pub struct Cli {
|
||||||
#[structopt(subcommand)]
|
#[structopt(subcommand)]
|
||||||
pub subcommand: Option<Subcommand>,
|
pub subcommand: Option<Subcommand>,
|
||||||
@@ -27,9 +27,10 @@ pub struct Cli {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Possible subcommands of the main binary.
|
/// Possible subcommands of the main binary.
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
pub enum Subcommand {
|
pub enum Subcommand {
|
||||||
/// Key management CLI utilities
|
/// Key management CLI utilities
|
||||||
|
#[clap(subcommand)]
|
||||||
Key(sc_cli::KeySubcommand),
|
Key(sc_cli::KeySubcommand),
|
||||||
|
|
||||||
/// Verify a signature for a message, provided on `STDIN`, with a given (public or secret) key.
|
/// Verify a signature for a message, provided on `STDIN`, with a given (public or secret) key.
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
// =====================================================================================
|
// =====================================================================================
|
||||||
|
|
||||||
use millau_runtime::{self, opaque::Block, RuntimeApi};
|
use millau_runtime::{self, opaque::Block, RuntimeApi};
|
||||||
use sc_client_api::ExecutorProvider;
|
use sc_client_api::{BlockBackend, ExecutorProvider};
|
||||||
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
|
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
|
||||||
pub use sc_executor::NativeElseWasmExecutor;
|
pub use sc_executor::NativeElseWasmExecutor;
|
||||||
use sc_finality_grandpa::SharedVoterState;
|
use sc_finality_grandpa::SharedVoterState;
|
||||||
@@ -108,6 +108,7 @@ pub fn new_partial(
|
|||||||
config.wasm_method,
|
config.wasm_method,
|
||||||
config.default_heap_pages,
|
config.default_heap_pages,
|
||||||
config.max_runtime_instances,
|
config.max_runtime_instances,
|
||||||
|
config.runtime_cache_size,
|
||||||
);
|
);
|
||||||
|
|
||||||
let (client, backend, keystore_container, task_manager) =
|
let (client, backend, keystore_container, task_manager) =
|
||||||
@@ -210,8 +211,27 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
config.network.extra_sets.push(sc_finality_grandpa::grandpa_peers_set_config());
|
// Note: GrandPa is pushed before the Polkadot-specific protocols. This doesn't change
|
||||||
config.network.extra_sets.push(beefy_gadget::beefy_peers_set_config());
|
// anything in terms of behaviour, but makes the logs more consistent with the other
|
||||||
|
// Substrate nodes.
|
||||||
|
let grandpa_protocol_name = sc_finality_grandpa::protocol_standard_name(
|
||||||
|
&client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"),
|
||||||
|
&config.chain_spec,
|
||||||
|
);
|
||||||
|
config
|
||||||
|
.network
|
||||||
|
.extra_sets
|
||||||
|
.push(sc_finality_grandpa::grandpa_peers_set_config(grandpa_protocol_name.clone()));
|
||||||
|
|
||||||
|
let beefy_protocol_name = beefy_gadget::protocol_standard_name(
|
||||||
|
&client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"),
|
||||||
|
&config.chain_spec,
|
||||||
|
);
|
||||||
|
config
|
||||||
|
.network
|
||||||
|
.extra_sets
|
||||||
|
.push(beefy_gadget::beefy_peers_set_config(beefy_protocol_name.clone()));
|
||||||
|
|
||||||
let warp_sync = Arc::new(sc_finality_grandpa::warp_proof::NetworkProvider::new(
|
let warp_sync = Arc::new(sc_finality_grandpa::warp_proof::NetworkProvider::new(
|
||||||
backend.clone(),
|
backend.clone(),
|
||||||
grandpa_link.shared_authority_set().clone(),
|
grandpa_link.shared_authority_set().clone(),
|
||||||
@@ -245,8 +265,10 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||||||
let enable_grandpa = !config.disable_grandpa;
|
let enable_grandpa = !config.disable_grandpa;
|
||||||
let prometheus_registry = config.prometheus_registry().cloned();
|
let prometheus_registry = config.prometheus_registry().cloned();
|
||||||
let shared_voter_state = SharedVoterState::empty();
|
let shared_voter_state = SharedVoterState::empty();
|
||||||
let (signed_commitment_sender, signed_commitment_stream) =
|
let (beefy_commitment_link, beefy_commitment_stream) =
|
||||||
beefy_gadget::notification::BeefySignedCommitmentStream::channel();
|
beefy_gadget::notification::BeefySignedCommitmentStream::<Block>::channel();
|
||||||
|
let (beefy_best_block_link, beefy_best_block_stream) =
|
||||||
|
beefy_gadget::notification::BeefyBestBlockStream::<Block>::channel();
|
||||||
|
|
||||||
let rpc_extensions_builder = {
|
let rpc_extensions_builder = {
|
||||||
use sc_finality_grandpa::FinalityProofProvider as GrandpaFinalityProofProvider;
|
use sc_finality_grandpa::FinalityProofProvider as GrandpaFinalityProofProvider;
|
||||||
@@ -287,10 +309,12 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||||||
finality_proof_provider.clone(),
|
finality_proof_provider.clone(),
|
||||||
)));
|
)));
|
||||||
io.extend_with(beefy_gadget_rpc::BeefyApi::to_delegate(
|
io.extend_with(beefy_gadget_rpc::BeefyApi::to_delegate(
|
||||||
beefy_gadget_rpc::BeefyRpcHandler::new(
|
beefy_gadget_rpc::BeefyRpcHandler::<Block>::new(
|
||||||
signed_commitment_stream.clone(),
|
beefy_commitment_stream.clone(),
|
||||||
|
beefy_best_block_stream.clone(),
|
||||||
subscription_executor,
|
subscription_executor,
|
||||||
),
|
)
|
||||||
|
.map_err(|e| sc_service::Error::Other(format!("{}", e)))?,
|
||||||
));
|
));
|
||||||
io.extend_with(pallet_mmr_rpc::MmrApi::to_delegate(pallet_mmr_rpc::Mmr::new(
|
io.extend_with(pallet_mmr_rpc::MmrApi::to_delegate(pallet_mmr_rpc::Mmr::new(
|
||||||
client.clone(),
|
client.clone(),
|
||||||
@@ -374,9 +398,11 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||||||
backend,
|
backend,
|
||||||
key_store: keystore.clone(),
|
key_store: keystore.clone(),
|
||||||
network: network.clone(),
|
network: network.clone(),
|
||||||
signed_commitment_sender,
|
signed_commitment_sender: beefy_commitment_link,
|
||||||
|
beefy_best_block_sender: beefy_best_block_link,
|
||||||
min_block_delta: 4,
|
min_block_delta: 4,
|
||||||
prometheus_registry: prometheus_registry.clone(),
|
prometheus_registry: prometheus_registry.clone(),
|
||||||
|
protocol_name: beefy_protocol_name,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Start the BEEFY bridge gadget.
|
// Start the BEEFY bridge gadget.
|
||||||
@@ -395,6 +421,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||||||
keystore,
|
keystore,
|
||||||
local_role: role,
|
local_role: role,
|
||||||
telemetry: telemetry.as_ref().map(|x| x.handle()),
|
telemetry: telemetry.as_ref().map(|x| x.handle()),
|
||||||
|
protocol_name: grandpa_protocol_name,
|
||||||
};
|
};
|
||||||
|
|
||||||
if enable_grandpa {
|
if enable_grandpa {
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
impl_version: 1,
|
impl_version: 1,
|
||||||
apis: RUNTIME_API_VERSIONS,
|
apis: RUNTIME_API_VERSIONS,
|
||||||
transaction_version: 1,
|
transaction_version: 1,
|
||||||
|
state_version: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The version information used to identify this runtime when compiled natively.
|
/// The version information used to identify this runtime when compiled natively.
|
||||||
@@ -204,6 +205,7 @@ impl frame_system::Config for Runtime {
|
|||||||
type SS58Prefix = SS58Prefix;
|
type SS58Prefix = SS58Prefix;
|
||||||
/// The set code logic, just the default since we're not a parachain.
|
/// The set code logic, just the default since we're not a parachain.
|
||||||
type OnSetCode = ();
|
type OnSetCode = ();
|
||||||
|
type MaxConsumers = frame_support::traits::ConstU32<16>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_randomness_collective_flip::Config for Runtime {}
|
impl pallet_randomness_collective_flip::Config for Runtime {}
|
||||||
@@ -562,7 +564,7 @@ pub type Executive = frame_executive::Executive<
|
|||||||
Block,
|
Block,
|
||||||
frame_system::ChainContext<Runtime>,
|
frame_system::ChainContext<Runtime>,
|
||||||
Runtime,
|
Runtime,
|
||||||
AllPallets,
|
AllPalletsWithSystem,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
impl_runtime_apis! {
|
impl_runtime_apis! {
|
||||||
@@ -664,7 +666,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl beefy_primitives::BeefyApi<Block> for Runtime {
|
impl beefy_primitives::BeefyApi<Block> for Runtime {
|
||||||
fn validator_set() -> ValidatorSet<BeefyId> {
|
fn validator_set() -> Option<ValidatorSet<BeefyId>> {
|
||||||
Beefy::validator_set()
|
Beefy::validator_set()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -841,7 +843,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn bridged_relayer_id() -> Self::InboundRelayer {
|
fn bridged_relayer_id() -> Self::InboundRelayer {
|
||||||
Default::default()
|
[0u8; 32].into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn account_balance(account: &Self::AccountId) -> Self::OutboundMessageFee {
|
fn account_balance(account: &Self::AccountId) -> Self::OutboundMessageFee {
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ default = []
|
|||||||
runtime-benchmarks = ['rialto-parachain-runtime/runtime-benchmarks']
|
runtime-benchmarks = ['rialto-parachain-runtime/runtime-benchmarks']
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
clap = { version = "3.0", features = ["derive"] }
|
||||||
derive_more = '0.99.2'
|
derive_more = '0.99.2'
|
||||||
log = '0.4.14'
|
log = '0.4.14'
|
||||||
codec = { package = 'parity-scale-codec', version = '2.0.0' }
|
codec = { package = 'parity-scale-codec', version = '2.0.0' }
|
||||||
structopt = '0.3.8'
|
|
||||||
serde = { version = '1.0', features = ['derive'] }
|
serde = { version = '1.0', features = ['derive'] }
|
||||||
hex-literal = '0.3.1'
|
hex-literal = '0.3.1'
|
||||||
|
|
||||||
@@ -80,6 +80,8 @@ cumulus-client-network = { git = "https://github.com/paritytech/cumulus", branch
|
|||||||
cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch = "master" }
|
cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch = "master" }
|
||||||
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "master" }
|
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "master" }
|
||||||
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "master" }
|
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "master" }
|
||||||
|
cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", branch = "master" }
|
||||||
|
cumulus-relay-chain-local = { git = "https://github.com/paritytech/cumulus", branch = "master" }
|
||||||
|
|
||||||
# Polkadot dependencies
|
# Polkadot dependencies
|
||||||
polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ pub fn development_config(id: ParaId) -> ChainSpec {
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
Extensions {
|
Extensions {
|
||||||
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
|
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
|
||||||
para_id: id.into(),
|
para_id: id.into(),
|
||||||
@@ -133,6 +134,7 @@ pub fn local_testnet_config(id: ParaId) -> ChainSpec {
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
Extensions {
|
Extensions {
|
||||||
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
|
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
|
||||||
para_id: id.into(),
|
para_id: id.into(),
|
||||||
@@ -155,7 +157,7 @@ fn testnet_genesis(
|
|||||||
balances: rialto_parachain_runtime::BalancesConfig {
|
balances: rialto_parachain_runtime::BalancesConfig {
|
||||||
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
|
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
|
||||||
},
|
},
|
||||||
sudo: rialto_parachain_runtime::SudoConfig { key: root_key },
|
sudo: rialto_parachain_runtime::SudoConfig { key: Some(root_key) },
|
||||||
parachain_info: rialto_parachain_runtime::ParachainInfoConfig { parachain_id: id },
|
parachain_info: rialto_parachain_runtime::ParachainInfoConfig { parachain_id: id },
|
||||||
aura: rialto_parachain_runtime::AuraConfig { authorities: initial_authorities },
|
aura: rialto_parachain_runtime::AuraConfig { authorities: initial_authorities },
|
||||||
aura_ext: Default::default(),
|
aura_ext: Default::default(),
|
||||||
|
|||||||
@@ -15,18 +15,18 @@
|
|||||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use crate::chain_spec;
|
use crate::chain_spec;
|
||||||
|
use clap::{AppSettings, Parser};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use structopt::StructOpt;
|
|
||||||
|
|
||||||
/// Sub-commands supported by the collator.
|
/// Sub-commands supported by the collator.
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
pub enum Subcommand {
|
pub enum Subcommand {
|
||||||
/// Export the genesis state of the parachain.
|
/// Export the genesis state of the parachain.
|
||||||
#[structopt(name = "export-genesis-state")]
|
#[clap(name = "export-genesis-state")]
|
||||||
ExportGenesisState(ExportGenesisStateCommand),
|
ExportGenesisState(ExportGenesisStateCommand),
|
||||||
|
|
||||||
/// Export the genesis wasm of the parachain.
|
/// Export the genesis wasm of the parachain.
|
||||||
#[structopt(name = "export-genesis-wasm")]
|
#[clap(name = "export-genesis-wasm")]
|
||||||
ExportGenesisWasm(ExportGenesisWasmCommand),
|
ExportGenesisWasm(ExportGenesisWasmCommand),
|
||||||
|
|
||||||
/// Build a chain specification.
|
/// Build a chain specification.
|
||||||
@@ -51,66 +51,66 @@ pub enum Subcommand {
|
|||||||
Revert(sc_cli::RevertCmd),
|
Revert(sc_cli::RevertCmd),
|
||||||
|
|
||||||
/// The custom benchmark subcommmand benchmarking runtime pallets.
|
/// The custom benchmark subcommmand benchmarking runtime pallets.
|
||||||
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
|
#[clap(name = "benchmark", about = "Benchmark runtime pallets.")]
|
||||||
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
|
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Command for exporting the genesis state of the parachain
|
/// Command for exporting the genesis state of the parachain
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct ExportGenesisStateCommand {
|
pub struct ExportGenesisStateCommand {
|
||||||
/// Output file name or stdout if unspecified.
|
/// Output file name or stdout if unspecified.
|
||||||
#[structopt(parse(from_os_str))]
|
#[clap(parse(from_os_str))]
|
||||||
pub output: Option<PathBuf>,
|
pub output: Option<PathBuf>,
|
||||||
|
|
||||||
/// Id of the parachain this state is for.
|
/// Id of the parachain this state is for.
|
||||||
///
|
///
|
||||||
/// Default: 100
|
/// Default: 100
|
||||||
#[structopt(long, conflicts_with = "chain")]
|
#[clap(long, conflicts_with = "chain")]
|
||||||
pub parachain_id: Option<u32>,
|
pub parachain_id: Option<u32>,
|
||||||
|
|
||||||
/// Write output in binary. Default is to write in hex.
|
/// Write output in binary. Default is to write in hex.
|
||||||
#[structopt(short, long)]
|
#[clap(short, long)]
|
||||||
pub raw: bool,
|
pub raw: bool,
|
||||||
|
|
||||||
/// The name of the chain for that the genesis state should be exported.
|
/// The name of the chain for that the genesis state should be exported.
|
||||||
#[structopt(long, conflicts_with = "parachain-id")]
|
#[clap(long, conflicts_with = "parachain-id")]
|
||||||
pub chain: Option<String>,
|
pub chain: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Command for exporting the genesis wasm file.
|
/// Command for exporting the genesis wasm file.
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct ExportGenesisWasmCommand {
|
pub struct ExportGenesisWasmCommand {
|
||||||
/// Output file name or stdout if unspecified.
|
/// Output file name or stdout if unspecified.
|
||||||
#[structopt(parse(from_os_str))]
|
#[clap(parse(from_os_str))]
|
||||||
pub output: Option<PathBuf>,
|
pub output: Option<PathBuf>,
|
||||||
|
|
||||||
/// Write output in binary. Default is to write in hex.
|
/// Write output in binary. Default is to write in hex.
|
||||||
#[structopt(short, long)]
|
#[clap(short, long)]
|
||||||
pub raw: bool,
|
pub raw: bool,
|
||||||
|
|
||||||
/// The name of the chain for that the genesis wasm file should be exported.
|
/// The name of the chain for that the genesis wasm file should be exported.
|
||||||
#[structopt(long)]
|
#[clap(long)]
|
||||||
pub chain: Option<String>,
|
pub chain: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
#[structopt(settings = &[
|
#[clap(setting(
|
||||||
structopt::clap::AppSettings::GlobalVersion,
|
AppSettings::PropagateVersion |
|
||||||
structopt::clap::AppSettings::ArgsNegateSubcommands,
|
AppSettings::ArgsNegateSubcommands |
|
||||||
structopt::clap::AppSettings::SubcommandsNegateReqs,
|
AppSettings::SubcommandsNegateReqs,
|
||||||
])]
|
))]
|
||||||
pub struct Cli {
|
pub struct Cli {
|
||||||
#[structopt(subcommand)]
|
#[clap(subcommand)]
|
||||||
pub subcommand: Option<Subcommand>,
|
pub subcommand: Option<Subcommand>,
|
||||||
|
|
||||||
#[structopt(long)]
|
#[clap(long)]
|
||||||
pub parachain_id: Option<u32>,
|
pub parachain_id: Option<u32>,
|
||||||
|
|
||||||
#[structopt(flatten)]
|
#[clap(flatten)]
|
||||||
pub run: cumulus_client_cli::RunCmd,
|
pub run: cumulus_client_cli::RunCmd,
|
||||||
|
|
||||||
/// Relaychain arguments
|
/// Relaychain arguments
|
||||||
#[structopt(raw = true)]
|
#[clap(raw = true)]
|
||||||
pub relaychain_args: Vec<String>,
|
pub relaychain_args: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,6 +135,6 @@ impl RelayChainCli {
|
|||||||
let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);
|
let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);
|
||||||
let chain_id = extension.map(|e| e.relay_chain.clone());
|
let chain_id = extension.map(|e| e.relay_chain.clone());
|
||||||
let base_path = para_config.base_path.as_ref().map(|x| x.path().join("rialto-bridge-node"));
|
let base_path = para_config.base_path.as_ref().map(|x| x.path().join("rialto-bridge-node"));
|
||||||
Self { base_path, chain_id, base: polkadot_cli::RunCmd::from_iter(relay_chain_args) }
|
Self { base_path, chain_id, base: polkadot_cli::RunCmd::parse_from(relay_chain_args) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,10 +211,12 @@ pub fn run() -> Result<()> {
|
|||||||
builder.with_profiling(sc_tracing::TracingReceiver::Log, "");
|
builder.with_profiling(sc_tracing::TracingReceiver::Log, "");
|
||||||
let _ = builder.init();
|
let _ = builder.init();
|
||||||
|
|
||||||
let block: Block = generate_genesis_block(&load_spec(
|
let spec = load_spec(
|
||||||
¶ms.chain.clone().unwrap_or_default(),
|
¶ms.chain.clone().unwrap_or_default(),
|
||||||
params.parachain_id.expect("Missing ParaId").into(),
|
params.parachain_id.expect("Missing ParaId").into(),
|
||||||
)?)?;
|
)?;
|
||||||
|
let state_version = Cli::native_runtime_version(&spec).state_version();
|
||||||
|
let block: Block = generate_genesis_block(&spec, state_version)?;
|
||||||
let raw_header = block.header().encode();
|
let raw_header = block.header().encode();
|
||||||
let output_buf = if params.raw {
|
let output_buf = if params.raw {
|
||||||
raw_header
|
raw_header
|
||||||
@@ -278,8 +280,10 @@ pub fn run() -> Result<()> {
|
|||||||
let parachain_account =
|
let parachain_account =
|
||||||
AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);
|
AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);
|
||||||
|
|
||||||
let block: Block =
|
let state_version =
|
||||||
generate_genesis_block(&config.chain_spec).map_err(|e| format!("{:?}", e))?;
|
RelayChainCli::native_runtime_version(&config.chain_spec).state_version();
|
||||||
|
let block: Block = generate_genesis_block(&config.chain_spec, state_version)
|
||||||
|
.map_err(|e| format!("{:?}", e))?;
|
||||||
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));
|
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));
|
||||||
|
|
||||||
let polkadot_config = SubstrateCli::create_configuration(
|
let polkadot_config = SubstrateCli::create_configuration(
|
||||||
@@ -357,11 +361,24 @@ impl CliConfiguration<Self> for RelayChainCli {
|
|||||||
self.base.base.rpc_ws(default_listen_port)
|
self.base.base.rpc_ws(default_listen_port)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prometheus_config(&self, default_listen_port: u16) -> Result<Option<PrometheusConfig>> {
|
fn prometheus_config(
|
||||||
self.base.base.prometheus_config(default_listen_port)
|
&self,
|
||||||
|
default_listen_port: u16,
|
||||||
|
chain_spec: &Box<dyn ChainSpec>,
|
||||||
|
) -> Result<Option<PrometheusConfig>> {
|
||||||
|
self.base.base.prometheus_config(default_listen_port, chain_spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init<C: SubstrateCli>(&self) -> Result<()> {
|
fn init<F>(
|
||||||
|
&self,
|
||||||
|
_support_url: &String,
|
||||||
|
_impl_version: &String,
|
||||||
|
_logger_hook: F,
|
||||||
|
_config: &sc_service::Configuration,
|
||||||
|
) -> Result<()>
|
||||||
|
where
|
||||||
|
F: FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Configuration),
|
||||||
|
{
|
||||||
unreachable!("PolkadotCli is never initialized; qed");
|
unreachable!("PolkadotCli is never initialized; qed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,21 +22,21 @@
|
|||||||
//! `substrate_frame_rpc_system::SystemApi`.
|
//! `substrate_frame_rpc_system::SystemApi`.
|
||||||
|
|
||||||
// std
|
// std
|
||||||
use std::sync::Arc;
|
use std::{sync::Arc, time::Duration};
|
||||||
|
|
||||||
// Local Runtime Types
|
// Local Runtime Types
|
||||||
use rialto_parachain_runtime::RuntimeApi;
|
use rialto_parachain_runtime::RuntimeApi;
|
||||||
|
|
||||||
// Cumulus Imports
|
// Cumulus Imports
|
||||||
use cumulus_client_consensus_aura::{
|
use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion};
|
||||||
build_aura_consensus, BuildAuraConsensusParams, SlotProportion,
|
|
||||||
};
|
|
||||||
use cumulus_client_consensus_common::ParachainConsensus;
|
use cumulus_client_consensus_common::ParachainConsensus;
|
||||||
use cumulus_client_network::build_block_announce_validator;
|
use cumulus_client_network::BlockAnnounceValidator;
|
||||||
use cumulus_client_service::{
|
use cumulus_client_service::{
|
||||||
prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,
|
prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,
|
||||||
};
|
};
|
||||||
use cumulus_primitives_core::ParaId;
|
use cumulus_primitives_core::ParaId;
|
||||||
|
use cumulus_relay_chain_interface::RelayChainInterface;
|
||||||
|
use cumulus_relay_chain_local::build_relay_chain_interface;
|
||||||
|
|
||||||
// Substrate Imports
|
// Substrate Imports
|
||||||
use sc_client_api::ExecutorProvider;
|
use sc_client_api::ExecutorProvider;
|
||||||
@@ -141,6 +141,7 @@ where
|
|||||||
config.wasm_method,
|
config.wasm_method,
|
||||||
config.default_heap_pages,
|
config.default_heap_pages,
|
||||||
config.max_runtime_instances,
|
config.max_runtime_instances,
|
||||||
|
config.runtime_cache_size,
|
||||||
);
|
);
|
||||||
|
|
||||||
let (client, backend, keystore_container, task_manager) =
|
let (client, backend, keystore_container, task_manager) =
|
||||||
@@ -247,7 +248,7 @@ where
|
|||||||
Option<&Registry>,
|
Option<&Registry>,
|
||||||
Option<TelemetryHandle>,
|
Option<TelemetryHandle>,
|
||||||
&TaskManager,
|
&TaskManager,
|
||||||
&polkadot_service::NewFull<polkadot_service::Client>,
|
Arc<dyn RelayChainInterface>,
|
||||||
Arc<
|
Arc<
|
||||||
sc_transaction_pool::FullPool<
|
sc_transaction_pool::FullPool<
|
||||||
Block,
|
Block,
|
||||||
@@ -268,8 +269,9 @@ where
|
|||||||
let params = new_partial::<RuntimeApi, Executor, BIQ>(¶chain_config, build_import_queue)?;
|
let params = new_partial::<RuntimeApi, Executor, BIQ>(¶chain_config, build_import_queue)?;
|
||||||
let (mut telemetry, telemetry_worker_handle) = params.other;
|
let (mut telemetry, telemetry_worker_handle) = params.other;
|
||||||
|
|
||||||
let relay_chain_full_node =
|
let mut task_manager = params.task_manager;
|
||||||
cumulus_client_service::build_polkadot_full_node(polkadot_config, telemetry_worker_handle)
|
let (relay_chain_interface, collator_key) =
|
||||||
|
build_relay_chain_interface(polkadot_config, telemetry_worker_handle, &mut task_manager)
|
||||||
.map_err(|e| match e {
|
.map_err(|e| match e {
|
||||||
polkadot_service::Error::Sub(x) => x,
|
polkadot_service::Error::Sub(x) => x,
|
||||||
s => format!("{}", s).into(),
|
s => format!("{}", s).into(),
|
||||||
@@ -277,18 +279,12 @@ where
|
|||||||
|
|
||||||
let client = params.client.clone();
|
let client = params.client.clone();
|
||||||
let backend = params.backend.clone();
|
let backend = params.backend.clone();
|
||||||
let block_announce_validator = build_block_announce_validator(
|
let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface.clone(), id);
|
||||||
relay_chain_full_node.client.clone(),
|
|
||||||
id,
|
|
||||||
Box::new(relay_chain_full_node.network.clone()),
|
|
||||||
relay_chain_full_node.backend.clone(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let force_authoring = parachain_config.force_authoring;
|
let force_authoring = parachain_config.force_authoring;
|
||||||
let validator = parachain_config.role.is_authority();
|
let validator = parachain_config.role.is_authority();
|
||||||
let prometheus_registry = parachain_config.prometheus_registry().cloned();
|
let prometheus_registry = parachain_config.prometheus_registry().cloned();
|
||||||
let transaction_pool = params.transaction_pool.clone();
|
let transaction_pool = params.transaction_pool.clone();
|
||||||
let mut task_manager = params.task_manager;
|
|
||||||
let import_queue = cumulus_client_service::SharedImportQueue::new(params.import_queue);
|
let import_queue = cumulus_client_service::SharedImportQueue::new(params.import_queue);
|
||||||
let (network, system_rpc_tx, start_network) =
|
let (network, system_rpc_tx, start_network) =
|
||||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||||
@@ -297,7 +293,9 @@ where
|
|||||||
transaction_pool: transaction_pool.clone(),
|
transaction_pool: transaction_pool.clone(),
|
||||||
spawn_handle: task_manager.spawn_handle(),
|
spawn_handle: task_manager.spawn_handle(),
|
||||||
import_queue: import_queue.clone(),
|
import_queue: import_queue.clone(),
|
||||||
block_announce_validator_builder: Some(Box::new(|_| block_announce_validator)),
|
block_announce_validator_builder: Some(Box::new(|_| {
|
||||||
|
Box::new(block_announce_validator)
|
||||||
|
})),
|
||||||
warp_sync: None,
|
warp_sync: None,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -325,13 +323,15 @@ where
|
|||||||
Arc::new(move |hash, data| network.announce_block(hash, data))
|
Arc::new(move |hash, data| network.announce_block(hash, data))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let relay_chain_slot_duration = Duration::from_secs(6);
|
||||||
|
|
||||||
if validator {
|
if validator {
|
||||||
let parachain_consensus = build_consensus(
|
let parachain_consensus = build_consensus(
|
||||||
client.clone(),
|
client.clone(),
|
||||||
prometheus_registry.as_ref(),
|
prometheus_registry.as_ref(),
|
||||||
telemetry.as_ref().map(|t| t.handle()),
|
telemetry.as_ref().map(|t| t.handle()),
|
||||||
&task_manager,
|
&task_manager,
|
||||||
&relay_chain_full_node,
|
relay_chain_interface.clone(),
|
||||||
transaction_pool,
|
transaction_pool,
|
||||||
network,
|
network,
|
||||||
params.keystore_container.sync_keystore(),
|
params.keystore_container.sync_keystore(),
|
||||||
@@ -346,10 +346,12 @@ where
|
|||||||
announce_block,
|
announce_block,
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
task_manager: &mut task_manager,
|
task_manager: &mut task_manager,
|
||||||
relay_chain_full_node,
|
relay_chain_interface,
|
||||||
spawner,
|
spawner,
|
||||||
parachain_consensus,
|
parachain_consensus,
|
||||||
import_queue,
|
import_queue,
|
||||||
|
collator_key,
|
||||||
|
relay_chain_slot_duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
start_collator(params).await?;
|
start_collator(params).await?;
|
||||||
@@ -359,7 +361,9 @@ where
|
|||||||
announce_block,
|
announce_block,
|
||||||
task_manager: &mut task_manager,
|
task_manager: &mut task_manager,
|
||||||
para_id: id,
|
para_id: id,
|
||||||
relay_chain_full_node,
|
relay_chain_interface,
|
||||||
|
relay_chain_slot_duration,
|
||||||
|
import_queue,
|
||||||
};
|
};
|
||||||
|
|
||||||
start_full_node(params)?;
|
start_full_node(params)?;
|
||||||
@@ -447,7 +451,7 @@ pub async fn start_node(
|
|||||||
prometheus_registry,
|
prometheus_registry,
|
||||||
telemetry,
|
telemetry,
|
||||||
task_manager,
|
task_manager,
|
||||||
relay_chain_node,
|
relay_chain_interface,
|
||||||
transaction_pool,
|
transaction_pool,
|
||||||
sync_oracle,
|
sync_oracle,
|
||||||
keystore,
|
keystore,
|
||||||
@@ -462,60 +466,47 @@ pub async fn start_node(
|
|||||||
telemetry.clone(),
|
telemetry.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let relay_chain_backend = relay_chain_node.backend.clone();
|
Ok(AuraConsensus::build::<sp_consensus_aura::sr25519::AuthorityPair, _, _, _, _, _, _>(
|
||||||
let relay_chain_client = relay_chain_node.client.clone();
|
BuildAuraConsensusParams {
|
||||||
Ok(build_aura_consensus::<
|
proposer_factory,
|
||||||
sp_consensus_aura::sr25519::AuthorityPair,
|
create_inherent_data_providers: move |_, (relay_parent, validation_data)| {
|
||||||
_,
|
let relay_chain_interface = relay_chain_interface.clone();
|
||||||
_,
|
async move {
|
||||||
_,
|
let parachain_inherent =
|
||||||
_,
|
cumulus_primitives_parachain_inherent::ParachainInherentData::create_at(
|
||||||
_,
|
|
||||||
_,
|
|
||||||
_,
|
|
||||||
_,
|
|
||||||
_,
|
|
||||||
>(BuildAuraConsensusParams {
|
|
||||||
proposer_factory,
|
|
||||||
create_inherent_data_providers: move |_, (relay_parent, validation_data)| {
|
|
||||||
let parachain_inherent =
|
|
||||||
cumulus_primitives_parachain_inherent::ParachainInherentData::create_at_with_client(
|
|
||||||
relay_parent,
|
relay_parent,
|
||||||
&relay_chain_client,
|
&relay_chain_interface,
|
||||||
&*relay_chain_backend,
|
|
||||||
&validation_data,
|
&validation_data,
|
||||||
id,
|
id,
|
||||||
);
|
).await;
|
||||||
async move {
|
let time = sp_timestamp::InherentDataProvider::from_system_time();
|
||||||
let time = sp_timestamp::InherentDataProvider::from_system_time();
|
|
||||||
|
|
||||||
let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
|
let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
|
||||||
*time,
|
*time,
|
||||||
slot_duration.slot_duration(),
|
slot_duration.slot_duration(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let parachain_inherent = parachain_inherent.ok_or_else(|| {
|
let parachain_inherent = parachain_inherent.ok_or_else(|| {
|
||||||
Box::<dyn std::error::Error + Send + Sync>::from(
|
Box::<dyn std::error::Error + Send + Sync>::from(
|
||||||
"Failed to create parachain inherent",
|
"Failed to create parachain inherent",
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
Ok((time, slot, parachain_inherent))
|
Ok((time, slot, parachain_inherent))
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
block_import: client.clone(),
|
||||||
|
para_client: client,
|
||||||
|
backoff_authoring_blocks: Option::<()>::None,
|
||||||
|
sync_oracle,
|
||||||
|
keystore,
|
||||||
|
force_authoring,
|
||||||
|
slot_duration,
|
||||||
|
// We got around 500ms for proposing
|
||||||
|
block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32),
|
||||||
|
telemetry,
|
||||||
|
max_block_proposal_slot_portion: None,
|
||||||
},
|
},
|
||||||
block_import: client.clone(),
|
))
|
||||||
relay_chain_client: relay_chain_node.client.clone(),
|
|
||||||
relay_chain_backend: relay_chain_node.backend.clone(),
|
|
||||||
para_client: client,
|
|
||||||
backoff_authoring_blocks: Option::<()>::None,
|
|
||||||
sync_oracle,
|
|
||||||
keystore,
|
|
||||||
force_authoring,
|
|
||||||
slot_duration,
|
|
||||||
// We got around 500ms for proposing
|
|
||||||
block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32),
|
|
||||||
telemetry,
|
|
||||||
max_block_proposal_slot_portion: None,
|
|
||||||
}))
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ pub use frame_support::{
|
|||||||
},
|
},
|
||||||
StorageValue,
|
StorageValue,
|
||||||
};
|
};
|
||||||
pub use frame_system::Call as SystemCall;
|
pub use frame_system::{Call as SystemCall, EnsureRoot};
|
||||||
pub use pallet_balances::Call as BalancesCall;
|
pub use pallet_balances::Call as BalancesCall;
|
||||||
pub use pallet_timestamp::Call as TimestampCall;
|
pub use pallet_timestamp::Call as TimestampCall;
|
||||||
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||||
@@ -70,7 +70,7 @@ use xcm::latest::prelude::*;
|
|||||||
use xcm_builder::{
|
use xcm_builder::{
|
||||||
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
|
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
|
||||||
EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,
|
EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,
|
||||||
ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,
|
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
|
||||||
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
|
||||||
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
|
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
|
||||||
};
|
};
|
||||||
@@ -103,7 +103,7 @@ pub type Executive = frame_executive::Executive<
|
|||||||
Block,
|
Block,
|
||||||
frame_system::ChainContext<Runtime>,
|
frame_system::ChainContext<Runtime>,
|
||||||
Runtime,
|
Runtime,
|
||||||
AllPallets,
|
AllPalletsWithSystem,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
impl_opaque_keys! {
|
impl_opaque_keys! {
|
||||||
@@ -122,6 +122,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
impl_version: 0,
|
impl_version: 0,
|
||||||
apis: RUNTIME_API_VERSIONS,
|
apis: RUNTIME_API_VERSIONS,
|
||||||
transaction_version: 1,
|
transaction_version: 1,
|
||||||
|
state_version: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This determines the average expected block time that we are targeting.
|
/// This determines the average expected block time that we are targeting.
|
||||||
@@ -209,6 +210,7 @@ impl frame_system::Config for Runtime {
|
|||||||
type SS58Prefix = SS58Prefix;
|
type SS58Prefix = SS58Prefix;
|
||||||
/// The action to take on a Runtime Upgrade
|
/// The action to take on a Runtime Upgrade
|
||||||
type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
|
type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
|
||||||
|
type MaxConsumers = frame_support::traits::ConstU32<16>;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
@@ -267,7 +269,7 @@ parameter_types! {
|
|||||||
|
|
||||||
impl cumulus_pallet_parachain_system::Config for Runtime {
|
impl cumulus_pallet_parachain_system::Config for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type OnValidationData = ();
|
type OnSystemEvent = ();
|
||||||
type SelfParaId = parachain_info::Pallet<Runtime>;
|
type SelfParaId = parachain_info::Pallet<Runtime>;
|
||||||
type OutboundXcmpMessageSource = XcmpQueue;
|
type OutboundXcmpMessageSource = XcmpQueue;
|
||||||
type DmpMessageHandler = DmpQueue;
|
type DmpMessageHandler = DmpQueue;
|
||||||
@@ -294,7 +296,7 @@ parameter_types! {
|
|||||||
/// `Transact` in order to determine the dispatch Origin.
|
/// `Transact` in order to determine the dispatch Origin.
|
||||||
pub type LocationToAccountId = (
|
pub type LocationToAccountId = (
|
||||||
// The parent (Relay-chain) origin converts to the default `AccountId`.
|
// The parent (Relay-chain) origin converts to the default `AccountId`.
|
||||||
ParentIsDefault<AccountId>,
|
ParentIsPreset<AccountId>,
|
||||||
// Sibling parachain origins convert to AccountId via the `ParaId::into`.
|
// Sibling parachain origins convert to AccountId via the `ParaId::into`.
|
||||||
SiblingParachainConvertsVia<Sibling, AccountId>,
|
SiblingParachainConvertsVia<Sibling, AccountId>,
|
||||||
// Straight up local `AccountId32` origins just alias directly to `AccountId`.
|
// Straight up local `AccountId32` origins just alias directly to `AccountId`.
|
||||||
@@ -420,6 +422,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
|
|||||||
type XcmExecutor = XcmExecutor<XcmConfig>;
|
type XcmExecutor = XcmExecutor<XcmConfig>;
|
||||||
type ChannelInfo = ParachainSystem;
|
type ChannelInfo = ParachainSystem;
|
||||||
type VersionWrapper = ();
|
type VersionWrapper = ();
|
||||||
|
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl cumulus_pallet_dmp_queue::Config for Runtime {
|
impl cumulus_pallet_dmp_queue::Config for Runtime {
|
||||||
@@ -554,8 +557,8 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
|
impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
|
||||||
fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {
|
fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
|
||||||
ParachainSystem::collect_collation_info()
|
ParachainSystem::collect_collation_info(header)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ repository = "https://github.com/paritytech/parity-bridges-common/"
|
|||||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
clap = { version = "3.0", features = ["derive"] }
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
jsonrpc-core = "18.0"
|
jsonrpc-core = "18.0"
|
||||||
kvdb = "0.10"
|
kvdb = "0.10"
|
||||||
kvdb-rocksdb = "0.12"
|
kvdb-rocksdb = "0.12"
|
||||||
lru = "0.7"
|
lru = "0.7"
|
||||||
structopt = "0.3.21"
|
|
||||||
serde_json = "1.0.59"
|
serde_json = "1.0.59"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ impl Alternative {
|
|||||||
vec![],
|
vec![],
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
properties,
|
properties,
|
||||||
Default::default(),
|
Default::default(),
|
||||||
),
|
),
|
||||||
@@ -128,6 +129,7 @@ impl Alternative {
|
|||||||
vec![],
|
vec![],
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
properties,
|
properties,
|
||||||
Default::default(),
|
Default::default(),
|
||||||
),
|
),
|
||||||
@@ -222,7 +224,7 @@ fn testnet_genesis(
|
|||||||
},
|
},
|
||||||
beefy: BeefyConfig { authorities: Vec::new() },
|
beefy: BeefyConfig { authorities: Vec::new() },
|
||||||
grandpa: GrandpaConfig { authorities: Vec::new() },
|
grandpa: GrandpaConfig { authorities: Vec::new() },
|
||||||
sudo: SudoConfig { key: root_key },
|
sudo: SudoConfig { key: Some(root_key) },
|
||||||
session: SessionConfig {
|
session: SessionConfig {
|
||||||
keys: initial_authorities
|
keys: initial_authorities
|
||||||
.iter()
|
.iter()
|
||||||
@@ -248,8 +250,8 @@ fn testnet_genesis(
|
|||||||
// (see /node/service/src/chain_spec.rs:default_parachains_host_configuration)
|
// (see /node/service/src/chain_spec.rs:default_parachains_host_configuration)
|
||||||
configuration: ConfigurationConfig {
|
configuration: ConfigurationConfig {
|
||||||
config: polkadot_runtime_parachains::configuration::HostConfiguration {
|
config: polkadot_runtime_parachains::configuration::HostConfiguration {
|
||||||
validation_upgrade_frequency: 1u32,
|
validation_upgrade_cooldown: 2u32,
|
||||||
validation_upgrade_delay: 1,
|
validation_upgrade_delay: 2,
|
||||||
code_retention_period: 1200,
|
code_retention_period: 1200,
|
||||||
max_code_size: polkadot_primitives::v1::MAX_CODE_SIZE,
|
max_code_size: polkadot_primitives::v1::MAX_CODE_SIZE,
|
||||||
max_pov_size: polkadot_primitives::v1::MAX_POV_SIZE,
|
max_pov_size: polkadot_primitives::v1::MAX_POV_SIZE,
|
||||||
@@ -259,13 +261,8 @@ fn testnet_genesis(
|
|||||||
thread_availability_period: 4,
|
thread_availability_period: 4,
|
||||||
max_upward_queue_count: 8,
|
max_upward_queue_count: 8,
|
||||||
max_upward_queue_size: 1024 * 1024,
|
max_upward_queue_size: 1024 * 1024,
|
||||||
max_downward_message_size: 1024,
|
max_downward_message_size: 1024 * 1024,
|
||||||
// this is approximatelly 4ms.
|
ump_service_total_weight: 100_000_000_000,
|
||||||
//
|
|
||||||
// Same as `4 * frame_support::weights::WEIGHT_PER_MILLIS`. We don't bother with
|
|
||||||
// an import since that's a made up number and should be replaced with a constant
|
|
||||||
// obtained by benchmarking anyway.
|
|
||||||
ump_service_total_weight: 4 * 1_000_000_000,
|
|
||||||
max_upward_message_size: 1024 * 1024,
|
max_upward_message_size: 1024 * 1024,
|
||||||
max_upward_message_num_per_candidate: 5,
|
max_upward_message_num_per_candidate: 5,
|
||||||
hrmp_sender_deposit: 0,
|
hrmp_sender_deposit: 0,
|
||||||
@@ -284,6 +281,7 @@ fn testnet_genesis(
|
|||||||
needed_approvals: 2,
|
needed_approvals: 2,
|
||||||
relay_vrf_modulo_samples: 2,
|
relay_vrf_modulo_samples: 2,
|
||||||
zeroth_delay_tranche_width: 0,
|
zeroth_delay_tranche_width: 0,
|
||||||
|
minimum_validation_upgrade_delay: 5,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,10 +14,10 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
use clap::{AppSettings, Parser};
|
||||||
use sc_cli::RunCmd;
|
use sc_cli::RunCmd;
|
||||||
use structopt::StructOpt;
|
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct Cli {
|
pub struct Cli {
|
||||||
#[structopt(subcommand)]
|
#[structopt(subcommand)]
|
||||||
pub subcommand: Option<Subcommand>,
|
pub subcommand: Option<Subcommand>,
|
||||||
@@ -27,9 +27,10 @@ pub struct Cli {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Possible subcommands of the main binary.
|
/// Possible subcommands of the main binary.
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
pub enum Subcommand {
|
pub enum Subcommand {
|
||||||
/// Key management CLI utilities
|
/// Key management CLI utilities
|
||||||
|
#[clap(subcommand)]
|
||||||
Key(sc_cli::KeySubcommand),
|
Key(sc_cli::KeySubcommand),
|
||||||
|
|
||||||
/// Verify a signature for a message, provided on `STDIN`, with a given (public or secret) key.
|
/// Verify a signature for a message, provided on `STDIN`, with a given (public or secret) key.
|
||||||
@@ -69,16 +70,16 @@ pub enum Subcommand {
|
|||||||
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
|
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
|
||||||
|
|
||||||
/// FOR INTERNAL USE: analog of the "prepare-worker" command of the polkadot binary.
|
/// FOR INTERNAL USE: analog of the "prepare-worker" command of the polkadot binary.
|
||||||
#[structopt(name = "prepare-worker", setting = structopt::clap::AppSettings::Hidden)]
|
#[clap(name = "prepare-worker", setting = AppSettings::Hidden)]
|
||||||
PvfPrepareWorker(ValidationWorkerCommand),
|
PvfPrepareWorker(ValidationWorkerCommand),
|
||||||
|
|
||||||
/// FOR INTERNAL USE: analog of the "execute-worker" command of the polkadot binary.
|
/// FOR INTERNAL USE: analog of the "execute-worker" command of the polkadot binary.
|
||||||
#[structopt(name = "execute-worker", setting = structopt::clap::AppSettings::Hidden)]
|
#[clap(name = "execute-worker", setting = AppSettings::Hidden)]
|
||||||
PvfExecuteWorker(ValidationWorkerCommand),
|
PvfExecuteWorker(ValidationWorkerCommand),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validation worker command.
|
/// Validation worker command.
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct ValidationWorkerCommand {
|
pub struct ValidationWorkerCommand {
|
||||||
/// The path to the validation host's socket.
|
/// The path to the validation host's socket.
|
||||||
pub socket_path: String,
|
pub socket_path: String,
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
impl_version: 1,
|
impl_version: 1,
|
||||||
apis: RUNTIME_API_VERSIONS,
|
apis: RUNTIME_API_VERSIONS,
|
||||||
transaction_version: 1,
|
transaction_version: 1,
|
||||||
|
state_version: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The version information used to identify this runtime when compiled natively.
|
/// The version information used to identify this runtime when compiled natively.
|
||||||
@@ -208,6 +209,7 @@ impl frame_system::Config for Runtime {
|
|||||||
type SS58Prefix = SS58Prefix;
|
type SS58Prefix = SS58Prefix;
|
||||||
/// The set code logic, just the default since we're not a parachain.
|
/// The set code logic, just the default since we're not a parachain.
|
||||||
type OnSetCode = ();
|
type OnSetCode = ();
|
||||||
|
type MaxConsumers = frame_support::traits::ConstU32<16>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The BABE epoch configuration at genesis.
|
/// The BABE epoch configuration at genesis.
|
||||||
@@ -553,7 +555,7 @@ pub type Executive = frame_executive::Executive<
|
|||||||
Block,
|
Block,
|
||||||
frame_system::ChainContext<Runtime>,
|
frame_system::ChainContext<Runtime>,
|
||||||
Runtime,
|
Runtime,
|
||||||
AllPallets,
|
AllPalletsWithSystem,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
impl_runtime_apis! {
|
impl_runtime_apis! {
|
||||||
@@ -605,7 +607,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl beefy_primitives::BeefyApi<Block> for Runtime {
|
impl beefy_primitives::BeefyApi<Block> for Runtime {
|
||||||
fn validator_set() -> ValidatorSet<BeefyId> {
|
fn validator_set() -> Option<ValidatorSet<BeefyId>> {
|
||||||
Beefy::validator_set()
|
Beefy::validator_set()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -715,15 +717,12 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl polkadot_primitives::v1::ParachainHost<Block, Hash, BlockNumber> for Runtime {
|
impl polkadot_primitives::v2::ParachainHost<Block, Hash, BlockNumber> for Runtime {
|
||||||
fn validators() -> Vec<polkadot_primitives::v1::ValidatorId> {
|
fn validators() -> Vec<polkadot_primitives::v1::ValidatorId> {
|
||||||
polkadot_runtime_parachains::runtime_api_impl::v1::validators::<Runtime>()
|
polkadot_runtime_parachains::runtime_api_impl::v1::validators::<Runtime>()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validator_groups() -> (
|
fn validator_groups() -> (Vec<Vec<polkadot_primitives::v1::ValidatorIndex>>, polkadot_primitives::v1::GroupRotationInfo<BlockNumber>) {
|
||||||
Vec<Vec<polkadot_primitives::v1::ValidatorIndex>>,
|
|
||||||
polkadot_primitives::v1::GroupRotationInfo<BlockNumber>,
|
|
||||||
) {
|
|
||||||
polkadot_runtime_parachains::runtime_api_impl::v1::validator_groups::<Runtime>()
|
polkadot_runtime_parachains::runtime_api_impl::v1::validator_groups::<Runtime>()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -731,10 +730,7 @@ impl_runtime_apis! {
|
|||||||
polkadot_runtime_parachains::runtime_api_impl::v1::availability_cores::<Runtime>()
|
polkadot_runtime_parachains::runtime_api_impl::v1::availability_cores::<Runtime>()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn persisted_validation_data(
|
fn persisted_validation_data(para_id: polkadot_primitives::v1::Id, assumption: polkadot_primitives::v1::OccupiedCoreAssumption)
|
||||||
para_id: polkadot_primitives::v1::Id,
|
|
||||||
assumption: polkadot_primitives::v1::OccupiedCoreAssumption,
|
|
||||||
)
|
|
||||||
-> Option<polkadot_primitives::v1::PersistedValidationData<Hash, BlockNumber>> {
|
-> Option<polkadot_primitives::v1::PersistedValidationData<Hash, BlockNumber>> {
|
||||||
polkadot_runtime_parachains::runtime_api_impl::v1::persisted_validation_data::<Runtime>(para_id, assumption)
|
polkadot_runtime_parachains::runtime_api_impl::v1::persisted_validation_data::<Runtime>(para_id, assumption)
|
||||||
}
|
}
|
||||||
@@ -743,7 +739,10 @@ impl_runtime_apis! {
|
|||||||
para_id: polkadot_primitives::v1::Id,
|
para_id: polkadot_primitives::v1::Id,
|
||||||
expected_persisted_validation_data_hash: Hash,
|
expected_persisted_validation_data_hash: Hash,
|
||||||
) -> Option<(polkadot_primitives::v1::PersistedValidationData<Hash, BlockNumber>, polkadot_primitives::v1::ValidationCodeHash)> {
|
) -> Option<(polkadot_primitives::v1::PersistedValidationData<Hash, BlockNumber>, polkadot_primitives::v1::ValidationCodeHash)> {
|
||||||
polkadot_runtime_parachains::runtime_api_impl::v1::assumed_validation_data::<Runtime>(para_id, expected_persisted_validation_data_hash)
|
polkadot_runtime_parachains::runtime_api_impl::v1::assumed_validation_data::<Runtime>(
|
||||||
|
para_id,
|
||||||
|
expected_persisted_validation_data_hash,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_validation_outputs(
|
fn check_validation_outputs(
|
||||||
@@ -757,17 +756,12 @@ impl_runtime_apis! {
|
|||||||
polkadot_runtime_parachains::runtime_api_impl::v1::session_index_for_child::<Runtime>()
|
polkadot_runtime_parachains::runtime_api_impl::v1::session_index_for_child::<Runtime>()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validation_code(
|
fn validation_code(para_id: polkadot_primitives::v1::Id, assumption: polkadot_primitives::v1::OccupiedCoreAssumption)
|
||||||
para_id: polkadot_primitives::v1::Id,
|
|
||||||
assumption: polkadot_primitives::v1::OccupiedCoreAssumption,
|
|
||||||
)
|
|
||||||
-> Option<polkadot_primitives::v1::ValidationCode> {
|
-> Option<polkadot_primitives::v1::ValidationCode> {
|
||||||
polkadot_runtime_parachains::runtime_api_impl::v1::validation_code::<Runtime>(para_id, assumption)
|
polkadot_runtime_parachains::runtime_api_impl::v1::validation_code::<Runtime>(para_id, assumption)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn candidate_pending_availability(
|
fn candidate_pending_availability(para_id: polkadot_primitives::v1::Id) -> Option<polkadot_primitives::v1::CommittedCandidateReceipt<Hash>> {
|
||||||
para_id: polkadot_primitives::v1::Id,
|
|
||||||
) -> Option<polkadot_primitives::v1::CommittedCandidateReceipt<Hash>> {
|
|
||||||
polkadot_runtime_parachains::runtime_api_impl::v1::candidate_pending_availability::<Runtime>(para_id)
|
polkadot_runtime_parachains::runtime_api_impl::v1::candidate_pending_availability::<Runtime>(para_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -782,13 +776,11 @@ impl_runtime_apis! {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn session_info(index: polkadot_primitives::v1::SessionIndex) -> Option<polkadot_primitives::v1::SessionInfo> {
|
fn session_info(index: polkadot_primitives::v1::SessionIndex) -> Option<polkadot_primitives::v2::SessionInfo> {
|
||||||
polkadot_runtime_parachains::runtime_api_impl::v1::session_info::<Runtime>(index)
|
polkadot_runtime_parachains::runtime_api_impl::v1::session_info::<Runtime>(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dmq_contents(
|
fn dmq_contents(recipient: polkadot_primitives::v1::Id) -> Vec<polkadot_primitives::v1::InboundDownwardMessage<BlockNumber>> {
|
||||||
recipient: polkadot_primitives::v1::Id,
|
|
||||||
) -> Vec<polkadot_primitives::v1::InboundDownwardMessage<BlockNumber>> {
|
|
||||||
polkadot_runtime_parachains::runtime_api_impl::v1::dmq_contents::<Runtime>(recipient)
|
polkadot_runtime_parachains::runtime_api_impl::v1::dmq_contents::<Runtime>(recipient)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -798,15 +790,27 @@ impl_runtime_apis! {
|
|||||||
polkadot_runtime_parachains::runtime_api_impl::v1::inbound_hrmp_channels_contents::<Runtime>(recipient)
|
polkadot_runtime_parachains::runtime_api_impl::v1::inbound_hrmp_channels_contents::<Runtime>(recipient)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validation_code_by_hash(
|
fn validation_code_by_hash(hash: polkadot_primitives::v1::ValidationCodeHash) -> Option<polkadot_primitives::v1::ValidationCode> {
|
||||||
hash: polkadot_primitives::v1::ValidationCodeHash,
|
|
||||||
) -> Option<polkadot_primitives::v1::ValidationCode> {
|
|
||||||
polkadot_runtime_parachains::runtime_api_impl::v1::validation_code_by_hash::<Runtime>(hash)
|
polkadot_runtime_parachains::runtime_api_impl::v1::validation_code_by_hash::<Runtime>(hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_chain_votes() -> Option<polkadot_primitives::v1::ScrapedOnChainVotes<Hash>> {
|
fn on_chain_votes() -> Option<polkadot_primitives::v1::ScrapedOnChainVotes<Hash>> {
|
||||||
polkadot_runtime_parachains::runtime_api_impl::v1::on_chain_votes::<Runtime>()
|
polkadot_runtime_parachains::runtime_api_impl::v1::on_chain_votes::<Runtime>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn submit_pvf_check_statement(stmt: polkadot_primitives::v2::PvfCheckStatement, signature: polkadot_primitives::v1::ValidatorSignature) {
|
||||||
|
polkadot_runtime_parachains::runtime_api_impl::v1::submit_pvf_check_statement::<Runtime>(stmt, signature)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pvfs_require_precheck() -> Vec<polkadot_primitives::v1::ValidationCodeHash> {
|
||||||
|
polkadot_runtime_parachains::runtime_api_impl::v1::pvfs_require_precheck::<Runtime>()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn validation_code_hash(para_id: polkadot_primitives::v1::Id, assumption: polkadot_primitives::v1::OccupiedCoreAssumption)
|
||||||
|
-> Option<polkadot_primitives::v1::ValidationCodeHash>
|
||||||
|
{
|
||||||
|
polkadot_runtime_parachains::runtime_api_impl::v1::validation_code_hash::<Runtime>(para_id, assumption)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
|
impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ mod tests {
|
|||||||
SystemConfig::default().build_storage::<Runtime>().unwrap().into();
|
SystemConfig::default().build_storage::<Runtime>().unwrap().into();
|
||||||
ext.execute_with(|| {
|
ext.execute_with(|| {
|
||||||
let bridge = MILLAU_CHAIN_ID;
|
let bridge = MILLAU_CHAIN_ID;
|
||||||
let call: Call = SystemCall::remark { remark: vec![] }.into();
|
let call: Call = SystemCall::set_heap_pages { pages: 64 }.into();
|
||||||
let dispatch_weight = call.get_dispatch_info().weight;
|
let dispatch_weight = call.get_dispatch_info().weight;
|
||||||
let dispatch_fee = <Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(
|
let dispatch_fee = <Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(
|
||||||
&dispatch_weight,
|
&dispatch_weight,
|
||||||
|
|||||||
@@ -16,7 +16,10 @@
|
|||||||
|
|
||||||
//! Parachains support in Rialto runtime.
|
//! Parachains support in Rialto runtime.
|
||||||
|
|
||||||
use crate::{AccountId, Balance, Balances, BlockNumber, Event, Origin, Registrar, Runtime, Slots};
|
use crate::{
|
||||||
|
AccountId, Babe, Balance, Balances, BlockNumber, Call, Event, Origin, Registrar, Runtime,
|
||||||
|
Slots, UncheckedExtrinsic,
|
||||||
|
};
|
||||||
|
|
||||||
use frame_support::{parameter_types, weights::Weight};
|
use frame_support::{parameter_types, weights::Weight};
|
||||||
use frame_system::EnsureRoot;
|
use frame_system::EnsureRoot;
|
||||||
@@ -29,6 +32,15 @@ use polkadot_runtime_parachains::{
|
|||||||
paras_inherent as parachains_paras_inherent, scheduler as parachains_scheduler,
|
paras_inherent as parachains_paras_inherent, scheduler as parachains_scheduler,
|
||||||
session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump,
|
session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump,
|
||||||
};
|
};
|
||||||
|
use sp_runtime::transaction_validity::TransactionPriority;
|
||||||
|
|
||||||
|
impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime
|
||||||
|
where
|
||||||
|
Call: From<C>,
|
||||||
|
{
|
||||||
|
type Extrinsic = UncheckedExtrinsic;
|
||||||
|
type OverarchingCall = Call;
|
||||||
|
}
|
||||||
|
|
||||||
/// Special `RewardValidators` that does nothing ;)
|
/// Special `RewardValidators` that does nothing ;)
|
||||||
pub struct RewardValidators;
|
pub struct RewardValidators;
|
||||||
@@ -49,6 +61,7 @@ impl parachains_hrmp::Config for Runtime {
|
|||||||
type Event = Event;
|
type Event = Event;
|
||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
type Currency = Balances;
|
type Currency = Balances;
|
||||||
|
type WeightInfo = parachains_hrmp::TestWeightInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl parachains_inclusion::Config for Runtime {
|
impl parachains_inclusion::Config for Runtime {
|
||||||
@@ -65,10 +78,15 @@ impl parachains_initializer::Config for Runtime {
|
|||||||
|
|
||||||
impl parachains_origin::Config for Runtime {}
|
impl parachains_origin::Config for Runtime {}
|
||||||
|
|
||||||
|
parameter_types! {
|
||||||
|
pub const ParasUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
|
||||||
|
}
|
||||||
|
|
||||||
impl parachains_paras::Config for Runtime {
|
impl parachains_paras::Config for Runtime {
|
||||||
type Origin = Origin;
|
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type WeightInfo = parachains_paras::TestWeightInfo;
|
type WeightInfo = parachains_paras::TestWeightInfo;
|
||||||
|
type UnsignedPriority = ParasUnsignedPriority;
|
||||||
|
type NextSessionRotation = Babe;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl parachains_paras_inherent::Config for Runtime {
|
impl parachains_paras_inherent::Config for Runtime {
|
||||||
@@ -120,6 +138,7 @@ impl slots::Config for Runtime {
|
|||||||
type LeasePeriod = LeasePeriod;
|
type LeasePeriod = LeasePeriod;
|
||||||
type WeightInfo = slots::TestWeightInfo;
|
type WeightInfo = slots::TestWeightInfo;
|
||||||
type LeaseOffset = ();
|
type LeaseOffset = ();
|
||||||
|
type ForceOrigin = EnsureRoot<AccountId>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl paras_sudo_wrapper::Config for Runtime {}
|
impl paras_sudo_wrapper::Config for Runtime {}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ use pallet_bridge_messages::benchmarking::{
|
|||||||
use sp_core::Hasher;
|
use sp_core::Hasher;
|
||||||
use sp_runtime::traits::{Header, IdentifyAccount, MaybeSerializeDeserialize, Zero};
|
use sp_runtime::traits::{Header, IdentifyAccount, MaybeSerializeDeserialize, Zero};
|
||||||
use sp_std::{fmt::Debug, prelude::*};
|
use sp_std::{fmt::Debug, prelude::*};
|
||||||
use sp_trie::{record_all_keys, trie_types::TrieDBMut, Layout, MemoryDB, Recorder, TrieMut};
|
use sp_trie::{record_all_keys, trie_types::TrieDBMutV1, LayoutV1, MemoryDB, Recorder, TrieMut};
|
||||||
use sp_version::RuntimeVersion;
|
use sp_version::RuntimeVersion;
|
||||||
|
|
||||||
/// Prepare outbound message for the `send_message` call.
|
/// Prepare outbound message for the `send_message` call.
|
||||||
@@ -177,7 +177,7 @@ where
|
|||||||
let mut root = Default::default();
|
let mut root = Default::default();
|
||||||
let mut mdb = MemoryDB::default();
|
let mut mdb = MemoryDB::default();
|
||||||
{
|
{
|
||||||
let mut trie = TrieDBMut::<BHH>::new(&mut mdb, &mut root);
|
let mut trie = TrieDBMutV1::<BHH>::new(&mut mdb, &mut root);
|
||||||
trie.insert(&storage_key, ¶ms.inbound_lane_data.encode())
|
trie.insert(&storage_key, ¶ms.inbound_lane_data.encode())
|
||||||
.map_err(|_| "TrieMut::insert has failed")
|
.map_err(|_| "TrieMut::insert has failed")
|
||||||
.expect("TrieMut::insert should not fail in benchmarks");
|
.expect("TrieMut::insert should not fail in benchmarks");
|
||||||
@@ -186,7 +186,7 @@ where
|
|||||||
|
|
||||||
// generate storage proof to be delivered to This chain
|
// generate storage proof to be delivered to This chain
|
||||||
let mut proof_recorder = Recorder::<BHH::Out>::new();
|
let mut proof_recorder = Recorder::<BHH::Out>::new();
|
||||||
record_all_keys::<Layout<BHH>, _>(&mdb, &root, &mut proof_recorder)
|
record_all_keys::<LayoutV1<BHH>, _>(&mdb, &root, &mut proof_recorder)
|
||||||
.map_err(|_| "record_all_keys has failed")
|
.map_err(|_| "record_all_keys has failed")
|
||||||
.expect("record_all_keys should not fail in benchmarks");
|
.expect("record_all_keys should not fail in benchmarks");
|
||||||
let storage_proof = proof_recorder.drain().into_iter().map(|n| n.data.to_vec()).collect();
|
let storage_proof = proof_recorder.drain().into_iter().map(|n| n.data.to_vec()).collect();
|
||||||
@@ -220,7 +220,7 @@ where
|
|||||||
let mut root = Default::default();
|
let mut root = Default::default();
|
||||||
let mut mdb = MemoryDB::default();
|
let mut mdb = MemoryDB::default();
|
||||||
{
|
{
|
||||||
let mut trie = TrieDBMut::<BHH>::new(&mut mdb, &mut root);
|
let mut trie = TrieDBMutV1::<BHH>::new(&mut mdb, &mut root);
|
||||||
|
|
||||||
// insert messages
|
// insert messages
|
||||||
for nonce in params.message_nonces.clone() {
|
for nonce in params.message_nonces.clone() {
|
||||||
@@ -256,7 +256,7 @@ where
|
|||||||
|
|
||||||
// generate storage proof to be delivered to This chain
|
// generate storage proof to be delivered to This chain
|
||||||
let mut proof_recorder = Recorder::<BHH::Out>::new();
|
let mut proof_recorder = Recorder::<BHH::Out>::new();
|
||||||
record_all_keys::<Layout<BHH>, _>(&mdb, &root, &mut proof_recorder)
|
record_all_keys::<LayoutV1<BHH>, _>(&mdb, &root, &mut proof_recorder)
|
||||||
.map_err(|_| "record_all_keys has failed")
|
.map_err(|_| "record_all_keys has failed")
|
||||||
.expect("record_all_keys should not fail in benchmarks");
|
.expect("record_all_keys should not fail in benchmarks");
|
||||||
let storage_proof = proof_recorder.drain().into_iter().map(|n| n.data.to_vec()).collect();
|
let storage_proof = proof_recorder.drain().into_iter().map(|n| n.data.to_vec()).collect();
|
||||||
@@ -339,7 +339,7 @@ fn grow_trie<H: Hasher>(mut root: H::Out, mdb: &mut MemoryDB<H>, trie_size: Proo
|
|||||||
loop {
|
loop {
|
||||||
// generate storage proof to be delivered to This chain
|
// generate storage proof to be delivered to This chain
|
||||||
let mut proof_recorder = Recorder::<H::Out>::new();
|
let mut proof_recorder = Recorder::<H::Out>::new();
|
||||||
record_all_keys::<Layout<H>, _>(mdb, &root, &mut proof_recorder)
|
record_all_keys::<LayoutV1<H>, _>(mdb, &root, &mut proof_recorder)
|
||||||
.map_err(|_| "record_all_keys has failed")
|
.map_err(|_| "record_all_keys has failed")
|
||||||
.expect("record_all_keys should not fail in benchmarks");
|
.expect("record_all_keys should not fail in benchmarks");
|
||||||
let size: usize = proof_recorder.drain().into_iter().map(|n| n.data.len()).sum();
|
let size: usize = proof_recorder.drain().into_iter().map(|n| n.data.len()).sum();
|
||||||
@@ -347,9 +347,9 @@ fn grow_trie<H: Hasher>(mut root: H::Out, mdb: &mut MemoryDB<H>, trie_size: Proo
|
|||||||
return root
|
return root
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut trie = TrieDBMut::<H>::from_existing(mdb, &mut root)
|
let mut trie = TrieDBMutV1::<H>::from_existing(mdb, &mut root)
|
||||||
.map_err(|_| "TrieDBMut::from_existing has failed")
|
.map_err(|_| "TrieDBMutV1::from_existing has failed")
|
||||||
.expect("TrieDBMut::from_existing should not fail in benchmarks");
|
.expect("TrieDBMutV1::from_existing should not fail in benchmarks");
|
||||||
for _ in 0..iterations {
|
for _ in 0..iterations {
|
||||||
trie.insert(&key_index.encode(), &vec![42u8; leaf_size as _])
|
trie.insert(&key_index.encode(), &vec![42u8; leaf_size as _])
|
||||||
.map_err(|_| "TrieMut::insert has failed")
|
.map_err(|_| "TrieMut::insert has failed")
|
||||||
|
|||||||
@@ -64,8 +64,7 @@ pub mod pallet {
|
|||||||
+ MaybeSerializeDeserialize
|
+ MaybeSerializeDeserialize
|
||||||
+ Debug
|
+ Debug
|
||||||
+ MaybeDisplay
|
+ MaybeDisplay
|
||||||
+ Ord
|
+ Ord;
|
||||||
+ Default;
|
|
||||||
/// Type of account public key on target chain.
|
/// Type of account public key on target chain.
|
||||||
type TargetChainAccountPublic: Parameter + IdentifyAccount<AccountId = Self::AccountId>;
|
type TargetChainAccountPublic: Parameter + IdentifyAccount<AccountId = Self::AccountId>;
|
||||||
/// Type of signature that may prove that the message has been signed by
|
/// Type of signature that may prove that the message has been signed by
|
||||||
@@ -520,6 +519,7 @@ mod tests {
|
|||||||
type DbWeight = ();
|
type DbWeight = ();
|
||||||
type SS58Prefix = ();
|
type SS58Prefix = ();
|
||||||
type OnSetCode = ();
|
type OnSetCode = ();
|
||||||
|
type MaxConsumers = frame_support::traits::ConstU32<16>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config for TestRuntime {
|
impl Config for TestRuntime {
|
||||||
@@ -649,11 +649,11 @@ mod tests {
|
|||||||
fn should_fail_on_weight_mismatch() {
|
fn should_fail_on_weight_mismatch() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
let id = [0; 4];
|
let id = [0; 4];
|
||||||
let call = Call::System(frame_system::Call::remark { remark: vec![1, 2, 3] });
|
let call = Call::System(frame_system::Call::set_heap_pages { pages: 42 });
|
||||||
let call_weight = call.get_dispatch_info().weight;
|
let call_weight = call.get_dispatch_info().weight;
|
||||||
let mut message = prepare_root_message(call);
|
let mut message = prepare_root_message(call);
|
||||||
message.weight = 7;
|
message.weight = 7;
|
||||||
assert!(call_weight != 7, "needed for test to actually trigger a weight mismatch");
|
assert!(call_weight > 7, "needed for test to actually trigger a weight mismatch");
|
||||||
|
|
||||||
System::set_block_number(1);
|
System::set_block_number(1);
|
||||||
let result = Dispatch::dispatch(
|
let result = Dispatch::dispatch(
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ pub mod pallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[pallet::pallet]
|
#[pallet::pallet]
|
||||||
|
#[pallet::without_storage_info]
|
||||||
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
|
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
|
||||||
|
|
||||||
#[pallet::hooks]
|
#[pallet::hooks]
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ impl frame_system::Config for TestRuntime {
|
|||||||
type BlockLength = ();
|
type BlockLength = ();
|
||||||
type SS58Prefix = ();
|
type SS58Prefix = ();
|
||||||
type OnSetCode = ();
|
type OnSetCode = ();
|
||||||
|
type MaxConsumers = frame_support::traits::ConstU32<16>;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ fn pay_relayers_rewards<Currency, AccountId>(
|
|||||||
relayer_fund_account: &AccountId,
|
relayer_fund_account: &AccountId,
|
||||||
confirmation_fee: Currency::Balance,
|
confirmation_fee: Currency::Balance,
|
||||||
) where
|
) where
|
||||||
AccountId: Debug + Default + Encode + PartialEq,
|
AccountId: Debug + Encode + PartialEq,
|
||||||
Currency: CurrencyT<AccountId>,
|
Currency: CurrencyT<AccountId>,
|
||||||
Currency::Balance: From<u64>,
|
Currency::Balance: From<u64>,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ pub mod pallet {
|
|||||||
|
|
||||||
#[pallet::pallet]
|
#[pallet::pallet]
|
||||||
#[pallet::generate_store(pub(super) trait Store)]
|
#[pallet::generate_store(pub(super) trait Store)]
|
||||||
|
#[pallet::without_storage_info]
|
||||||
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
|
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
|
||||||
|
|
||||||
#[pallet::call]
|
#[pallet::call]
|
||||||
@@ -2116,6 +2117,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
fn receive_messages_panics_in_debug_mode_if_callback_is_wrong() {
|
fn receive_messages_panics_in_debug_mode_if_callback_is_wrong() {
|
||||||
run_test(|| {
|
run_test(|| {
|
||||||
TestOnDeliveryConfirmed1::set_consumed_weight_per_message(
|
TestOnDeliveryConfirmed1::set_consumed_weight_per_message(
|
||||||
@@ -2248,6 +2250,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
fn message_accepted_panics_in_debug_mode_if_callback_is_wrong() {
|
fn message_accepted_panics_in_debug_mode_if_callback_is_wrong() {
|
||||||
run_test(|| {
|
run_test(|| {
|
||||||
TestOnMessageAccepted::set_consumed_weight_per_message(
|
TestOnMessageAccepted::set_consumed_weight_per_message(
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ impl frame_system::Config for TestRuntime {
|
|||||||
type DbWeight = DbWeight;
|
type DbWeight = DbWeight;
|
||||||
type SS58Prefix = ();
|
type SS58Prefix = ();
|
||||||
type OnSetCode = ();
|
type OnSetCode = ();
|
||||||
|
type MaxConsumers = frame_support::traits::ConstU32<16>;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ pub mod pallet {
|
|||||||
|
|
||||||
#[pallet::pallet]
|
#[pallet::pallet]
|
||||||
#[pallet::generate_store(pub(super) trait Store)]
|
#[pallet::generate_store(pub(super) trait Store)]
|
||||||
|
#[pallet::without_storage_info]
|
||||||
pub struct Pallet<T>(PhantomData<T>);
|
pub struct Pallet<T>(PhantomData<T>);
|
||||||
|
|
||||||
#[pallet::hooks]
|
#[pallet::hooks]
|
||||||
@@ -162,6 +163,7 @@ mod tests {
|
|||||||
type DbWeight = ();
|
type DbWeight = ();
|
||||||
type SS58Prefix = ();
|
type SS58Prefix = ();
|
||||||
type OnSetCode = ();
|
type OnSetCode = ();
|
||||||
|
type MaxConsumers = frame_support::traits::ConstU32<16>;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use bp_token_swap::{TokenSwap, TokenSwapCreation, TokenSwapState, TokenSwapType};
|
use bp_token_swap::{TokenSwap, TokenSwapCreation, TokenSwapState, TokenSwapType};
|
||||||
use codec::Encode;
|
use codec::{Decode, Encode};
|
||||||
use frame_benchmarking::{account, benchmarks_instance_pallet};
|
use frame_benchmarking::{account, benchmarks_instance_pallet};
|
||||||
use frame_support::{traits::Currency, Parameter};
|
use frame_support::{traits::Currency, Parameter};
|
||||||
use frame_system::RawOrigin;
|
use frame_system::RawOrigin;
|
||||||
use sp_core::H256;
|
use sp_core::H256;
|
||||||
use sp_io::hashing::blake2_256;
|
use sp_io::hashing::blake2_256;
|
||||||
use sp_runtime::traits::Bounded;
|
use sp_runtime::traits::{Bounded, TrailingZeroInput};
|
||||||
use sp_std::{boxed::Box, vec::Vec};
|
use sp_std::{boxed::Box, vec::Vec};
|
||||||
|
|
||||||
const SEED: u32 = 0;
|
const SEED: u32 = 0;
|
||||||
@@ -43,8 +43,8 @@ pub trait Config<I: 'static>: crate::Config<I> {
|
|||||||
benchmarks_instance_pallet! {
|
benchmarks_instance_pallet! {
|
||||||
where_clause {
|
where_clause {
|
||||||
where
|
where
|
||||||
BridgedAccountPublicOf<T, I>: Default + Parameter,
|
BridgedAccountPublicOf<T, I>: Decode + Parameter,
|
||||||
BridgedAccountSignatureOf<T, I>: Default,
|
BridgedAccountSignatureOf<T, I>: Decode,
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -138,8 +138,8 @@ fn test_swap_hash<T: Config<I>, I: 'static>(sender: T::AccountId, is_create: boo
|
|||||||
/// Returns test token swap creation params.
|
/// Returns test token swap creation params.
|
||||||
fn test_swap_creation<T: Config<I>, I: 'static>() -> TokenSwapCreationOf<T, I>
|
fn test_swap_creation<T: Config<I>, I: 'static>() -> TokenSwapCreationOf<T, I>
|
||||||
where
|
where
|
||||||
BridgedAccountPublicOf<T, I>: Default,
|
BridgedAccountPublicOf<T, I>: Decode,
|
||||||
BridgedAccountSignatureOf<T, I>: Default,
|
BridgedAccountSignatureOf<T, I>: Decode,
|
||||||
{
|
{
|
||||||
TokenSwapCreation {
|
TokenSwapCreation {
|
||||||
target_public_at_bridged_chain: target_public_at_bridged_chain::<T, I>(),
|
target_public_at_bridged_chain: target_public_at_bridged_chain::<T, I>(),
|
||||||
@@ -176,20 +176,22 @@ fn target_balance_to_swap<T: Config<I>, I: 'static>() -> BridgedBalanceOf<T, I>
|
|||||||
/// Public key of `target_account_at_bridged_chain`.
|
/// Public key of `target_account_at_bridged_chain`.
|
||||||
fn target_public_at_bridged_chain<T: Config<I>, I: 'static>() -> BridgedAccountPublicOf<T, I>
|
fn target_public_at_bridged_chain<T: Config<I>, I: 'static>() -> BridgedAccountPublicOf<T, I>
|
||||||
where
|
where
|
||||||
BridgedAccountPublicOf<T, I>: Default,
|
BridgedAccountPublicOf<T, I>: Decode,
|
||||||
{
|
{
|
||||||
Default::default()
|
BridgedAccountPublicOf::<T, I>::decode(&mut TrailingZeroInput::zeroes())
|
||||||
|
.expect("failed to decode `BridgedAccountPublicOf` from zeroes")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Signature of `target_account_at_bridged_chain` over message.
|
/// Signature of `target_account_at_bridged_chain` over message.
|
||||||
fn bridged_currency_transfer_signature<T: Config<I>, I: 'static>() -> BridgedAccountSignatureOf<T, I>
|
fn bridged_currency_transfer_signature<T: Config<I>, I: 'static>() -> BridgedAccountSignatureOf<T, I>
|
||||||
where
|
where
|
||||||
BridgedAccountSignatureOf<T, I>: Default,
|
BridgedAccountSignatureOf<T, I>: Decode,
|
||||||
{
|
{
|
||||||
Default::default()
|
BridgedAccountSignatureOf::<T, I>::decode(&mut TrailingZeroInput::zeroes())
|
||||||
|
.expect("failed to decode `BridgedAccountSignatureOf` from zeroes")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Account at the bridged chain that is participating in the swap.
|
/// Account at the bridged chain that is participating in the swap.
|
||||||
fn target_account_at_bridged_chain<T: Config<I>, I: 'static>() -> BridgedAccountIdOf<T, I> {
|
fn target_account_at_bridged_chain<T: Config<I>, I: 'static>() -> BridgedAccountIdOf<T, I> {
|
||||||
Default::default()
|
account("target_account_at_bridged_chain", 0, SEED)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ pub mod pallet {
|
|||||||
|
|
||||||
#[pallet::pallet]
|
#[pallet::pallet]
|
||||||
#[pallet::generate_store(pub(super) trait Store)]
|
#[pallet::generate_store(pub(super) trait Store)]
|
||||||
|
#[pallet::without_storage_info]
|
||||||
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
|
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
|
||||||
|
|
||||||
#[pallet::hooks]
|
#[pallet::hooks]
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ impl frame_system::Config for TestRuntime {
|
|||||||
type DbWeight = ();
|
type DbWeight = ();
|
||||||
type SS58Prefix = ();
|
type SS58Prefix = ();
|
||||||
type OnSetCode = ();
|
type OnSetCode = ();
|
||||||
|
type MaxConsumers = frame_support::traits::ConstU32<16>;
|
||||||
}
|
}
|
||||||
|
|
||||||
frame_support::parameter_types! {
|
frame_support::parameter_types! {
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
impl_version: 0,
|
impl_version: 0,
|
||||||
apis: sp_version::create_apis_vec![[]],
|
apis: sp_version::create_apis_vec![[]],
|
||||||
transaction_version: 5,
|
transaction_version: 5,
|
||||||
|
state_version: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOTE: This needs to be kept up to date with the Kusama runtime found in the Polkadot repo.
|
// NOTE: This needs to be kept up to date with the Kusama runtime found in the Polkadot repo.
|
||||||
|
|||||||
@@ -30,13 +30,13 @@ use frame_support::{
|
|||||||
};
|
};
|
||||||
use frame_system::limits;
|
use frame_system::limits;
|
||||||
use scale_info::TypeInfo;
|
use scale_info::TypeInfo;
|
||||||
use sp_core::Hasher as HasherT;
|
use sp_core::{storage::StateVersion, Hasher as HasherT};
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{Convert, IdentifyAccount, Verify},
|
traits::{Convert, IdentifyAccount, Verify},
|
||||||
MultiSignature, MultiSigner, Perbill,
|
MultiSignature, MultiSigner, Perbill,
|
||||||
};
|
};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use sp_trie::{trie_types::Layout, TrieConfiguration};
|
use sp_trie::{LayoutV0, LayoutV1, TrieConfiguration};
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -206,12 +206,18 @@ impl sp_core::Hasher for BlakeTwoAndKeccak256 {
|
|||||||
impl sp_runtime::traits::Hash for BlakeTwoAndKeccak256 {
|
impl sp_runtime::traits::Hash for BlakeTwoAndKeccak256 {
|
||||||
type Output = MillauHash;
|
type Output = MillauHash;
|
||||||
|
|
||||||
fn trie_root(input: Vec<(Vec<u8>, Vec<u8>)>) -> Self::Output {
|
fn trie_root(input: Vec<(Vec<u8>, Vec<u8>)>, state_version: StateVersion) -> Self::Output {
|
||||||
Layout::<BlakeTwoAndKeccak256>::trie_root(input)
|
match state_version {
|
||||||
|
StateVersion::V0 => LayoutV0::<BlakeTwoAndKeccak256>::trie_root(input),
|
||||||
|
StateVersion::V1 => LayoutV1::<BlakeTwoAndKeccak256>::trie_root(input),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ordered_trie_root(input: Vec<Vec<u8>>) -> Self::Output {
|
fn ordered_trie_root(input: Vec<Vec<u8>>, state_version: StateVersion) -> Self::Output {
|
||||||
Layout::<BlakeTwoAndKeccak256>::ordered_trie_root(input)
|
match state_version {
|
||||||
|
StateVersion::V0 => LayoutV0::<BlakeTwoAndKeccak256>::ordered_trie_root(input),
|
||||||
|
StateVersion::V1 => LayoutV1::<BlakeTwoAndKeccak256>::ordered_trie_root(input),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,9 +346,9 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn maximal_account_size_does_not_overflow_constant() {
|
fn maximal_account_size_does_not_overflow_constant() {
|
||||||
assert!(
|
assert!(
|
||||||
MAXIMAL_ENCODED_ACCOUNT_ID_SIZE as usize >= AccountId::default().encode().len(),
|
MAXIMAL_ENCODED_ACCOUNT_ID_SIZE as usize >= AccountId::from([0u8; 32]).encode().len(),
|
||||||
"Actual maximal size of encoded AccountId ({}) overflows expected ({})",
|
"Actual maximal size of encoded AccountId ({}) overflows expected ({})",
|
||||||
AccountId::default().encode().len(),
|
AccountId::from([0u8; 32]).encode().len(),
|
||||||
MAXIMAL_ENCODED_ACCOUNT_ID_SIZE,
|
MAXIMAL_ENCODED_ACCOUNT_ID_SIZE,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
impl_version: 0,
|
impl_version: 0,
|
||||||
apis: sp_version::create_apis_vec![[]],
|
apis: sp_version::create_apis_vec![[]],
|
||||||
transaction_version: 7,
|
transaction_version: 7,
|
||||||
|
state_version: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOTE: This needs to be kept up to date with the Polkadot runtime found in the Polkadot repo.
|
// NOTE: This needs to be kept up to date with the Polkadot runtime found in the Polkadot repo.
|
||||||
|
|||||||
@@ -312,9 +312,9 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn maximal_account_size_does_not_overflow_constant() {
|
fn maximal_account_size_does_not_overflow_constant() {
|
||||||
assert!(
|
assert!(
|
||||||
MAXIMAL_ENCODED_ACCOUNT_ID_SIZE as usize >= AccountId::default().encode().len(),
|
MAXIMAL_ENCODED_ACCOUNT_ID_SIZE as usize >= AccountId::from([0u8; 32]).encode().len(),
|
||||||
"Actual maximal size of encoded AccountId ({}) overflows expected ({})",
|
"Actual maximal size of encoded AccountId ({}) overflows expected ({})",
|
||||||
AccountId::default().encode().len(),
|
AccountId::from([0u8; 32]).encode().len(),
|
||||||
MAXIMAL_ENCODED_ACCOUNT_ID_SIZE,
|
MAXIMAL_ENCODED_ACCOUNT_ID_SIZE,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
impl_version: 0,
|
impl_version: 0,
|
||||||
apis: sp_version::create_apis_vec![[]],
|
apis: sp_version::create_apis_vec![[]],
|
||||||
transaction_version: 0,
|
transaction_version: 0,
|
||||||
|
state_version: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOTE: This needs to be kept up to date with the Rococo runtime found in the Polkadot repo.
|
// NOTE: This needs to be kept up to date with the Rococo runtime found in the Polkadot repo.
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
impl_version: 0,
|
impl_version: 0,
|
||||||
apis: sp_version::create_apis_vec![[]],
|
apis: sp_version::create_apis_vec![[]],
|
||||||
transaction_version: 5,
|
transaction_version: 5,
|
||||||
|
state_version: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Westend Runtime `Call` enum.
|
/// Westend Runtime `Call` enum.
|
||||||
|
|||||||
@@ -136,7 +136,8 @@ fn justification_with_invalid_commit_rejected() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn justification_with_invalid_authority_signature_rejected() {
|
fn justification_with_invalid_authority_signature_rejected() {
|
||||||
let mut justification = make_default_justification::<TestHeader>(&test_header(1));
|
let mut justification = make_default_justification::<TestHeader>(&test_header(1));
|
||||||
justification.commit.precommits[0].signature = Default::default();
|
justification.commit.precommits[0].signature =
|
||||||
|
sp_core::crypto::UncheckedFrom::unchecked_from([1u8; 64]);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
verify_justification::<TestHeader>(
|
verify_justification::<TestHeader>(
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ use scale_info::{StaticTypeInfo, TypeInfo};
|
|||||||
use sp_core::Hasher as HasherT;
|
use sp_core::Hasher as HasherT;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
generic,
|
generic,
|
||||||
traits::{BlakeTwo256, IdentifyAccount, Verify},
|
traits::{BlakeTwo256, DispatchInfoOf, IdentifyAccount, Verify},
|
||||||
|
transaction_validity::TransactionValidityError,
|
||||||
MultiAddress, MultiSignature, OpaqueExtrinsic,
|
MultiAddress, MultiSignature, OpaqueExtrinsic,
|
||||||
};
|
};
|
||||||
use sp_std::prelude::Vec;
|
use sp_std::prelude::Vec;
|
||||||
@@ -332,6 +333,16 @@ where
|
|||||||
) -> Result<Self::AdditionalSigned, frame_support::unsigned::TransactionValidityError> {
|
) -> Result<Self::AdditionalSigned, frame_support::unsigned::TransactionValidityError> {
|
||||||
Ok(self.additional_signed)
|
Ok(self.additional_signed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn pre_dispatch(
|
||||||
|
self,
|
||||||
|
who: &Self::AccountId,
|
||||||
|
call: &Self::Call,
|
||||||
|
info: &DispatchInfoOf<Self::Call>,
|
||||||
|
len: usize,
|
||||||
|
) -> Result<Self::Pre, TransactionValidityError> {
|
||||||
|
Ok(self.validate(who, call, info, len).map(|_| ())?)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Polkadot-like chain.
|
/// Polkadot-like chain.
|
||||||
@@ -399,7 +410,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn maximal_encoded_account_id_size_is_correct() {
|
fn maximal_encoded_account_id_size_is_correct() {
|
||||||
let actual_size = AccountId::default().encode().len();
|
let actual_size = AccountId::from([0u8; 32]).encode().len();
|
||||||
assert!(
|
assert!(
|
||||||
actual_size <= MAXIMAL_ENCODED_ACCOUNT_ID_SIZE as usize,
|
actual_size <= MAXIMAL_ENCODED_ACCOUNT_ID_SIZE as usize,
|
||||||
"Actual size of encoded account id for Polkadot-like chains ({}) is larger than expected {}",
|
"Actual size of encoded account id for Polkadot-like chains ({}) is larger than expected {}",
|
||||||
|
|||||||
@@ -83,13 +83,7 @@ pub trait Chain: Send + Sync + 'static {
|
|||||||
+ MaybeSerializeDeserialize;
|
+ MaybeSerializeDeserialize;
|
||||||
|
|
||||||
/// The user account identifier type for the runtime.
|
/// The user account identifier type for the runtime.
|
||||||
type AccountId: Parameter
|
type AccountId: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + Ord;
|
||||||
+ Member
|
|
||||||
+ MaybeSerializeDeserialize
|
|
||||||
+ Debug
|
|
||||||
+ MaybeDisplay
|
|
||||||
+ Ord
|
|
||||||
+ Default;
|
|
||||||
/// Balance of an account in native tokens.
|
/// Balance of an account in native tokens.
|
||||||
///
|
///
|
||||||
/// The chain may support multiple tokens, but this particular type is for token that is used
|
/// The chain may support multiple tokens, but this particular type is for token that is used
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
use hash_db::{HashDB, Hasher, EMPTY_PREFIX};
|
use hash_db::{HashDB, Hasher, EMPTY_PREFIX};
|
||||||
use sp_runtime::RuntimeDebug;
|
use sp_runtime::RuntimeDebug;
|
||||||
use sp_std::vec::Vec;
|
use sp_std::vec::Vec;
|
||||||
use sp_trie::{read_trie_value, Layout, MemoryDB, StorageProof};
|
use sp_trie::{read_trie_value, LayoutV1, MemoryDB, StorageProof};
|
||||||
|
|
||||||
/// This struct is used to read storage values from a subset of a Merklized database. The "proof"
|
/// This struct is used to read storage values from a subset of a Merklized database. The "proof"
|
||||||
/// is a subset of the nodes in the Merkle structure of the database, so that it provides
|
/// is a subset of the nodes in the Merkle structure of the database, so that it provides
|
||||||
@@ -52,7 +52,8 @@ where
|
|||||||
/// Reads a value from the available subset of storage. If the value cannot be read due to an
|
/// Reads a value from the available subset of storage. If the value cannot be read due to an
|
||||||
/// incomplete or otherwise invalid proof, this returns an error.
|
/// incomplete or otherwise invalid proof, this returns an error.
|
||||||
pub fn read_value(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Error> {
|
pub fn read_value(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Error> {
|
||||||
read_trie_value::<Layout<H>, _>(&self.db, &self.root, key)
|
// LayoutV1 or LayoutV0 is identical for proof that only read values.
|
||||||
|
read_trie_value::<LayoutV1<H>, _>(&self.db, &self.root, key)
|
||||||
.map_err(|_| Error::StorageValueUnavailable)
|
.map_err(|_| Error::StorageValueUnavailable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,15 +71,20 @@ pub enum Error {
|
|||||||
pub fn craft_valid_storage_proof() -> (sp_core::H256, StorageProof) {
|
pub fn craft_valid_storage_proof() -> (sp_core::H256, StorageProof) {
|
||||||
use sp_state_machine::{backend::Backend, prove_read, InMemoryBackend};
|
use sp_state_machine::{backend::Backend, prove_read, InMemoryBackend};
|
||||||
|
|
||||||
|
let state_version = sp_runtime::StateVersion::default();
|
||||||
|
|
||||||
// construct storage proof
|
// construct storage proof
|
||||||
let backend = <InMemoryBackend<sp_core::Blake2Hasher>>::from(vec![
|
let backend = <InMemoryBackend<sp_core::Blake2Hasher>>::from((
|
||||||
(None, vec![(b"key1".to_vec(), Some(b"value1".to_vec()))]),
|
vec![
|
||||||
(None, vec![(b"key2".to_vec(), Some(b"value2".to_vec()))]),
|
(None, vec![(b"key1".to_vec(), Some(b"value1".to_vec()))]),
|
||||||
(None, vec![(b"key3".to_vec(), Some(b"value3".to_vec()))]),
|
(None, vec![(b"key2".to_vec(), Some(b"value2".to_vec()))]),
|
||||||
// Value is too big to fit in a branch node
|
(None, vec![(b"key3".to_vec(), Some(b"value3".to_vec()))]),
|
||||||
(None, vec![(b"key11".to_vec(), Some(vec![0u8; 32]))]),
|
// Value is too big to fit in a branch node
|
||||||
]);
|
(None, vec![(b"key11".to_vec(), Some(vec![0u8; 32]))]),
|
||||||
let root = backend.storage_root(std::iter::empty()).0;
|
],
|
||||||
|
state_version,
|
||||||
|
));
|
||||||
|
let root = backend.storage_root(std::iter::empty(), state_version).0;
|
||||||
let proof = StorageProof::new(
|
let proof = StorageProof::new(
|
||||||
prove_read(backend, &[&b"key1"[..], &b"key2"[..], &b"key22"[..]])
|
prove_read(backend, &[&b"key1"[..], &b"key2"[..], &b"key22"[..]])
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
use ed25519_dalek::{Keypair, PublicKey, SecretKey, Signature};
|
use ed25519_dalek::{Keypair, PublicKey, SecretKey, Signature};
|
||||||
use finality_grandpa::voter_set::VoterSet;
|
use finality_grandpa::voter_set::VoterSet;
|
||||||
use sp_application_crypto::Public;
|
|
||||||
use sp_finality_grandpa::{AuthorityId, AuthorityList, AuthorityWeight};
|
use sp_finality_grandpa::{AuthorityId, AuthorityList, AuthorityWeight};
|
||||||
use sp_runtime::RuntimeDebug;
|
use sp_runtime::RuntimeDebug;
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
@@ -70,7 +69,7 @@ impl Account {
|
|||||||
|
|
||||||
impl From<Account> for AuthorityId {
|
impl From<Account> for AuthorityId {
|
||||||
fn from(p: Account) -> Self {
|
fn from(p: Account) -> Self {
|
||||||
AuthorityId::from_slice(&p.public().to_bytes())
|
sp_application_crypto::UncheckedFrom::unchecked_from(p.public().to_bytes())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -343,7 +343,7 @@ mod tests {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assert!(format!("{:?}", call_hex).starts_with(
|
assert!(format!("{:?}", call_hex).starts_with(
|
||||||
"0x0f030000000001000000381409000000000001d43593c715fdd31c61141abd04a99fd6822c8558854cc\
|
"0x0f030000000001000000000000000000000001d43593c715fdd31c61141abd04a99fd6822c8558854cc\
|
||||||
de39a5684e7a56da27d01d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d01"
|
de39a5684e7a56da27d01d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d01"
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,6 +106,6 @@ mod tests {
|
|||||||
let hex = encode_message.encode().unwrap();
|
let hex = encode_message.encode().unwrap();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert_eq!(format!("{:?}", hex), "0x0100000010f108000000000002d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d003c000130000000000000000000000000");
|
assert_eq!(format!("{:?}", hex), "0x01000000000000000000000002d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d003c000130000000000000000000000000");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ mod tests {
|
|||||||
payload,
|
payload,
|
||||||
MessagePayload {
|
MessagePayload {
|
||||||
spec_version: relay_millau_client::Millau::RUNTIME_VERSION.spec_version,
|
spec_version: relay_millau_client::Millau::RUNTIME_VERSION.spec_version,
|
||||||
weight: 576000,
|
weight: 0,
|
||||||
origin: CallOrigin::SourceAccount(
|
origin: CallOrigin::SourceAccount(
|
||||||
sp_keyring::AccountKeyring::Alice.to_account_id()
|
sp_keyring::AccountKeyring::Alice.to_account_id()
|
||||||
),
|
),
|
||||||
@@ -366,7 +366,7 @@ mod tests {
|
|||||||
payload,
|
payload,
|
||||||
MessagePayload {
|
MessagePayload {
|
||||||
spec_version: relay_millau_client::Millau::RUNTIME_VERSION.spec_version,
|
spec_version: relay_millau_client::Millau::RUNTIME_VERSION.spec_version,
|
||||||
weight: 576000,
|
weight: 0,
|
||||||
origin: CallOrigin::TargetAccount(
|
origin: CallOrigin::TargetAccount(
|
||||||
sp_keyring::AccountKeyring::Alice.to_account_id(),
|
sp_keyring::AccountKeyring::Alice.to_account_id(),
|
||||||
sp_keyring::AccountKeyring::Bob.into(),
|
sp_keyring::AccountKeyring::Bob.into(),
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ where
|
|||||||
&self.transaction_params,
|
&self.transaction_params,
|
||||||
HeaderId(Default::default(), Default::default()),
|
HeaderId(Default::default(), Default::default()),
|
||||||
Zero::zero(),
|
Zero::zero(),
|
||||||
Default::default(),
|
self.relayer_id_at_source.clone(),
|
||||||
nonces.clone(),
|
nonces.clone(),
|
||||||
prepare_dummy_messages_proof::<P::SourceChain>(
|
prepare_dummy_messages_proof::<P::SourceChain>(
|
||||||
nonces.clone(),
|
nonces.clone(),
|
||||||
@@ -332,7 +332,7 @@ where
|
|||||||
&self.transaction_params,
|
&self.transaction_params,
|
||||||
HeaderId(Default::default(), Default::default()),
|
HeaderId(Default::default(), Default::default()),
|
||||||
Zero::zero(),
|
Zero::zero(),
|
||||||
Default::default(),
|
self.relayer_id_at_source.clone(),
|
||||||
nonces.clone(),
|
nonces.clone(),
|
||||||
prepare_dummy_messages_proof::<P::SourceChain>(
|
prepare_dummy_messages_proof::<P::SourceChain>(
|
||||||
nonces.clone(),
|
nonces.clone(),
|
||||||
|
|||||||
Reference in New Issue
Block a user