@@ -42,9 +42,25 @@ let main ~archive_uri () =
4242 ~metadata: [ (" error" , `String (Caqti_error. show msg)) ] ;
4343 exit 1
4444 in
45- (* filter out genesis block *)
45+ (* filters out genesis or first fork block. This is needed as they are not considered missing and
46+ archive blocks can start from block with height > 1 in case of sandbox network forked from devnet/mainnet.
47+ Archive of such network won't include genesis block but fork block as a first block *)
48+ let % bind genesis_or_fork_block_height =
49+ match % bind
50+ Mina_caqti.Pool. use
51+ (fun db -> Sql.GenesisOrFirstForkBlockHeight. run db () )
52+ pool
53+ with
54+ | Ok height ->
55+ return height
56+ | Error msg ->
57+ [% log error] " Error getting genesis or first fork block height"
58+ ~metadata: [ (" error" , `String (Caqti_error. show msg)) ] ;
59+ exit 1
60+ in
4661 let missing_blocks =
47- List. filter missing_blocks_raw ~f: (fun (_ , _ , height , _ ) -> height <> 1 )
62+ List. filter missing_blocks_raw ~f: (fun (_ , _ , height , _ ) ->
63+ height <> genesis_or_fork_block_height )
4864 in
4965 let % bind () =
5066 if List. is_empty missing_blocks then
@@ -134,8 +150,14 @@ let main ~archive_uri () =
134150 [% log info] " Length of canonical chain is %Ld blocks" chain_len
135151 else (
136152 add_error chain_length_error ;
137- [% log info] " Length of canonical chain is %Ld blocks, expected: %Ld"
138- chain_len highest_canonical ) ;
153+ if genesis_or_fork_block_height = 1 then
154+ [% log info] " Length of canonical chain is %Ld blocks, expected: %Ld"
155+ chain_len highest_canonical
156+ else
157+ [% log info]
158+ " Length of canonical chain is %Ld blocks, expected: %Ld. (Note: \
159+ genesis or first fork block has height %d)"
160+ chain_len highest_canonical genesis_or_fork_block_height ) ;
139161 let invalid_chain =
140162 List. filter canonical_chain
141163 ~f: (fun (_block_id , _state_hash , chain_status ) ->
0 commit comments