Skip to content

Commit

Permalink
chore: unify noop provider impls (#13345)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Dec 12, 2024
1 parent aca4a2d commit 90fcfb9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 572 deletions.
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

0 comments on commit 90fcfb9

Please sign in to comment.