@@ -5,6 +5,9 @@ use std::sync::Arc;
55use apollo_batcher_config:: config:: BatcherConfig ;
66use apollo_batcher_types:: batcher_types:: {
77 BatcherResult ,
8+ BatcherStorageReaderServerHandler ,
9+ BatcherStorageRequest ,
10+ BatcherStorageResponse ,
811 CentralObjects ,
912 DecisionReachedInput ,
1013 DecisionReachedResponse ,
@@ -35,7 +38,13 @@ use apollo_reverts::revert_block;
3538use apollo_state_sync_types:: state_sync_types:: SyncBlock ;
3639use apollo_storage:: metrics:: BATCHER_STORAGE_OPEN_READ_TRANSACTIONS ;
3740use apollo_storage:: state:: { StateStorageReader , StateStorageWriter } ;
38- use apollo_storage:: { open_storage_with_metric, StorageReader , StorageResult , StorageWriter } ;
41+ use apollo_storage:: storage_reader_server:: StorageReaderServer ;
42+ use apollo_storage:: {
43+ open_storage_with_metric_and_server,
44+ StorageReader ,
45+ StorageResult ,
46+ StorageWriter ,
47+ } ;
3948use async_trait:: async_trait;
4049use blockifier:: concurrency:: worker_pool:: WorkerPool ;
4150use blockifier:: state:: contract_class_manager:: ContractClassManager ;
@@ -100,6 +109,11 @@ use crate::utils::{
100109
101110type OutputStreamReceiver = tokio:: sync:: mpsc:: UnboundedReceiver < InternalConsensusTransaction > ;
102111type InputStreamSender = tokio:: sync:: mpsc:: Sender < InternalConsensusTransaction > ;
112+ type BatcherStorageReaderServer = StorageReaderServer <
113+ BatcherStorageReaderServerHandler ,
114+ BatcherStorageRequest ,
115+ BatcherStorageResponse ,
116+ > ;
103117
104118pub struct Batcher {
105119 pub config : BatcherConfig ,
@@ -145,6 +159,11 @@ pub struct Batcher {
145159 /// The proposal commitment of the previous height.
146160 /// This is returned by the decision_reached function.
147161 prev_proposal_commitment : Option < ( BlockNumber , ProposalCommitment ) > ,
162+
163+ // TODO(Nadin): Remove #[allow(dead_code)].
164+ /// Optional storage reader server for handling remote storage reader queries.
165+ #[ allow( dead_code) ]
166+ storage_reader_server : Option < BatcherStorageReaderServer > ,
148167}
149168
150169impl Batcher {
@@ -158,6 +177,7 @@ impl Batcher {
158177 transaction_converter : TransactionConverter ,
159178 block_builder_factory : Box < dyn BlockBuilderFactoryTrait > ,
160179 pre_confirmed_block_writer_factory : Box < dyn PreconfirmedBlockWriterFactoryTrait > ,
180+ storage_reader_server : Option < BatcherStorageReaderServer > ,
161181 ) -> Self {
162182 Self {
163183 config,
@@ -177,6 +197,7 @@ impl Batcher {
177197 // Allow the first few proposals to be without L1 txs while system starts up.
178198 proposals_counter : 1 ,
179199 prev_proposal_commitment : None ,
200+ storage_reader_server,
180201 }
181202 }
182203
@@ -1020,9 +1041,13 @@ pub fn create_batcher(
10201041 class_manager_client : SharedClassManagerClient ,
10211042 pre_confirmed_cende_client : Arc < dyn PreconfirmedCendeClientTrait > ,
10221043) -> Batcher {
1023- let ( storage_reader, storage_writer) =
1024- open_storage_with_metric ( config. storage . clone ( ) , & BATCHER_STORAGE_OPEN_READ_TRANSACTIONS )
1025- . expect ( "Failed to open batcher's storage" ) ;
1044+ let ( storage_reader, storage_writer, storage_reader_server) =
1045+ open_storage_with_metric_and_server (
1046+ config. storage . clone ( ) ,
1047+ & BATCHER_STORAGE_OPEN_READ_TRANSACTIONS ,
1048+ config. storage_reader_server_config . clone ( ) ,
1049+ )
1050+ . expect ( "Failed to open batcher's storage" ) ;
10261051
10271052 let execute_config = & config. block_builder_config . execute_config ;
10281053 let worker_pool = Arc :: new ( WorkerPool :: start ( execute_config) ) ;
@@ -1053,6 +1078,7 @@ pub fn create_batcher(
10531078 transaction_converter,
10541079 block_builder_factory,
10551080 pre_confirmed_block_writer_factory,
1081+ storage_reader_server,
10561082 )
10571083}
10581084
0 commit comments