Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Update Substrate & Polkadot #557

Merged
merged 3 commits into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update Substrate & Polkadot
  • Loading branch information
bkchr committed Aug 2, 2021
commit 9edaaee85b8ed22c15b8c56f3eccd1f5e91e6aef
732 changes: 381 additions & 351 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions client/consensus/aura/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "mas
sc-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" }

# Polkadot dependencies
Expand Down
5 changes: 2 additions & 3 deletions client/consensus/aura/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@

use codec::Codec;
use sc_client_api::{backend::AuxStore, BlockOf, UsageProvider};
use sc_consensus::{import_queue::DefaultImportQueue, BlockImport};
use sc_consensus_aura::AuraVerifier;
use sc_consensus_slots::InherentDataProviderExt;
use sc_telemetry::TelemetryHandle;
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder as BlockBuilderApi;
use sp_blockchain::{HeaderBackend, ProvideCache};
use sp_consensus::{
import_queue::DefaultImportQueue, BlockImport, CanAuthorWith, Error as ConsensusError,
};
use sp_consensus::{CanAuthorWith, Error as ConsensusError};
use sp_consensus_aura::{digests::CompatibleDigestItem, AuraApi};
use sp_core::crypto::Pair;
use sp_inherents::CreateInherentDataProviders;
Expand Down
13 changes: 7 additions & 6 deletions client/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ use cumulus_primitives_core::{
use futures::lock::Mutex;
use polkadot_client::ClientHandle;
use sc_client_api::{backend::AuxStore, Backend, BlockOf};
use sc_consensus::BlockImport;
use sc_consensus_slots::{BackoffAuthoringBlocksStrategy, SlotInfo};
use sc_telemetry::TelemetryHandle;
use sp_api::ProvideRuntimeApi;
use sp_application_crypto::AppPublic;
use sp_blockchain::{HeaderBackend, ProvideCache};
use sp_consensus::{
BlockImport, EnableProofRecording, Environment, ProofRecording, Proposer, SlotData, SyncOracle,
EnableProofRecording, Environment, ProofRecording, Proposer, SlotData, SyncOracle,
};
use sp_consensus_aura::AuraApi;
use sp_core::crypto::Pair;
Expand All @@ -52,8 +53,7 @@ mod import_queue;

pub use import_queue::{build_verifier, import_queue, BuildVerifierParams, ImportQueueParams};
pub use sc_consensus_aura::{
slot_duration, AuraVerifier, BuildAuraWorkerParams, SlotDuration,
SlotProportion,
slot_duration, AuraVerifier, BuildAuraWorkerParams, SlotDuration, SlotProportion,
};
pub use sc_consensus_slots::InherentDataProviderExt;

Expand Down Expand Up @@ -138,8 +138,8 @@ where
P::Public: AppPublic + Hash + Member + Encode + Decode,
P::Signature: TryFrom<Vec<u8>> + Hash + Member + Encode + Decode,
{
let worker =
sc_consensus_aura::build_aura_worker::<P, _, _, _, _, _, _, _, _>(BuildAuraWorkerParams {
let worker = sc_consensus_aura::build_aura_worker::<P, _, _, _, _, _, _, _, _>(
BuildAuraWorkerParams {
client: para_client,
block_import: ParachainBlockImport::new(block_import),
justification_sync_link: (),
Expand All @@ -151,7 +151,8 @@ where
telemetry,
block_proposal_slot_portion,
max_block_proposal_slot_portion,
});
},
);

Self {
create_inherent_data_providers: Arc::new(create_inherent_data_providers),
Expand Down
1 change: 1 addition & 0 deletions client/consensus/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2018"

[dependencies]
# Substrate deps
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
14 changes: 7 additions & 7 deletions client/consensus/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.

use polkadot_primitives::v1::{Hash as PHash, PersistedValidationData};
use sp_consensus::BlockImport;
use sc_consensus::BlockImport;
use sp_runtime::traits::Block as BlockT;

mod parachain_consensus;
Expand Down Expand Up @@ -96,19 +96,19 @@ where

async fn check_block(
&mut self,
block: sp_consensus::BlockCheckParams<Block>,
) -> Result<sp_consensus::ImportResult, Self::Error> {
block: sc_consensus::BlockCheckParams<Block>,
) -> Result<sc_consensus::ImportResult, Self::Error> {
self.0.check_block(block).await
}

async fn import_block(
&mut self,
mut block_import_params: sp_consensus::BlockImportParams<Block, Self::Transaction>,
cache: std::collections::HashMap<sp_consensus::import_queue::CacheKeyId, Vec<u8>>,
) -> Result<sp_consensus::ImportResult, Self::Error> {
mut block_import_params: sc_consensus::BlockImportParams<Block, Self::Transaction>,
cache: std::collections::HashMap<sp_consensus::CacheKeyId, Vec<u8>>,
) -> Result<sc_consensus::ImportResult, Self::Error> {
// Best block is determined by the relay chain, or if we are doing the intial sync
// we import all blocks as new best.
block_import_params.fork_choice = Some(sp_consensus::ForkChoiceStrategy::Custom(
block_import_params.fork_choice = Some(sc_consensus::ForkChoiceStrategy::Custom(
block_import_params.origin == sp_consensus::BlockOrigin::NetworkInitialSync,
));
self.0.import_block(block_import_params, cache).await
Expand Down
3 changes: 2 additions & 1 deletion client/consensus/common/src/parachain_consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
use sc_client_api::{
Backend, BlockBackend, BlockImportNotification, BlockchainEvents, Finalizer, UsageProvider,
};
use sc_consensus::{BlockImport, BlockImportParams, ForkChoiceStrategy};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::{Error as ClientError, Result as ClientResult};
use sp_consensus::{BlockImport, BlockImportParams, BlockOrigin, BlockStatus, ForkChoiceStrategy};
use sp_consensus::{BlockOrigin, BlockStatus};
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, Header as HeaderT},
Expand Down
3 changes: 2 additions & 1 deletion client/consensus/common/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ use futures::{channel::mpsc, executor::block_on, select, FutureExt, Stream, Stre
use futures_timer::Delay;
use polkadot_primitives::v1::{Block as PBlock, Id as ParaId};
use sc_client_api::UsageProvider;
use sc_consensus::{BlockImport, BlockImportParams, ForkChoiceStrategy};
use sp_blockchain::{Error as ClientError, Result as ClientResult};
use sp_consensus::{BlockImport, BlockImportParams, BlockOrigin, ForkChoiceStrategy};
use sp_consensus::BlockOrigin;
use sp_runtime::generic::BlockId;
use std::{
sync::{Arc, Mutex},
Expand Down
1 change: 1 addition & 0 deletions client/consensus/relay-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "mas
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" }

# Polkadot dependencies
Expand Down
35 changes: 13 additions & 22 deletions client/consensus/relay-chain/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,18 @@

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

use sc_consensus::{
import_queue::{BasicQueue, Verifier as VerifierT},
BlockImport, BlockImportParams,
};
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder as BlockBuilderApi;
use sp_blockchain::Result as ClientResult;
use sp_consensus::{
error::Error as ConsensusError,
import_queue::{BasicQueue, CacheKeyId, Verifier as VerifierT},
BlockImport, BlockImportParams, BlockOrigin,
};
use sp_consensus::{error::Error as ConsensusError, CacheKeyId};
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider};
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, Header as HeaderT},
Justifications,
};

/// A verifier that just checks the inherents.
Expand Down Expand Up @@ -59,35 +58,32 @@ where
{
async fn verify(
&mut self,
origin: BlockOrigin,
header: Block::Header,
justifications: Option<Justifications>,
mut body: Option<Vec<Block::Extrinsic>>,
mut block_params: BlockImportParams<Block, ()>,
) -> Result<
(
BlockImportParams<Block, ()>,
Option<Vec<(CacheKeyId, Vec<u8>)>>,
),
String,
> {
if let Some(inner_body) = body.take() {
if let Some(inner_body) = block_params.body.take() {
let inherent_data_providers = self
.create_inherent_data_providers
.create_inherent_data_providers(*header.parent_hash(), ())
.create_inherent_data_providers(*block_params.header.parent_hash(), ())
.await
.map_err(|e| e.to_string())?;

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

let block = Block::new(header.clone(), inner_body);
let block = Block::new(block_params.header.clone(), inner_body);

let inherent_res = self
.client
.runtime_api()
.check_inherents(
&BlockId::Hash(*header.parent_hash()),
&BlockId::Hash(*block.header().parent_hash()),
block.clone(),
inherent_data,
)
Expand All @@ -106,17 +102,12 @@ where
}

let (_, inner_body) = block.deconstruct();
body = Some(inner_body);
block_params.body = Some(inner_body);
}

let post_hash = Some(header.hash());
let mut block_import_params = BlockImportParams::new(origin, header);
block_import_params.body = body;
block_import_params.justifications = justifications;

block_import_params.post_hash = post_hash;
block_params.post_hash = Some(block_params.header.hash());

Ok((block_import_params, None))
Ok((block_params, None))
}
}

Expand Down
8 changes: 4 additions & 4 deletions client/consensus/relay-chain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ use cumulus_primitives_core::{
use parking_lot::Mutex;
use polkadot_client::ClientHandle;
use sc_client_api::Backend;
use sc_consensus::{BlockImport, BlockImportParams};
use sp_api::ProvideRuntimeApi;
use sp_consensus::{
BlockImport, BlockImportParams, BlockOrigin, EnableProofRecording, Environment, ProofRecording,
Proposal, Proposer,
BlockOrigin, EnableProofRecording, Environment, ProofRecording, Proposal, Proposer,
};
use sp_inherents::{CreateInherentDataProviders, InherentData, InherentDataProvider};
use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT};
Expand Down Expand Up @@ -208,8 +208,8 @@ where

let mut block_import_params = BlockImportParams::new(BlockOrigin::Own, header);
block_import_params.body = Some(extrinsics);
block_import_params.state_action = sp_consensus::StateAction::ApplyChanges(
sp_consensus::StorageChanges::Changes(storage_changes)
block_import_params.state_action = sc_consensus::StateAction::ApplyChanges(
sc_consensus::StorageChanges::Changes(storage_changes),
);

if let Err(err) = self
Expand Down
2 changes: 1 addition & 1 deletion client/pov-recovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-maybe-compressed-blob = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }

# Polkadot deps
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" }
Expand Down Expand Up @@ -44,7 +45,6 @@ sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "mas
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" }
6 changes: 2 additions & 4 deletions client/pov-recovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@
//! make sure that the blocks are imported in the correct order.

use sc_client_api::{BlockBackend, BlockchainEvents, UsageProvider};
use sc_consensus::import_queue::{ImportQueue, IncomingBlock};
use sp_api::ProvideRuntimeApi;
use sp_consensus::{
import_queue::{ImportQueue, IncomingBlock},
BlockOrigin, BlockStatus,
};
use sp_consensus::{BlockOrigin, BlockStatus};
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, Header as HeaderT, NumberFor},
Expand Down
1 change: 1 addition & 0 deletions client/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ sc-service = { git = "https://github.com/paritytech/substrate", branch = "master
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
29 changes: 15 additions & 14 deletions client/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ use polkadot_service::{AbstractClient, Client as PClient, ClientHandle, RuntimeA
use sc_client_api::{
Backend as BackendT, BlockBackend, BlockchainEvents, Finalizer, UsageProvider,
};
use sc_consensus::{
import_queue::{ImportQueue, IncomingBlock, Link, Origin},
BlockImport,
};
use sc_service::{Configuration, Role, TaskManager};
use sc_telemetry::TelemetryWorkerHandle;
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_consensus::{
import_queue::{ImportQueue, IncomingBlock, Link, Origin},
BlockImport, BlockOrigin,
};
use sp_consensus::BlockOrigin;
use sp_core::{traits::SpawnNamed, Pair};
use sp_runtime::{
traits::{BlakeTwo256, Block as BlockT, NumberFor},
Expand Down Expand Up @@ -118,18 +119,18 @@ where
});

relay_chain_full_node
.client
.execute_with(StartPoVRecovery {
para_id,
client: client.clone(),
import_queue,
task_manager,
overseer_handle: relay_chain_full_node
.overseer_handle
.client
.execute_with(StartPoVRecovery {
para_id,
client: client.clone(),
import_queue,
task_manager,
overseer_handle: relay_chain_full_node
.overseer_handle
.clone()
.ok_or_else(|| "Polkadot full node did not provide an `OverseerHandle`!")?,
_phantom: PhantomData,
})?;
_phantom: PhantomData,
})?;

cumulus_client_collator::start_collator(cumulus_client_collator::StartCollatorParams {
runtime_api: client.clone(),
Expand Down
Loading