@@ -4,7 +4,7 @@ use std::{
44} ;
55
66use anyhow:: anyhow;
7- use forester_utils:: { forester_epoch:: EpochPhases , utils :: wait_for_indexer } ;
7+ use forester_utils:: forester_epoch:: EpochPhases ;
88use light_client:: rpc:: Rpc ;
99use light_compressed_account:: QueueType ;
1010use solana_sdk:: pubkey:: Pubkey ;
@@ -14,7 +14,6 @@ use tracing::{debug, info, warn};
1414use crate :: {
1515 epoch_manager:: { CircuitMetrics , ProcessingMetrics } ,
1616 errors:: ForesterError ,
17- logging:: should_emit_rate_limited_warning,
1817 processor:: v2:: {
1918 batch_job_builder:: BatchJobBuilder ,
2019 common:: WorkerPool ,
@@ -136,6 +135,20 @@ where
136135 self . worker_pool = Some ( WorkerPool { job_tx } ) ;
137136 }
138137
138+ if self . cached_state . is_some ( ) {
139+ let onchain_root = self . strategy . fetch_onchain_root ( & self . context ) . await ?;
140+ if onchain_root != self . current_root {
141+ warn ! (
142+ tree = %self . context. merkle_tree,
143+ expected_root_prefix = ?& self . current_root[ ..4 ] ,
144+ onchain_root_prefix = ?& onchain_root[ ..4 ] ,
145+ "Discarding cached proof state because the on-chain root advanced"
146+ ) ;
147+ self . current_root = onchain_root;
148+ self . clear_cache ( ) . await ;
149+ }
150+ }
151+
139152 if let Some ( cached) = self . cached_state . take ( ) {
140153 let actual_available = self
141154 . strategy
@@ -188,26 +201,6 @@ where
188201 ) ;
189202 }
190203
191- {
192- let rpc = self . context . rpc_pool . get_connection ( ) . await ?;
193- if let Err ( e) = wait_for_indexer ( & * rpc) . await {
194- if should_emit_rate_limited_warning ( "v2_wait_for_indexer" , Duration :: from_secs ( 30 ) )
195- {
196- warn ! (
197- event = "wait_for_indexer_error" ,
198- error = %e,
199- "wait_for_indexer error (proceeding anyway)"
200- ) ;
201- } else {
202- debug ! (
203- event = "wait_for_indexer_error_suppressed" ,
204- error = %e,
205- "Suppressing repeated wait_for_indexer warning"
206- ) ;
207- }
208- }
209- }
210-
211204 let queue_data = match self
212205 . strategy
213206 . fetch_queue_data ( & self . context , fetch_batches, self . zkp_batch_size )
@@ -217,14 +210,6 @@ where
217210 None => return Ok ( ProcessingResult :: default ( ) ) ,
218211 } ;
219212
220- if self . current_root == [ 0u8 ; 32 ] || queue_data. initial_root == self . current_root {
221- let total_batches = queue_data. num_batches ;
222- let process_now = total_batches. min ( self . context . max_batches_per_tree ) ;
223- return self
224- . process_batches ( queue_data, 0 , process_now, total_batches)
225- . await ;
226- }
227-
228213 let onchain_root = self . strategy . fetch_onchain_root ( & self . context ) . await ?;
229214 match reconcile_roots ( self . current_root , queue_data. initial_root , onchain_root) {
230215 RootReconcileDecision :: Proceed => {
0 commit comments