mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 20:31:13 +00:00
Kill the light client, CHTs and change tries. (#10080)
* Remove light client, change tries and CHTs * Update tests * fmt * Restore changes_root * Fixed benches * Cargo fmt * fmt * fmt
This commit is contained in:
@@ -33,7 +33,7 @@ use sp_api::{ApiExt, ProvideRuntimeApi};
|
||||
use sp_block_builder::BlockBuilder as BlockBuilderApi;
|
||||
use sp_blockchain::{
|
||||
well_known_cache_keys::{self, Id as CacheKeyId},
|
||||
HeaderBackend, ProvideCache,
|
||||
HeaderBackend,
|
||||
};
|
||||
use sp_consensus::{CanAuthorWith, Error as ConsensusError};
|
||||
use sp_consensus_aura::{
|
||||
@@ -45,7 +45,8 @@ use sp_core::{crypto::Pair, ExecutionContext};
|
||||
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider as _};
|
||||
use sp_runtime::{
|
||||
generic::{BlockId, OpaqueDigestItemId},
|
||||
traits::{Block as BlockT, DigestItemFor, Header},
|
||||
traits::{Block as BlockT, Header},
|
||||
DigestItem,
|
||||
};
|
||||
use std::{fmt::Debug, hash::Hash, marker::PhantomData, sync::Arc};
|
||||
|
||||
@@ -61,9 +62,8 @@ fn check_header<C, B: BlockT, P: Pair>(
|
||||
hash: B::Hash,
|
||||
authorities: &[AuthorityId<P>],
|
||||
check_for_equivocation: CheckForEquivocation,
|
||||
) -> Result<CheckedHeader<B::Header, (Slot, DigestItemFor<B>)>, Error<B>>
|
||||
) -> Result<CheckedHeader<B::Header, (Slot, DigestItem)>, Error<B>>
|
||||
where
|
||||
DigestItemFor<B>: CompatibleDigestItem<P::Signature>,
|
||||
P::Signature: Codec,
|
||||
C: sc_client_api::backend::AuxStore,
|
||||
P::Public: Encode + Decode + PartialEq + Clone,
|
||||
@@ -189,14 +189,8 @@ where
|
||||
#[async_trait::async_trait]
|
||||
impl<B: BlockT, C, P, CAW, CIDP> Verifier<B> for AuraVerifier<C, P, CAW, CIDP>
|
||||
where
|
||||
C: ProvideRuntimeApi<B>
|
||||
+ Send
|
||||
+ Sync
|
||||
+ sc_client_api::backend::AuxStore
|
||||
+ ProvideCache<B>
|
||||
+ BlockOf,
|
||||
C: ProvideRuntimeApi<B> + Send + Sync + sc_client_api::backend::AuxStore + BlockOf,
|
||||
C::Api: BlockBuilderApi<B> + AuraApi<B, AuthorityId<P>> + ApiExt<B>,
|
||||
DigestItemFor<B>: CompatibleDigestItem<P::Signature>,
|
||||
P: Pair + Send + Sync + 'static,
|
||||
P::Public: Send + Sync + Hash + Eq + Clone + Decode + Encode + Debug + 'static,
|
||||
P::Signature: Encode + Decode,
|
||||
@@ -385,7 +379,6 @@ where
|
||||
C: 'static
|
||||
+ ProvideRuntimeApi<Block>
|
||||
+ BlockOf
|
||||
+ ProvideCache<Block>
|
||||
+ Send
|
||||
+ Sync
|
||||
+ AuxStore
|
||||
@@ -395,7 +388,6 @@ where
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
DigestItemFor<Block>: CompatibleDigestItem<P::Signature>,
|
||||
P: Pair + Send + Sync + 'static,
|
||||
P::Public: Clone + Eq + Send + Sync + Hash + Debug + Encode + Decode,
|
||||
P::Signature: Encode + Decode,
|
||||
|
||||
@@ -52,7 +52,7 @@ use sc_consensus_slots::{
|
||||
use sc_telemetry::TelemetryHandle;
|
||||
use sp_api::ProvideRuntimeApi;
|
||||
use sp_application_crypto::{AppKey, AppPublic};
|
||||
use sp_blockchain::{HeaderBackend, ProvideCache, Result as CResult};
|
||||
use sp_blockchain::{HeaderBackend, Result as CResult};
|
||||
use sp_consensus::{
|
||||
BlockOrigin, CanAuthorWith, Environment, Error as ConsensusError, Proposer, SelectChain,
|
||||
};
|
||||
@@ -62,7 +62,8 @@ use sp_inherents::CreateInherentDataProviders;
|
||||
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
|
||||
use sp_runtime::{
|
||||
generic::BlockId,
|
||||
traits::{Block as BlockT, DigestItemFor, Header, Member, NumberFor, Zero},
|
||||
traits::{Block as BlockT, Header, Member, NumberFor, Zero},
|
||||
DigestItem,
|
||||
};
|
||||
|
||||
mod import_queue;
|
||||
@@ -178,7 +179,7 @@ where
|
||||
P::Public: AppPublic + Hash + Member + Encode + Decode,
|
||||
P::Signature: TryFrom<Vec<u8>> + Hash + Member + Encode + Decode,
|
||||
B: BlockT,
|
||||
C: ProvideRuntimeApi<B> + BlockOf + ProvideCache<B> + AuxStore + HeaderBackend<B> + Send + Sync,
|
||||
C: ProvideRuntimeApi<B> + BlockOf + AuxStore + HeaderBackend<B> + Send + Sync,
|
||||
C::Api: AuraApi<B, AuthorityId<P>>,
|
||||
SC: SelectChain<B>,
|
||||
I: BlockImport<B, Transaction = sp_api::TransactionFor<C, B>> + Send + Sync + 'static,
|
||||
@@ -267,7 +268,7 @@ pub fn build_aura_worker<P, B, C, PF, I, SO, L, BS, Error>(
|
||||
) -> impl sc_consensus_slots::SlotWorker<B, <PF::Proposer as Proposer<B>>::Proof>
|
||||
where
|
||||
B: BlockT,
|
||||
C: ProvideRuntimeApi<B> + BlockOf + ProvideCache<B> + AuxStore + HeaderBackend<B> + Send + Sync,
|
||||
C: ProvideRuntimeApi<B> + BlockOf + AuxStore + HeaderBackend<B> + Send + Sync,
|
||||
C::Api: AuraApi<B, AuthorityId<P>>,
|
||||
PF: Environment<B, Error = Error> + Send + Sync + 'static,
|
||||
PF::Proposer: Proposer<B, Error = Error, Transaction = sp_api::TransactionFor<C, B>>,
|
||||
@@ -316,7 +317,7 @@ impl<B, C, E, I, P, Error, SO, L, BS> sc_consensus_slots::SimpleSlotWorker<B>
|
||||
for AuraWorker<C, E, I, P, SO, L, BS>
|
||||
where
|
||||
B: BlockT,
|
||||
C: ProvideRuntimeApi<B> + BlockOf + ProvideCache<B> + HeaderBackend<B> + Sync,
|
||||
C: ProvideRuntimeApi<B> + BlockOf + HeaderBackend<B> + Sync,
|
||||
C::Api: AuraApi<B, AuthorityId<P>>,
|
||||
E: Environment<B, Error = Error> + Send + Sync,
|
||||
E::Proposer: Proposer<B, Error = Error, Transaction = sp_api::TransactionFor<C, B>>,
|
||||
@@ -377,12 +378,8 @@ where
|
||||
})
|
||||
}
|
||||
|
||||
fn pre_digest_data(
|
||||
&self,
|
||||
slot: Slot,
|
||||
_claim: &Self::Claim,
|
||||
) -> Vec<sp_runtime::DigestItem<B::Hash>> {
|
||||
vec![<DigestItemFor<B> as CompatibleDigestItem<P::Signature>>::aura_pre_digest(slot)]
|
||||
fn pre_digest_data(&self, slot: Slot, _claim: &Self::Claim) -> Vec<sp_runtime::DigestItem> {
|
||||
vec![<DigestItem as CompatibleDigestItem<P::Signature>>::aura_pre_digest(slot)]
|
||||
}
|
||||
|
||||
fn block_import_params(
|
||||
@@ -426,7 +423,7 @@ where
|
||||
.map_err(|_| sp_consensus::Error::InvalidSignature(signature, public))?;
|
||||
|
||||
let signature_digest_item =
|
||||
<DigestItemFor<B> as CompatibleDigestItem<P::Signature>>::aura_seal(signature);
|
||||
<DigestItem as CompatibleDigestItem<P::Signature>>::aura_seal(signature);
|
||||
|
||||
let mut import_block = BlockImportParams::new(BlockOrigin::Own, header);
|
||||
import_block.post_digests.push(signature_digest_item);
|
||||
@@ -545,7 +542,7 @@ fn authorities<A, B, C>(client: &C, at: &BlockId<B>) -> Result<Vec<A>, Consensus
|
||||
where
|
||||
A: Codec + Debug,
|
||||
B: BlockT,
|
||||
C: ProvideRuntimeApi<B> + BlockOf + ProvideCache<B>,
|
||||
C: ProvideRuntimeApi<B> + BlockOf,
|
||||
C::Api: AuraApi<B, A>,
|
||||
{
|
||||
client
|
||||
@@ -574,7 +571,10 @@ mod tests {
|
||||
use sp_consensus_aura::sr25519::AuthorityPair;
|
||||
use sp_inherents::InherentData;
|
||||
use sp_keyring::sr25519::Keyring;
|
||||
use sp_runtime::traits::{Block as BlockT, DigestFor, Header as _};
|
||||
use sp_runtime::{
|
||||
traits::{Block as BlockT, Header as _},
|
||||
Digest,
|
||||
};
|
||||
use sp_timestamp::InherentDataProvider as TimestampInherentDataProvider;
|
||||
use std::{
|
||||
task::Poll,
|
||||
@@ -611,7 +611,7 @@ mod tests {
|
||||
fn propose(
|
||||
self,
|
||||
_: InherentData,
|
||||
digests: DigestFor<TestBlock>,
|
||||
digests: Digest,
|
||||
_: Duration,
|
||||
_: Option<usize>,
|
||||
) -> Self::Proposal {
|
||||
@@ -661,29 +661,25 @@ mod tests {
|
||||
_cfg: &ProtocolConfig,
|
||||
_peer_data: &(),
|
||||
) -> Self::Verifier {
|
||||
match client {
|
||||
PeersClient::Full(client, _) => {
|
||||
let slot_duration = slot_duration(&*client).expect("slot duration available");
|
||||
let client = client.as_client();
|
||||
let slot_duration = slot_duration(&*client).expect("slot duration available");
|
||||
|
||||
assert_eq!(slot_duration.slot_duration().as_millis() as u64, SLOT_DURATION);
|
||||
import_queue::AuraVerifier::new(
|
||||
client,
|
||||
Box::new(|_, _| async {
|
||||
let timestamp = TimestampInherentDataProvider::from_system_time();
|
||||
let slot = InherentDataProvider::from_timestamp_and_duration(
|
||||
*timestamp,
|
||||
Duration::from_secs(6),
|
||||
);
|
||||
assert_eq!(slot_duration.slot_duration().as_millis() as u64, SLOT_DURATION);
|
||||
import_queue::AuraVerifier::new(
|
||||
client,
|
||||
Box::new(|_, _| async {
|
||||
let timestamp = TimestampInherentDataProvider::from_system_time();
|
||||
let slot = InherentDataProvider::from_timestamp_and_duration(
|
||||
*timestamp,
|
||||
Duration::from_secs(6),
|
||||
);
|
||||
|
||||
Ok((timestamp, slot))
|
||||
}),
|
||||
AlwaysCanAuthor,
|
||||
CheckForEquivocation::Yes,
|
||||
None,
|
||||
)
|
||||
},
|
||||
PeersClient::Light(_, _) => unreachable!("No (yet) tests for light client + Aura"),
|
||||
}
|
||||
Ok((timestamp, slot))
|
||||
}),
|
||||
AlwaysCanAuthor,
|
||||
CheckForEquivocation::Yes,
|
||||
None,
|
||||
)
|
||||
}
|
||||
|
||||
fn make_block_import(
|
||||
@@ -724,7 +720,7 @@ mod tests {
|
||||
for (peer_id, key) in peers {
|
||||
let mut net = net.lock();
|
||||
let peer = net.peer(*peer_id);
|
||||
let client = peer.client().as_full().expect("full clients are created").clone();
|
||||
let client = peer.client().as_client();
|
||||
let select_chain = peer.select_chain().expect("full client has a select chain");
|
||||
let keystore_path = tempfile::tempdir().expect("Creates keystore path");
|
||||
let keystore = Arc::new(
|
||||
@@ -823,7 +819,7 @@ mod tests {
|
||||
|
||||
let mut net = net.lock();
|
||||
let peer = net.peer(3);
|
||||
let client = peer.client().as_full().expect("full clients are created").clone();
|
||||
let client = peer.client().as_client();
|
||||
let environ = DummyFactory(client.clone());
|
||||
|
||||
let worker = AuraWorker {
|
||||
@@ -875,7 +871,7 @@ mod tests {
|
||||
|
||||
let mut net = net.lock();
|
||||
let peer = net.peer(3);
|
||||
let client = peer.client().as_full().expect("full clients are created").clone();
|
||||
let client = peer.client().as_client();
|
||||
let environ = DummyFactory(client.clone());
|
||||
|
||||
let mut worker = AuraWorker {
|
||||
|
||||
Reference in New Issue
Block a user