mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 11:41:02 +00:00
Substrate.from() (#426)
* Substrate.from() * Fix some transaction validation code * must be more specific for matching now. * Update `wasm-builder` and add `build-only-wasm` script * Update to latest service builder interfaces * ANother substrate update * Another update
This commit is contained in:
+20
-20
@@ -18,23 +18,23 @@ polkadot-primitives = { path = "../primitives" }
|
||||
polkadot-runtime = { path = "../runtime" }
|
||||
polkadot-executor = { path = "../executor" }
|
||||
polkadot-network = { path = "../network" }
|
||||
sr-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
client-db = { package = "substrate-client-db", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
consensus_common = { package = "substrate-consensus-common", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
grandpa = { package = "substrate-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
grandpa_primitives = { package = "substrate-finality-grandpa-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
inherents = { package = "substrate-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
service = { package = "substrate-service", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
telemetry = { package = "substrate-telemetry", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
transaction_pool = { package = "substrate-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
srml-babe = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
srml-staking = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
im-online = { package = "srml-im-online", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
babe = { package = "substrate-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
babe-primitives = { package = "substrate-consensus-babe-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
sr-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
|
||||
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
|
||||
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
|
||||
client-db = { package = "substrate-client-db", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
|
||||
substrate-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
|
||||
substrate-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
|
||||
consensus_common = { package = "substrate-consensus-common", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
|
||||
grandpa = { package = "substrate-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
|
||||
grandpa_primitives = { package = "substrate-finality-grandpa-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
|
||||
inherents = { package = "substrate-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
|
||||
service = { package = "substrate-service", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
|
||||
telemetry = { package = "substrate-telemetry", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
|
||||
transaction_pool = { package = "substrate-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
|
||||
substrate-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
|
||||
srml-babe = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
|
||||
srml-staking = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
|
||||
im-online = { package = "srml-im-online", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
|
||||
babe = { package = "substrate-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
|
||||
babe-primitives = { package = "substrate-consensus-babe-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
|
||||
|
||||
+26
-21
@@ -84,9 +84,8 @@ macro_rules! new_full_start {
|
||||
let builder = service::ServiceBuilder::new_full::<
|
||||
Block, RuntimeApi, polkadot_executor::Executor
|
||||
>($config)?
|
||||
.with_select_chain(|_config, client| {
|
||||
#[allow(deprecated)]
|
||||
Ok(client::LongestChain::new(client.backend().clone()))
|
||||
.with_select_chain(|_, backend| {
|
||||
Ok(client::LongestChain::new(backend.clone()))
|
||||
})?
|
||||
.with_transaction_pool(|config, client|
|
||||
Ok(transaction_pool::txpool::Pool::new(config, transaction_pool::ChainApi::new(client)))
|
||||
@@ -137,12 +136,20 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
CallExecutor = impl CallExecutor<Block, Blake2Hasher> + Clone + Send + Sync + 'static,
|
||||
>, ServiceError>
|
||||
{
|
||||
let is_authority = config.roles.is_authority();
|
||||
let is_collator = config.custom.collating_for.is_some();
|
||||
let force_authoring = config.force_authoring;
|
||||
let max_block_data_size = config.custom.max_block_data_size;
|
||||
let db_path = config.database_path.clone();
|
||||
let disable_grandpa = config.disable_grandpa;
|
||||
let name = config.name.clone();
|
||||
|
||||
let (builder, mut import_setup, inherent_data_providers, mut tasks_to_spawn) = new_full_start!(config);
|
||||
|
||||
let service = builder
|
||||
.with_network_protocol(|config| Ok(PolkadotProtocol::new(config.custom.collating_for.clone())))?
|
||||
.with_finality_proof_provider(|client|
|
||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(client.clone(), client)) as _)
|
||||
.with_finality_proof_provider(|client, backend|
|
||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
|
||||
)?
|
||||
.build()?;
|
||||
|
||||
@@ -160,7 +167,7 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
}
|
||||
}
|
||||
|
||||
if service.config().custom.collating_for.is_some() {
|
||||
if is_collator {
|
||||
info!(
|
||||
"The node cannot start as an authority because it is also configured to run as a collator."
|
||||
);
|
||||
@@ -201,11 +208,11 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
(is_known, client.clone()),
|
||||
);
|
||||
|
||||
if service.config().roles.is_authority() {
|
||||
if is_authority {
|
||||
let availability_store = {
|
||||
use std::path::PathBuf;
|
||||
|
||||
let mut path = PathBuf::from(service.config().database_path.clone());
|
||||
let mut path = PathBuf::from(db_path);
|
||||
path.push("availability");
|
||||
|
||||
av_store::Store::new(::av_store::Config {
|
||||
@@ -239,7 +246,7 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
service.keystore(),
|
||||
availability_store,
|
||||
polkadot_runtime::constants::time::SLOT_DURATION,
|
||||
service.config().custom.max_block_data_size,
|
||||
max_block_data_size,
|
||||
);
|
||||
|
||||
let client = service.client();
|
||||
@@ -254,7 +261,7 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
env: proposer,
|
||||
sync_oracle: service.network(),
|
||||
inherent_data_providers: inherent_data_providers.clone(),
|
||||
force_authoring: service.config().force_authoring,
|
||||
force_authoring: force_authoring,
|
||||
time_source: babe_link,
|
||||
};
|
||||
|
||||
@@ -269,11 +276,11 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
// FIXME substrate#1578 make this available through chainspec
|
||||
gossip_duration: Duration::from_millis(333),
|
||||
justification_period: 4096,
|
||||
name: Some(service.config().name.clone()),
|
||||
name: Some(name),
|
||||
keystore: Some(service.keystore()),
|
||||
};
|
||||
|
||||
match (service.config().roles.is_authority(), service.config().disable_grandpa) {
|
||||
match (is_authority, disable_grandpa) {
|
||||
(false, false) => {
|
||||
// start the lightweight GRANDPA observer
|
||||
service.spawn_task(Box::new(grandpa::run_grandpa_observer(
|
||||
@@ -319,21 +326,19 @@ pub fn new_light(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
let inherent_data_providers = InherentDataProviders::new();
|
||||
|
||||
ServiceBuilder::new_light::<Block, RuntimeApi, polkadot_executor::Executor>(config)?
|
||||
.with_select_chain(|_config, client| {
|
||||
#[allow(deprecated)]
|
||||
Ok(LongestChain::new(client.backend().clone()))
|
||||
.with_select_chain(|_, backend| {
|
||||
Ok(LongestChain::new(backend.clone()))
|
||||
})?
|
||||
.with_transaction_pool(|config, client|
|
||||
Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client)))
|
||||
)?
|
||||
.with_import_queue_and_fprb(|_config, client, _select_chain, transaction_pool| {
|
||||
#[allow(deprecated)]
|
||||
let fetch_checker = client.backend().blockchain().fetcher()
|
||||
.with_import_queue_and_fprb(|_config, client, backend, _select_chain, transaction_pool| {
|
||||
let fetch_checker = backend.blockchain().fetcher()
|
||||
.upgrade()
|
||||
.map(|fetcher| fetcher.checker().clone())
|
||||
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
|
||||
let block_import = grandpa::light_block_import::<_, _, _, RuntimeApi, _>(
|
||||
client.clone(), Arc::new(fetch_checker), client.clone()
|
||||
client.clone(), backend, Arc::new(fetch_checker), client.clone()
|
||||
)?;
|
||||
|
||||
let finality_proof_import = block_import.clone();
|
||||
@@ -355,8 +360,8 @@ pub fn new_light(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
Ok((import_queue, finality_proof_request_builder))
|
||||
})?
|
||||
.with_network_protocol(|config| Ok(PolkadotProtocol::new(config.custom.collating_for.clone())))?
|
||||
.with_finality_proof_provider(|client|
|
||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(client.clone(), client)) as _)
|
||||
.with_finality_proof_provider(|client, backend|
|
||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
|
||||
)?
|
||||
.build()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user