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

Commit

Permalink
moved client code out of primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
gilescope committed Jul 20, 2021
1 parent 03d4d0d commit add2e9d
Show file tree
Hide file tree
Showing 72 changed files with 745 additions and 534 deletions.
32 changes: 31 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/node-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;

pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponents<
FullClient, FullBackend, FullSelectChain,
sp_consensus::DefaultImportQueue<Block, FullClient>,
sc_consensus::DefaultImportQueue<Block, FullClient>,
sc_transaction_pool::FullPool<Block, FullClient>,
(
sc_finality_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
Expand Down
7 changes: 3 additions & 4 deletions bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn new_partial(
config: &Configuration,
) -> Result<sc_service::PartialComponents<
FullClient, FullBackend, FullSelectChain,
sp_consensus::DefaultImportQueue<Block, FullClient>,
sc_consensus::DefaultImportQueue<Block, FullClient>,
sc_transaction_pool::FullPool<Block, FullClient>,
(
impl Fn(
Expand Down Expand Up @@ -605,9 +605,8 @@ mod tests {
use std::{sync::Arc, borrow::Cow, convert::TryInto};
use sc_consensus_babe::{CompatibleDigestItem, BabeIntermediate, INTERMEDIATE_KEY};
use sc_consensus_epochs::descendent_query;
use sp_consensus::{
Environment, Proposer, BlockImportParams, BlockOrigin, ForkChoiceStrategy, BlockImport,
};
use sp_consensus::{BlockOrigin, Environment, Proposer};
use sc_consensus::{BlockImportParams, ForkChoiceStrategy, BlockImport,};
use node_primitives::{Block, DigestItem, Signature};
use node_runtime::{BalancesCall, Call, UncheckedExtrinsic, Address};
use node_runtime::constants::{currency::CENTS, time::SLOT_DURATION};
Expand Down
2 changes: 2 additions & 0 deletions bin/node/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pallet-transaction-payment = { version = "4.0.0-dev", path = "../../../frame/tra
pallet-treasury = { version = "4.0.0-dev", path = "../../../frame/treasury" }
sp-application-crypto = { version = "4.0.0-dev", path = "../../../primitives/application-crypto" }
sp-consensus-babe = { version = "0.10.0-dev", path = "../../../primitives/consensus/babe" }
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
sc-consensus = { version = "0.10.0-dev", path = "../../../client/consensus/common" }
sp-runtime = { version = "4.0.0-dev", path = "../../../primitives/runtime" }
sp-externalities = { version = "0.10.0-dev", path = "../../../primitives/externalities" }
substrate-test-client = { version = "2.0.0", path = "../../../test-utils/client" }
Expand Down
2 changes: 1 addition & 1 deletion bin/node/executor/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,8 +836,8 @@ fn full_wasm_block_import_works_with_changes_trie() {
fn should_import_block_with_test_client() {
use node_testing::client::{
ClientBlockImportExt, TestClientBuilderExt, TestClientBuilder,
sp_consensus::BlockOrigin,
};
use sp_consensus::BlockOrigin;

let mut client = TestClientBuilder::new().build();
let block1 = changes_trie_block();
Expand Down
1 change: 1 addition & 0 deletions bin/node/testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pallet-balances = { version = "4.0.0-dev", path = "../../../frame/balances" }
sc-service = { version = "0.10.0-dev", features = ["test-helpers", "db"], path = "../../../client/service" }
sc-client-db = { version = "0.10.0-dev", path = "../../../client/db/", features = ["kvdb-rocksdb", "parity-db"] }
sc-client-api = { version = "4.0.0-dev", path = "../../../client/api/" }
sc-consensus = { version = "0.10.0-dev", path = "../../../client/consensus/common" }
codec = { package = "parity-scale-codec", version = "2.0.0" }
pallet-contracts = { version = "4.0.0-dev", path = "../../../frame/contracts" }
pallet-grandpa = { version = "4.0.0-dev", path = "../../../frame/grandpa" }
Expand Down
5 changes: 3 additions & 2 deletions bin/node/testing/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ use crate::client::{Client, Backend};
use crate::keyring::*;
use sc_client_db::PruningMode;
use sc_executor::{NativeExecutor, WasmExecutionMethod};
use sp_consensus::{
BlockOrigin, BlockImport, BlockImportParams,
use sc_consensus::{
BlockImport, BlockImportParams,
ForkChoiceStrategy, ImportResult, ImportedAux
};
use sp_consensus::BlockOrigin;
use sp_runtime::{
generic::BlockId,
OpaqueExtrinsic,
Expand Down
1 change: 0 additions & 1 deletion client/api/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ use sp_consensus::BlockOrigin;
use parking_lot::RwLock;

pub use sp_state_machine::Backend as StateBackend;
pub use sp_consensus::ImportedState;
use std::marker::PhantomData;

/// Extracts the state backend type for the given backend.
Expand Down
1 change: 1 addition & 0 deletions client/basic-authorship/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ sc-proposer-metrics = { version = "0.9.0", path = "../proposer-metrics" }

[dev-dependencies]
sc-transaction-pool = { version = "4.0.0-dev", path = "../transaction-pool" }
sc-consensus = { version = "0.10.0-dev", path = "../consensus/common" }
substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" }
parking_lot = "0.11.1"
2 changes: 1 addition & 1 deletion client/basic-authorship/src/basic_authorship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ mod tests {
use super::*;

use parking_lot::Mutex;
use sp_consensus::{BlockOrigin, Proposer};
use sp_consensus::{Proposer,BlockOrigin};
use substrate_test_runtime_client::{
prelude::*, TestClientBuilder, runtime::{Extrinsic, Transfer}, TestClientBuilderExt,
};
Expand Down
1 change: 1 addition & 0 deletions client/consensus/aura/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ sc-block-builder = { version = "0.10.0-dev", path = "../../block-builder" }
sc-client-api = { version = "4.0.0-dev", path = "../../api" }
codec = { package = "parity-scale-codec", version = "2.0.0" }
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
sc-consensus = { version = "0.10.0-dev", path = "../../../client/consensus/common" }
sp-consensus-slots = { version = "0.10.0-dev", path = "../../../primitives/consensus/slots" }
derive_more = "0.99.2"
futures = "0.3.9"
Expand Down
10 changes: 7 additions & 3 deletions client/consensus/aura/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ use log::{debug, info, trace};
use prometheus_endpoint::Registry;
use codec::{Encode, Decode, Codec};
use sp_consensus::{
BlockImport, CanAuthorWith, ForkChoiceStrategy, BlockImportParams,
BlockOrigin, Error as ConsensusError,
BlockOrigin,
CanAuthorWith,
Error as ConsensusError,
};
use sc_consensus::{
block_import::{BlockImport, ForkChoiceStrategy, BlockImportParams},
import_queue::{
Verifier, BasicQueue, DefaultImportQueue, BoxJustificationImport,
},
}
};
use sc_client_api::{BlockOf, UsageProvider, backend::AuxStore};
use sp_blockchain::{well_known_cache_keys::{self, Id as CacheKeyId}, ProvideCache, HeaderBackend};
Expand Down
20 changes: 12 additions & 8 deletions client/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ use log::{debug, trace};
use codec::{Encode, Decode, Codec};

use sp_consensus::{
BlockImport, Environment, Proposer, CanAuthorWith, ForkChoiceStrategy, BlockImportParams,
BlockOrigin, Error as ConsensusError, SelectChain, StateAction,
BlockOrigin, Environment, Proposer, CanAuthorWith,
Error as ConsensusError, SelectChain,
};
use sc_consensus::{
BlockImport,StateAction,ForkChoiceStrategy, BlockImportParams
};
use sc_client_api::{backend::AuxStore, BlockOf, UsageProvider};
use sp_blockchain::{Result as CResult, ProvideCache, HeaderBackend};
Expand Down Expand Up @@ -179,7 +182,7 @@ where
PF: Environment<B, Error = Error> + Send + Sync + 'static,
PF::Proposer: Proposer<B, Error = Error, Transaction = sp_api::TransactionFor<C, B>>,
SO: SyncOracle + Send + Sync + Clone,
L: sp_consensus::JustificationSyncLink<B>,
L: sc_consensus::JustificationSyncLink<B>,
CIDP: CreateInherentDataProviders<B, ()> + Send,
CIDP::InherentDataProviders: InherentDataProviderExt + Send,
BS: BackoffAuthoringBlocksStrategy<NumberFor<B>> + Send + 'static,
Expand Down Expand Up @@ -271,7 +274,7 @@ where
I: BlockImport<B, Transaction = sp_api::TransactionFor<C, B>> + Send + Sync + 'static,
Error: std::error::Error + Send + From<sp_consensus::Error> + 'static,
SO: SyncOracle + Send + Sync + Clone,
L: sp_consensus::JustificationSyncLink<B>,
L: sc_consensus::JustificationSyncLink<B>,
BS: BackoffAuthoringBlocksStrategy<NumberFor<B>> + Send + 'static,
{
AuraWorker {
Expand Down Expand Up @@ -318,7 +321,7 @@ where
P::Public: AppPublic + Public + Member + Encode + Decode + Hash,
P::Signature: TryFrom<Vec<u8>> + Member + Encode + Decode + Hash + Debug,
SO: SyncOracle + Send + Clone,
L: sp_consensus::JustificationSyncLink<B>,
L: sc_consensus::JustificationSyncLink<B>,
BS: BackoffAuthoringBlocksStrategy<NumberFor<B>> + Send + 'static,
Error: std::error::Error + Send + From<sp_consensus::Error> + 'static,
{
Expand Down Expand Up @@ -389,7 +392,7 @@ where
Self::Claim,
Self::EpochData,
) -> Result<
sp_consensus::BlockImportParams<B, sp_api::TransactionFor<C, B>>,
sc_consensus::BlockImportParams<B, sp_api::TransactionFor<C, B>>,
sp_consensus::Error> + Send + 'static>
{
let keystore = self.keystore.clone();
Expand Down Expand Up @@ -422,7 +425,7 @@ where
import_block.post_digests.push(signature_digest_item);
import_block.body = Some(body);
import_block.state_action = StateAction::ApplyChanges(
sp_consensus::StorageChanges::Changes(storage_changes)
sc_consensus::StorageChanges::Changes(storage_changes)
);
import_block.fork_choice = Some(ForkChoiceStrategy::LongestChain);

Expand Down Expand Up @@ -547,8 +550,9 @@ mod tests {
use super::*;
use sp_consensus::{
NoNetwork as DummyOracle, Proposal, AlwaysCanAuthor, DisableProofRecording,
import_queue::BoxJustificationImport, SlotData,
SlotData,
};
use sc_consensus::BoxJustificationImport;
use sc_network_test::{Block as TestBlock, *};
use sp_runtime::traits::{Block as BlockT, DigestFor};
use sc_network::config::ProtocolConfig;
Expand Down
1 change: 1 addition & 0 deletions client/consensus/babe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0", features = ["derive"] }
sp-consensus-babe = { version = "0.10.0-dev", path = "../../../primitives/consensus/babe" }
sc-consensus = { version = "0.10.0-dev", path = "../../../client/consensus/common" }
sp-core = { version = "4.0.0-dev", path = "../../../primitives/core" }
sp-application-crypto = { version = "4.0.0-dev", path = "../../../primitives/application-crypto" }
sp-keystore = { version = "0.10.0-dev", path = "../../../primitives/keystore" }
Expand Down
Loading

0 comments on commit add2e9d

Please sign in to comment.