Skip to content

Commit 71ed6b2

Browse files
authored
Update Substrate & Polkadot (paritytech#557)
* Update Substrate & Polkadot * Format * Update again
1 parent 2fd51bd commit 71ed6b2

File tree

19 files changed

+562
-541
lines changed

19 files changed

+562
-541
lines changed

Cargo.lock

+381-351
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/consensus/aura/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "mas
2121
sc-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "master" }
2222
sc-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "master" }
2323
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "master" }
24+
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
2425
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" }
2526

2627
# Polkadot dependencies

client/consensus/aura/src/import_queue.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@
1818
1919
use codec::Codec;
2020
use sc_client_api::{backend::AuxStore, BlockOf, UsageProvider};
21+
use sc_consensus::{import_queue::DefaultImportQueue, BlockImport};
2122
use sc_consensus_aura::AuraVerifier;
2223
use sc_consensus_slots::InherentDataProviderExt;
2324
use sc_telemetry::TelemetryHandle;
2425
use sp_api::{ApiExt, ProvideRuntimeApi};
2526
use sp_block_builder::BlockBuilder as BlockBuilderApi;
2627
use sp_blockchain::{HeaderBackend, ProvideCache};
27-
use sp_consensus::{
28-
import_queue::DefaultImportQueue, BlockImport, CanAuthorWith, Error as ConsensusError,
29-
};
28+
use sp_consensus::{CanAuthorWith, Error as ConsensusError};
3029
use sp_consensus_aura::{digests::CompatibleDigestItem, AuraApi};
3130
use sp_core::crypto::Pair;
3231
use sp_inherents::CreateInherentDataProviders;

client/consensus/aura/src/lib.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ use cumulus_primitives_core::{
3333
use futures::lock::Mutex;
3434
use polkadot_client::ClientHandle;
3535
use sc_client_api::{backend::AuxStore, Backend, BlockOf};
36+
use sc_consensus::BlockImport;
3637
use sc_consensus_slots::{BackoffAuthoringBlocksStrategy, SlotInfo};
3738
use sc_telemetry::TelemetryHandle;
3839
use sp_api::ProvideRuntimeApi;
3940
use sp_application_crypto::AppPublic;
4041
use sp_blockchain::{HeaderBackend, ProvideCache};
4142
use sp_consensus::{
42-
BlockImport, EnableProofRecording, Environment, ProofRecording, Proposer, SlotData, SyncOracle,
43+
EnableProofRecording, Environment, ProofRecording, Proposer, SlotData, SyncOracle,
4344
};
4445
use sp_consensus_aura::AuraApi;
4546
use sp_core::crypto::Pair;
@@ -52,8 +53,7 @@ mod import_queue;
5253

5354
pub use import_queue::{build_verifier, import_queue, BuildVerifierParams, ImportQueueParams};
5455
pub use sc_consensus_aura::{
55-
slot_duration, AuraVerifier, BuildAuraWorkerParams, SlotDuration,
56-
SlotProportion,
56+
slot_duration, AuraVerifier, BuildAuraWorkerParams, SlotDuration, SlotProportion,
5757
};
5858
pub use sc_consensus_slots::InherentDataProviderExt;
5959

@@ -138,8 +138,8 @@ where
138138
P::Public: AppPublic + Hash + Member + Encode + Decode,
139139
P::Signature: TryFrom<Vec<u8>> + Hash + Member + Encode + Decode,
140140
{
141-
let worker =
142-
sc_consensus_aura::build_aura_worker::<P, _, _, _, _, _, _, _, _>(BuildAuraWorkerParams {
141+
let worker = sc_consensus_aura::build_aura_worker::<P, _, _, _, _, _, _, _, _>(
142+
BuildAuraWorkerParams {
143143
client: para_client,
144144
block_import: ParachainBlockImport::new(block_import),
145145
justification_sync_link: (),
@@ -151,7 +151,8 @@ where
151151
telemetry,
152152
block_proposal_slot_portion,
153153
max_block_proposal_slot_portion,
154-
});
154+
},
155+
);
155156

156157
Self {
157158
create_inherent_data_providers: Arc::new(create_inherent_data_providers),

client/consensus/common/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ edition = "2018"
77

88
[dependencies]
99
# Substrate deps
10+
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
1011
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
1112
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
1213
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }

client/consensus/common/src/lib.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
1616

1717
use polkadot_primitives::v1::{Hash as PHash, PersistedValidationData};
18-
use sp_consensus::BlockImport;
18+
use sc_consensus::BlockImport;
1919
use sp_runtime::traits::Block as BlockT;
2020

2121
mod parachain_consensus;
@@ -96,19 +96,19 @@ where
9696

9797
async fn check_block(
9898
&mut self,
99-
block: sp_consensus::BlockCheckParams<Block>,
100-
) -> Result<sp_consensus::ImportResult, Self::Error> {
99+
block: sc_consensus::BlockCheckParams<Block>,
100+
) -> Result<sc_consensus::ImportResult, Self::Error> {
101101
self.0.check_block(block).await
102102
}
103103

104104
async fn import_block(
105105
&mut self,
106-
mut block_import_params: sp_consensus::BlockImportParams<Block, Self::Transaction>,
107-
cache: std::collections::HashMap<sp_consensus::import_queue::CacheKeyId, Vec<u8>>,
108-
) -> Result<sp_consensus::ImportResult, Self::Error> {
106+
mut block_import_params: sc_consensus::BlockImportParams<Block, Self::Transaction>,
107+
cache: std::collections::HashMap<sp_consensus::CacheKeyId, Vec<u8>>,
108+
) -> Result<sc_consensus::ImportResult, Self::Error> {
109109
// Best block is determined by the relay chain, or if we are doing the intial sync
110110
// we import all blocks as new best.
111-
block_import_params.fork_choice = Some(sp_consensus::ForkChoiceStrategy::Custom(
111+
block_import_params.fork_choice = Some(sc_consensus::ForkChoiceStrategy::Custom(
112112
block_import_params.origin == sp_consensus::BlockOrigin::NetworkInitialSync,
113113
));
114114
self.0.import_block(block_import_params, cache).await

client/consensus/common/src/parachain_consensus.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
use sc_client_api::{
1818
Backend, BlockBackend, BlockImportNotification, BlockchainEvents, Finalizer, UsageProvider,
1919
};
20+
use sc_consensus::{BlockImport, BlockImportParams, ForkChoiceStrategy};
2021
use sp_api::ProvideRuntimeApi;
2122
use sp_blockchain::{Error as ClientError, Result as ClientResult};
22-
use sp_consensus::{BlockImport, BlockImportParams, BlockOrigin, BlockStatus, ForkChoiceStrategy};
23+
use sp_consensus::{BlockOrigin, BlockStatus};
2324
use sp_runtime::{
2425
generic::BlockId,
2526
traits::{Block as BlockT, Header as HeaderT},

client/consensus/common/src/tests.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ use futures::{channel::mpsc, executor::block_on, select, FutureExt, Stream, Stre
2525
use futures_timer::Delay;
2626
use polkadot_primitives::v1::{Block as PBlock, Id as ParaId};
2727
use sc_client_api::UsageProvider;
28+
use sc_consensus::{BlockImport, BlockImportParams, ForkChoiceStrategy};
2829
use sp_blockchain::{Error as ClientError, Result as ClientResult};
29-
use sp_consensus::{BlockImport, BlockImportParams, BlockOrigin, ForkChoiceStrategy};
30+
use sp_consensus::BlockOrigin;
3031
use sp_runtime::generic::BlockId;
3132
use std::{
3233
sync::{Arc, Mutex},

client/consensus/relay-chain/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "mas
1515
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
1616
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
1717
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
18+
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
1819
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" }
1920

2021
# Polkadot dependencies

client/consensus/relay-chain/src/import_queue.rs

+13-22
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,18 @@
1616

1717
use std::{marker::PhantomData, sync::Arc};
1818

19+
use sc_consensus::{
20+
import_queue::{BasicQueue, Verifier as VerifierT},
21+
BlockImport, BlockImportParams,
22+
};
1923
use sp_api::ProvideRuntimeApi;
2024
use sp_block_builder::BlockBuilder as BlockBuilderApi;
2125
use sp_blockchain::Result as ClientResult;
22-
use sp_consensus::{
23-
error::Error as ConsensusError,
24-
import_queue::{BasicQueue, CacheKeyId, Verifier as VerifierT},
25-
BlockImport, BlockImportParams, BlockOrigin,
26-
};
26+
use sp_consensus::{error::Error as ConsensusError, CacheKeyId};
2727
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider};
2828
use sp_runtime::{
2929
generic::BlockId,
3030
traits::{Block as BlockT, Header as HeaderT},
31-
Justifications,
3231
};
3332

3433
/// A verifier that just checks the inherents.
@@ -59,35 +58,32 @@ where
5958
{
6059
async fn verify(
6160
&mut self,
62-
origin: BlockOrigin,
63-
header: Block::Header,
64-
justifications: Option<Justifications>,
65-
mut body: Option<Vec<Block::Extrinsic>>,
61+
mut block_params: BlockImportParams<Block, ()>,
6662
) -> Result<
6763
(
6864
BlockImportParams<Block, ()>,
6965
Option<Vec<(CacheKeyId, Vec<u8>)>>,
7066
),
7167
String,
7268
> {
73-
if let Some(inner_body) = body.take() {
69+
if let Some(inner_body) = block_params.body.take() {
7470
let inherent_data_providers = self
7571
.create_inherent_data_providers
76-
.create_inherent_data_providers(*header.parent_hash(), ())
72+
.create_inherent_data_providers(*block_params.header.parent_hash(), ())
7773
.await
7874
.map_err(|e| e.to_string())?;
7975

8076
let inherent_data = inherent_data_providers
8177
.create_inherent_data()
8278
.map_err(|e| format!("{:?}", e))?;
8379

84-
let block = Block::new(header.clone(), inner_body);
80+
let block = Block::new(block_params.header.clone(), inner_body);
8581

8682
let inherent_res = self
8783
.client
8884
.runtime_api()
8985
.check_inherents(
90-
&BlockId::Hash(*header.parent_hash()),
86+
&BlockId::Hash(*block.header().parent_hash()),
9187
block.clone(),
9288
inherent_data,
9389
)
@@ -106,17 +102,12 @@ where
106102
}
107103

108104
let (_, inner_body) = block.deconstruct();
109-
body = Some(inner_body);
105+
block_params.body = Some(inner_body);
110106
}
111107

112-
let post_hash = Some(header.hash());
113-
let mut block_import_params = BlockImportParams::new(origin, header);
114-
block_import_params.body = body;
115-
block_import_params.justifications = justifications;
116-
117-
block_import_params.post_hash = post_hash;
108+
block_params.post_hash = Some(block_params.header.hash());
118109

119-
Ok((block_import_params, None))
110+
Ok((block_params, None))
120111
}
121112
}
122113

client/consensus/relay-chain/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ use cumulus_primitives_core::{
4343
use parking_lot::Mutex;
4444
use polkadot_client::ClientHandle;
4545
use sc_client_api::Backend;
46+
use sc_consensus::{BlockImport, BlockImportParams};
4647
use sp_api::ProvideRuntimeApi;
4748
use sp_consensus::{
48-
BlockImport, BlockImportParams, BlockOrigin, EnableProofRecording, Environment, ProofRecording,
49-
Proposal, Proposer,
49+
BlockOrigin, EnableProofRecording, Environment, ProofRecording, Proposal, Proposer,
5050
};
5151
use sp_inherents::{CreateInherentDataProviders, InherentData, InherentDataProvider};
5252
use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT};
@@ -208,8 +208,8 @@ where
208208

209209
let mut block_import_params = BlockImportParams::new(BlockOrigin::Own, header);
210210
block_import_params.body = Some(extrinsics);
211-
block_import_params.state_action = sp_consensus::StateAction::ApplyChanges(
212-
sp_consensus::StorageChanges::Changes(storage_changes)
211+
block_import_params.state_action = sc_consensus::StateAction::ApplyChanges(
212+
sc_consensus::StorageChanges::Changes(storage_changes),
213213
);
214214

215215
if let Err(err) = self

client/pov-recovery/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
1313
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
1414
sp-maybe-compressed-blob = { git = "https://github.com/paritytech/substrate", branch = "master" }
1515
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
16+
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
1617

1718
# Polkadot deps
1819
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" }
@@ -44,7 +45,6 @@ sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "mas
4445
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
4546
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
4647
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
47-
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
4848
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
4949
substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "master" }
5050
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" }

client/pov-recovery/src/lib.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,9 @@
4343
//! make sure that the blocks are imported in the correct order.
4444
4545
use sc_client_api::{BlockBackend, BlockchainEvents, UsageProvider};
46+
use sc_consensus::import_queue::{ImportQueue, IncomingBlock};
4647
use sp_api::ProvideRuntimeApi;
47-
use sp_consensus::{
48-
import_queue::{ImportQueue, IncomingBlock},
49-
BlockOrigin, BlockStatus,
50-
};
48+
use sp_consensus::{BlockOrigin, BlockStatus};
5149
use sp_runtime::{
5250
generic::BlockId,
5351
traits::{Block as BlockT, Header as HeaderT, NumberFor},

client/service/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ sc-service = { git = "https://github.com/paritytech/substrate", branch = "master
1818
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "master" }
1919
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }
2020
sc-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
21+
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
2122
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
2223
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
2324
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }

client/service/src/lib.rs

+15-14
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ use polkadot_service::{AbstractClient, Client as PClient, ClientHandle, RuntimeA
2626
use sc_client_api::{
2727
Backend as BackendT, BlockBackend, BlockchainEvents, Finalizer, UsageProvider,
2828
};
29+
use sc_consensus::{
30+
import_queue::{ImportQueue, IncomingBlock, Link, Origin},
31+
BlockImport,
32+
};
2933
use sc_service::{Configuration, Role, TaskManager};
3034
use sc_telemetry::TelemetryWorkerHandle;
3135
use sp_api::ProvideRuntimeApi;
3236
use sp_blockchain::HeaderBackend;
33-
use sp_consensus::{
34-
import_queue::{ImportQueue, IncomingBlock, Link, Origin},
35-
BlockImport, BlockOrigin,
36-
};
37+
use sp_consensus::BlockOrigin;
3738
use sp_core::{traits::SpawnNamed, Pair};
3839
use sp_runtime::{
3940
traits::{BlakeTwo256, Block as BlockT, NumberFor},
@@ -118,18 +119,18 @@ where
118119
});
119120

120121
relay_chain_full_node
121-
.client
122-
.execute_with(StartPoVRecovery {
123-
para_id,
124-
client: client.clone(),
125-
import_queue,
126-
task_manager,
127-
overseer_handle: relay_chain_full_node
128-
.overseer_handle
122+
.client
123+
.execute_with(StartPoVRecovery {
124+
para_id,
125+
client: client.clone(),
126+
import_queue,
127+
task_manager,
128+
overseer_handle: relay_chain_full_node
129+
.overseer_handle
129130
.clone()
130131
.ok_or_else(|| "Polkadot full node did not provide an `OverseerHandle`!")?,
131-
_phantom: PhantomData,
132-
})?;
132+
_phantom: PhantomData,
133+
})?;
133134

134135
cumulus_client_collator::start_collator(cumulus_client_collator::StartCollatorParams {
135136
runtime_api: client.clone(),

0 commit comments

Comments
 (0)