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:
Arkadiy Paronyan
2021-11-12 14:15:01 +01:00
committed by GitHub
parent 112b7dac47
commit 4cbbf0cf43
141 changed files with 532 additions and 17807 deletions
+35 -39
View File
@@ -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 {