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 <123550+andresilva@users.noreply.github.com>

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
Squirrel
2021-07-30 14:27:17 +01:00
committed by GitHub
parent 8a44bec2dc
commit df59596ec0
69 changed files with 339 additions and 283 deletions
@@ -26,6 +26,7 @@ assert_matches = "1.3.0"
async-trait = "0.1.50"
sc-client-api = { path = "../../api", version = "4.0.0-dev"}
sc-consensus = { version = "0.10.0-dev", path = "../../consensus/common" }
sc-consensus-babe = { path = "../../consensus/babe", version = "0.10.0-dev"}
sc-consensus-epochs = { path = "../../consensus/epochs", version = "0.10.0-dev"}
sp-consensus-babe = { path = "../../../primitives/consensus/babe", version = "0.10.0-dev"}
@@ -19,7 +19,7 @@
//! Extensions for manual seal to produce blocks valid for any runtime.
use super::Error;
use sp_consensus::BlockImportParams;
use sc_consensus::BlockImportParams;
use sp_inherents::InherentData;
use sp_runtime::traits::{Block as BlockT, DigestFor};
@@ -36,12 +36,10 @@ use std::{
time::SystemTime,
};
use sc_consensus::{BlockImportParams, ForkChoiceStrategy, Verifier};
use sp_api::{ProvideRuntimeApi, TransactionFor};
use sp_blockchain::{HeaderBackend, HeaderMetadata};
use sp_consensus::{
import_queue::{CacheKeyId, Verifier},
BlockImportParams, BlockOrigin, ForkChoiceStrategy,
};
use sp_consensus::{BlockOrigin, CacheKeyId};
use sp_consensus_babe::{
digests::{NextEpochDescriptor, PreDigest, SecondaryPlainPreDigest},
inherents::BabeInherentData,
@@ -20,8 +20,9 @@
//! This is suitable for a testing environment.
use futures::channel::{mpsc::SendError, oneshot};
use sc_consensus::ImportResult;
use sp_blockchain::Error as BlockchainError;
use sp_consensus::{Error as ConsensusError, ImportResult};
use sp_consensus::Error as ConsensusError;
use sp_inherents::Error as InherentsError;
/// Error code for rpc
@@ -22,12 +22,12 @@
use futures::prelude::*;
use prometheus_endpoint::Registry;
use sc_client_api::backend::{Backend as ClientBackend, Finalizer};
use sp_blockchain::HeaderBackend;
use sp_consensus::{
import_queue::{BasicQueue, BoxBlockImport, CacheKeyId, Verifier},
BlockImport, BlockImportParams, BlockOrigin, Environment, ForkChoiceStrategy, Proposer,
SelectChain,
use sc_consensus::{
block_import::{BlockImport, BlockImportParams, ForkChoiceStrategy},
import_queue::{BasicQueue, BoxBlockImport, Verifier},
};
use sp_blockchain::HeaderBackend;
use sp_consensus::{BlockOrigin, CacheKeyId, Environment, Proposer, SelectChain};
use sp_inherents::CreateInherentDataProviders;
use sp_runtime::{traits::Block as BlockT, ConsensusEngineId, Justifications};
use std::{marker::PhantomData, sync::Arc};
@@ -257,9 +257,9 @@ mod tests {
use super::*;
use sc_basic_authorship::ProposerFactory;
use sc_client_api::BlockBackend;
use sc_consensus::ImportedAux;
use sc_transaction_pool::{BasicPool, Options, RevalidationType};
use sc_transaction_pool_api::{MaintainedTransactionPool, TransactionPool, TransactionSource};
use sp_consensus::ImportedAux;
use sp_runtime::generic::BlockId;
use substrate_test_runtime_client::{
AccountKeyring::*, DefaultTestClientBuilderExt, TestClientBuilder, TestClientBuilderExt,
@@ -25,8 +25,8 @@ use futures::{
};
use jsonrpc_core::Error;
use jsonrpc_derive::rpc;
use sc_consensus::ImportedAux;
use serde::{Deserialize, Serialize};
use sp_consensus::ImportedAux;
use sp_runtime::EncodedJustification;
/// Future's type for jsonrpc
@@ -20,13 +20,11 @@
use crate::{rpc, ConsensusDataProvider, CreatedBlock, Error};
use futures::prelude::*;
use sc_consensus::{BlockImport, BlockImportParams, ForkChoiceStrategy, ImportResult, StateAction};
use sc_transaction_pool_api::TransactionPool;
use sp_api::{ProvideRuntimeApi, TransactionFor};
use sp_blockchain::HeaderBackend;
use sp_consensus::{
self, BlockImport, BlockImportParams, BlockOrigin, Environment, ForkChoiceStrategy,
ImportResult, Proposer, SelectChain, StateAction,
};
use sp_consensus::{self, BlockOrigin, Environment, Proposer, SelectChain};
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider};
use sp_runtime::{
generic::BlockId,
@@ -147,7 +145,7 @@ pub async fn seal_block<B, BI, SC, C, E, TP, CIDP>(
params.body = Some(body);
params.finalized = finalize;
params.fork_choice = Some(ForkChoiceStrategy::LongestChain);
params.state_action = StateAction::ApplyChanges(sp_consensus::StorageChanges::Changes(
params.state_action = StateAction::ApplyChanges(sc_consensus::StorageChanges::Changes(
proposal.storage_changes,
));