@@ -39,6 +39,7 @@ func IndexClusterBlockHeight(lctx lockctx.Proof, rw storage.ReaderBatchWriter, c
3939 return fmt .Errorf ("cluster block height already indexed with different block ID: %s vs %s: %w" , existing , blockID , storage .ErrDataMismatch )
4040 }
4141 return nil // for the specified height, the finalized block is already set to `blockID`
42+ }
4243 // We do NOT want to continue with the WRITE UNLESS `storage.ErrNotFound` was received when checking for existing data.
4344 if ! errors .Is (err , storage .ErrNotFound ) {
4445 return fmt .Errorf ("failed to check existing cluster block height index: %w" , err )
@@ -111,11 +112,11 @@ func UpdateClusterFinalizedHeight(lctx lockctx.Proof, rw storage.ReaderBatchWrit
111112 return fmt .Errorf ("failed to check existing finalized height: %w" , err )
112113 }
113114
114- if existing + 1 != number {
115- return fmt .Errorf ("finalization isn't sequential: existing %d, new %d" , existing , number )
115+ if existing + 1 != latestFinalizedHeight {
116+ return fmt .Errorf ("finalization isn't sequential: existing %d, new %d" , existing , latestFinalizedHeight )
116117 }
117118
118- return UpsertByKey (rw .Writer (), key , number )
119+ return UpsertByKey (rw .Writer (), key , latestFinalizedHeight )
119120}
120121
121122// RetrieveClusterFinalizedHeight retrieves the latest finalized cluster block height of the given cluster.
0 commit comments