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

Commit 4d28ebe

Browse files
Move client consensus parts out of primitives and into client/consensus/api (#9319)
* moved client code out of primitives * bump ci * Fixup from merge. * Removed unused deps thanks to review feedback * Removing unneeded deps * updating lock file * note about rustfmt * fixed typo to bump ci * Move lonely CacheKeyId to parent * cargo fmt * updating import style * Update docs/STYLE_GUIDE.md Co-authored-by: André Silva <[email protected]> Co-authored-by: André Silva <[email protected]>
1 parent 3478e0f commit 4d28ebe

File tree

69 files changed

+339
-283
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+339
-283
lines changed

Cargo.lock

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

bin/node-template/node/src/service.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn new_partial(
3232
FullClient,
3333
FullBackend,
3434
FullSelectChain,
35-
sp_consensus::DefaultImportQueue<Block, FullClient>,
35+
sc_consensus::DefaultImportQueue<Block, FullClient>,
3636
sc_transaction_pool::FullPool<Block, FullClient>,
3737
(
3838
sc_finality_grandpa::GrandpaBlockImport<

bin/node/cli/src/service.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub fn new_partial(
4646
FullClient,
4747
FullBackend,
4848
FullSelectChain,
49-
sp_consensus::DefaultImportQueue<Block, FullClient>,
49+
sc_consensus::DefaultImportQueue<Block, FullClient>,
5050
sc_transaction_pool::FullPool<Block, FullClient>,
5151
(
5252
impl Fn(node_rpc::DenyUnsafe, sc_rpc::SubscriptionTaskExecutor) -> node_rpc::IoHandler,
@@ -595,14 +595,13 @@ mod tests {
595595
Address, BalancesCall, Call, UncheckedExtrinsic,
596596
};
597597
use sc_client_api::BlockBackend;
598+
use sc_consensus::{BlockImport, BlockImportParams, ForkChoiceStrategy};
598599
use sc_consensus_babe::{BabeIntermediate, CompatibleDigestItem, INTERMEDIATE_KEY};
599600
use sc_consensus_epochs::descendent_query;
600601
use sc_keystore::LocalKeystore;
601602
use sc_service_test::TestNetNode;
602603
use sc_transaction_pool_api::{ChainEvent, MaintainedTransactionPool};
603-
use sp_consensus::{
604-
BlockImport, BlockImportParams, BlockOrigin, Environment, ForkChoiceStrategy, Proposer,
605-
};
604+
use sp_consensus::{BlockOrigin, Environment, Proposer};
606605
use sp_core::{crypto::Pair as CryptoPair, Public, H256};
607606
use sp_inherents::InherentDataProvider;
608607
use sp_keyring::AccountKeyring;

bin/node/test-runner-example/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ sc-informant = { path = "../../../client/informant" }
3131
sc-consensus = { path = "../../../client/consensus/common" }
3232

3333
sp-runtime = { path = "../../../primitives/runtime" }
34-
sp-consensus = { path = "../../../primitives/consensus/common" }
3534
sp-keyring = { path = "../../../primitives/keyring" }
3635
sp-timestamp = { path = "../../../primitives/timestamp" }
3736
sp-api = { path = "../../../primitives/api" }

bin/node/testing/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pallet-balances = { version = "4.0.0-dev", path = "../../../frame/balances" }
1717
sc-service = { version = "0.10.0-dev", features = ["test-helpers", "db"], path = "../../../client/service" }
1818
sc-client-db = { version = "0.10.0-dev", path = "../../../client/db/", features = ["kvdb-rocksdb", "parity-db"] }
1919
sc-client-api = { version = "4.0.0-dev", path = "../../../client/api/" }
20+
sc-consensus = { version = "0.10.0-dev", path = "../../../client/consensus/common" }
2021
codec = { package = "parity-scale-codec", version = "2.0.0" }
2122
pallet-contracts = { version = "4.0.0-dev", path = "../../../frame/contracts" }
2223
pallet-grandpa = { version = "4.0.0-dev", path = "../../../frame/grandpa" }

bin/node/testing/src/bench.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@ use sc_client_api::{
4545
BlockBackend, ExecutionStrategy,
4646
};
4747
use sc_client_db::PruningMode;
48+
use sc_consensus::{BlockImport, BlockImportParams, ForkChoiceStrategy, ImportResult, ImportedAux};
4849
use sc_executor::{NativeExecutor, WasmExecutionMethod};
4950
use sp_api::ProvideRuntimeApi;
5051
use sp_block_builder::BlockBuilder;
51-
use sp_consensus::{
52-
BlockImport, BlockImportParams, BlockOrigin, ForkChoiceStrategy, ImportResult, ImportedAux,
53-
};
52+
use sp_consensus::BlockOrigin;
5453
use sp_core::{blake2_256, ed25519, sr25519, traits::SpawnNamed, ExecutionContext, Pair, Public};
5554
use sp_inherents::InherentData;
5655
use sp_runtime::{

client/api/src/backend.rs

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use std::{
4242
sync::Arc,
4343
};
4444

45-
pub use sp_consensus::ImportedState;
4645
pub use sp_state_machine::Backend as StateBackend;
4746
use std::marker::PhantomData;
4847

client/consensus/aura/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ sc-block-builder = { version = "0.10.0-dev", path = "../../block-builder" }
2020
sc-client-api = { version = "4.0.0-dev", path = "../../api" }
2121
codec = { package = "parity-scale-codec", version = "2.0.0" }
2222
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
23+
sc-consensus = { version = "0.10.0-dev", path = "../../../client/consensus/common" }
2324
sp-consensus-slots = { version = "0.10.0-dev", path = "../../../primitives/consensus/slots" }
2425
derive_more = "0.99.2"
2526
futures = "0.3.9"

client/consensus/aura/src/import_queue.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ use codec::{Codec, Decode, Encode};
2323
use log::{debug, info, trace};
2424
use prometheus_endpoint::Registry;
2525
use sc_client_api::{backend::AuxStore, BlockOf, UsageProvider};
26+
use sc_consensus::{
27+
block_import::{BlockImport, BlockImportParams, ForkChoiceStrategy},
28+
import_queue::{BasicQueue, BoxJustificationImport, DefaultImportQueue, Verifier},
29+
};
2630
use sc_consensus_slots::{check_equivocation, CheckedHeader, InherentDataProviderExt};
2731
use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG, CONSENSUS_TRACE};
2832
use sp_api::{ApiExt, ProvideRuntimeApi};
@@ -31,11 +35,7 @@ use sp_blockchain::{
3135
well_known_cache_keys::{self, Id as CacheKeyId},
3236
HeaderBackend, ProvideCache,
3337
};
34-
use sp_consensus::{
35-
import_queue::{BasicQueue, BoxJustificationImport, DefaultImportQueue, Verifier},
36-
BlockImport, BlockImportParams, BlockOrigin, CanAuthorWith, Error as ConsensusError,
37-
ForkChoiceStrategy,
38-
};
38+
use sp_consensus::{BlockOrigin, CanAuthorWith, Error as ConsensusError};
3939
use sp_consensus_aura::{
4040
digests::CompatibleDigestItem, inherents::AuraInherentData, AuraApi, ConsensusLog,
4141
AURA_ENGINE_ID,

client/consensus/aura/src/lib.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ use log::{debug, trace};
4545
use codec::{Codec, Decode, Encode};
4646

4747
use sc_client_api::{backend::AuxStore, BlockOf, UsageProvider};
48+
use sc_consensus::{BlockImport, BlockImportParams, ForkChoiceStrategy, StateAction};
4849
use sc_consensus_slots::{
4950
BackoffAuthoringBlocksStrategy, InherentDataProviderExt, SlotInfo, StorageChanges,
5051
};
@@ -53,8 +54,7 @@ use sp_api::ProvideRuntimeApi;
5354
use sp_application_crypto::{AppKey, AppPublic};
5455
use sp_blockchain::{HeaderBackend, ProvideCache, Result as CResult};
5556
use sp_consensus::{
56-
BlockImport, BlockImportParams, BlockOrigin, CanAuthorWith, Environment,
57-
Error as ConsensusError, ForkChoiceStrategy, Proposer, SelectChain, StateAction,
57+
BlockOrigin, CanAuthorWith, Environment, Error as ConsensusError, Proposer, SelectChain,
5858
};
5959
use sp_consensus_slots::Slot;
6060
use sp_core::crypto::{Pair, Public};
@@ -185,7 +185,7 @@ where
185185
PF: Environment<B, Error = Error> + Send + Sync + 'static,
186186
PF::Proposer: Proposer<B, Error = Error, Transaction = sp_api::TransactionFor<C, B>>,
187187
SO: SyncOracle + Send + Sync + Clone,
188-
L: sp_consensus::JustificationSyncLink<B>,
188+
L: sc_consensus::JustificationSyncLink<B>,
189189
CIDP: CreateInherentDataProviders<B, ()> + Send,
190190
CIDP::InherentDataProviders: InherentDataProviderExt + Send,
191191
BS: BackoffAuthoringBlocksStrategy<NumberFor<B>> + Send + 'static,
@@ -277,7 +277,7 @@ where
277277
I: BlockImport<B, Transaction = sp_api::TransactionFor<C, B>> + Send + Sync + 'static,
278278
Error: std::error::Error + Send + From<sp_consensus::Error> + 'static,
279279
SO: SyncOracle + Send + Sync + Clone,
280-
L: sp_consensus::JustificationSyncLink<B>,
280+
L: sc_consensus::JustificationSyncLink<B>,
281281
BS: BackoffAuthoringBlocksStrategy<NumberFor<B>> + Send + 'static,
282282
{
283283
AuraWorker {
@@ -324,7 +324,7 @@ where
324324
P::Public: AppPublic + Public + Member + Encode + Decode + Hash,
325325
P::Signature: TryFrom<Vec<u8>> + Member + Encode + Decode + Hash + Debug,
326326
SO: SyncOracle + Send + Clone,
327-
L: sp_consensus::JustificationSyncLink<B>,
327+
L: sc_consensus::JustificationSyncLink<B>,
328328
BS: BackoffAuthoringBlocksStrategy<NumberFor<B>> + Send + 'static,
329329
Error: std::error::Error + Send + From<sp_consensus::Error> + 'static,
330330
{
@@ -395,7 +395,7 @@ where
395395
Self::Claim,
396396
Self::EpochData,
397397
) -> Result<
398-
sp_consensus::BlockImportParams<B, sp_api::TransactionFor<C, B>>,
398+
sc_consensus::BlockImportParams<B, sp_api::TransactionFor<C, B>>,
399399
sp_consensus::Error,
400400
> + Send
401401
+ 'static,
@@ -431,7 +431,7 @@ where
431431
import_block.post_digests.push(signature_digest_item);
432432
import_block.body = Some(body);
433433
import_block.state_action =
434-
StateAction::ApplyChanges(sp_consensus::StorageChanges::Changes(storage_changes));
434+
StateAction::ApplyChanges(sc_consensus::StorageChanges::Changes(storage_changes));
435435
import_block.fork_choice = Some(ForkChoiceStrategy::LongestChain);
436436

437437
Ok(import_block)
@@ -560,14 +560,14 @@ mod tests {
560560
use parking_lot::Mutex;
561561
use sc_block_builder::BlockBuilderProvider;
562562
use sc_client_api::BlockchainEvents;
563+
use sc_consensus::BoxJustificationImport;
563564
use sc_consensus_slots::{BackoffAuthoringOnFinalizedHeadLagging, SimpleSlotWorker};
564565
use sc_keystore::LocalKeystore;
565566
use sc_network::config::ProtocolConfig;
566567
use sc_network_test::{Block as TestBlock, *};
567568
use sp_application_crypto::key_types::AURA;
568569
use sp_consensus::{
569-
import_queue::BoxJustificationImport, AlwaysCanAuthor, DisableProofRecording,
570-
NoNetwork as DummyOracle, Proposal, SlotData,
570+
AlwaysCanAuthor, DisableProofRecording, NoNetwork as DummyOracle, Proposal, SlotData,
571571
};
572572
use sp_consensus_aura::sr25519::AuthorityPair;
573573
use sp_inherents::InherentData;

client/consensus/babe/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
1616
[dependencies]
1717
codec = { package = "parity-scale-codec", version = "2.0.0", features = ["derive"] }
1818
sp-consensus-babe = { version = "0.10.0-dev", path = "../../../primitives/consensus/babe" }
19+
sc-consensus = { version = "0.10.0-dev", path = "../../../client/consensus/common" }
1920
sp-core = { version = "4.0.0-dev", path = "../../../primitives/core" }
2021
sp-application-crypto = { version = "4.0.0-dev", path = "../../../primitives/application-crypto" }
2122
sp-keystore = { version = "0.10.0-dev", path = "../../../primitives/keystore" }

0 commit comments

Comments
 (0)