Companion for Substrate#14612 (#2923)

* Companion for Substrate#14612

https://github.com/paritytech/substrate/pull/14612

* Remove patch

* Cargo.lock

* Fix

* Fix compilation

* Fix Fix

* ...

* :face_palm:

* .................

* update lockfile for {"polkadot", "substrate"}

* ".git/.scripts/commands/fmt/fmt.sh"

---------

Co-authored-by: parity-processbot <>
This commit is contained in:
Bastian Köcher
2023-08-17 14:39:09 +02:00
committed by GitHub
parent 061eee1382
commit 02691d94d8
20 changed files with 332 additions and 398 deletions
+5 -7
View File
@@ -406,14 +406,12 @@ mod tests {
// Ensure that we did not include `:code` in the proof.
let proof = block.storage_proof();
let db = proof
.to_storage_proof::<BlakeTwo256>(Some(header.state_root()))
.unwrap()
.0
.into_memory_db();
let backend = sp_state_machine::new_in_mem_hash_key::<BlakeTwo256>()
.update_backend(*header.state_root(), db);
let backend = sp_state_machine::create_proof_check_backend::<BlakeTwo256>(
*header.state_root(),
proof.to_storage_proof::<BlakeTwo256>(None).unwrap().0,
)
.unwrap();
// Should return an error, as it was not included while building the proof.
assert!(backend
@@ -95,8 +95,7 @@ where
RClient: RelayChainInterface,
CIDP: CreateInherentDataProviders<Block, ()> + 'static,
BI: BlockImport<Block> + ParachainBlockImportMarker + Send + Sync + 'static,
Proposer: ProposerInterface<Block, Transaction = BI::Transaction>,
Proposer::Transaction: Sync,
Proposer: ProposerInterface<Block>,
CS: CollatorServiceInterface<Block>,
P: Pair,
P::Public: AppPublic + Member,
@@ -190,7 +189,7 @@ where
.await
.map_err(|e| Box::new(e))?;
let sealed_importable = seal::<_, _, P>(
let sealed_importable = seal::<_, P>(
proposal.block,
proposal.storage_changes,
&slot_claim.author_pub,
@@ -322,12 +321,12 @@ where
}
/// Seal a block with a signature in the header.
pub fn seal<B: BlockT, T, P>(
pub fn seal<B: BlockT, P>(
pre_sealed: B,
storage_changes: StorageChanges<T, HashingFor<B>>,
storage_changes: StorageChanges<HashingFor<B>>,
author_pub: &P::Public,
keystore: &KeystorePtr,
) -> Result<BlockImportParams<B, T>, Box<dyn Error>>
) -> Result<BlockImportParams<B>, Box<dyn Error>>
where
P: Pair,
P::Signature: Codec + TryFrom<Vec<u8>>,
@@ -84,8 +84,7 @@ pub async fn run<Block, P, BI, CIDP, Client, RClient, SO, Proposer, CS>(
CIDP: CreateInherentDataProviders<Block, ()> + 'static,
BI: BlockImport<Block> + ParachainBlockImportMarker + Send + Sync + 'static,
SO: SyncOracle + Send + Sync + Clone + 'static,
Proposer: ProposerInterface<Block, Transaction = BI::Transaction>,
Proposer::Transaction: Sync,
Proposer: ProposerInterface<Block>,
CS: CollatorServiceInterface<Block>,
P: Pair,
P::Public: AppPublic + Member,
@@ -103,8 +103,7 @@ pub async fn run<Block, P, BI, CIDP, Client, Backend, RClient, SO, Proposer, CS>
CIDP: CreateInherentDataProviders<Block, ()> + 'static,
BI: BlockImport<Block> + ParachainBlockImportMarker + Send + Sync + 'static,
SO: SyncOracle + Send + Sync + Clone + 'static,
Proposer: ProposerInterface<Block, Transaction = BI::Transaction>,
Proposer::Transaction: Sync,
Proposer: ProposerInterface<Block>,
CS: CollatorServiceInterface<Block>,
P: Pair,
P::Public: AppPublic + Member,
@@ -89,8 +89,8 @@ where
{
async fn verify(
&mut self,
mut block_params: BlockImportParams<Block, ()>,
) -> Result<BlockImportParams<Block, ()>, String> {
mut block_params: BlockImportParams<Block>,
) -> Result<BlockImportParams<Block>, String> {
// Skip checks that include execution, if being told so, or when importing only state.
//
// This is done for example when gap syncing and it is expected that the block after the gap
@@ -221,7 +221,7 @@ pub fn fully_verifying_import_queue<P, Client, Block: BlockT, I, CIDP>(
spawner: &impl sp_core::traits::SpawnEssentialNamed,
registry: Option<&substrate_prometheus_endpoint::Registry>,
telemetry: Option<TelemetryHandle>,
) -> BasicQueue<Block, I::Transaction>
) -> BasicQueue<Block>
where
P: Pair + 'static,
P::Signature: Codec,
@@ -231,7 +231,6 @@ where
+ Send
+ Sync
+ 'static,
I::Transaction: Send,
Client: ProvideRuntimeApi<Block> + Send + Sync + 'static,
<Client as ProvideRuntimeApi<Block>>::Api: BlockBuilderApi<Block> + AuraApi<Block, P::Public>,
CIDP: CreateInherentDataProviders<Block, ()> + 'static,
@@ -60,7 +60,7 @@ pub fn import_queue<P, Block, I, C, S, CIDP>(
registry,
telemetry,
}: ImportQueueParams<'_, I, C, CIDP, S>,
) -> Result<DefaultImportQueue<Block, C>, sp_consensus::Error>
) -> Result<DefaultImportQueue<Block>, sp_consensus::Error>
where
Block: BlockT,
C::Api: BlockBuilderApi<Block> + AuraApi<Block, P::Public> + ApiExt<Block>,
@@ -72,7 +72,7 @@ where
+ AuxStore
+ UsageProvider<Block>
+ HeaderBackend<Block>,
I: BlockImport<Block, Error = ConsensusError, Transaction = sp_api::TransactionFor<C, Block>>
I: BlockImport<Block, Error = ConsensusError>
+ ParachainBlockImportMarker
+ Send
+ Sync
+1 -6
View File
@@ -118,18 +118,13 @@ where
Client:
ProvideRuntimeApi<B> + BlockOf + AuxStore + HeaderBackend<B> + Send + Sync + 'static,
Client::Api: AuraApi<B, P::Public>,
BI: BlockImport<B, Transaction = sp_api::TransactionFor<Client, B>>
+ ParachainBlockImportMarker
+ Send
+ Sync
+ 'static,
BI: BlockImport<B> + ParachainBlockImportMarker + Send + Sync + 'static,
SO: SyncOracle + Send + Sync + Clone + 'static,
BS: BackoffAuthoringBlocksStrategy<NumberFor<B>> + Send + Sync + 'static,
PF: Environment<B, Error = Error> + Send + Sync + 'static,
PF::Proposer: Proposer<
B,
Error = Error,
Transaction = sp_api::TransactionFor<Client, B>,
ProofRecording = EnableProofRecording,
Proof = <EnableProofRecording as ProofRecording>::Proof,
>,
@@ -51,8 +51,8 @@ pub struct VerifyNothing;
impl<Block: BlockT> Verifier<Block> for VerifyNothing {
async fn verify(
&mut self,
params: BlockImportParams<Block, ()>,
) -> Result<BlockImportParams<Block, ()>, String> {
params: BlockImportParams<Block>,
) -> Result<BlockImportParams<Block>, String> {
Ok(params)
}
}
@@ -64,14 +64,13 @@ pub fn verify_nothing_import_queue<Block: BlockT, I>(
block_import: I,
spawner: &impl sp_core::traits::SpawnEssentialNamed,
registry: Option<&substrate_prometheus_endpoint::Registry>,
) -> BasicQueue<Block, I::Transaction>
) -> BasicQueue<Block>
where
I: BlockImport<Block, Error = ConsensusError>
+ ParachainBlockImportMarker
+ Send
+ Sync
+ 'static,
I::Transaction: Send,
{
BasicQueue::new(VerifyNothing, Box::new(block_import), None, spawner, registry)
}
+1 -2
View File
@@ -143,7 +143,6 @@ where
BE: Backend<Block>,
{
type Error = BI::Error;
type Transaction = BI::Transaction;
async fn check_block(
&mut self,
@@ -154,7 +153,7 @@ where
async fn import_block(
&mut self,
mut params: sc_consensus::BlockImportParams<Block, Self::Transaction>,
mut params: sc_consensus::BlockImportParams<Block>,
) -> Result<sc_consensus::ImportResult, Self::Error> {
// Blocks are stored within the backend by using POST hash.
let hash = params.post_hash();
+3 -8
View File
@@ -50,14 +50,11 @@ impl Error {
/// A type alias for easily referring to the type of a proposal produced by a specific
/// [`Proposer`].
pub type ProposalOf<B, T> = Proposal<B, <T as ProposerInterface<B>>::Transaction, StorageProof>;
pub type ProposalOf<B> = Proposal<B, StorageProof>;
/// An interface for proposers.
#[async_trait]
pub trait ProposerInterface<Block: BlockT> {
/// The underlying DB transaction type produced with the block proposal.
type Transaction: Default + Send + 'static;
/// Propose a collation using the supplied `InherentData` and the provided
/// `ParachainInherentData`.
///
@@ -79,7 +76,7 @@ pub trait ProposerInterface<Block: BlockT> {
inherent_digests: Digest,
max_duration: Duration,
block_size_limit: Option<usize>,
) -> Result<Proposal<Block, Self::Transaction, StorageProof>, Error>;
) -> Result<Proposal<Block, StorageProof>, Error>;
}
/// A simple wrapper around a Substrate proposer for creating collations.
@@ -104,8 +101,6 @@ where
T::Proposer: SubstrateProposer<B, ProofRecording = EnableProofRecording, Proof = StorageProof>,
<T::Proposer as SubstrateProposer<B>>::Error: Send + Sync + 'static,
{
type Transaction = <<T as Environment<B>>::Proposer as SubstrateProposer<B>>::Transaction;
async fn propose(
&mut self,
parent_header: &B::Header,
@@ -114,7 +109,7 @@ where
inherent_digests: Digest,
max_duration: Duration,
block_size_limit: Option<usize>,
) -> Result<Proposal<B, Self::Transaction, StorageProof>, Error> {
) -> Result<Proposal<B, StorageProof>, Error> {
let proposer = self
.inner
.init(parent_header)
@@ -53,8 +53,8 @@ where
{
async fn verify(
&mut self,
mut block_params: BlockImportParams<Block, ()>,
) -> Result<BlockImportParams<Block, ()>, String> {
mut block_params: BlockImportParams<Block>,
) -> Result<BlockImportParams<Block>, String> {
// Skip checks that include execution, if being told so, or when importing only state.
//
// This is done for example when gap syncing and it is expected that the block after the gap
@@ -112,14 +112,13 @@ pub fn import_queue<Client, Block: BlockT, I, CIDP>(
create_inherent_data_providers: CIDP,
spawner: &impl sp_core::traits::SpawnEssentialNamed,
registry: Option<&substrate_prometheus_endpoint::Registry>,
) -> ClientResult<BasicQueue<Block, I::Transaction>>
) -> ClientResult<BasicQueue<Block>>
where
I: BlockImport<Block, Error = ConsensusError>
+ ParachainBlockImportMarker
+ Send
+ Sync
+ 'static,
I::Transaction: Send,
Client: ProvideRuntimeApi<Block> + Send + Sync + 'static,
<Client as ProvideRuntimeApi<Block>>::Api: BlockBuilderApi<Block>,
CIDP: CreateInherentDataProviders<Block, ()> + 'static,
@@ -150,7 +150,6 @@ where
PF: Environment<B> + Send + Sync,
PF::Proposer: Proposer<
B,
Transaction = BI::Transaction,
ProofRecording = EnableProofRecording,
Proof = <EnableProofRecording as ProofRecording>::Proof,
>,
@@ -239,7 +238,6 @@ where
PF: Environment<Block> + Send + Sync + 'static,
PF::Proposer: Proposer<
Block,
Transaction = BI::Transaction,
ProofRecording = EnableProofRecording,
Proof = <EnableProofRecording as ProofRecording>::Proof,
>,