mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31:03 +00:00
Make everything compile and fix tests
This commit is contained in:
+19
-16
@@ -12,31 +12,33 @@ path = 'src/main.rs'
|
||||
[dependencies]
|
||||
derive_more = '0.15.0'
|
||||
exit-future = '0.1.4'
|
||||
futures = '0.1.29'
|
||||
futures03 = { package = "futures-preview", version = "0.3.0-alpha.19", features = ["compat"] }
|
||||
futures = { version = "0.3.1", features = ["compat"] }
|
||||
log = '0.4.8'
|
||||
parking_lot = '0.9.0'
|
||||
tokio = '0.1.22'
|
||||
trie-root = '0.15.2'
|
||||
codec = { package = 'parity-scale-codec', version = '1.0.0' }
|
||||
parachain-runtime = { package = "cumulus-test-parachain-runtime", path = "runtime" }
|
||||
structopt = "0.3.3"
|
||||
ctrlc = { version = "3.1.3", features = ["termination"] }
|
||||
|
||||
# Parachain dependencies
|
||||
parachain-runtime = { package = "cumulus-test-parachain-runtime", path = "runtime" }
|
||||
|
||||
# Substrate dependencies
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
sr-io = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
substrate-cli = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
substrate-primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
substrate-executor = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
substrate-service = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
inherents = { package = "substrate-inherents", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
transaction-pool = { package = "substrate-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
network = { package = "substrate-network", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
substrate-client = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
srml-timestamp = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
basic-authorship = { package = "substrate-basic-authorship", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
consensus-common = { package = "substrate-consensus-common", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
sp-io = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sc-service = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sc-network = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sc-client = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sc-basic-authority = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
|
||||
# Cumulus dependencies
|
||||
cumulus-consensus = { path = "../../consensus" }
|
||||
@@ -45,6 +47,7 @@ cumulus-collator = { path = "../../collator" }
|
||||
# Polkadot dependencies
|
||||
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "bkchr-cumulus-branch" }
|
||||
polkadot-collator = { git = "https://github.com/paritytech/polkadot", branch = "bkchr-cumulus-branch" }
|
||||
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "bkchr-cumulus-branch" }
|
||||
|
||||
[build-dependencies]
|
||||
vergen = '3.0.4'
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
use std::{env, path::PathBuf};
|
||||
|
||||
use vergen::{ConstantsFlags, generate_cargo_keys};
|
||||
use vergen::{generate_cargo_keys, ConstantsFlags};
|
||||
|
||||
const ERROR_MSG: &str = "Failed to generate metadata files";
|
||||
|
||||
@@ -24,13 +24,16 @@ fn main() {
|
||||
generate_cargo_keys(ConstantsFlags::SHA_SHORT).expect(ERROR_MSG);
|
||||
|
||||
let mut manifest_dir = PathBuf::from(
|
||||
env::var("CARGO_MANIFEST_DIR").expect("`CARGO_MANIFEST_DIR` is always set by cargo.")
|
||||
env::var("CARGO_MANIFEST_DIR").expect("`CARGO_MANIFEST_DIR` is always set by cargo."),
|
||||
);
|
||||
|
||||
while manifest_dir.parent().is_some() {
|
||||
if manifest_dir.join(".git/HEAD").exists() {
|
||||
println!("cargo:rerun-if-changed={}", manifest_dir.join(".git/HEAD").display());
|
||||
return
|
||||
println!(
|
||||
"cargo:rerun-if-changed={}",
|
||||
manifest_dir.join(".git/HEAD").display()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
manifest_dir.pop();
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -6,27 +6,30 @@ edition = '2018'
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
safe-mix = { version = "1.0.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] }
|
||||
|
||||
# Substrate dependencies
|
||||
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
runtime-io = { package = "sr-io", git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
version = { package = "sr-version", git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
support = { package = "srml-support", git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
substrate-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
|
||||
balances = { package = "srml-balances", git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
executive = { package = "srml-executive", git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
indices = { package = "srml-indices", git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
randomness-collective-flip = { package = "srml-randomness-collective-flip", git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
system = { package = "srml-system", git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
timestamp = { package = "srml-timestamp", git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
sudo = { package = "srml-sudo", git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
offchain-primitives = { package = "substrate-offchain-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
|
||||
transaction-payment = { package = "srml-transaction-payment", git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
|
||||
sp-std = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
sp-api = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
sp-io = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
sp-version = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
sp-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
|
||||
sp-offchain = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
|
||||
sp-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
|
||||
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
|
||||
sp-inherents = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
|
||||
|
||||
frame-support = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
frame-executive = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
frame-system = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
pallet-balances = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
pallet-indices = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
pallet-timestamp = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
pallet-sudo = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "bkchr-cumulus-branch" }
|
||||
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
|
||||
|
||||
# Cumulus dependencies
|
||||
cumulus-runtime = { path = "../../../runtime", default-features = false }
|
||||
@@ -38,24 +41,26 @@ wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.
|
||||
default = ['std']
|
||||
std = [
|
||||
'codec/std',
|
||||
'client/std',
|
||||
'rstd/std',
|
||||
'runtime-io/std',
|
||||
'support/std',
|
||||
'balances/std',
|
||||
'executive/std',
|
||||
'indices/std',
|
||||
'primitives/std',
|
||||
'sr-primitives/std',
|
||||
'randomness-collective-flip/std',
|
||||
'system/std',
|
||||
'timestamp/std',
|
||||
'sudo/std',
|
||||
'version/std',
|
||||
'serde',
|
||||
'safe-mix/std',
|
||||
'offchain-primitives/std',
|
||||
'substrate-session/std',
|
||||
'sp-api/std',
|
||||
'sp-std/std',
|
||||
'sp-io/std',
|
||||
'sp-core/std',
|
||||
'sp-runtime/std',
|
||||
'sp-version/std',
|
||||
'sp-offchain/std',
|
||||
'sp-session/std',
|
||||
'sp-block-builder/std',
|
||||
'sp-transaction-pool/std',
|
||||
'sp-inherents/std',
|
||||
'frame-support/std',
|
||||
'frame-executive/std',
|
||||
'frame-system/std',
|
||||
'pallet-balances/std',
|
||||
'pallet-indices/std',
|
||||
'pallet-randomness-collective-flip/std',
|
||||
'pallet-timestamp/std',
|
||||
'pallet-sudo/std',
|
||||
'pallet-transaction-payment/std',
|
||||
'cumulus-runtime/std',
|
||||
'transaction-payment/std',
|
||||
]
|
||||
|
||||
@@ -16,35 +16,35 @@
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
|
||||
#![recursion_limit="256"]
|
||||
#![recursion_limit = "256"]
|
||||
|
||||
// Make the WASM binary available.
|
||||
#[cfg(feature = "std")]
|
||||
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
|
||||
use rstd::prelude::*;
|
||||
use primitives::OpaqueMetadata;
|
||||
use sr_primitives::{
|
||||
ApplyResult, transaction_validity::TransactionValidity, generic, create_runtime_str,
|
||||
impl_opaque_keys, AnySignature
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_core::OpaqueMetadata;
|
||||
use sp_runtime::traits::{
|
||||
BlakeTwo256, Block as BlockT, ConvertInto, NumberFor, StaticLookup, Verify,
|
||||
};
|
||||
use sr_primitives::traits::{NumberFor, BlakeTwo256, Block as BlockT, StaticLookup, Verify, ConvertInto};
|
||||
use sr_primitives::weights::Weight;
|
||||
use client::{
|
||||
block_builder::api::{CheckInherentsResult, InherentData, self as block_builder_api},
|
||||
runtime_api as client_api, impl_runtime_apis
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic, impl_opaque_keys, transaction_validity::TransactionValidity,
|
||||
AnySignature, ApplyExtrinsicResult,
|
||||
};
|
||||
use version::RuntimeVersion;
|
||||
use sp_std::prelude::*;
|
||||
#[cfg(feature = "std")]
|
||||
use version::NativeVersion;
|
||||
use sp_version::NativeVersion;
|
||||
use sp_version::RuntimeVersion;
|
||||
|
||||
// A few exports that help ease life for downstream crates.
|
||||
pub use frame_support::{
|
||||
construct_runtime, parameter_types, traits::Randomness, weights::Weight, StorageValue,
|
||||
};
|
||||
pub use pallet_balances::Call as BalancesCall;
|
||||
pub use pallet_timestamp::Call as TimestampCall;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub use sr_primitives::BuildStorage;
|
||||
pub use timestamp::Call as TimestampCall;
|
||||
pub use balances::Call as BalancesCall;
|
||||
pub use sr_primitives::{Permill, Perbill};
|
||||
pub use support::{StorageValue, construct_runtime, parameter_types, traits::Randomness};
|
||||
pub use sp_runtime::BuildStorage;
|
||||
pub use sp_runtime::{Perbill, Permill};
|
||||
|
||||
/// An index to a block.
|
||||
pub type BlockNumber = u32;
|
||||
@@ -67,7 +67,7 @@ pub type Balance = u128;
|
||||
pub type Index = u32;
|
||||
|
||||
/// A hash of some data used by the chain.
|
||||
pub type Hash = primitives::H256;
|
||||
pub type Hash = sp_core::H256;
|
||||
|
||||
/// Digest item type.
|
||||
pub type DigestItem = generic::DigestItem<Hash>;
|
||||
@@ -79,7 +79,7 @@ pub type DigestItem = generic::DigestItem<Hash>;
|
||||
pub mod opaque {
|
||||
use super::*;
|
||||
|
||||
pub use sr_primitives::OpaqueExtrinsic as UncheckedExtrinsic;
|
||||
pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
|
||||
|
||||
/// Opaque block header type.
|
||||
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
|
||||
@@ -136,7 +136,7 @@ parameter_types! {
|
||||
pub const Version: RuntimeVersion = VERSION;
|
||||
}
|
||||
|
||||
impl system::Trait for Runtime {
|
||||
impl frame_system::Trait for Runtime {
|
||||
/// The identifier used to distinguish between accounts.
|
||||
type AccountId = AccountId;
|
||||
/// The aggregated dispatch type that is available for extrinsics.
|
||||
@@ -165,15 +165,18 @@ impl system::Trait for Runtime {
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
/// Portion of the block weight that is available to all normal transactions.
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
/// Runtime version.
|
||||
type Version = Version;
|
||||
/// Converts a module to an index of this module in the runtime.
|
||||
type ModuleToIndex = ModuleToIndex;
|
||||
}
|
||||
|
||||
impl indices::Trait for Runtime {
|
||||
impl pallet_indices::Trait for Runtime {
|
||||
/// The type for recording indexing into the account enumeration. If this ever overflows, there
|
||||
/// will be problems!
|
||||
type AccountIndex = u32;
|
||||
/// Use the standard means of resolving an index hint from an id.
|
||||
type ResolveHint = indices::SimpleResolveHint<Self::AccountId, Self::AccountIndex>;
|
||||
type ResolveHint = pallet_indices::SimpleResolveHint<Self::AccountId, Self::AccountIndex>;
|
||||
/// Determine whether an account is dead.
|
||||
type IsDeadAccount = Balances;
|
||||
/// The ubiquitous event type.
|
||||
@@ -184,7 +187,7 @@ parameter_types! {
|
||||
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
|
||||
}
|
||||
|
||||
impl timestamp::Trait for Runtime {
|
||||
impl pallet_timestamp::Trait for Runtime {
|
||||
/// A timestamp: milliseconds since the unix epoch.
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = ();
|
||||
@@ -199,7 +202,7 @@ parameter_types! {
|
||||
pub const TransactionByteFee: u128 = 1;
|
||||
}
|
||||
|
||||
impl balances::Trait for Runtime {
|
||||
impl pallet_balances::Trait for Runtime {
|
||||
/// The type for recording an account's balance.
|
||||
type Balance = Balance;
|
||||
/// What to do if an account's free balance gets zeroed.
|
||||
@@ -215,7 +218,7 @@ impl balances::Trait for Runtime {
|
||||
type CreationFee = CreationFee;
|
||||
}
|
||||
|
||||
impl transaction_payment::Trait for Runtime {
|
||||
impl pallet_transaction_payment::Trait for Runtime {
|
||||
type Currency = Balances;
|
||||
type OnTransactionPayment = ();
|
||||
type TransactionBaseFee = TransactionBaseFee;
|
||||
@@ -224,7 +227,7 @@ impl transaction_payment::Trait for Runtime {
|
||||
type FeeMultiplierUpdate = ();
|
||||
}
|
||||
|
||||
impl sudo::Trait for Runtime {
|
||||
impl pallet_sudo::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type Proposal = Call;
|
||||
}
|
||||
@@ -235,12 +238,12 @@ construct_runtime! {
|
||||
NodeBlock = opaque::Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic
|
||||
{
|
||||
System: system::{Module, Call, Storage, Config, Event},
|
||||
Timestamp: timestamp::{Module, Call, Storage, Inherent},
|
||||
Indices: indices::{default, Config<T>},
|
||||
Balances: balances::{default, Error},
|
||||
Sudo: sudo,
|
||||
RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},
|
||||
System: frame_system::{Module, Call, Storage, Config, Event},
|
||||
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
|
||||
Indices: pallet_indices,
|
||||
Balances: pallet_balances,
|
||||
Sudo: pallet_sudo,
|
||||
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,22 +259,28 @@ pub type SignedBlock = generic::SignedBlock<Block>;
|
||||
pub type BlockId = generic::BlockId<Block>;
|
||||
/// The SignedExtension to the basic transaction logic.
|
||||
pub type SignedExtra = (
|
||||
system::CheckVersion<Runtime>,
|
||||
system::CheckGenesis<Runtime>,
|
||||
system::CheckEra<Runtime>,
|
||||
system::CheckNonce<Runtime>,
|
||||
system::CheckWeight<Runtime>,
|
||||
transaction_payment::ChargeTransactionPayment<Runtime>,
|
||||
frame_system::CheckVersion<Runtime>,
|
||||
frame_system::CheckGenesis<Runtime>,
|
||||
frame_system::CheckEra<Runtime>,
|
||||
frame_system::CheckNonce<Runtime>,
|
||||
frame_system::CheckWeight<Runtime>,
|
||||
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
|
||||
);
|
||||
/// Unchecked extrinsic type as expected by this runtime.
|
||||
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
|
||||
/// Extrinsic type that has already been checked.
|
||||
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;
|
||||
/// Executive: handles dispatch to the various modules.
|
||||
pub type Executive = executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;
|
||||
pub type Executive = frame_executive::Executive<
|
||||
Runtime,
|
||||
Block,
|
||||
frame_system::ChainContext<Runtime>,
|
||||
Runtime,
|
||||
AllModules,
|
||||
>;
|
||||
|
||||
impl_runtime_apis! {
|
||||
impl client_api::Core<Block> for Runtime {
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
fn version() -> RuntimeVersion {
|
||||
VERSION
|
||||
}
|
||||
@@ -285,14 +294,16 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl client_api::Metadata<Block> for Runtime {
|
||||
impl sp_api::Metadata<Block> for Runtime {
|
||||
fn metadata() -> OpaqueMetadata {
|
||||
Runtime::metadata().into()
|
||||
}
|
||||
}
|
||||
|
||||
impl block_builder_api::BlockBuilder<Block> for Runtime {
|
||||
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyResult {
|
||||
impl sp_block_builder::BlockBuilder<Block> for Runtime {
|
||||
fn apply_extrinsic(
|
||||
extrinsic: <Block as BlockT>::Extrinsic,
|
||||
) -> ApplyExtrinsicResult {
|
||||
Executive::apply_extrinsic(extrinsic)
|
||||
}
|
||||
|
||||
@@ -300,11 +311,11 @@ impl_runtime_apis! {
|
||||
Executive::finalize_block()
|
||||
}
|
||||
|
||||
fn inherent_extrinsics(data: InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
|
||||
fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
|
||||
data.create_extrinsics()
|
||||
}
|
||||
|
||||
fn check_inherents(block: Block, data: InherentData) -> CheckInherentsResult {
|
||||
fn check_inherents(block: Block, data: sp_inherents::InherentData) -> sp_inherents::CheckInherentsResult {
|
||||
data.check_extrinsics(&block)
|
||||
}
|
||||
|
||||
@@ -313,21 +324,20 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl client_api::TaggedTransactionQueue<Block> for Runtime {
|
||||
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
|
||||
fn validate_transaction(tx: <Block as BlockT>::Extrinsic) -> TransactionValidity {
|
||||
Executive::validate_transaction(tx)
|
||||
}
|
||||
}
|
||||
|
||||
impl offchain_primitives::OffchainWorkerApi<Block> for Runtime {
|
||||
impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
|
||||
fn offchain_worker(number: NumberFor<Block>) {
|
||||
Executive::offchain_worker(number)
|
||||
}
|
||||
}
|
||||
|
||||
impl substrate_session::SessionKeys<Block> for Runtime {
|
||||
impl sp_session::SessionKeys<Block> for Runtime {
|
||||
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
|
||||
let seed = seed.as_ref().map(|s| rstd::str::from_utf8(&s).expect("Seed is an utf8 string"));
|
||||
opaque::SessionKeys::generate(seed)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use substrate_primitives::{Pair, Public};
|
||||
use parachain_runtime::{
|
||||
AccountId, BalancesConfig, GenesisConfig, SudoConfig, IndicesConfig, SystemConfig, WASM_BINARY,
|
||||
AccountId, BalancesConfig, GenesisConfig, IndicesConfig, SudoConfig, SystemConfig, WASM_BINARY,
|
||||
};
|
||||
use substrate_service;
|
||||
use sc_service;
|
||||
use sp_core::{Pair, Public};
|
||||
|
||||
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
|
||||
pub type ChainSpec = substrate_service::ChainSpec<GenesisConfig>;
|
||||
pub type ChainSpec = sc_service::ChainSpec<GenesisConfig>;
|
||||
|
||||
/// Helper function to generate a crypto pair from seed
|
||||
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
|
||||
@@ -32,7 +32,10 @@ pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Pu
|
||||
|
||||
/// Helper function to generate stash, controller and session key from seed
|
||||
pub fn get_authority_keys_from_seed(seed: &str) -> (AccountId, AccountId) {
|
||||
(get_from_seed::<AccountId>(&format!("{}//stash", seed)), get_from_seed::<AccountId>(seed))
|
||||
(
|
||||
get_from_seed::<AccountId>(&format!("{}//stash", seed)),
|
||||
get_from_seed::<AccountId>(seed),
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns the chain spec.
|
||||
@@ -40,28 +43,30 @@ pub fn get_chain_spec() -> ChainSpec {
|
||||
ChainSpec::from_genesis(
|
||||
"Local Testnet",
|
||||
"parachain_local_testnet",
|
||||
|| testnet_genesis(
|
||||
vec![
|
||||
get_authority_keys_from_seed("Alice"),
|
||||
get_authority_keys_from_seed("Bob"),
|
||||
],
|
||||
get_from_seed::<AccountId>("Alice"),
|
||||
vec![
|
||||
|| {
|
||||
testnet_genesis(
|
||||
vec![
|
||||
get_authority_keys_from_seed("Alice"),
|
||||
get_authority_keys_from_seed("Bob"),
|
||||
],
|
||||
get_from_seed::<AccountId>("Alice"),
|
||||
get_from_seed::<AccountId>("Bob"),
|
||||
get_from_seed::<AccountId>("Charlie"),
|
||||
get_from_seed::<AccountId>("Dave"),
|
||||
get_from_seed::<AccountId>("Eve"),
|
||||
get_from_seed::<AccountId>("Ferdie"),
|
||||
get_from_seed::<AccountId>("Alice//stash"),
|
||||
get_from_seed::<AccountId>("Bob//stash"),
|
||||
get_from_seed::<AccountId>("Charlie//stash"),
|
||||
get_from_seed::<AccountId>("Dave//stash"),
|
||||
get_from_seed::<AccountId>("Eve//stash"),
|
||||
get_from_seed::<AccountId>("Ferdie//stash"),
|
||||
],
|
||||
true,
|
||||
),
|
||||
vec![
|
||||
get_from_seed::<AccountId>("Alice"),
|
||||
get_from_seed::<AccountId>("Bob"),
|
||||
get_from_seed::<AccountId>("Charlie"),
|
||||
get_from_seed::<AccountId>("Dave"),
|
||||
get_from_seed::<AccountId>("Eve"),
|
||||
get_from_seed::<AccountId>("Ferdie"),
|
||||
get_from_seed::<AccountId>("Alice//stash"),
|
||||
get_from_seed::<AccountId>("Bob//stash"),
|
||||
get_from_seed::<AccountId>("Charlie//stash"),
|
||||
get_from_seed::<AccountId>("Dave//stash"),
|
||||
get_from_seed::<AccountId>("Eve//stash"),
|
||||
get_from_seed::<AccountId>("Ferdie//stash"),
|
||||
],
|
||||
true,
|
||||
)
|
||||
},
|
||||
vec![],
|
||||
None,
|
||||
None,
|
||||
@@ -77,19 +82,21 @@ fn testnet_genesis(
|
||||
_enable_println: bool,
|
||||
) -> GenesisConfig {
|
||||
GenesisConfig {
|
||||
system: Some(SystemConfig {
|
||||
frame_system: Some(SystemConfig {
|
||||
code: WASM_BINARY.to_vec(),
|
||||
changes_trie_config: Default::default(),
|
||||
}),
|
||||
indices: Some(IndicesConfig {
|
||||
pallet_indices: Some(IndicesConfig {
|
||||
ids: endowed_accounts.clone(),
|
||||
}),
|
||||
balances: Some(BalancesConfig {
|
||||
balances: endowed_accounts.iter().cloned().map(|k|(k, 1 << 60)).collect(),
|
||||
pallet_balances: Some(BalancesConfig {
|
||||
balances: endowed_accounts
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|k| (k, 1 << 60))
|
||||
.collect(),
|
||||
vesting: vec![],
|
||||
}),
|
||||
sudo: Some(SudoConfig {
|
||||
key: root_key,
|
||||
}),
|
||||
pallet_sudo: Some(SudoConfig { key: root_key }),
|
||||
}
|
||||
}
|
||||
|
||||
+93
-50
@@ -18,23 +18,29 @@ use crate::chain_spec;
|
||||
|
||||
use parachain_runtime::Block;
|
||||
|
||||
pub use substrate_cli::{VersionInfo, IntoExit, error::{self, Result}};
|
||||
use substrate_cli::{parse_and_prepare, ParseAndPrepare, NoCustom};
|
||||
use substrate_service::{Roles as ServiceRoles, Configuration};
|
||||
use sr_primitives::{traits::{Block as BlockT, Header as HeaderT, Hash as HashT}, BuildStorage};
|
||||
use substrate_client::genesis;
|
||||
use substrate_primitives::hexdisplay::HexDisplay;
|
||||
pub use sc_cli::{
|
||||
error::{self, Result},
|
||||
IntoExit, VersionInfo,
|
||||
};
|
||||
use sc_cli::{parse_and_prepare, NoCustom, ParseAndPrepare};
|
||||
use sc_client::genesis;
|
||||
use sc_service::{Configuration, Roles as ServiceRoles};
|
||||
use sp_core::hexdisplay::HexDisplay;
|
||||
use sp_runtime::{
|
||||
traits::{Block as BlockT, Hash as HashT, Header as HeaderT},
|
||||
BuildStorage,
|
||||
};
|
||||
|
||||
use futures::{channel::oneshot, future::Map, FutureExt};
|
||||
|
||||
use codec::Encode;
|
||||
|
||||
use log::info;
|
||||
|
||||
use std::{path::PathBuf, cell::RefCell, sync::Arc};
|
||||
use std::{cell::RefCell, path::PathBuf, sync::Arc};
|
||||
|
||||
use structopt::StructOpt;
|
||||
|
||||
use futures::{sync::oneshot, future, Future};
|
||||
|
||||
/// Sub-commands supported by the collator.
|
||||
#[derive(Debug, StructOpt, Clone)]
|
||||
enum SubCommands {
|
||||
@@ -43,8 +49,10 @@ enum SubCommands {
|
||||
ExportGenesisState(ExportGenesisStateCommand),
|
||||
}
|
||||
|
||||
impl substrate_cli::GetLogFilter for SubCommands {
|
||||
fn get_log_filter(&self) -> Option<String> { None }
|
||||
impl sc_cli::GetSharedParams for SubCommands {
|
||||
fn shared_params(&self) -> Option<&sc_cli::SharedParams> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Command for exporting the genesis state of the parachain
|
||||
@@ -57,10 +65,10 @@ struct ExportGenesisStateCommand {
|
||||
|
||||
/// Parse command line arguments into service configuration.
|
||||
pub fn run<I, T, E>(args: I, exit: E, version: VersionInfo) -> error::Result<()>
|
||||
where
|
||||
I: IntoIterator<Item = T>,
|
||||
T: Into<std::ffi::OsString> + Clone,
|
||||
E: IntoExit + Send + 'static,
|
||||
where
|
||||
I: IntoIterator<Item = T>,
|
||||
T: Into<std::ffi::OsString> + Clone,
|
||||
E: IntoExit + Send + 'static,
|
||||
{
|
||||
type Config<T> = Configuration<(), T>;
|
||||
match parse_and_prepare::<SubCommands, NoCustom, _>(
|
||||
@@ -68,37 +76,68 @@ pub fn run<I, T, E>(args: I, exit: E, version: VersionInfo) -> error::Result<()>
|
||||
"cumulus-test-parachain-collator",
|
||||
args,
|
||||
) {
|
||||
ParseAndPrepare::Run(cmd) => cmd.run(load_spec, exit,
|
||||
|exit, _cli_args, _custom_args, mut config: Config<_>| {
|
||||
info!("{}", version.name);
|
||||
info!(" version {}", config.full_version());
|
||||
info!(" by {}, 2019", version.author);
|
||||
info!("Chain specification: {}", config.chain_spec.name());
|
||||
info!("Node name: {}", config.name);
|
||||
info!("Roles: {:?}", config.roles);
|
||||
info!("Parachain id: {:?}", crate::PARA_ID);
|
||||
ParseAndPrepare::Run(cmd) => cmd.run(
|
||||
load_spec,
|
||||
exit,
|
||||
|exit, _cli_args, _custom_args, mut config: Config<_>| {
|
||||
info!("{}", version.name);
|
||||
info!(" version {}", config.full_version());
|
||||
info!(" by {}, 2019", version.author);
|
||||
info!("Chain specification: {}", config.chain_spec.name());
|
||||
info!("Node name: {}", config.name);
|
||||
info!("Roles: {:?}", config.roles);
|
||||
info!("Parachain id: {:?}", crate::PARA_ID);
|
||||
|
||||
// TODO
|
||||
let key = Arc::new(substrate_primitives::Pair::from_seed(&[10; 32]));
|
||||
// TODO
|
||||
let key = Arc::new(sp_core::Pair::from_seed(&[10; 32]));
|
||||
|
||||
// TODO
|
||||
config.network.listen_addresses = Vec::new();
|
||||
config.network.boot_nodes = vec![];
|
||||
config.chain_spec = chain_spec::get_chain_spec();
|
||||
// TODO
|
||||
config.network.listen_addresses = Vec::new();
|
||||
|
||||
match config.roles {
|
||||
ServiceRoles::LIGHT => unimplemented!("Light client not supported!"),
|
||||
_ => crate::service::run_collator(config, exit, key, version.clone()),
|
||||
}.map_err(|e| format!("{:?}", e))
|
||||
}),
|
||||
ParseAndPrepare::BuildSpec(cmd) => cmd.run(load_spec),
|
||||
ParseAndPrepare::ExportBlocks(cmd) => cmd.run_with_builder(|config: Config<_>|
|
||||
Ok(new_full_start!(config).0), load_spec, exit),
|
||||
ParseAndPrepare::ImportBlocks(cmd) => cmd.run_with_builder(|config: Config<_>|
|
||||
Ok(new_full_start!(config).0), load_spec, exit),
|
||||
// TODO
|
||||
let mut polkadot_config =
|
||||
polkadot_collator::Configuration::default_with_spec_and_base_path(
|
||||
polkadot_service::ChainSpec::from_json_bytes(
|
||||
&include_bytes!("../res/polkadot_chainspec.json")[..],
|
||||
)?,
|
||||
config.in_chain_config_dir("polkadot"),
|
||||
);
|
||||
polkadot_config.network.boot_nodes = config.network.boot_nodes.clone();
|
||||
|
||||
if let Some(ref config_dir) = polkadot_config.config_dir {
|
||||
polkadot_config.database = sc_service::config::DatabaseConfig::Path {
|
||||
cache_size: Default::default(),
|
||||
path: config_dir.join("db"),
|
||||
};
|
||||
}
|
||||
|
||||
match config.roles {
|
||||
ServiceRoles::LIGHT => unimplemented!("Light client not supported!"),
|
||||
_ => crate::service::run_collator(config, exit, key, polkadot_config),
|
||||
}
|
||||
.map_err(|e| format!("{:?}", e))
|
||||
},
|
||||
),
|
||||
ParseAndPrepare::BuildSpec(cmd) => cmd.run::<NoCustom, _, _, _>(load_spec),
|
||||
ParseAndPrepare::ExportBlocks(cmd) => cmd.run_with_builder(
|
||||
|config: Config<_>| Ok(new_full_start!(config).0),
|
||||
load_spec,
|
||||
exit,
|
||||
),
|
||||
ParseAndPrepare::ImportBlocks(cmd) => cmd.run_with_builder(
|
||||
|config: Config<_>| Ok(new_full_start!(config).0),
|
||||
load_spec,
|
||||
exit,
|
||||
),
|
||||
ParseAndPrepare::CheckBlock(cmd) => cmd.run_with_builder(
|
||||
|config: Config<_>| Ok(new_full_start!(config).0),
|
||||
load_spec,
|
||||
exit,
|
||||
),
|
||||
ParseAndPrepare::PurgeChain(cmd) => cmd.run(load_spec),
|
||||
ParseAndPrepare::RevertChain(cmd) => cmd.run_with_builder(|config: Config<_>|
|
||||
Ok(new_full_start!(config).0), load_spec),
|
||||
ParseAndPrepare::RevertChain(cmd) => {
|
||||
cmd.run_with_builder(|config: Config<_>| Ok(new_full_start!(config).0), load_spec)
|
||||
}
|
||||
ParseAndPrepare::CustomCommand(SubCommands::ExportGenesisState(cmd)) => {
|
||||
export_genesis_state(cmd.output)
|
||||
}
|
||||
@@ -113,16 +152,16 @@ fn load_spec(_: &str) -> std::result::Result<Option<chain_spec::ChainSpec>, Stri
|
||||
|
||||
/// Export the genesis state of the parachain.
|
||||
fn export_genesis_state(output: Option<PathBuf>) -> error::Result<()> {
|
||||
let storage = chain_spec::get_chain_spec().build_storage()?;
|
||||
let storage = (&chain_spec::get_chain_spec()).build_storage()?;
|
||||
|
||||
let child_roots = storage.1.iter().map(|(sk, child_map)| {
|
||||
let child_roots = storage.children.iter().map(|(sk, child_content)| {
|
||||
let state_root = <<<Block as BlockT>::Header as HeaderT>::Hashing as HashT>::trie_root(
|
||||
child_map.clone().into_iter().collect()
|
||||
child_content.data.clone().into_iter().collect(),
|
||||
);
|
||||
(sk.clone(), state_root.encode())
|
||||
});
|
||||
let state_root = <<<Block as BlockT>::Header as HeaderT>::Hashing as HashT>::trie_root(
|
||||
storage.0.clone().into_iter().chain(child_roots).collect()
|
||||
storage.top.clone().into_iter().chain(child_roots).collect(),
|
||||
);
|
||||
let block: Block = genesis::construct_genesis_block(state_root);
|
||||
|
||||
@@ -140,19 +179,23 @@ fn export_genesis_state(output: Option<PathBuf>) -> error::Result<()> {
|
||||
// handles ctrl-c
|
||||
pub struct Exit;
|
||||
impl IntoExit for Exit {
|
||||
type Exit = future::MapErr<oneshot::Receiver<()>, fn(oneshot::Canceled) -> ()>;
|
||||
type Exit = Map<oneshot::Receiver<()>, fn(std::result::Result<(), oneshot::Canceled>) -> ()>;
|
||||
fn into_exit(self) -> Self::Exit {
|
||||
// can't use signal directly here because CtrlC takes only `Fn`.
|
||||
let (exit_send, exit) = oneshot::channel();
|
||||
|
||||
let exit_send_cell = RefCell::new(Some(exit_send));
|
||||
ctrlc::set_handler(move || {
|
||||
let exit_send = exit_send_cell.try_borrow_mut().expect("signal handler not reentrant; qed").take();
|
||||
let exit_send = exit_send_cell
|
||||
.try_borrow_mut()
|
||||
.expect("signal handler not reentrant; qed")
|
||||
.take();
|
||||
if let Some(exit_send) = exit_send {
|
||||
exit_send.send(()).expect("Error sending exit notification");
|
||||
}
|
||||
}).expect("Error setting Ctrl-C handler");
|
||||
})
|
||||
.expect("Error setting Ctrl-C handler");
|
||||
|
||||
exit.map_err(drop)
|
||||
exit.map(drop)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ mod chain_spec;
|
||||
mod service;
|
||||
mod cli;
|
||||
|
||||
pub use substrate_cli::{VersionInfo, IntoExit, error};
|
||||
pub use sc_cli::{error, IntoExit, VersionInfo};
|
||||
|
||||
/// The parachain id of this parachain.
|
||||
pub const PARA_ID: ParaId = ParaId::new(100);
|
||||
|
||||
@@ -16,20 +16,19 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use parachain_runtime::{self, GenesisConfig, opaque::Block};
|
||||
use parachain_runtime::{self, opaque::Block, GenesisConfig};
|
||||
|
||||
use inherents::InherentDataProviders;
|
||||
use substrate_service::{AbstractService, Configuration};
|
||||
use network::construct_simple_protocol;
|
||||
use substrate_executor::native_executor_instance;
|
||||
use sc_executor::native_executor_instance;
|
||||
use sc_network::construct_simple_protocol;
|
||||
use sc_service::{AbstractService, Configuration};
|
||||
use sp_consensus::{BlockImport, Environment, Proposer};
|
||||
use sp_inherents::InherentDataProviders;
|
||||
|
||||
use futures::prelude::*;
|
||||
|
||||
use futures03::FutureExt;
|
||||
use futures::{compat::Future01CompatExt, future, task::Spawn, FutureExt, TryFutureExt};
|
||||
|
||||
use log::error;
|
||||
|
||||
pub use substrate_executor::NativeExecutor;
|
||||
pub use sc_executor::NativeExecutor;
|
||||
|
||||
// Our native executor instance.
|
||||
native_executor_instance!(
|
||||
@@ -49,29 +48,35 @@ construct_simple_protocol! {
|
||||
/// be able to perform chain operations.
|
||||
macro_rules! new_full_start {
|
||||
($config:expr) => {{
|
||||
let inherent_data_providers = inherents::InherentDataProviders::new();
|
||||
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
|
||||
|
||||
let builder = substrate_service::ServiceBuilder::new_full::<
|
||||
parachain_runtime::opaque::Block, parachain_runtime::RuntimeApi, crate::service::Executor,
|
||||
let builder = sc_service::ServiceBuilder::new_full::<
|
||||
parachain_runtime::opaque::Block,
|
||||
parachain_runtime::RuntimeApi,
|
||||
crate::service::Executor,
|
||||
>($config)?
|
||||
.with_select_chain(|_config, backend| {
|
||||
Ok(substrate_client::LongestChain::new(backend.clone()))
|
||||
})?
|
||||
.with_transaction_pool(|config, client|
|
||||
Ok(transaction_pool::txpool::Pool::new(config, transaction_pool::FullChainApi::new(client)))
|
||||
)?
|
||||
.with_import_queue(|_config, client, _, _| {
|
||||
let import_queue = cumulus_consensus::import_queue::import_queue(
|
||||
client.clone(),
|
||||
client,
|
||||
inherent_data_providers.clone(),
|
||||
)?;
|
||||
.with_select_chain(|_config, backend| Ok(sc_client::LongestChain::new(backend.clone())))?
|
||||
.with_transaction_pool(|config, client, _| {
|
||||
let pool_api = sc_transaction_pool::FullChainApi::new(client.clone());
|
||||
let pool = sc_transaction_pool::BasicPool::new(config, pool_api);
|
||||
let maintainer =
|
||||
sc_transaction_pool::FullBasicPoolMaintainer::new(pool.pool().clone(), client);
|
||||
let maintainable_pool =
|
||||
sp_transaction_pool::MaintainableTransactionPool::new(pool, maintainer);
|
||||
Ok(maintainable_pool)
|
||||
})?
|
||||
.with_import_queue(|_config, client, _, _| {
|
||||
let import_queue = cumulus_consensus::import_queue::import_queue(
|
||||
client.clone(),
|
||||
client,
|
||||
inherent_data_providers.clone(),
|
||||
)?;
|
||||
|
||||
Ok(import_queue)
|
||||
})?;
|
||||
Ok(import_queue)
|
||||
})?;
|
||||
|
||||
(builder, inherent_data_providers)
|
||||
}}
|
||||
}};
|
||||
}
|
||||
|
||||
/// Run the collator with the given `config`.
|
||||
@@ -79,13 +84,17 @@ pub fn run_collator<C: Send + Default + 'static, E: crate::cli::IntoExit + Send
|
||||
config: Configuration<C, GenesisConfig>,
|
||||
exit: E,
|
||||
key: Arc<polkadot_primitives::parachain::CollatorPair>,
|
||||
version: crate::cli::VersionInfo,
|
||||
polkadot_config: polkadot_collator::Configuration,
|
||||
) -> crate::cli::Result<()> {
|
||||
let (builder, inherent_data_providers) = new_full_start!(config);
|
||||
inherent_data_providers.register_provider(srml_timestamp::InherentDataProvider).unwrap();
|
||||
inherent_data_providers
|
||||
.register_provider(sp_timestamp::InherentDataProvider)
|
||||
.unwrap();
|
||||
|
||||
let service = builder.with_network_protocol(|_| Ok(NodeProtocol::new()))?.build()?;
|
||||
let proposer_factory = basic_authorship::ProposerFactory {
|
||||
let service = builder
|
||||
.with_network_protocol(|_| Ok(NodeProtocol::new()))?
|
||||
.build()?;
|
||||
let proposer_factory = sc_basic_authority::ProposerFactory {
|
||||
client: service.client(),
|
||||
transaction_pool: service.transaction_pool(),
|
||||
};
|
||||
@@ -101,7 +110,13 @@ pub fn run_collator<C: Send + Default + 'static, E: crate::cli::IntoExit + Send
|
||||
block_import,
|
||||
};
|
||||
|
||||
cumulus_collator::run_collator(setup_parachain, crate::PARA_ID, on_exit, key, version)
|
||||
cumulus_collator::run_collator(
|
||||
setup_parachain,
|
||||
crate::PARA_ID,
|
||||
on_exit,
|
||||
key,
|
||||
polkadot_config,
|
||||
)
|
||||
}
|
||||
|
||||
struct SetupParachain<S, PF, E, BI> {
|
||||
@@ -112,43 +127,66 @@ struct SetupParachain<S, PF, E, BI> {
|
||||
block_import: BI,
|
||||
}
|
||||
|
||||
type TransactionFor<E, Block> =
|
||||
<<E as Environment<Block>>::Proposer as Proposer<Block>>::Transaction;
|
||||
|
||||
impl<S, PF, E, BI> cumulus_collator::SetupParachain<Block> for SetupParachain<S, PF, E, BI>
|
||||
where
|
||||
S: AbstractService,
|
||||
E: Send + crate::cli::IntoExit,
|
||||
PF: consensus_common::Environment<Block> + Send + 'static,
|
||||
BI: consensus_common::BlockImport<Block, Error=consensus_common::Error> + Send + Sync + 'static,
|
||||
where
|
||||
S: AbstractService,
|
||||
E: Send + crate::cli::IntoExit,
|
||||
PF: Environment<Block> + Send + 'static,
|
||||
BI: BlockImport<Block, Error = sp_consensus::Error, Transaction = TransactionFor<PF, Block>>
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
{
|
||||
type ProposerFactory = PF;
|
||||
type BlockImport = BI;
|
||||
|
||||
fn setup_parachain<P: cumulus_consensus::PolkadotClient>(
|
||||
fn setup_parachain<P: cumulus_consensus::PolkadotClient, Spawner>(
|
||||
self,
|
||||
polkadot_client: P,
|
||||
task_executor: polkadot_collator::TaskExecutor,
|
||||
) -> Result<(Self::ProposerFactory, Self::BlockImport, InherentDataProviders), String> {
|
||||
spawner: Spawner,
|
||||
) -> Result<
|
||||
(
|
||||
Self::ProposerFactory,
|
||||
Self::BlockImport,
|
||||
InherentDataProviders,
|
||||
),
|
||||
String,
|
||||
>
|
||||
where
|
||||
Spawner: Spawn + Clone + Send + Sync + 'static,
|
||||
{
|
||||
let client = self.service.client();
|
||||
|
||||
let follow = match cumulus_consensus::follow_polkadot(crate::PARA_ID, client, polkadot_client) {
|
||||
Ok(follow) => follow,
|
||||
Err(e) => {
|
||||
return Err(format!("Could not start following polkadot: {:?}", e));
|
||||
}
|
||||
};
|
||||
let follow =
|
||||
match cumulus_consensus::follow_polkadot(crate::PARA_ID, client, polkadot_client) {
|
||||
Ok(follow) => follow,
|
||||
Err(e) => {
|
||||
return Err(format!("Could not start following polkadot: {:?}", e));
|
||||
}
|
||||
};
|
||||
|
||||
task_executor.execute(
|
||||
Box::new(
|
||||
self.service
|
||||
.map_err(|e| error!("Parachain service error: {:?}", e))
|
||||
.select(futures03::compat::Compat::new(follow.map(|_| Ok::<(), ()>(()))))
|
||||
.map(|_| ())
|
||||
.map_err(|_| ())
|
||||
.select(self.exit.into_exit())
|
||||
.map(|_| ())
|
||||
.map_err(|_| ())
|
||||
),
|
||||
).map_err(|_| "Could not spawn parachain server!")?;
|
||||
spawner
|
||||
.spawn_obj(
|
||||
Box::new(
|
||||
future::select(
|
||||
self.service
|
||||
.compat()
|
||||
.map_err(|e| error!("Parachain service error: {:?}", e)),
|
||||
future::select(follow, self.exit.into_exit()),
|
||||
)
|
||||
.map(|_| ()),
|
||||
)
|
||||
.into(),
|
||||
)
|
||||
.map_err(|_| "Could not spawn parachain server!")?;
|
||||
|
||||
Ok((self.proposer_factory, self.block_import, self.inherent_data_providers))
|
||||
Ok((
|
||||
self.proposer_factory,
|
||||
self.block_import,
|
||||
self.inherent_data_providers,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user