mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 22:11:06 +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:
@@ -492,11 +492,8 @@ where
|
||||
C::Api: BabeApi<B>,
|
||||
SC: SelectChain<B> + 'static,
|
||||
E: Environment<B, Error = Error> + Send + Sync + 'static,
|
||||
E::Proposer: Proposer<B, Error = Error, Transaction = sp_api::TransactionFor<C, B>>,
|
||||
I: BlockImport<B, Error = ConsensusError, Transaction = sp_api::TransactionFor<C, B>>
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
E::Proposer: Proposer<B, Error = Error>,
|
||||
I: BlockImport<B, Error = ConsensusError> + Send + Sync + 'static,
|
||||
SO: SyncOracle + Send + Sync + Clone + 'static,
|
||||
L: sc_consensus::JustificationSyncLink<B> + 'static,
|
||||
CIDP: CreateInherentDataProviders<B, ()> + Send + Sync + 'static,
|
||||
@@ -727,8 +724,8 @@ where
|
||||
C: ProvideRuntimeApi<B> + HeaderBackend<B> + HeaderMetadata<B, Error = ClientError>,
|
||||
C::Api: BabeApi<B>,
|
||||
E: Environment<B, Error = Error> + Sync,
|
||||
E::Proposer: Proposer<B, Error = Error, Transaction = sp_api::TransactionFor<C, B>>,
|
||||
I: BlockImport<B, Transaction = sp_api::TransactionFor<C, B>> + Send + Sync + 'static,
|
||||
E::Proposer: Proposer<B, Error = Error>,
|
||||
I: BlockImport<B> + Send + Sync + 'static,
|
||||
SO: SyncOracle + Send + Clone + Sync,
|
||||
L: sc_consensus::JustificationSyncLink<B>,
|
||||
BS: BackoffAuthoringBlocksStrategy<NumberFor<B>> + Sync,
|
||||
@@ -822,13 +819,10 @@ where
|
||||
header: B::Header,
|
||||
header_hash: &B::Hash,
|
||||
body: Vec<B::Extrinsic>,
|
||||
storage_changes: StorageChanges<<Self::BlockImport as BlockImport<B>>::Transaction, B>,
|
||||
storage_changes: StorageChanges<B>,
|
||||
(_, public): Self::Claim,
|
||||
epoch_descriptor: Self::AuxData,
|
||||
) -> Result<
|
||||
BlockImportParams<B, <Self::BlockImport as BlockImport<B>>::Transaction>,
|
||||
ConsensusError,
|
||||
> {
|
||||
) -> Result<BlockImportParams<B>, ConsensusError> {
|
||||
let signature = self
|
||||
.keystore
|
||||
.sr25519_sign(<AuthorityId as AppCrypto>::ID, public.as_ref(), header_hash.as_ref())
|
||||
@@ -1137,8 +1131,8 @@ where
|
||||
{
|
||||
async fn verify(
|
||||
&mut self,
|
||||
mut block: BlockImportParams<Block, ()>,
|
||||
) -> Result<BlockImportParams<Block, ()>, String> {
|
||||
mut block: BlockImportParams<Block>,
|
||||
) -> Result<BlockImportParams<Block>, String> {
|
||||
trace!(
|
||||
target: LOG_TARGET,
|
||||
"Verifying origin: {:?} header: {:?} justification(s): {:?} body: {:?}",
|
||||
@@ -1336,7 +1330,7 @@ impl<Block: BlockT, Client, I> BabeBlockImport<Block, Client, I> {
|
||||
impl<Block, Client, Inner> BabeBlockImport<Block, Client, Inner>
|
||||
where
|
||||
Block: BlockT,
|
||||
Inner: BlockImport<Block, Transaction = sp_api::TransactionFor<Client, Block>> + Send + Sync,
|
||||
Inner: BlockImport<Block> + Send + Sync,
|
||||
Inner::Error: Into<ConsensusError>,
|
||||
Client: HeaderBackend<Block>
|
||||
+ HeaderMetadata<Block, Error = sp_blockchain::Error>
|
||||
@@ -1351,7 +1345,7 @@ where
|
||||
// end up in an inconsistent state and have to resync.
|
||||
async fn import_state(
|
||||
&mut self,
|
||||
mut block: BlockImportParams<Block, sp_api::TransactionFor<Client, Block>>,
|
||||
mut block: BlockImportParams<Block>,
|
||||
) -> Result<ImportResult, ConsensusError> {
|
||||
let hash = block.post_hash();
|
||||
let parent_hash = *block.header.parent_hash();
|
||||
@@ -1400,7 +1394,7 @@ where
|
||||
impl<Block, Client, Inner> BlockImport<Block> for BabeBlockImport<Block, Client, Inner>
|
||||
where
|
||||
Block: BlockT,
|
||||
Inner: BlockImport<Block, Transaction = sp_api::TransactionFor<Client, Block>> + Send + Sync,
|
||||
Inner: BlockImport<Block> + Send + Sync,
|
||||
Inner::Error: Into<ConsensusError>,
|
||||
Client: HeaderBackend<Block>
|
||||
+ HeaderMetadata<Block, Error = sp_blockchain::Error>
|
||||
@@ -1411,11 +1405,10 @@ where
|
||||
Client::Api: BabeApi<Block> + ApiExt<Block>,
|
||||
{
|
||||
type Error = ConsensusError;
|
||||
type Transaction = sp_api::TransactionFor<Client, Block>;
|
||||
|
||||
async fn import_block(
|
||||
&mut self,
|
||||
mut block: BlockImportParams<Block, Self::Transaction>,
|
||||
mut block: BlockImportParams<Block>,
|
||||
) -> Result<ImportResult, Self::Error> {
|
||||
let hash = block.post_hash();
|
||||
let number = *block.header.number();
|
||||
@@ -1827,15 +1820,9 @@ pub fn import_queue<Block: BlockT, Client, SelectChain, BI, CIDP, Spawn>(
|
||||
telemetry,
|
||||
offchain_tx_pool_factory,
|
||||
}: ImportQueueParams<'_, Block, BI, Client, CIDP, SelectChain, Spawn>,
|
||||
) -> ClientResult<(DefaultImportQueue<Block, Client>, BabeWorkerHandle<Block>)>
|
||||
) -> ClientResult<(DefaultImportQueue<Block>, BabeWorkerHandle<Block>)>
|
||||
where
|
||||
BI: BlockImport<
|
||||
Block,
|
||||
Error = ConsensusError,
|
||||
Transaction = sp_api::TransactionFor<Client, Block>,
|
||||
> + Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
BI: BlockImport<Block, Error = ConsensusError> + Send + Sync + 'static,
|
||||
Client: ProvideRuntimeApi<Block>
|
||||
+ HeaderBackend<Block>
|
||||
+ HeaderMetadata<Block, Error = sp_blockchain::Error>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
use super::*;
|
||||
use authorship::claim_slot;
|
||||
use sc_block_builder::{BlockBuilder, BlockBuilderProvider};
|
||||
use sc_client_api::{backend::TransactionFor, BlockchainEvents, Finalizer};
|
||||
use sc_client_api::{BlockchainEvents, Finalizer};
|
||||
use sc_consensus::{BoxBlockImport, BoxJustificationImport};
|
||||
use sc_consensus_epochs::{EpochIdentifier, EpochIdentifierPosition};
|
||||
use sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging;
|
||||
@@ -97,16 +97,7 @@ impl DummyProposer {
|
||||
fn propose_with(
|
||||
&mut self,
|
||||
pre_digests: Digest,
|
||||
) -> future::Ready<
|
||||
Result<
|
||||
Proposal<
|
||||
TestBlock,
|
||||
sc_client_api::TransactionFor<substrate_test_runtime_client::Backend, TestBlock>,
|
||||
(),
|
||||
>,
|
||||
Error,
|
||||
>,
|
||||
> {
|
||||
) -> future::Ready<Result<Proposal<TestBlock, ()>, Error>> {
|
||||
let block_builder =
|
||||
self.factory.client.new_block_at(self.parent_hash, pre_digests, false).unwrap();
|
||||
|
||||
@@ -124,9 +115,7 @@ impl DummyProposer {
|
||||
|
||||
impl Proposer<TestBlock> for DummyProposer {
|
||||
type Error = Error;
|
||||
type Transaction =
|
||||
sc_client_api::TransactionFor<substrate_test_runtime_client::Backend, TestBlock>;
|
||||
type Proposal = future::Ready<Result<Proposal<TestBlock, Self::Transaction, ()>, Error>>;
|
||||
type Proposal = future::Ready<Result<Proposal<TestBlock, ()>, Error>>;
|
||||
type ProofRecording = DisableProofRecording;
|
||||
type Proof = ();
|
||||
|
||||
@@ -151,15 +140,13 @@ pub struct PanickingBlockImport<B>(B);
|
||||
#[async_trait::async_trait]
|
||||
impl<B: BlockImport<TestBlock>> BlockImport<TestBlock> for PanickingBlockImport<B>
|
||||
where
|
||||
B::Transaction: Send,
|
||||
B: Send,
|
||||
{
|
||||
type Error = B::Error;
|
||||
type Transaction = B::Transaction;
|
||||
|
||||
async fn import_block(
|
||||
&mut self,
|
||||
block: BlockImportParams<TestBlock, Self::Transaction>,
|
||||
block: BlockImportParams<TestBlock>,
|
||||
) -> Result<ImportResult, Self::Error> {
|
||||
Ok(self.0.import_block(block).await.expect("importing block failed"))
|
||||
}
|
||||
@@ -207,8 +194,8 @@ impl Verifier<TestBlock> for TestVerifier {
|
||||
/// presented to the User in the logs.
|
||||
async fn verify(
|
||||
&mut self,
|
||||
mut block: BlockImportParams<TestBlock, ()>,
|
||||
) -> Result<BlockImportParams<TestBlock, ()>, String> {
|
||||
mut block: BlockImportParams<TestBlock>,
|
||||
) -> Result<BlockImportParams<TestBlock>, String> {
|
||||
// apply post-sealing mutations (i.e. stripping seal, if desired).
|
||||
(self.mutator)(&mut block.header, Stage::PostSeal);
|
||||
self.inner.verify(block).await
|
||||
@@ -217,14 +204,7 @@ impl Verifier<TestBlock> for TestVerifier {
|
||||
|
||||
pub struct PeerData {
|
||||
link: BabeLink<TestBlock>,
|
||||
block_import: Mutex<
|
||||
Option<
|
||||
BoxBlockImport<
|
||||
TestBlock,
|
||||
TransactionFor<substrate_test_runtime_client::Backend, TestBlock>,
|
||||
>,
|
||||
>,
|
||||
>,
|
||||
block_import: Mutex<Option<BoxBlockImport<TestBlock>>>,
|
||||
}
|
||||
|
||||
impl TestNetFactory for BabeTestNet {
|
||||
@@ -249,7 +229,7 @@ impl TestNetFactory for BabeTestNet {
|
||||
let block_import = PanickingBlockImport(block_import);
|
||||
|
||||
let data_block_import =
|
||||
Mutex::new(Some(Box::new(block_import.clone()) as BoxBlockImport<_, _>));
|
||||
Mutex::new(Some(Box::new(block_import.clone()) as BoxBlockImport<_>));
|
||||
(
|
||||
BlockImportAdapter::new(block_import),
|
||||
None,
|
||||
@@ -630,11 +610,11 @@ fn claim_vrf_check() {
|
||||
}
|
||||
|
||||
// Propose and import a new BABE block on top of the given parent.
|
||||
async fn propose_and_import_block<Transaction: Send + 'static>(
|
||||
async fn propose_and_import_block(
|
||||
parent: &TestHeader,
|
||||
slot: Option<Slot>,
|
||||
proposer_factory: &mut DummyFactory,
|
||||
block_import: &mut BoxBlockImport<TestBlock, Transaction>,
|
||||
block_import: &mut BoxBlockImport<TestBlock>,
|
||||
) -> Hash {
|
||||
let mut proposer = proposer_factory.init(parent).await.unwrap();
|
||||
|
||||
@@ -701,10 +681,10 @@ async fn propose_and_import_block<Transaction: Send + 'static>(
|
||||
// Propose and import n valid BABE blocks that are built on top of the given parent.
|
||||
// The proposer takes care of producing epoch change digests according to the epoch
|
||||
// duration (which is set to 6 slots in the test runtime).
|
||||
async fn propose_and_import_blocks<Transaction: Send + 'static>(
|
||||
async fn propose_and_import_blocks(
|
||||
client: &PeersFullClient,
|
||||
proposer_factory: &mut DummyFactory,
|
||||
block_import: &mut BoxBlockImport<TestBlock, Transaction>,
|
||||
block_import: &mut BoxBlockImport<TestBlock>,
|
||||
parent_hash: Hash,
|
||||
n: usize,
|
||||
) -> Vec<Hash> {
|
||||
|
||||
Reference in New Issue
Block a user