mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 08:11:03 +00:00
Update to latest Substrate & Polkadot (#131)
* Switch to latest Substrate & Polkadot * Update again
This commit is contained in:
Generated
+643
-363
File diff suppressed because it is too large
Load Diff
+38
-29
@@ -20,8 +20,12 @@ use cumulus_network::{
|
|||||||
DelayedBlockAnnounceValidator, JustifiedBlockAnnounceValidator, WaitToAnnounce,
|
DelayedBlockAnnounceValidator, JustifiedBlockAnnounceValidator, WaitToAnnounce,
|
||||||
};
|
};
|
||||||
use cumulus_primitives::{
|
use cumulus_primitives::{
|
||||||
inherents::{VALIDATION_FUNCTION_PARAMS_IDENTIFIER as VFP_IDENT, DOWNWARD_MESSAGES_IDENTIFIER, DownwardMessagesType},
|
inherents::{
|
||||||
validation_function_params::ValidationFunctionParams, HeadData,
|
DownwardMessagesType, DOWNWARD_MESSAGES_IDENTIFIER,
|
||||||
|
VALIDATION_FUNCTION_PARAMS_IDENTIFIER as VFP_IDENT,
|
||||||
|
},
|
||||||
|
validation_function_params::ValidationFunctionParams,
|
||||||
|
HeadData,
|
||||||
};
|
};
|
||||||
use cumulus_runtime::ParachainBlockData;
|
use cumulus_runtime::ParachainBlockData;
|
||||||
|
|
||||||
@@ -37,8 +41,7 @@ use sp_inherents::{InherentData, InherentDataProviders};
|
|||||||
use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT};
|
use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT};
|
||||||
|
|
||||||
use polkadot_collator::{
|
use polkadot_collator::{
|
||||||
BuildParachainContext, InvalidHead, Network as CollatorNetwork, ParachainContext,
|
BuildParachainContext, Network as CollatorNetwork, ParachainContext, RuntimeApiCollection,
|
||||||
RuntimeApiCollection,
|
|
||||||
};
|
};
|
||||||
use polkadot_primitives::{
|
use polkadot_primitives::{
|
||||||
parachain::{self, BlockData, GlobalValidationSchedule, Id as ParaId, LocalValidationData},
|
parachain::{self, BlockData, GlobalValidationSchedule, Id as ParaId, LocalValidationData},
|
||||||
@@ -99,15 +102,17 @@ impl<Block: BlockT, PF, BI> Collator<Block, PF, BI> {
|
|||||||
global_validation: GlobalValidationSchedule,
|
global_validation: GlobalValidationSchedule,
|
||||||
local_validation: LocalValidationData,
|
local_validation: LocalValidationData,
|
||||||
downward_messages: DownwardMessagesType,
|
downward_messages: DownwardMessagesType,
|
||||||
) -> Result<InherentData, InvalidHead> {
|
) -> Option<InherentData> {
|
||||||
let mut inherent_data = inherent_providers.create_inherent_data().map_err(|e| {
|
let mut inherent_data = inherent_providers
|
||||||
|
.create_inherent_data()
|
||||||
|
.map_err(|e| {
|
||||||
error!(
|
error!(
|
||||||
target: "cumulus-collator",
|
target: "cumulus-collator",
|
||||||
"Failed to create inherent data: {:?}",
|
"Failed to create inherent data: {:?}",
|
||||||
e,
|
e,
|
||||||
);
|
);
|
||||||
InvalidHead
|
})
|
||||||
})?;
|
.ok()?;
|
||||||
|
|
||||||
inherent_data
|
inherent_data
|
||||||
.put_data(
|
.put_data(
|
||||||
@@ -120,24 +125,21 @@ impl<Block: BlockT, PF, BI> Collator<Block, PF, BI> {
|
|||||||
"Failed to put validation function params into inherent data: {:?}",
|
"Failed to put validation function params into inherent data: {:?}",
|
||||||
e,
|
e,
|
||||||
);
|
);
|
||||||
InvalidHead
|
})
|
||||||
})?;
|
.ok()?;
|
||||||
|
|
||||||
inherent_data
|
inherent_data
|
||||||
.put_data(
|
.put_data(DOWNWARD_MESSAGES_IDENTIFIER, &downward_messages)
|
||||||
DOWNWARD_MESSAGES_IDENTIFIER,
|
|
||||||
&downward_messages,
|
|
||||||
)
|
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
error!(
|
error!(
|
||||||
target: "cumulus-collator",
|
target: "cumulus-collator",
|
||||||
"Failed to put downward messages into inherent data: {:?}",
|
"Failed to put downward messages into inherent data: {:?}",
|
||||||
e,
|
e,
|
||||||
);
|
);
|
||||||
InvalidHead
|
})
|
||||||
})?;
|
.ok()?;
|
||||||
|
|
||||||
Ok(inherent_data)
|
Some(inherent_data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +170,7 @@ where
|
|||||||
+ 'static,
|
+ 'static,
|
||||||
{
|
{
|
||||||
type ProduceCandidate =
|
type ProduceCandidate =
|
||||||
Pin<Box<dyn Future<Output = Result<(BlockData, parachain::HeadData), InvalidHead>> + Send>>;
|
Pin<Box<dyn Future<Output = Option<(BlockData, parachain::HeadData)>> + Send>>;
|
||||||
|
|
||||||
fn produce_candidate(
|
fn produce_candidate(
|
||||||
&mut self,
|
&mut self,
|
||||||
@@ -187,7 +189,7 @@ where
|
|||||||
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);
|
||||||
return Box::pin(future::ready(Err(InvalidHead)));
|
return Box::pin(future::ready(None));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -196,14 +198,16 @@ where
|
|||||||
let wait_to_announce = self.wait_to_announce.clone();
|
let wait_to_announce = self.wait_to_announce.clone();
|
||||||
|
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
let proposer = proposer_future.await.map_err(|e| {
|
let proposer = proposer_future
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
error!(
|
error!(
|
||||||
target: "cumulus-collator",
|
target: "cumulus-collator",
|
||||||
"Could not create proposer: {:?}",
|
"Could not create proposer: {:?}",
|
||||||
e,
|
e,
|
||||||
);
|
);
|
||||||
InvalidHead
|
})
|
||||||
})?;
|
.ok()?;
|
||||||
|
|
||||||
let inherent_data = Self::inherent_data(
|
let inherent_data = Self::inherent_data(
|
||||||
inherent_providers,
|
inherent_providers,
|
||||||
@@ -231,16 +235,20 @@ where
|
|||||||
"Proposing failed: {:?}",
|
"Proposing failed: {:?}",
|
||||||
e,
|
e,
|
||||||
);
|
);
|
||||||
InvalidHead
|
})
|
||||||
})?;
|
.ok()?;
|
||||||
|
|
||||||
let proof = proof.ok_or_else(|| {
|
let proof = match proof {
|
||||||
|
Some(proof) => proof,
|
||||||
|
None => {
|
||||||
error!(
|
error!(
|
||||||
target: "cumulus-collator",
|
target: "cumulus-collator",
|
||||||
"Proposer did not return the requested proof.",
|
"Proposer did not return the requested proof.",
|
||||||
);
|
);
|
||||||
InvalidHead
|
|
||||||
})?;
|
return None;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let (header, extrinsics) = block.deconstruct();
|
let (header, extrinsics) = block.deconstruct();
|
||||||
|
|
||||||
@@ -266,7 +274,8 @@ where
|
|||||||
b.header().parent_hash(),
|
b.header().parent_hash(),
|
||||||
err,
|
err,
|
||||||
);
|
);
|
||||||
return Err(InvalidHead);
|
|
||||||
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let block_data = BlockData(b.encode());
|
let block_data = BlockData(b.encode());
|
||||||
@@ -283,7 +292,7 @@ where
|
|||||||
|
|
||||||
trace!(target: "cumulus-collator", "Produced candidate: {:?}", candidate);
|
trace!(target: "cumulus-collator", "Produced candidate: {:?}", candidate);
|
||||||
|
|
||||||
Ok(candidate)
|
Some(candidate)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ pub fn import_queue<Client, Block: BlockT, I>(
|
|||||||
client: Arc<Client>,
|
client: Arc<Client>,
|
||||||
block_import: I,
|
block_import: I,
|
||||||
inherent_data_providers: InherentDataProviders,
|
inherent_data_providers: InherentDataProviders,
|
||||||
spawner: &impl sp_core::traits::SpawnBlocking,
|
spawner: &impl sp_core::traits::SpawnNamed,
|
||||||
registry: Option<&substrate_prometheus_endpoint::Registry>,
|
registry: Option<&substrate_prometheus_endpoint::Registry>,
|
||||||
) -> ClientResult<BasicQueue<Block, I::Transaction>>
|
) -> ClientResult<BasicQueue<Block, I::Transaction>>
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ where
|
|||||||
|
|
||||||
Validation::Failure
|
Validation::Failure
|
||||||
} else {
|
} else {
|
||||||
Validation::Success
|
Validation::Success { is_new_best: false }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ where
|
|||||||
)) as Box<_>);
|
)) as Box<_>);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Validation::Success)
|
Ok(Validation::Success { is_new_best: false })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ fn valid_if_no_data_and_less_than_best_known_number() {
|
|||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.unwrap(),
|
res.unwrap(),
|
||||||
Validation::Success,
|
Validation::Success { is_new_best: false },
|
||||||
"validating without data with block number < best known number is always a success",
|
"validating without data with block number < best known number is always a success",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,14 +233,16 @@ mod tests {
|
|||||||
|
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
assert_ok, impl_outer_event, impl_outer_origin, parameter_types,
|
assert_ok,
|
||||||
|
dispatch::UnfilteredDispatchable,
|
||||||
|
impl_outer_event, impl_outer_origin, parameter_types,
|
||||||
traits::{OnFinalize, OnInitialize},
|
traits::{OnFinalize, OnInitialize},
|
||||||
weights::Weight,
|
weights::Weight,
|
||||||
};
|
};
|
||||||
use sp_core::H256;
|
use sp_core::H256;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
testing::Header,
|
testing::Header,
|
||||||
traits::{BlakeTwo256, Dispatchable, IdentityLookup},
|
traits::{BlakeTwo256, IdentityLookup},
|
||||||
Perbill,
|
Perbill,
|
||||||
};
|
};
|
||||||
use sp_version::RuntimeVersion;
|
use sp_version::RuntimeVersion;
|
||||||
@@ -305,6 +307,7 @@ mod tests {
|
|||||||
type DbWeight = ();
|
type DbWeight = ();
|
||||||
type BlockExecutionWeight = ();
|
type BlockExecutionWeight = ();
|
||||||
type ExtrinsicBaseWeight = ();
|
type ExtrinsicBaseWeight = ();
|
||||||
|
type BaseCallFilter = ();
|
||||||
}
|
}
|
||||||
impl Trait for Test {
|
impl Trait for Test {
|
||||||
type Event = TestEvent;
|
type Event = TestEvent;
|
||||||
@@ -472,7 +475,7 @@ mod tests {
|
|||||||
ParachainUpgrade::on_initialize(*n);
|
ParachainUpgrade::on_initialize(*n);
|
||||||
ParachainUpgrade::create_inherent(&inherent_data)
|
ParachainUpgrade::create_inherent(&inherent_data)
|
||||||
.expect("got an inherent")
|
.expect("got an inherent")
|
||||||
.dispatch(RawOrigin::None.into())
|
.dispatch_bypass_filter(RawOrigin::None.into())
|
||||||
.expect("dispatch succeeded");
|
.expect("dispatch succeeded");
|
||||||
within_block();
|
within_block();
|
||||||
ParachainUpgrade::on_finalize(*n);
|
ParachainUpgrade::on_finalize(*n);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ edition = "2018"
|
|||||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = [ "derive" ] }
|
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = [ "derive" ] }
|
||||||
memory-db = { version = "0.18.0", default-features = false }
|
memory-db = { version = "0.18.0", default-features = false }
|
||||||
hash-db = { version = "0.15.2", default-features = false }
|
hash-db = { version = "0.15.2", default-features = false }
|
||||||
trie-db = { version = "0.20.1", default-features = false }
|
trie-db = { version = "0.21.0", default-features = false }
|
||||||
hashbrown = "0.6.1"
|
hashbrown = "0.6.1"
|
||||||
|
|
||||||
# Cumulus dependencies
|
# Cumulus dependencies
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ sc-network = { git = "https://github.com/paritytech/substrate", branch = "cumulu
|
|||||||
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", version = "0.8.0-alpha.5" }
|
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", version = "0.8.0-alpha.5" }
|
||||||
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" }
|
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
|
sc-informant = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
|
|
||||||
# Cumulus dependencies
|
# Cumulus dependencies
|
||||||
cumulus-consensus = { path = "../../consensus" }
|
cumulus-consensus = { path = "../../consensus" }
|
||||||
|
|||||||
@@ -191,6 +191,7 @@ impl frame_system::Trait for Runtime {
|
|||||||
type ExtrinsicBaseWeight = ExtrinsicBaseWeight;
|
type ExtrinsicBaseWeight = ExtrinsicBaseWeight;
|
||||||
type BlockExecutionWeight = ();
|
type BlockExecutionWeight = ();
|
||||||
type MaximumExtrinsicWeight = MaximumExtrinsicWeight;
|
type MaximumExtrinsicWeight = MaximumExtrinsicWeight;
|
||||||
|
type BaseCallFilter = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
|
|||||||
@@ -17,14 +17,14 @@
|
|||||||
use crate::chain_spec;
|
use crate::chain_spec;
|
||||||
use crate::cli::{Cli, PolkadotCli, Subcommand};
|
use crate::cli::{Cli, PolkadotCli, Subcommand};
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
|
use cumulus_primitives::ParaId;
|
||||||
use log::info;
|
use log::info;
|
||||||
use parachain_runtime::Block;
|
use parachain_runtime::Block;
|
||||||
use polkadot_parachain::primitives::AccountIdConversion;
|
use polkadot_parachain::primitives::AccountIdConversion;
|
||||||
use sc_cli::{
|
use sc_cli::{
|
||||||
CliConfiguration, Error, ImportParams, KeystoreParams, NetworkParams, Result, SharedParams,
|
ChainSpec, CliConfiguration, Error, ImportParams, KeystoreParams, NetworkParams, Result, Role,
|
||||||
SubstrateCli,
|
RuntimeVersion, SharedParams, SubstrateCli,
|
||||||
};
|
};
|
||||||
use sc_executor::NativeExecutionDispatch;
|
|
||||||
use sc_service::config::{BasePath, PrometheusConfig};
|
use sc_service::config::{BasePath, PrometheusConfig};
|
||||||
use sp_core::hexdisplay::HexDisplay;
|
use sp_core::hexdisplay::HexDisplay;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
@@ -32,7 +32,6 @@ use sp_runtime::{
|
|||||||
BuildStorage,
|
BuildStorage,
|
||||||
};
|
};
|
||||||
use std::{net::SocketAddr, sync::Arc};
|
use std::{net::SocketAddr, sync::Arc};
|
||||||
use cumulus_primitives::ParaId;
|
|
||||||
|
|
||||||
impl SubstrateCli for Cli {
|
impl SubstrateCli for Cli {
|
||||||
fn impl_name() -> &'static str {
|
fn impl_name() -> &'static str {
|
||||||
@@ -68,7 +67,13 @@ impl SubstrateCli for Cli {
|
|||||||
|
|
||||||
fn load_spec(&self, _id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
|
fn load_spec(&self, _id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
|
||||||
// Such a hack :(
|
// Such a hack :(
|
||||||
Ok(Box::new(chain_spec::get_chain_spec(self.run.parachain_id.into())))
|
Ok(Box::new(chain_spec::get_chain_spec(
|
||||||
|
self.run.parachain_id.into(),
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
|
||||||
|
¶chain_runtime::VERSION
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,6 +119,10 @@ impl SubstrateCli for PolkadotCli {
|
|||||||
)?),
|
)?),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
|
||||||
|
polkadot_cli::Cli::native_runtime_version(chain_spec)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_genesis_state(para_id: ParaId) -> Result<Block> {
|
fn generate_genesis_state(para_id: ParaId) -> Result<Block> {
|
||||||
@@ -180,22 +189,18 @@ pub fn run() -> Result<()> {
|
|||||||
))
|
))
|
||||||
};
|
};
|
||||||
|
|
||||||
runner.run_node(
|
runner.run_node_until_exit(|config| match config.role {
|
||||||
|config| polkadot_service::polkadot_new_light(config),
|
Role::Light => polkadot_service::polkadot_new_light(config).map(|r| r.0),
|
||||||
|config| {
|
_ => polkadot_service::polkadot_new_full(
|
||||||
polkadot_service::polkadot_new_full(
|
|
||||||
config,
|
config,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
authority_discovery_enabled,
|
authority_discovery_enabled,
|
||||||
6000,
|
6000,
|
||||||
grandpa_pause,
|
grandpa_pause,
|
||||||
None,
|
|
||||||
)
|
|
||||||
.map(|(s, _, _)| s)
|
|
||||||
},
|
|
||||||
polkadot_service::PolkadotExecutor::native_version().runtime_version,
|
|
||||||
)
|
)
|
||||||
|
.map(|(s, _, _)| s),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
Some(Subcommand::PolkadotValidationWorker(cmd)) => {
|
Some(Subcommand::PolkadotValidationWorker(cmd)) => {
|
||||||
sc_cli::init_logger("");
|
sc_cli::init_logger("");
|
||||||
@@ -223,17 +228,17 @@ pub fn run() -> Result<()> {
|
|||||||
let block = generate_genesis_state(id)?;
|
let block = generate_genesis_state(id)?;
|
||||||
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));
|
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));
|
||||||
|
|
||||||
runner.run_full_node(
|
runner.run_node_until_exit(|config| {
|
||||||
|config| {
|
if matches!(config.role, Role::Light) {
|
||||||
|
return Err("Light client not supporter!".into());
|
||||||
|
}
|
||||||
|
|
||||||
polkadot_cli.base_path =
|
polkadot_cli.base_path =
|
||||||
config.base_path.as_ref().map(|x| x.path().join("polkadot"));
|
config.base_path.as_ref().map(|x| x.path().join("polkadot"));
|
||||||
|
|
||||||
let task_executor = config.task_executor.clone();
|
let task_executor = config.task_executor.clone();
|
||||||
let polkadot_config = SubstrateCli::create_configuration(
|
let polkadot_config =
|
||||||
&polkadot_cli,
|
SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, task_executor)
|
||||||
&polkadot_cli,
|
|
||||||
task_executor,
|
|
||||||
)
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
info!("Parachain id: {:?}", id);
|
info!("Parachain id: {:?}", id);
|
||||||
@@ -241,9 +246,7 @@ pub fn run() -> Result<()> {
|
|||||||
info!("Parachain genesis state: {}", genesis_state);
|
info!("Parachain genesis state: {}", genesis_state);
|
||||||
|
|
||||||
crate::service::run_collator(config, key, polkadot_config, id)
|
crate::service::run_collator(config, key, polkadot_config, id)
|
||||||
},
|
})
|
||||||
parachain_runtime::VERSION,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -269,8 +272,7 @@ impl CliConfiguration for PolkadotCli {
|
|||||||
Ok(self
|
Ok(self
|
||||||
.shared_params()
|
.shared_params()
|
||||||
.base_path()
|
.base_path()
|
||||||
.or_else(|| self.base_path.clone().map(Into::into))
|
.or_else(|| self.base_path.clone().map(Into::into)))
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rpc_http(&self) -> Result<Option<SocketAddr>> {
|
fn rpc_http(&self) -> Result<Option<SocketAddr>> {
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ pub use sc_executor::NativeExecutor;
|
|||||||
use sc_finality_grandpa::{
|
use sc_finality_grandpa::{
|
||||||
FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider,
|
FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider,
|
||||||
};
|
};
|
||||||
use sc_service::{AbstractService, Configuration};
|
use sc_informant::OutputFormat;
|
||||||
|
use sc_service::{Configuration, TaskManager};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
// Our native executor instance.
|
// Our native executor instance.
|
||||||
@@ -80,10 +81,15 @@ macro_rules! new_full_start {
|
|||||||
pub fn run_collator(
|
pub fn run_collator(
|
||||||
parachain_config: Configuration,
|
parachain_config: Configuration,
|
||||||
key: Arc<CollatorPair>,
|
key: Arc<CollatorPair>,
|
||||||
polkadot_config: polkadot_collator::Configuration,
|
mut polkadot_config: polkadot_collator::Configuration,
|
||||||
id: polkadot_primitives::parachain::Id,
|
id: polkadot_primitives::parachain::Id,
|
||||||
) -> sc_service::error::Result<impl AbstractService> {
|
) -> sc_service::error::Result<TaskManager> {
|
||||||
let parachain_config = prepare_collator_config(parachain_config);
|
let mut parachain_config = prepare_collator_config(parachain_config);
|
||||||
|
|
||||||
|
parachain_config.informant_output_format = OutputFormat {
|
||||||
|
enable_color: true,
|
||||||
|
prefix: format!("[{}] ", Color::Yellow.bold().paint("Parachain")),
|
||||||
|
};
|
||||||
|
|
||||||
let (builder, inherent_data_providers) = new_full_start!(parachain_config);
|
let (builder, inherent_data_providers) = new_full_start!(parachain_config);
|
||||||
inherent_data_providers
|
inherent_data_providers
|
||||||
@@ -93,7 +99,6 @@ pub fn run_collator(
|
|||||||
let block_announce_validator = DelayedBlockAnnounceValidator::new();
|
let block_announce_validator = DelayedBlockAnnounceValidator::new();
|
||||||
let block_announce_validator_copy = block_announce_validator.clone();
|
let block_announce_validator_copy = block_announce_validator.clone();
|
||||||
let service = builder
|
let service = builder
|
||||||
.with_informant_prefix(format!("[{}] ", Color::Yellow.bold().paint("Parachain")))?
|
|
||||||
.with_finality_proof_provider(|client, backend| {
|
.with_finality_proof_provider(|client, backend| {
|
||||||
// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
|
// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
|
||||||
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
|
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
|
||||||
@@ -102,17 +107,17 @@ pub fn run_collator(
|
|||||||
.with_block_announce_validator(|_client| Box::new(block_announce_validator_copy))?
|
.with_block_announce_validator(|_client| Box::new(block_announce_validator_copy))?
|
||||||
.build_full()?;
|
.build_full()?;
|
||||||
|
|
||||||
let registry = service.prometheus_registry();
|
let registry = service.prometheus_registry.clone();
|
||||||
|
|
||||||
let proposer_factory = sc_basic_authorship::ProposerFactory::new(
|
let proposer_factory = sc_basic_authorship::ProposerFactory::new(
|
||||||
service.client(),
|
service.client.clone(),
|
||||||
service.transaction_pool(),
|
service.transaction_pool.clone(),
|
||||||
registry.as_ref(),
|
registry.as_ref(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let block_import = service.client();
|
let block_import = service.client.clone();
|
||||||
let client = service.client();
|
let client = service.client.clone();
|
||||||
let network = service.network();
|
let network = service.network.clone();
|
||||||
let announce_block = Arc::new(move |hash, data| network.announce_block(hash, data));
|
let announce_block = Arc::new(move |hash, data| network.announce_block(hash, data));
|
||||||
let builder = CollatorBuilder::new(
|
let builder = CollatorBuilder::new(
|
||||||
proposer_factory,
|
proposer_factory,
|
||||||
@@ -124,15 +129,14 @@ pub fn run_collator(
|
|||||||
block_announce_validator,
|
block_announce_validator,
|
||||||
);
|
);
|
||||||
|
|
||||||
let polkadot_future = polkadot_collator::start_collator(
|
polkadot_config.informant_output_format = OutputFormat {
|
||||||
builder,
|
enable_color: true,
|
||||||
id,
|
prefix: format!("[{}] ", Color::Blue.bold().paint("Relaychain")),
|
||||||
key,
|
};
|
||||||
polkadot_config,
|
|
||||||
Some(format!("[{}] ", Color::Blue.bold().paint("Relaychain"))),
|
|
||||||
)
|
|
||||||
.map(|_| ());
|
|
||||||
service.spawn_essential_task("polkadot", polkadot_future);
|
|
||||||
|
|
||||||
Ok(service)
|
let polkadot_future =
|
||||||
|
polkadot_collator::start_collator(builder, id, key, polkadot_config).map(|_| ());
|
||||||
|
service.task_manager.spawn_essential_handle().spawn("polkadot", polkadot_future);
|
||||||
|
|
||||||
|
Ok(service.task_manager)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ use futures::{future::FutureExt, join, pin_mut, select};
|
|||||||
use jsonrpsee::{raw::RawClient, transport::http::HttpTransportClient};
|
use jsonrpsee::{raw::RawClient, transport::http::HttpTransportClient};
|
||||||
use polkadot_primitives::parachain::{Info, Scheduling};
|
use polkadot_primitives::parachain::{Info, Scheduling};
|
||||||
use polkadot_primitives::Hash as PHash;
|
use polkadot_primitives::Hash as PHash;
|
||||||
use polkadot_runtime::{Header, Runtime, SignedExtra, SignedPayload, IsCallable};
|
use polkadot_runtime::{Header, Runtime, SignedExtra, SignedPayload};
|
||||||
use polkadot_runtime_common::{parachains, registrar, BlockHashCount, claims, TransactionCallFilter};
|
use polkadot_runtime_common::{parachains, registrar, BlockHashCount, claims};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use sp_arithmetic::traits::SaturatedConversion;
|
use sp_arithmetic::traits::SaturatedConversion;
|
||||||
use sp_runtime::generic;
|
use sp_runtime::generic;
|
||||||
|
|||||||
Reference in New Issue
Block a user