mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 15:11:03 +00:00
Set StateBackend::Transaction to PrefixedMemoryDB (#14612)
* Yep * Try to get it working everywhere * Make `from_raw_storage` start with an empty db * More fixes! * Make everything compile * Fix `child_storage_root` * Fix after merge * Cleanups * Update primitives/state-machine/src/overlayed_changes/mod.rs Co-authored-by: Davide Galassi <davxy@datawok.net> * Review comments * Fix issues * Silence warning * FMT * Clippy --------- Co-authored-by: Davide Galassi <davxy@datawok.net>
This commit is contained in:
@@ -237,7 +237,7 @@ impl<B: BlockT, I: Clone, C, S: Clone, Algorithm: Clone, CIDP> Clone
|
||||
impl<B, I, C, S, Algorithm, CIDP> PowBlockImport<B, I, C, S, Algorithm, CIDP>
|
||||
where
|
||||
B: BlockT,
|
||||
I: BlockImport<B, Transaction = sp_api::TransactionFor<C, B>> + Send + Sync,
|
||||
I: BlockImport<B> + Send + Sync,
|
||||
I::Error: Into<ConsensusError>,
|
||||
C: ProvideRuntimeApi<B> + Send + Sync + HeaderBackend<B> + AuxStore + BlockOf,
|
||||
C::Api: BlockBuilderApi<B>,
|
||||
@@ -301,7 +301,7 @@ where
|
||||
impl<B, I, C, S, Algorithm, CIDP> BlockImport<B> for PowBlockImport<B, I, C, S, Algorithm, CIDP>
|
||||
where
|
||||
B: BlockT,
|
||||
I: BlockImport<B, Transaction = sp_api::TransactionFor<C, B>> + Send + Sync,
|
||||
I: BlockImport<B> + Send + Sync,
|
||||
I::Error: Into<ConsensusError>,
|
||||
S: SelectChain<B>,
|
||||
C: ProvideRuntimeApi<B> + Send + Sync + HeaderBackend<B> + AuxStore + BlockOf,
|
||||
@@ -311,7 +311,6 @@ where
|
||||
CIDP: CreateInherentDataProviders<B, ()> + Send + Sync,
|
||||
{
|
||||
type Error = ConsensusError;
|
||||
type Transaction = sp_api::TransactionFor<C, B>;
|
||||
|
||||
async fn check_block(
|
||||
&mut self,
|
||||
@@ -322,7 +321,7 @@ where
|
||||
|
||||
async fn import_block(
|
||||
&mut self,
|
||||
mut block: BlockImportParams<B, Self::Transaction>,
|
||||
mut block: BlockImportParams<B>,
|
||||
) -> Result<ImportResult, Self::Error> {
|
||||
let best_header = self
|
||||
.select_chain
|
||||
@@ -444,8 +443,8 @@ where
|
||||
{
|
||||
async fn verify(
|
||||
&mut self,
|
||||
mut block: BlockImportParams<B, ()>,
|
||||
) -> Result<BlockImportParams<B, ()>, String> {
|
||||
mut block: BlockImportParams<B>,
|
||||
) -> Result<BlockImportParams<B>, String> {
|
||||
let hash = block.header.hash();
|
||||
let (checked_header, seal) = self.check_header(block.header)?;
|
||||
|
||||
@@ -460,19 +459,18 @@ where
|
||||
}
|
||||
|
||||
/// The PoW import queue type.
|
||||
pub type PowImportQueue<B, Transaction> = BasicQueue<B, Transaction>;
|
||||
pub type PowImportQueue<B> = BasicQueue<B>;
|
||||
|
||||
/// Import queue for PoW engine.
|
||||
pub fn import_queue<B, Transaction, Algorithm>(
|
||||
block_import: BoxBlockImport<B, Transaction>,
|
||||
pub fn import_queue<B, Algorithm>(
|
||||
block_import: BoxBlockImport<B>,
|
||||
justification_import: Option<BoxJustificationImport<B>>,
|
||||
algorithm: Algorithm,
|
||||
spawner: &impl sp_core::traits::SpawnEssentialNamed,
|
||||
registry: Option<&Registry>,
|
||||
) -> Result<PowImportQueue<B, Transaction>, sp_consensus::Error>
|
||||
) -> Result<PowImportQueue<B>, sp_consensus::Error>
|
||||
where
|
||||
B: BlockT,
|
||||
Transaction: Send + Sync + 'static,
|
||||
Algorithm: PowAlgorithm<B> + Clone + Send + Sync + 'static,
|
||||
Algorithm::Difficulty: Send,
|
||||
{
|
||||
@@ -491,7 +489,7 @@ where
|
||||
/// `pre_runtime` is a parameter that allows a custom additional pre-runtime digest to be inserted
|
||||
/// for blocks being built. This can encode authorship information, or just be a graffiti.
|
||||
pub fn start_mining_worker<Block, C, S, Algorithm, E, SO, L, CIDP>(
|
||||
block_import: BoxBlockImport<Block, sp_api::TransactionFor<C, Block>>,
|
||||
block_import: BoxBlockImport<Block>,
|
||||
client: Arc<C>,
|
||||
select_chain: S,
|
||||
algorithm: Algorithm,
|
||||
@@ -503,18 +501,18 @@ pub fn start_mining_worker<Block, C, S, Algorithm, E, SO, L, CIDP>(
|
||||
timeout: Duration,
|
||||
build_time: Duration,
|
||||
) -> (
|
||||
MiningHandle<Block, Algorithm, C, L, <E::Proposer as Proposer<Block>>::Proof>,
|
||||
MiningHandle<Block, Algorithm, L, <E::Proposer as Proposer<Block>>::Proof>,
|
||||
impl Future<Output = ()>,
|
||||
)
|
||||
where
|
||||
Block: BlockT,
|
||||
C: ProvideRuntimeApi<Block> + BlockchainEvents<Block> + 'static,
|
||||
C: BlockchainEvents<Block> + 'static,
|
||||
S: SelectChain<Block> + 'static,
|
||||
Algorithm: PowAlgorithm<Block> + Clone,
|
||||
Algorithm::Difficulty: Send + 'static,
|
||||
E: Environment<Block> + Send + Sync + 'static,
|
||||
E::Error: std::fmt::Debug,
|
||||
E::Proposer: Proposer<Block, Transaction = sp_api::TransactionFor<C, Block>>,
|
||||
E::Proposer: Proposer<Block>,
|
||||
SO: SyncOracle + Clone + Send + Sync + 'static,
|
||||
L: sc_consensus::JustificationSyncLink<Block>,
|
||||
CIDP: CreateInherentDataProviders<Block, ()>,
|
||||
@@ -632,7 +630,7 @@ where
|
||||
},
|
||||
};
|
||||
|
||||
let build = MiningBuild::<Block, Algorithm, C, _> {
|
||||
let build = MiningBuild::<Block, Algorithm, _> {
|
||||
metadata: MiningMetadata {
|
||||
best_hash,
|
||||
pre_hash: proposal.block.header().hash(),
|
||||
|
||||
@@ -56,16 +56,11 @@ pub struct MiningMetadata<H, D> {
|
||||
}
|
||||
|
||||
/// A build of mining, containing the metadata and the block proposal.
|
||||
pub struct MiningBuild<
|
||||
Block: BlockT,
|
||||
Algorithm: PowAlgorithm<Block>,
|
||||
C: sp_api::ProvideRuntimeApi<Block>,
|
||||
Proof,
|
||||
> {
|
||||
pub struct MiningBuild<Block: BlockT, Algorithm: PowAlgorithm<Block>, Proof> {
|
||||
/// Mining metadata.
|
||||
pub metadata: MiningMetadata<Block::Hash, Algorithm::Difficulty>,
|
||||
/// Mining proposal.
|
||||
pub proposal: Proposal<Block, sp_api::TransactionFor<C, Block>, Proof>,
|
||||
pub proposal: Proposal<Block, Proof>,
|
||||
}
|
||||
|
||||
/// Version of the mining worker.
|
||||
@@ -76,25 +71,22 @@ pub struct Version(usize);
|
||||
pub struct MiningHandle<
|
||||
Block: BlockT,
|
||||
Algorithm: PowAlgorithm<Block>,
|
||||
C: sp_api::ProvideRuntimeApi<Block>,
|
||||
L: sc_consensus::JustificationSyncLink<Block>,
|
||||
Proof,
|
||||
> {
|
||||
version: Arc<AtomicUsize>,
|
||||
algorithm: Arc<Algorithm>,
|
||||
justification_sync_link: Arc<L>,
|
||||
build: Arc<Mutex<Option<MiningBuild<Block, Algorithm, C, Proof>>>>,
|
||||
block_import: Arc<Mutex<BoxBlockImport<Block, sp_api::TransactionFor<C, Block>>>>,
|
||||
build: Arc<Mutex<Option<MiningBuild<Block, Algorithm, Proof>>>>,
|
||||
block_import: Arc<Mutex<BoxBlockImport<Block>>>,
|
||||
}
|
||||
|
||||
impl<Block, Algorithm, C, L, Proof> MiningHandle<Block, Algorithm, C, L, Proof>
|
||||
impl<Block, Algorithm, L, Proof> MiningHandle<Block, Algorithm, L, Proof>
|
||||
where
|
||||
Block: BlockT,
|
||||
C: sp_api::ProvideRuntimeApi<Block>,
|
||||
Algorithm: PowAlgorithm<Block>,
|
||||
Algorithm::Difficulty: 'static + Send,
|
||||
L: sc_consensus::JustificationSyncLink<Block>,
|
||||
sp_api::TransactionFor<C, Block>: Send + 'static,
|
||||
{
|
||||
fn increment_version(&self) {
|
||||
self.version.fetch_add(1, Ordering::SeqCst);
|
||||
@@ -102,7 +94,7 @@ where
|
||||
|
||||
pub(crate) fn new(
|
||||
algorithm: Algorithm,
|
||||
block_import: BoxBlockImport<Block, sp_api::TransactionFor<C, Block>>,
|
||||
block_import: BoxBlockImport<Block>,
|
||||
justification_sync_link: L,
|
||||
) -> Self {
|
||||
Self {
|
||||
@@ -120,7 +112,7 @@ where
|
||||
self.increment_version();
|
||||
}
|
||||
|
||||
pub(crate) fn on_build(&self, value: MiningBuild<Block, Algorithm, C, Proof>) {
|
||||
pub(crate) fn on_build(&self, value: MiningBuild<Block, Algorithm, Proof>) {
|
||||
let mut build = self.build.lock();
|
||||
*build = Some(value);
|
||||
self.increment_version();
|
||||
@@ -224,11 +216,10 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block, Algorithm, C, L, Proof> Clone for MiningHandle<Block, Algorithm, C, L, Proof>
|
||||
impl<Block, Algorithm, L, Proof> Clone for MiningHandle<Block, Algorithm, L, Proof>
|
||||
where
|
||||
Block: BlockT,
|
||||
Algorithm: PowAlgorithm<Block>,
|
||||
C: sp_api::ProvideRuntimeApi<Block>,
|
||||
L: sc_consensus::JustificationSyncLink<Block>,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
|
||||
Reference in New Issue
Block a user