@@ -160,7 +160,7 @@ where
160160 finalizations_by_height : FC ,
161161 mut finalized_blocks : FB ,
162162 config : Config < P , ES , T , V :: ApplicationBlock , V :: Block , V :: Commitment > ,
163- ) -> ( Self , Mailbox < P :: Scheme , V > , Height ) {
163+ ) -> ( Self , Mailbox < P :: Scheme , V > , Option < Height > ) {
164164 // Initialize cache
165165 let prunable_config = cache:: Config {
166166 partition_prefix : format ! ( "{}-cache" , config. partition_prefix) ,
@@ -178,7 +178,8 @@ where
178178 . await ;
179179
180180 let stream = Stream :: new ( context. child ( "stream" ) , & config. partition_prefix ) . await ;
181- let last_processed_height = stream. processed_height ( ) . unwrap_or_else ( Height :: zero) ;
181+ let last_processed_height = stream. processed_height ( ) ;
182+ let processed_height_floor = last_processed_height. unwrap_or_else ( Height :: zero) ;
182183
183184 // Genesis is a local anchor. A floor finalization is verified and
184185 // resolved after `run` receives the resolver and buffer.
@@ -201,11 +202,13 @@ where
201202 // Create metrics
202203 let finalized_height = context. gauge ( "finalized_height" , "Finalized height of application" ) ;
203204 let processed_height = context. gauge ( "processed_height" , "Processed height of application" ) ;
204- let _ = processed_height. try_set ( last_processed_height. get ( ) ) ;
205+ if let Some ( last_processed_height) = last_processed_height {
206+ let _ = processed_height. try_set ( last_processed_height. get ( ) ) ;
207+ }
205208 let floor = pending_floor_anchor. map_or_else (
206- || Floor :: resolved ( last_processed_height , last_processed_round) ,
209+ || Floor :: resolved ( processed_height_floor , last_processed_round) ,
207210 |finalization| {
208- Floor :: awaiting_anchor ( last_processed_height , last_processed_round, finalization)
211+ Floor :: awaiting_anchor ( processed_height_floor , last_processed_round, finalization)
209212 } ,
210213 ) ;
211214
@@ -241,7 +244,7 @@ where
241244 async fn ensure_genesis_anchor (
242245 finalized_blocks : & mut FB ,
243246 anchor : V :: Block ,
244- last_processed_height : Height ,
247+ last_processed_height : Option < Height > ,
245248 ) {
246249 let anchor_height = anchor. height ( ) ;
247250 let anchor_commitment = V :: commitment ( & anchor) ;
@@ -262,10 +265,12 @@ where
262265 ) ;
263266 }
264267 Ok ( None ) => {
265- if anchor_height < last_processed_height {
268+ if let Some ( existing) =
269+ last_processed_height. filter ( |height| anchor_height < * height)
270+ {
266271 warn ! (
267272 height = %anchor_height,
268- existing = %last_processed_height ,
273+ %existing ,
269274 "ignoring stale anchor"
270275 ) ;
271276 return ;
@@ -675,7 +680,7 @@ where
675680 response. send_lossy ( finalization) ;
676681 }
677682 Message :: GetProcessedHeight { response } => {
678- response. send_lossy ( self . floor . processed_height ( ) ) ;
683+ response. send_lossy ( self . stream . processed_height ( ) ) ;
679684 }
680685 Message :: HintFinalized { height, targets } => {
681686 // Skip if finalization is already available locally.
@@ -2034,7 +2039,13 @@ where
20342039 }
20352040
20362041 /// Returns the latest known finalization round at or below the processed height.
2037- async fn latest_processed_round ( finalizations_by_height : & FC , height : Height ) -> Round {
2042+ async fn latest_processed_round (
2043+ finalizations_by_height : & FC ,
2044+ height : Option < Height > ,
2045+ ) -> Round {
2046+ let Some ( height) = height else {
2047+ return Round :: zero ( ) ;
2048+ } ;
20382049 let Some ( finalization_height) = finalizations_by_height
20392050 . ranges_from ( Height :: zero ( ) )
20402051 . filter_map ( |( start, end) | ( start <= height) . then_some ( end. min ( height) ) )
0 commit comments