Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove async-trait as dependency from crate stages #6771

Merged
merged 2 commits into from Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/stages/Cargo.toml
Expand Up @@ -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

Expand Down
12 changes: 7 additions & 5 deletions crates/stages/src/stage.rs
Expand Up @@ -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},
};
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
}
}

Expand Down
1 change: 0 additions & 1 deletion crates/stages/src/stages/bodies.rs
Expand Up @@ -565,7 +565,6 @@ mod tests {
}
}

#[async_trait::async_trait]
impl ExecuteStageTestRunner for BodyTestRunner {
type Seed = Vec<SealedBlock>;

Expand Down
1 change: 0 additions & 1 deletion crates/stages/src/stages/hashing_account.rs
Expand Up @@ -520,7 +520,6 @@ mod tests {
}
}

#[async_trait::async_trait]
impl ExecuteStageTestRunner for AccountHashingTestRunner {
type Seed = Vec<(Address, Account)>;

Expand Down
1 change: 0 additions & 1 deletion crates/stages/src/stages/hashing_storage.rs
Expand Up @@ -477,7 +477,6 @@ mod tests {
}
}

#[async_trait::async_trait]
impl ExecuteStageTestRunner for StorageHashingTestRunner {
type Seed = Vec<SealedBlock>;

Expand Down
1 change: 0 additions & 1 deletion crates/stages/src/stages/headers.rs
Expand Up @@ -382,7 +382,6 @@ mod tests {
}
}

#[async_trait::async_trait]
impl<D: HeaderDownloader + 'static> ExecuteStageTestRunner for HeadersTestRunner<D> {
type Seed = Vec<SealedHeader>;

Expand Down
1 change: 0 additions & 1 deletion crates/stages/src/stages/merkle.rs
Expand Up @@ -460,7 +460,6 @@ mod tests {
}
}

#[async_trait::async_trait]
impl ExecuteStageTestRunner for MerkleTestRunner {
type Seed = Vec<SealedBlock>;

Expand Down
1 change: 0 additions & 1 deletion crates/stages/src/stages/total_difficulty.rs
Expand Up @@ -224,7 +224,6 @@ mod tests {
}
}

#[async_trait::async_trait]
impl ExecuteStageTestRunner for TotalDifficultyTestRunner {
type Seed = Vec<SealedHeader>;

Expand Down
4 changes: 1 addition & 3 deletions crates/stages/src/test_utils/runner.rs
Expand Up @@ -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;

Expand Down Expand Up @@ -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>;
Expand All @@ -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.
Expand Down