mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 12:51:02 +00:00
Update to latest Substrate & Polkadot (#131)
* Switch to latest Substrate & Polkadot * Update again
This commit is contained in:
@@ -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" }
|
||||
sp-timestamp = { 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-consensus = { path = "../../consensus" }
|
||||
|
||||
@@ -191,6 +191,7 @@ impl frame_system::Trait for Runtime {
|
||||
type ExtrinsicBaseWeight = ExtrinsicBaseWeight;
|
||||
type BlockExecutionWeight = ();
|
||||
type MaximumExtrinsicWeight = MaximumExtrinsicWeight;
|
||||
type BaseCallFilter = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
use crate::chain_spec;
|
||||
use crate::cli::{Cli, PolkadotCli, Subcommand};
|
||||
use codec::Encode;
|
||||
use cumulus_primitives::ParaId;
|
||||
use log::info;
|
||||
use parachain_runtime::Block;
|
||||
use polkadot_parachain::primitives::AccountIdConversion;
|
||||
use sc_cli::{
|
||||
CliConfiguration, Error, ImportParams, KeystoreParams, NetworkParams, Result, SharedParams,
|
||||
SubstrateCli,
|
||||
ChainSpec, CliConfiguration, Error, ImportParams, KeystoreParams, NetworkParams, Result, Role,
|
||||
RuntimeVersion, SharedParams, SubstrateCli,
|
||||
};
|
||||
use sc_executor::NativeExecutionDispatch;
|
||||
use sc_service::config::{BasePath, PrometheusConfig};
|
||||
use sp_core::hexdisplay::HexDisplay;
|
||||
use sp_runtime::{
|
||||
@@ -32,7 +32,6 @@ use sp_runtime::{
|
||||
BuildStorage,
|
||||
};
|
||||
use std::{net::SocketAddr, sync::Arc};
|
||||
use cumulus_primitives::ParaId;
|
||||
|
||||
impl SubstrateCli for Cli {
|
||||
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> {
|
||||
// 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> {
|
||||
@@ -180,22 +189,18 @@ pub fn run() -> Result<()> {
|
||||
))
|
||||
};
|
||||
|
||||
runner.run_node(
|
||||
|config| polkadot_service::polkadot_new_light(config),
|
||||
|config| {
|
||||
polkadot_service::polkadot_new_full(
|
||||
config,
|
||||
None,
|
||||
None,
|
||||
authority_discovery_enabled,
|
||||
6000,
|
||||
grandpa_pause,
|
||||
None,
|
||||
)
|
||||
.map(|(s, _, _)| s)
|
||||
},
|
||||
polkadot_service::PolkadotExecutor::native_version().runtime_version,
|
||||
)
|
||||
runner.run_node_until_exit(|config| match config.role {
|
||||
Role::Light => polkadot_service::polkadot_new_light(config).map(|r| r.0),
|
||||
_ => polkadot_service::polkadot_new_full(
|
||||
config,
|
||||
None,
|
||||
None,
|
||||
authority_discovery_enabled,
|
||||
6000,
|
||||
grandpa_pause,
|
||||
)
|
||||
.map(|(s, _, _)| s),
|
||||
})
|
||||
}
|
||||
Some(Subcommand::PolkadotValidationWorker(cmd)) => {
|
||||
sc_cli::init_logger("");
|
||||
@@ -223,27 +228,25 @@ pub fn run() -> Result<()> {
|
||||
let block = generate_genesis_state(id)?;
|
||||
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));
|
||||
|
||||
runner.run_full_node(
|
||||
|config| {
|
||||
polkadot_cli.base_path =
|
||||
config.base_path.as_ref().map(|x| x.path().join("polkadot"));
|
||||
runner.run_node_until_exit(|config| {
|
||||
if matches!(config.role, Role::Light) {
|
||||
return Err("Light client not supporter!".into());
|
||||
}
|
||||
|
||||
let task_executor = config.task_executor.clone();
|
||||
let polkadot_config = SubstrateCli::create_configuration(
|
||||
&polkadot_cli,
|
||||
&polkadot_cli,
|
||||
task_executor,
|
||||
)
|
||||
.unwrap();
|
||||
polkadot_cli.base_path =
|
||||
config.base_path.as_ref().map(|x| x.path().join("polkadot"));
|
||||
|
||||
info!("Parachain id: {:?}", id);
|
||||
info!("Parachain Account: {}", parachain_account);
|
||||
info!("Parachain genesis state: {}", genesis_state);
|
||||
let task_executor = config.task_executor.clone();
|
||||
let polkadot_config =
|
||||
SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, task_executor)
|
||||
.unwrap();
|
||||
|
||||
crate::service::run_collator(config, key, polkadot_config, id)
|
||||
},
|
||||
parachain_runtime::VERSION,
|
||||
)
|
||||
info!("Parachain id: {:?}", id);
|
||||
info!("Parachain Account: {}", parachain_account);
|
||||
info!("Parachain genesis state: {}", genesis_state);
|
||||
|
||||
crate::service::run_collator(config, key, polkadot_config, id)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -269,8 +272,7 @@ impl CliConfiguration for PolkadotCli {
|
||||
Ok(self
|
||||
.shared_params()
|
||||
.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>> {
|
||||
|
||||
@@ -24,7 +24,8 @@ pub use sc_executor::NativeExecutor;
|
||||
use sc_finality_grandpa::{
|
||||
FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider,
|
||||
};
|
||||
use sc_service::{AbstractService, Configuration};
|
||||
use sc_informant::OutputFormat;
|
||||
use sc_service::{Configuration, TaskManager};
|
||||
use std::sync::Arc;
|
||||
|
||||
// Our native executor instance.
|
||||
@@ -71,7 +72,7 @@ macro_rules! new_full_start {
|
||||
})?;
|
||||
|
||||
(builder, inherent_data_providers)
|
||||
}};
|
||||
}};
|
||||
}
|
||||
|
||||
/// Run a collator node with the given parachain `Configuration` and relaychain `Configuration`
|
||||
@@ -80,10 +81,15 @@ macro_rules! new_full_start {
|
||||
pub fn run_collator(
|
||||
parachain_config: Configuration,
|
||||
key: Arc<CollatorPair>,
|
||||
polkadot_config: polkadot_collator::Configuration,
|
||||
mut polkadot_config: polkadot_collator::Configuration,
|
||||
id: polkadot_primitives::parachain::Id,
|
||||
) -> sc_service::error::Result<impl AbstractService> {
|
||||
let parachain_config = prepare_collator_config(parachain_config);
|
||||
) -> sc_service::error::Result<TaskManager> {
|
||||
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);
|
||||
inherent_data_providers
|
||||
@@ -93,7 +99,6 @@ pub fn run_collator(
|
||||
let block_announce_validator = DelayedBlockAnnounceValidator::new();
|
||||
let block_announce_validator_copy = block_announce_validator.clone();
|
||||
let service = builder
|
||||
.with_informant_prefix(format!("[{}] ", Color::Yellow.bold().paint("Parachain")))?
|
||||
.with_finality_proof_provider(|client, backend| {
|
||||
// GenesisAuthoritySetProvider is implemented for 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))?
|
||||
.build_full()?;
|
||||
|
||||
let registry = service.prometheus_registry();
|
||||
let registry = service.prometheus_registry.clone();
|
||||
|
||||
let proposer_factory = sc_basic_authorship::ProposerFactory::new(
|
||||
service.client(),
|
||||
service.transaction_pool(),
|
||||
service.client.clone(),
|
||||
service.transaction_pool.clone(),
|
||||
registry.as_ref(),
|
||||
);
|
||||
|
||||
let block_import = service.client();
|
||||
let client = service.client();
|
||||
let network = service.network();
|
||||
let block_import = service.client.clone();
|
||||
let client = service.client.clone();
|
||||
let network = service.network.clone();
|
||||
let announce_block = Arc::new(move |hash, data| network.announce_block(hash, data));
|
||||
let builder = CollatorBuilder::new(
|
||||
proposer_factory,
|
||||
@@ -124,15 +129,14 @@ pub fn run_collator(
|
||||
block_announce_validator,
|
||||
);
|
||||
|
||||
let polkadot_future = polkadot_collator::start_collator(
|
||||
builder,
|
||||
id,
|
||||
key,
|
||||
polkadot_config,
|
||||
Some(format!("[{}] ", Color::Blue.bold().paint("Relaychain"))),
|
||||
)
|
||||
.map(|_| ());
|
||||
service.spawn_essential_task("polkadot", polkadot_future);
|
||||
polkadot_config.informant_output_format = OutputFormat {
|
||||
enable_color: true,
|
||||
prefix: format!("[{}] ", Color::Blue.bold().paint("Relaychain")),
|
||||
};
|
||||
|
||||
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 polkadot_primitives::parachain::{Info, Scheduling};
|
||||
use polkadot_primitives::Hash as PHash;
|
||||
use polkadot_runtime::{Header, Runtime, SignedExtra, SignedPayload, IsCallable};
|
||||
use polkadot_runtime_common::{parachains, registrar, BlockHashCount, claims, TransactionCallFilter};
|
||||
use polkadot_runtime::{Header, Runtime, SignedExtra, SignedPayload};
|
||||
use polkadot_runtime_common::{parachains, registrar, BlockHashCount, claims};
|
||||
use serde_json::Value;
|
||||
use sp_arithmetic::traits::SaturatedConversion;
|
||||
use sp_runtime::generic;
|
||||
|
||||
Reference in New Issue
Block a user