11use crate :: {
22 HostBlockSpec , NotificationSpec , NotificationWithSidecars , RuBlockSpec ,
3- convert:: ToRethPrimitive ,
3+ convert:: to_host_notification ,
44 types:: { CtxProvider , Log , TestCounterInstance , TestErc20Instance , TestLogInstance } ,
55} ;
66use alloy:: {
@@ -14,37 +14,81 @@ use alloy::{
1414 } ,
1515 rpc:: types:: eth:: { TransactionReceipt , TransactionRequest } ,
1616} ;
17- use reth:: transaction_pool:: { TransactionOrigin , TransactionPool , test_utils:: MockTransaction } ;
18- use reth_exex_test_utils:: { Adapter , TestExExHandle } ;
19- use reth_node_api:: FullNodeComponents ;
17+ use reth:: {
18+ api:: FullNodeComponents ,
19+ transaction_pool:: { TransactionOrigin , TransactionPool , test_utils:: MockTransaction } ,
20+ } ;
21+ use reth_exex_test_utils:: Adapter ;
2022use signet_cold:: { ColdStorageReadHandle , mem:: MemColdBackend } ;
21- use signet_host_reth:: decompose_exex_context;
2223use signet_hot:: {
2324 db:: { HotDbRead , UnsafeDbWrite } ,
2425 mem:: MemKv ,
2526} ;
2627use signet_node:: { NodeStatus , SignetNodeBuilder } ;
2728use signet_node_config:: test_utils:: test_config;
29+ use signet_node_types:: { HostNotification , HostNotifier } ;
30+ use signet_rpc:: { ServeConfig , StorageRpcConfig } ;
2831use signet_storage:: { CancellationToken , HistoryRead , HistoryWrite , HotKv , UnifiedStorage } ;
2932use signet_storage_types:: { Account , BlockNumberList , DbSignetEvent , RecoveredTx , SealedHeader } ;
30- use signet_test_utils:: contracts:: counter:: COUNTER_DEPLOY_CODE ;
33+ use signet_test_utils:: { chain :: Chain , contracts:: counter:: COUNTER_DEPLOY_CODE } ;
3134use signet_types:: constants:: { HostPermitted , RollupPermitted , SignetSystemConstants } ;
3235use signet_zenith:: { HostOrders :: OrdersInstance , RollupPassage :: RollupPassageInstance } ;
3336use std:: sync:: {
3437 Arc , Mutex ,
3538 atomic:: { AtomicU64 , Ordering } ,
3639} ;
37- use tokio:: { sync:: watch, task:: JoinHandle } ;
40+ use tokio:: {
41+ sync:: { mpsc, watch} ,
42+ task:: JoinHandle ,
43+ } ;
3844use tracing:: instrument;
3945
46+ /// A channel-backed [`HostNotifier`] for integration tests.
47+ ///
48+ /// Receives [`HostNotification`]s from the test harness and yields them
49+ /// to the signet node's main loop.
50+ pub struct TestHostNotifier {
51+ receiver : mpsc:: UnboundedReceiver < HostNotification < Chain > > ,
52+ }
53+
54+ impl TestHostNotifier {
55+ /// Create a new test notifier from a receiver.
56+ pub const fn new ( receiver : mpsc:: UnboundedReceiver < HostNotification < Chain > > ) -> Self {
57+ Self { receiver }
58+ }
59+ }
60+
61+ impl core:: fmt:: Debug for TestHostNotifier {
62+ fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
63+ f. debug_struct ( "TestHostNotifier" ) . finish_non_exhaustive ( )
64+ }
65+ }
66+
67+ impl HostNotifier for TestHostNotifier {
68+ type Chain = Chain ;
69+ type Error = core:: convert:: Infallible ;
70+
71+ async fn next_notification (
72+ & mut self ,
73+ ) -> Option < Result < HostNotification < Self :: Chain > , Self :: Error > > {
74+ self . receiver . recv ( ) . await . map ( Ok )
75+ }
76+
77+ fn set_head ( & mut self , _block_number : u64 ) { }
78+
79+ fn set_backfill_thresholds ( & mut self , _max_blocks : Option < u64 > ) { }
80+
81+ fn send_finished_height ( & self , _block_number : u64 ) -> Result < ( ) , Self :: Error > {
82+ Ok ( ( ) )
83+ }
84+ }
85+
4086/// Signet Node test context
4187///
4288/// This contains the following:
4389///
44- /// - Reth/ExEx context info
45- /// - The test exex handle, which is used to send notifications to the signet
46- /// instance.
47- /// - The components for the Signet Node instance
90+ /// - A channel sender for host notifications
91+ /// - The reth test components (for pool access)
4892/// - A receiver for the node status (latest block processed)
4993/// - Unified storage backed by in-memory hot and cold storage
5094/// - An alloy provider connected to the Signet Node RPC,
@@ -53,10 +97,10 @@ use tracing::instrument;
5397/// - A set of addresses for testing, each of which has a pre-existing balance
5498/// on the Signet Node chain.
5599pub struct SignetTestContext {
56- /// The test exex handle
57- pub handle : TestExExHandle ,
100+ /// The notification sender for the test host notifier.
101+ pub sender : mpsc :: UnboundedSender < HostNotification < Chain > > ,
58102
59- /// The components for the Signet Node instance
103+ /// The reth test components ( for pool access).
60104 pub components : Adapter ,
61105
62106 /// The Signet Node status receiver
@@ -102,12 +146,9 @@ impl SignetTestContext {
102146 #[ instrument]
103147 pub async fn new ( ) -> ( Self , JoinHandle < eyre:: Result < ( ) > > ) {
104148 let cfg = test_config ( ) ;
105- let ( ctx, handle ) = reth_exex_test_utils:: test_exex_context ( ) . await . unwrap ( ) ;
149+ let ( ctx, _handle ) = reth_exex_test_utils:: test_exex_context ( ) . await . unwrap ( ) ;
106150 let components = ctx. components . clone ( ) ;
107151
108- // Decompose the ExEx context into notifier + configs
109- let decomposed = decompose_exex_context ( ctx) ;
110-
111152 // set up Signet Node storage
112153 let constants = cfg. constants ( ) . unwrap ( ) ;
113154
@@ -152,11 +193,22 @@ impl SignetTestContext {
152193
153194 let alias_oracle: Arc < Mutex < HashSet < Address > > > = Arc :: new ( Mutex :: new ( HashSet :: default ( ) ) ) ;
154195
155- let blob_cacher = crate :: test_blob_cacher ( & cfg, decomposed. pool ) ;
196+ // Create the test host notifier channel
197+ let ( sender, receiver) = mpsc:: unbounded_channel ( ) ;
198+ let notifier = TestHostNotifier { receiver } ;
156199
157- // Build serve config from the Signet test config rather than the
158- // reth defaults (which have IPC/HTTP disabled).
159- let serve_config = signet_rpc:: ServeConfig {
200+ // Build the blob cacher from the reth test pool
201+ let blob_cacher = signet_blobber:: BlobFetcher :: builder ( )
202+ . with_config ( cfg. block_extractor ( ) )
203+ . unwrap ( )
204+ . with_pool ( components. pool ( ) . clone ( ) )
205+ . with_client ( reqwest:: Client :: new ( ) )
206+ . build_cache ( )
207+ . unwrap ( )
208+ . spawn ( ) ;
209+
210+ // Build ServeConfig from the test config's IPC endpoint
211+ let serve_config = ServeConfig {
160212 http : vec ! [ ] ,
161213 http_cors : None ,
162214 ws : vec ! [ ] ,
@@ -165,13 +217,12 @@ impl SignetTestContext {
165217 } ;
166218
167219 let ( node, mut node_status) = SignetNodeBuilder :: new ( cfg. clone ( ) )
168- . with_notifier ( decomposed . notifier )
220+ . with_notifier ( notifier)
169221 . with_storage ( Arc :: clone ( & storage) )
170222 . with_alias_oracle ( Arc :: clone ( & alias_oracle) )
171223 . with_blob_cacher ( blob_cacher)
172224 . with_serve_config ( serve_config)
173- . with_rpc_config ( decomposed. rpc_config )
174- . with_client ( reqwest:: Client :: new ( ) )
225+ . with_rpc_config ( StorageRpcConfig :: default ( ) )
175226 . build ( )
176227 . await
177228 . unwrap ( ) ;
@@ -199,7 +250,7 @@ impl SignetTestContext {
199250 . unwrap ( ) ;
200251
201252 let this = Self {
202- handle ,
253+ sender ,
203254 components,
204255 node_status,
205256 storage,
@@ -304,7 +355,8 @@ impl SignetTestContext {
304355 assert ! ( pool. get_blob( tx_hash) . unwrap( ) . is_some( ) , "Missing blob we just inserted" ) ;
305356 }
306357
307- self . handle . notifications_tx . send ( notification. notification . to_reth ( ) ) . await . unwrap ( ) ;
358+ let host_notification = to_host_notification ( & notification. notification ) ;
359+ self . sender . send ( host_notification) . unwrap ( ) ;
308360 }
309361
310362 /// Send a notification to the Signet Node instance and wait for it to be
0 commit comments