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

chore: unify noop provider impls #13345

Merged
merged 1 commit into from
Dec 12, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/chain-state/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
mod in_memory;
pub use in_memory::*;

mod noop;

mod chain_info;
pub use chain_info::ChainInfoTracker;

Expand Down
29 changes: 29 additions & 0 deletions crates/chain-state/src/noop.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//! Noop impls for testing.

use crate::{
CanonStateNotifications, CanonStateSubscriptions, ForkChoiceNotifications,
ForkChoiceSubscriptions,
};
use reth_primitives_traits::NodePrimitives;
use reth_storage_api::noop::NoopProvider;
use tokio::sync::{broadcast, watch};

impl<C: Send + Sync, N: NodePrimitives> CanonStateSubscriptions for NoopProvider<C, N> {
fn subscribe_to_canonical_state(&self) -> CanonStateNotifications<N> {
broadcast::channel(1).1
}
}

impl<C: Send + Sync, N: NodePrimitives> ForkChoiceSubscriptions for NoopProvider<C, N> {
type Header = N::BlockHeader;

fn subscribe_safe_block(&self) -> ForkChoiceNotifications<N::BlockHeader> {
let (_, rx) = watch::channel(None);
ForkChoiceNotifications(rx)
}

fn subscribe_finalized_block(&self) -> ForkChoiceNotifications<N::BlockHeader> {
let (_, rx) = watch::channel(None);
ForkChoiceNotifications(rx)
}
}
7 changes: 3 additions & 4 deletions crates/rpc/rpc/src/eth/helpers/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ where

#[cfg(test)]
mod tests {
use super::*;
use alloy_eips::eip1559::ETHEREUM_BLOCK_GAS_LIMIT;
use alloy_primitives::{hex_literal::hex, Bytes};
use reth_chainspec::ChainSpecProvider;
Expand All @@ -71,8 +72,6 @@ mod tests {
use reth_tasks::pool::BlockingTaskPool;
use reth_transaction_pool::{test_utils::testing_pool, TransactionPool};

use super::*;

#[tokio::test]
async fn send_raw_transaction() {
let noop_provider = NoopProvider::default();
Expand All @@ -81,10 +80,10 @@ mod tests {
let pool = testing_pool();

let evm_config = EthEvmConfig::new(noop_provider.chain_spec());
let cache = EthStateCache::spawn(noop_provider, Default::default());
let cache = EthStateCache::spawn(noop_provider.clone(), Default::default());
let fee_history_cache = FeeHistoryCache::new(FeeHistoryCacheConfig::default());
let eth_api = EthApi::new(
noop_provider,
noop_provider.clone(),
pool.clone(),
noop_network_provider,
cache.clone(),
Expand Down
Loading
Loading