Remove async-trait as dependency from crate stages (#6771)

This commit is contained in:
Abner Zheng
2024-02-26 19:40:15 +08:00
committed by GitHub
parent d3d994cedd
commit 92396b39c4
10 changed files with 8 additions and 16 deletions

1
Cargo.lock generated
View File

@ -6872,7 +6872,6 @@ dependencies = [
"alloy-rlp",
"aquamarine",
"assert_matches",
"async-trait",
"auto_impl",
"criterion",
"futures-util",

View File

@ -33,7 +33,6 @@ revm.workspace = true
# async
tokio = { workspace = true, features = ["sync"] }
tokio-stream.workspace = true
async-trait.workspace = true
futures-util.workspace = true
pin-project.workspace = true

View File

@ -7,7 +7,7 @@ use reth_primitives::{
use reth_provider::{BlockReader, DatabaseProviderRW, ProviderError, TransactionsProvider};
use std::{
cmp::{max, min},
future::poll_fn,
future::{poll_fn, Future},
ops::{Range, RangeInclusive},
task::{Context, Poll},
};
@ -96,7 +96,7 @@ impl ExecInput {
if all_tx_cnt == 0 {
// if there is no more transaction return back.
return Ok((first_tx_num..first_tx_num, start_block..=target_block, true))
return Ok((first_tx_num..first_tx_num, start_block..=target_block, true));
}
// get block of this tx
@ -247,12 +247,14 @@ pub trait Stage<DB: Database>: Send + Sync {
}
/// [Stage] trait extension.
#[async_trait::async_trait]
pub trait StageExt<DB: Database>: Stage<DB> {
/// Utility extension for the `Stage` trait that invokes `Stage::poll_execute_ready`
/// with [poll_fn] context. For more information see [Stage::poll_execute_ready].
async fn execute_ready(&mut self, input: ExecInput) -> Result<(), StageError> {
poll_fn(|cx| self.poll_execute_ready(cx, input)).await
fn execute_ready(
&mut self,
input: ExecInput,
) -> impl Future<Output = Result<(), StageError>> + Send {
poll_fn(move |cx| self.poll_execute_ready(cx, input))
}
}

View File

@ -565,7 +565,6 @@ mod tests {
}
}
#[async_trait::async_trait]
impl ExecuteStageTestRunner for BodyTestRunner {
type Seed = Vec<SealedBlock>;

View File

@ -520,7 +520,6 @@ mod tests {
}
}
#[async_trait::async_trait]
impl ExecuteStageTestRunner for AccountHashingTestRunner {
type Seed = Vec<(Address, Account)>;

View File

@ -477,7 +477,6 @@ mod tests {
}
}
#[async_trait::async_trait]
impl ExecuteStageTestRunner for StorageHashingTestRunner {
type Seed = Vec<SealedBlock>;

View File

@ -382,7 +382,6 @@ mod tests {
}
}
#[async_trait::async_trait]
impl<D: HeaderDownloader + 'static> ExecuteStageTestRunner for HeadersTestRunner<D> {
type Seed = Vec<SealedHeader>;

View File

@ -460,7 +460,6 @@ mod tests {
}
}
#[async_trait::async_trait]
impl ExecuteStageTestRunner for MerkleTestRunner {
type Seed = Vec<SealedBlock>;

View File

@ -224,7 +224,6 @@ mod tests {
}
}
#[async_trait::async_trait]
impl ExecuteStageTestRunner for TotalDifficultyTestRunner {
type Seed = Vec<SealedHeader>;

View File

@ -27,7 +27,6 @@ pub(crate) trait StageTestRunner {
fn stage(&self) -> Self::S;
}
#[async_trait::async_trait]
pub(crate) trait ExecuteStageTestRunner: StageTestRunner {
type Seed: Send + Sync;
@ -63,7 +62,6 @@ pub(crate) trait ExecuteStageTestRunner: StageTestRunner {
}
}
#[async_trait::async_trait]
pub(crate) trait UnwindStageTestRunner: StageTestRunner {
/// Validate the unwind
fn validate_unwind(&self, input: UnwindInput) -> Result<(), TestRunnerError>;
@ -78,7 +76,7 @@ pub(crate) trait UnwindStageTestRunner: StageTestRunner {
provider.commit().expect("failed to commit");
tx.send(result).expect("failed to send result");
});
Box::pin(rx).await.unwrap()
rx.await.unwrap()
}
/// Run a hook before [Stage::unwind]. Required for MerkleStage.