mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 09:21:04 +00:00
Update polkadot and substrate (#71)
This commit is contained in:
Generated
+2243
-2238
File diff suppressed because it is too large
Load Diff
+24
-29
@@ -31,7 +31,7 @@ use polkadot_collator::{
|
|||||||
PolkadotClient,
|
PolkadotClient,
|
||||||
};
|
};
|
||||||
use polkadot_primitives::{
|
use polkadot_primitives::{
|
||||||
parachain::{self, BlockData, Status as ParachainStatus, Id as ParaId}, Block as PBlock,
|
parachain::{self, BlockData, LocalValidationData, Id as ParaId}, Block as PBlock,
|
||||||
Hash as PHash,
|
Hash as PHash,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,14 +65,14 @@ impl<Block, PF, BI> Collator<Block, PF, BI> {
|
|||||||
fn new(
|
fn new(
|
||||||
proposer_factory: PF,
|
proposer_factory: PF,
|
||||||
inherent_data_providers: InherentDataProviders,
|
inherent_data_providers: InherentDataProviders,
|
||||||
collator_network: Arc<dyn CollatorNetwork>,
|
collator_network: impl CollatorNetwork + Clone + 'static,
|
||||||
block_import: BI,
|
block_import: BI,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
proposer_factory: Arc::new(Mutex::new(proposer_factory)),
|
proposer_factory: Arc::new(Mutex::new(proposer_factory)),
|
||||||
inherent_data_providers,
|
inherent_data_providers,
|
||||||
_phantom: PhantomData,
|
_phantom: PhantomData,
|
||||||
collator_network,
|
collator_network: Arc::new(collator_network),
|
||||||
block_import: Arc::new(Mutex::new(block_import)),
|
block_import: Arc::new(Mutex::new(block_import)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ where
|
|||||||
fn produce_candidate(
|
fn produce_candidate(
|
||||||
&mut self,
|
&mut self,
|
||||||
_relay_chain_parent: PHash,
|
_relay_chain_parent: PHash,
|
||||||
status: ParachainStatus,
|
status: LocalValidationData,
|
||||||
) -> Self::ProduceCandidate {
|
) -> Self::ProduceCandidate {
|
||||||
let factory = self.proposer_factory.clone();
|
let factory = self.proposer_factory.clone();
|
||||||
let inherent_providers = self.inherent_data_providers.clone();
|
let inherent_providers = self.inherent_data_providers.clone();
|
||||||
@@ -119,7 +119,7 @@ where
|
|||||||
|
|
||||||
trace!(target: "cumulus-collator", "Producing candidate");
|
trace!(target: "cumulus-collator", "Producing candidate");
|
||||||
|
|
||||||
let last_head = match HeadData::<Block>::decode(&mut &status.head_data.0[..]) {
|
let last_head = match HeadData::<Block>::decode(&mut &status.parent_head.0[..]) {
|
||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!(target: "cumulus-collator", "Could not decode the head data: {:?}", e);
|
error!(target: "cumulus-collator", "Could not decode the head data: {:?}", e);
|
||||||
@@ -285,7 +285,7 @@ where
|
|||||||
self,
|
self,
|
||||||
polkadot_client: Arc<PolkadotClient<B, E, R>>,
|
polkadot_client: Arc<PolkadotClient<B, E, R>>,
|
||||||
spawner: Spawner,
|
spawner: Spawner,
|
||||||
network: Arc<dyn CollatorNetwork>,
|
network: impl CollatorNetwork + Clone + 'static,
|
||||||
) -> Result<Self::ParachainContext, ()>
|
) -> Result<Self::ParachainContext, ()>
|
||||||
where
|
where
|
||||||
PolkadotClient<B, E, R>: sp_api::ProvideRuntimeApi<PBlock>,
|
PolkadotClient<B, E, R>: sp_api::ProvideRuntimeApi<PBlock>,
|
||||||
@@ -296,11 +296,11 @@ where
|
|||||||
Extrinsic: codec::Codec + Send + Sync + 'static,
|
Extrinsic: codec::Codec + Send + Sync + 'static,
|
||||||
<<PolkadotClient<B, E, R> as sp_api::ProvideRuntimeApi<PBlock>>::Api as sp_api::ApiExt<
|
<<PolkadotClient<B, E, R> as sp_api::ProvideRuntimeApi<PBlock>>::Api as sp_api::ApiExt<
|
||||||
PBlock,
|
PBlock,
|
||||||
>>::StateBackend: sp_api::StateBackend<sp_core::Blake2Hasher>,
|
>>::StateBackend: sp_api::StateBackend<sp_runtime::traits::BlakeTwo256>,
|
||||||
R: Send + Sync + 'static,
|
R: Send + Sync + 'static,
|
||||||
B: sc_client_api::Backend<PBlock> + 'static,
|
B: sc_client_api::Backend<PBlock> + 'static,
|
||||||
// Rust bug: https://github.com/rust-lang/rust/issues/24159
|
// Rust bug: https://github.com/rust-lang/rust/issues/24159
|
||||||
B::State: sp_api::StateBackend<sp_core::Blake2Hasher>,
|
B::State: sp_api::StateBackend<sp_runtime::traits::BlakeTwo256>,
|
||||||
{
|
{
|
||||||
let follow =
|
let follow =
|
||||||
match cumulus_consensus::follow_polkadot(self.para_id, self.client, polkadot_client) {
|
match cumulus_consensus::follow_polkadot(self.para_id, self.client, polkadot_client) {
|
||||||
@@ -333,8 +333,8 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use polkadot_collator::{collate, CollatorId, PeerId, SignedStatement};
|
use polkadot_collator::{collate, SignedStatement};
|
||||||
use polkadot_primitives::parachain::{FeeSchedule, HeadData, Id as ParaId};
|
use polkadot_primitives::parachain::{HeadData, Id as ParaId};
|
||||||
|
|
||||||
use sp_blockchain::Result as ClientResult;
|
use sp_blockchain::Result as ClientResult;
|
||||||
use sp_inherents::InherentData;
|
use sp_inherents::InherentData;
|
||||||
@@ -406,17 +406,11 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
struct DummyCollatorNetwork;
|
struct DummyCollatorNetwork;
|
||||||
|
|
||||||
impl CollatorNetwork for DummyCollatorNetwork {
|
impl CollatorNetwork for DummyCollatorNetwork {
|
||||||
fn collator_id_to_peer_id(
|
fn checked_statements(&self, _: PHash) -> Pin<Box<dyn Stream<Item = SignedStatement>>> {
|
||||||
&self,
|
|
||||||
_: CollatorId,
|
|
||||||
) -> Box<dyn Future<Output = Option<PeerId>> + Send> {
|
|
||||||
unimplemented!("Not required in tests")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn checked_statements(&self, _: PHash) -> Box<dyn Stream<Item = SignedStatement>> {
|
|
||||||
unimplemented!("Not required in tests")
|
unimplemented!("Not required in tests")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -455,16 +449,21 @@ mod tests {
|
|||||||
Arc::new(TestClientBuilder::new().build()),
|
Arc::new(TestClientBuilder::new().build()),
|
||||||
);
|
);
|
||||||
let context = builder
|
let context = builder
|
||||||
.build::<_, _, polkadot_service::polkadot_runtime::RuntimeApi, _, _>(
|
.build(
|
||||||
Arc::new(
|
Arc::new(
|
||||||
substrate_test_client::TestClientBuilder::<_, _, _, ()>::default()
|
substrate_test_client::TestClientBuilder::<_, _, _, ()>::default()
|
||||||
.build_with_native_executor(Some(NativeExecutor::<
|
.build_with_native_executor::<polkadot_service::polkadot_runtime::RuntimeApi, _>(
|
||||||
polkadot_service::PolkadotExecutor,
|
Some(
|
||||||
>::new(Interpreted, None)))
|
NativeExecutor::<polkadot_service::PolkadotExecutor>::new(
|
||||||
|
Interpreted,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
.0,
|
.0,
|
||||||
),
|
),
|
||||||
spawner,
|
spawner,
|
||||||
Arc::new(DummyCollatorNetwork),
|
DummyCollatorNetwork,
|
||||||
)
|
)
|
||||||
.expect("Creates parachain context");
|
.expect("Creates parachain context");
|
||||||
|
|
||||||
@@ -479,13 +478,9 @@ mod tests {
|
|||||||
let collation = collate(
|
let collation = collate(
|
||||||
Default::default(),
|
Default::default(),
|
||||||
id,
|
id,
|
||||||
ParachainStatus {
|
LocalValidationData {
|
||||||
head_data: HeadData(header.encode()),
|
parent_head: HeadData(header.encode()),
|
||||||
balance: 10,
|
balance: 10,
|
||||||
fee_schedule: FeeSchedule {
|
|
||||||
base: 0,
|
|
||||||
per_byte: 1,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
context,
|
context,
|
||||||
Arc::new(Sr25519Keyring::Alice.pair().into()),
|
Arc::new(Sr25519Keyring::Alice.pair().into()),
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ where
|
|||||||
<Client<B, E, PBlock, RA> as ProvideRuntimeApi<PBlock>>::Api:
|
<Client<B, E, PBlock, RA> as ProvideRuntimeApi<PBlock>>::Api:
|
||||||
ParachainHost<PBlock, Error = ClientError>,
|
ParachainHost<PBlock, Error = ClientError>,
|
||||||
// Rust bug: https://github.com/rust-lang/rust/issues/24159
|
// Rust bug: https://github.com/rust-lang/rust/issues/24159
|
||||||
StateBackendFor<B, PBlock>: StateBackend<sp_core::Blake2Hasher>,
|
StateBackendFor<B, PBlock>: StateBackend<sp_runtime::traits::BlakeTwo256>,
|
||||||
{
|
{
|
||||||
type Error = ClientError;
|
type Error = ClientError;
|
||||||
|
|
||||||
@@ -181,8 +181,8 @@ where
|
|||||||
para_id: ParaId,
|
para_id: ParaId,
|
||||||
) -> ClientResult<Option<Vec<u8>>> {
|
) -> ClientResult<Option<Vec<u8>>> {
|
||||||
self.runtime_api()
|
self.runtime_api()
|
||||||
.parachain_status(at, para_id)
|
.local_validation_data(at, para_id)
|
||||||
.map(|s| s.map(|s| s.head_data.0))
|
.map(|s| s.map(|s| s.parent_head.0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ sp-trie = { git = "https://github.com/paritytech/substrate", default-features =
|
|||||||
parachain = { package = "polkadot-parachain", git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch", default-features = false, features = [ "wasm-api" ] }
|
parachain = { package = "polkadot-parachain", git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch", default-features = false, features = [ "wasm-api" ] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
sc-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" }
|
||||||
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
use crate::WitnessData;
|
use crate::WitnessData;
|
||||||
use frame_executive::ExecuteBlock;
|
use frame_executive::ExecuteBlock;
|
||||||
use sp_runtime::traits::{Block as BlockT, HasherFor, Header as HeaderT};
|
use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT};
|
||||||
|
|
||||||
use sp_trie::{delta_trie_root, read_trie_value, Layout, MemoryDB};
|
use sp_trie::{delta_trie_root, read_trie_value, Layout, MemoryDB};
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ pub fn validate_block<B: BlockT, E: ExecuteBlock<B>>(params: ValidationParams) -
|
|||||||
/// The storage implementation used when validating a block that is using the
|
/// The storage implementation used when validating a block that is using the
|
||||||
/// witness data as source.
|
/// witness data as source.
|
||||||
struct WitnessStorage<B: BlockT> {
|
struct WitnessStorage<B: BlockT> {
|
||||||
witness_data: MemoryDB<HasherFor<B>>,
|
witness_data: MemoryDB<HashFor<B>>,
|
||||||
overlay: hashbrown::HashMap<Vec<u8>, Option<Vec<u8>>>,
|
overlay: hashbrown::HashMap<Vec<u8>, Option<Vec<u8>>>,
|
||||||
storage_root: B::Hash,
|
storage_root: B::Hash,
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ impl<B: BlockT> Storage for WitnessStorage<B> {
|
|||||||
.get(key)
|
.get(key)
|
||||||
.cloned()
|
.cloned()
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
read_trie_value::<Layout<HasherFor<B>>, _>(
|
read_trie_value::<Layout<HashFor<B>>, _>(
|
||||||
&self.witness_data,
|
&self.witness_data,
|
||||||
&self.storage_root,
|
&self.storage_root,
|
||||||
key,
|
key,
|
||||||
@@ -168,7 +168,7 @@ impl<B: BlockT> Storage for WitnessStorage<B> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn storage_root(&mut self) -> Vec<u8> {
|
fn storage_root(&mut self) -> Vec<u8> {
|
||||||
let root = delta_trie_root::<Layout<HasherFor<B>>, _, _, _, _>(
|
let root = delta_trie_root::<Layout<HashFor<B>>, _, _, _, _>(
|
||||||
&mut self.witness_data,
|
&mut self.witness_data,
|
||||||
self.storage_root.clone(),
|
self.storage_root.clone(),
|
||||||
self.overlay.drain(),
|
self.overlay.drain(),
|
||||||
@@ -184,7 +184,7 @@ impl<B: BlockT> Storage for WitnessStorage<B> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let trie = match TrieDB::<Layout<HasherFor<B>>>::new(&self.witness_data, &self.storage_root)
|
let trie = match TrieDB::<Layout<HashFor<B>>>::new(&self.witness_data, &self.storage_root)
|
||||||
{
|
{
|
||||||
Ok(r) => r,
|
Ok(r) => r,
|
||||||
Err(_) => panic!(),
|
Err(_) => panic!(),
|
||||||
|
|||||||
@@ -17,9 +17,13 @@
|
|||||||
use crate::{ParachainBlockData, WitnessData};
|
use crate::{ParachainBlockData, WitnessData};
|
||||||
|
|
||||||
use parachain::{ValidationParams, ValidationResult};
|
use parachain::{ValidationParams, ValidationResult};
|
||||||
use sc_executor::{call_in_wasm, error::Result, WasmExecutionMethod};
|
use sc_executor::{
|
||||||
|
error::Result, WasmExecutionMethod, WasmExecutor, sp_wasm_interface::HostFunctions,
|
||||||
|
};
|
||||||
|
use sc_block_builder::BlockBuilderProvider;
|
||||||
use sp_blockchain::HeaderBackend;
|
use sp_blockchain::HeaderBackend;
|
||||||
use sp_consensus::SelectChain;
|
use sp_consensus::SelectChain;
|
||||||
|
use sp_core::traits::CallInWasm;
|
||||||
use sp_io::TestExternalities;
|
use sp_io::TestExternalities;
|
||||||
use sp_keyring::AccountKeyring;
|
use sp_keyring::AccountKeyring;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
@@ -45,22 +49,22 @@ fn call_validate_block(
|
|||||||
}
|
}
|
||||||
.encode();
|
.encode();
|
||||||
|
|
||||||
call_in_wasm::<
|
let executor = WasmExecutor::new(
|
||||||
(
|
WasmExecutionMethod::Interpreted,
|
||||||
sp_io::SubstrateHostFunctions,
|
Some(1024),
|
||||||
sc_executor::deprecated_host_interface::SubstrateExternals,
|
sp_io::SubstrateHostFunctions::host_functions(),
|
||||||
),
|
false,
|
||||||
>(
|
);
|
||||||
|
|
||||||
|
executor.call_in_wasm(
|
||||||
|
&WASM_BINARY,
|
||||||
"validate_block",
|
"validate_block",
|
||||||
¶ms,
|
¶ms,
|
||||||
WasmExecutionMethod::Interpreted,
|
|
||||||
&mut ext_ext,
|
&mut ext_ext,
|
||||||
&WASM_BINARY,
|
|
||||||
1024,
|
|
||||||
false,
|
|
||||||
)
|
)
|
||||||
.map(|v| ValidationResult::decode(&mut &v[..]).expect("Decode `ValidationResult`."))
|
.map(|v| ValidationResult::decode(&mut &v[..]).expect("Decode `ValidationResult`."))
|
||||||
.map(|v| Header::decode(&mut &v.head_data[..]).expect("Decode `Header`."))
|
.map(|v| Header::decode(&mut &v.head_data[..]).expect("Decode `Header`."))
|
||||||
|
.map_err(|err| err.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_extrinsics() -> Vec<<Block as BlockT>::Extrinsic> {
|
fn create_extrinsics() -> Vec<<Block as BlockT>::Extrinsic> {
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ sc-network = { git = "https://github.com/paritytech/substrate", branch = "cumulu
|
|||||||
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
|
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
|
|
||||||
# Cumulus dependencies
|
# Cumulus dependencies
|
||||||
cumulus-consensus = { path = "../../consensus" }
|
cumulus-consensus = { path = "../../consensus" }
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -171,7 +171,7 @@ impl frame_system::Trait for Runtime {
|
|||||||
type ModuleToIndex = ModuleToIndex;
|
type ModuleToIndex = ModuleToIndex;
|
||||||
type AccountData = pallet_balances::AccountData<Balance>;
|
type AccountData = pallet_balances::AccountData<Balance>;
|
||||||
type OnNewAccount = ();
|
type OnNewAccount = ();
|
||||||
type OnReapAccount = Balances;
|
type OnKilledAccount = Balances;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
@@ -303,10 +303,6 @@ impl_runtime_apis! {
|
|||||||
Executive::apply_extrinsic(extrinsic)
|
Executive::apply_extrinsic(extrinsic)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_trusted_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
|
|
||||||
Executive::apply_trusted_extrinsic(extrinsic)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn finalize_block() -> <Block as BlockT>::Header {
|
fn finalize_block() -> <Block as BlockT>::Header {
|
||||||
Executive::finalize_block()
|
Executive::finalize_block()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,8 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use parachain_runtime::Block;
|
use parachain_runtime::Block;
|
||||||
|
|
||||||
use sc_cli::{error, VersionInfo};
|
|
||||||
use sc_client::genesis;
|
use sc_client::genesis;
|
||||||
use sc_service::{Configuration, Roles as ServiceRoles};
|
use sc_service::{Configuration, Roles as ServiceRoles, config::PrometheusConfig};
|
||||||
use sp_core::hexdisplay::HexDisplay;
|
use sp_core::hexdisplay::HexDisplay;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{Block as BlockT, Hash as HashT, Header as HeaderT},
|
traits::{Block as BlockT, Hash as HashT, Header as HeaderT},
|
||||||
@@ -37,23 +36,24 @@ use log::info;
|
|||||||
|
|
||||||
const DEFAULT_POLKADOT_RPC_HTTP: &'static str = "127.0.0.1:9934";
|
const DEFAULT_POLKADOT_RPC_HTTP: &'static str = "127.0.0.1:9934";
|
||||||
const DEFAULT_POLKADOT_RPC_WS: &'static str = "127.0.0.1:9945";
|
const DEFAULT_POLKADOT_RPC_WS: &'static str = "127.0.0.1:9945";
|
||||||
const DEFAULT_POLKADOT_GRAFANA_PORT: &'static str = "127.0.0.1:9956";
|
const DEFAULT_POLKADOT_PROMETHEUS_PORT: &'static str = "127.0.0.1:9616";
|
||||||
|
|
||||||
/// Parse command line arguments into service configuration.
|
/// Parse command line arguments into service configuration.
|
||||||
pub fn run(version: VersionInfo) -> error::Result<()> {
|
pub fn run(version: sc_cli::VersionInfo) -> sc_cli::Result<()> {
|
||||||
let opt: Cli = sc_cli::from_args(&version);
|
let opt: Cli = sc_cli::from_args(&version);
|
||||||
|
|
||||||
let mut config = sc_service::Configuration::new(&version);
|
let mut config = sc_service::Configuration::from_version(&version);
|
||||||
let mut polkadot_config = Configuration::new(&version);
|
let mut polkadot_config = Configuration::from_version(&version);
|
||||||
|
|
||||||
match opt.subcommand {
|
match opt.subcommand {
|
||||||
Some(Subcommand::Base(subcommand)) => sc_cli::run_subcommand(
|
Some(Subcommand::Base(subcommand)) => {
|
||||||
|
subcommand.init(&version)?;
|
||||||
|
subcommand.update_config(&mut config, load_spec, &version)?;
|
||||||
|
subcommand.run(
|
||||||
config,
|
config,
|
||||||
subcommand,
|
|
||||||
load_spec,
|
|
||||||
|config: Configuration<_, _>| Ok(new_full_start!(config).0),
|
|config: Configuration<_, _>| Ok(new_full_start!(config).0),
|
||||||
&version,
|
)
|
||||||
),
|
},
|
||||||
Some(Subcommand::ExportGenesisState(params)) => {
|
Some(Subcommand::ExportGenesisState(params)) => {
|
||||||
sc_cli::init_logger("");
|
sc_cli::init_logger("");
|
||||||
|
|
||||||
@@ -81,9 +81,8 @@ pub fn run(version: VersionInfo) -> error::Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
sc_cli::init(&opt.run.shared_params, &version)?;
|
opt.run.init(&version)?;
|
||||||
sc_cli::init_config(&mut config, &opt.run.shared_params, &version, load_spec)?;
|
opt.run.update_config(&mut config, load_spec, &version)?;
|
||||||
sc_cli::update_config_for_running_node(&mut config, opt.run)?;
|
|
||||||
|
|
||||||
info!("{}", version.name);
|
info!("{}", version.name);
|
||||||
info!(" version {}", config.full_version());
|
info!(" version {}", config.full_version());
|
||||||
@@ -106,15 +105,17 @@ pub fn run(version: VersionInfo) -> error::Result<()> {
|
|||||||
|
|
||||||
polkadot_config.rpc_http = Some(DEFAULT_POLKADOT_RPC_HTTP.parse().unwrap());
|
polkadot_config.rpc_http = Some(DEFAULT_POLKADOT_RPC_HTTP.parse().unwrap());
|
||||||
polkadot_config.rpc_ws = Some(DEFAULT_POLKADOT_RPC_WS.parse().unwrap());
|
polkadot_config.rpc_ws = Some(DEFAULT_POLKADOT_RPC_WS.parse().unwrap());
|
||||||
polkadot_config.grafana_port = Some(DEFAULT_POLKADOT_GRAFANA_PORT.parse().unwrap());
|
polkadot_config.prometheus_config = Some(
|
||||||
|
PrometheusConfig::new_with_default_registry(
|
||||||
|
DEFAULT_POLKADOT_PROMETHEUS_PORT.parse().unwrap(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
sc_cli::init_config(
|
polkadot_opt.run.update_config(
|
||||||
&mut polkadot_config,
|
&mut polkadot_config,
|
||||||
&polkadot_opt.run.shared_params,
|
|
||||||
&version,
|
|
||||||
load_spec_polkadot,
|
load_spec_polkadot,
|
||||||
|
&version,
|
||||||
)?;
|
)?;
|
||||||
sc_cli::update_config_for_running_node(&mut polkadot_config, polkadot_opt.run)?;
|
|
||||||
|
|
||||||
// TODO: we disable mdns for the polkadot node because it prevents the process to exit
|
// TODO: we disable mdns for the polkadot node because it prevents the process to exit
|
||||||
// properly. See https://github.com/paritytech/cumulus/issues/57
|
// properly. See https://github.com/paritytech/cumulus/issues/57
|
||||||
@@ -133,11 +134,11 @@ pub fn run(version: VersionInfo) -> error::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_spec(_: &str) -> std::result::Result<Option<chain_spec::ChainSpec>, String> {
|
fn load_spec(_: &str) -> Result<Option<chain_spec::ChainSpec>, String> {
|
||||||
Ok(Some(chain_spec::get_chain_spec()))
|
Ok(Some(chain_spec::get_chain_spec()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_spec_polkadot(_: &str) -> std::result::Result<Option<ChainSpecPolkadot>, String> {
|
fn load_spec_polkadot(_: &str) -> Result<Option<ChainSpecPolkadot>, String> {
|
||||||
Some(polkadot_service::ChainSpec::from_json_bytes(
|
Some(polkadot_service::ChainSpec::from_json_bytes(
|
||||||
&include_bytes!("../res/polkadot_chainspec.json")[..],
|
&include_bytes!("../res/polkadot_chainspec.json")[..],
|
||||||
)).transpose()
|
)).transpose()
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ mod service;
|
|||||||
mod cli;
|
mod cli;
|
||||||
mod command;
|
mod command;
|
||||||
|
|
||||||
pub use sc_cli::{error, VersionInfo};
|
|
||||||
|
|
||||||
/// The parachain id of this parachain.
|
/// The parachain id of this parachain.
|
||||||
pub const PARA_ID: ParaId = ParaId::new(100);
|
pub const PARA_ID: ParaId = ParaId::new(100);
|
||||||
const EXECUTABLE_NAME: &'static str = "cumulus-test-parachain-collator";
|
const EXECUTABLE_NAME: &'static str = "cumulus-test-parachain-collator";
|
||||||
@@ -38,8 +36,8 @@ const DESCRIPTION: &'static str =
|
|||||||
to the relaychain node.\n\n\
|
to the relaychain node.\n\n\
|
||||||
cumulus-test-parachain-collator [parachain-args] -- [relaychain-args]";
|
cumulus-test-parachain-collator [parachain-args] -- [relaychain-args]";
|
||||||
|
|
||||||
fn main() -> Result<(), error::Error> {
|
fn main() -> sc_cli::Result<()> {
|
||||||
let version = VersionInfo {
|
let version = sc_cli::VersionInfo {
|
||||||
name: "Cumulus Test Parachain Collator",
|
name: "Cumulus Test Parachain Collator",
|
||||||
commit: env!("VERGEN_SHA_SHORT"),
|
commit: env!("VERGEN_SHA_SHORT"),
|
||||||
version: env!("CARGO_PKG_VERSION"),
|
version: env!("CARGO_PKG_VERSION"),
|
||||||
|
|||||||
@@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use parachain_runtime::{self, opaque::Block, GenesisConfig};
|
use parachain_runtime::{self, GenesisConfig};
|
||||||
|
|
||||||
use sc_executor::native_executor_instance;
|
use sc_executor::native_executor_instance;
|
||||||
use sc_network::construct_simple_protocol;
|
|
||||||
use sc_service::{AbstractService, Configuration};
|
use sc_service::{AbstractService, Configuration};
|
||||||
|
use sc_finality_grandpa::{FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider};
|
||||||
|
|
||||||
use polkadot_primitives::parachain::CollatorPair;
|
use polkadot_primitives::parachain::CollatorPair;
|
||||||
|
|
||||||
@@ -37,11 +37,6 @@ native_executor_instance!(
|
|||||||
parachain_runtime::native_version,
|
parachain_runtime::native_version,
|
||||||
);
|
);
|
||||||
|
|
||||||
construct_simple_protocol! {
|
|
||||||
/// Demo protocol attachment for substrate.
|
|
||||||
pub struct NodeProtocol where Block = Block { }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Starts a `ServiceBuilder` for a full service.
|
/// Starts a `ServiceBuilder` for a full service.
|
||||||
///
|
///
|
||||||
/// Use this macro if you don't actually need the full service, but just the builder in order to
|
/// Use this macro if you don't actually need the full service, but just the builder in order to
|
||||||
@@ -82,7 +77,7 @@ pub fn run_collator<E: sc_service::ChainSpecExtension>(
|
|||||||
parachain_config: Configuration<GenesisConfig, E>,
|
parachain_config: Configuration<GenesisConfig, E>,
|
||||||
key: Arc<CollatorPair>,
|
key: Arc<CollatorPair>,
|
||||||
mut polkadot_config: polkadot_collator::Configuration,
|
mut polkadot_config: polkadot_collator::Configuration,
|
||||||
) -> sc_cli::error::Result<()> {
|
) -> sc_cli::Result<()> {
|
||||||
sc_cli::run_service_until_exit(parachain_config, move |parachain_config| {
|
sc_cli::run_service_until_exit(parachain_config, move |parachain_config| {
|
||||||
polkadot_config.task_executor = parachain_config.task_executor.clone();
|
polkadot_config.task_executor = parachain_config.task_executor.clone();
|
||||||
|
|
||||||
@@ -92,13 +87,17 @@ pub fn run_collator<E: sc_service::ChainSpecExtension>(
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let service = builder
|
let service = builder
|
||||||
.with_network_protocol(|_| Ok(NodeProtocol::new()))?
|
.with_finality_proof_provider(|client, backend| {
|
||||||
|
// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
|
||||||
|
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
|
||||||
|
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
|
||||||
|
})?
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
let proposer_factory = sc_basic_authorship::ProposerFactory {
|
let proposer_factory = sc_basic_authorship::ProposerFactory::new(
|
||||||
client: service.client(),
|
service.client(),
|
||||||
transaction_pool: service.transaction_pool(),
|
service.transaction_pool(),
|
||||||
};
|
);
|
||||||
|
|
||||||
let block_import = service.client();
|
let block_import = service.client();
|
||||||
let client = service.client();
|
let client = service.client();
|
||||||
|
|||||||
Reference in New Issue
Block a user