From b8b5805548c103062812820935f1fafc74815f95 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Cornilleau Date: Wed, 23 Jul 2025 10:41:14 +0200 Subject: [PATCH] Tezlink/Node: fix block info lvl 2 mock when non tz1 bootstrap account --- .../bin_node/lib_dev/tezlink/tezos_types.ml | 8 +---- .../bin_node/lib_dev/tezlink/tezos_types.mli | 2 +- .../bin_node/lib_dev/tezlink_services_impl.ml | 4 +-- etherlink/tezt/tests/tezlink.ml | 30 +++++++++++++++++++ 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/etherlink/bin_node/lib_dev/tezlink/tezos_types.ml b/etherlink/bin_node/lib_dev/tezlink/tezos_types.ml index 4d41b5c9734b..b63f68fd9cd4 100644 --- a/etherlink/bin_node/lib_dev/tezlink/tezos_types.ml +++ b/etherlink/bin_node/lib_dev/tezlink/tezos_types.ml @@ -63,13 +63,7 @@ module Contract = struct let of_hex contract = let bytes = Hex.to_bytes_exn (`Hex contract) in - match Data_encoding.Binary.of_bytes_opt implicit_encoding bytes with - | None -> - failwith - "subkey %s is not a contract root, expected a public key hash in \ - hexadecimal representation" - contract - | Some contract -> Lwt_result_syntax.return contract + Data_encoding.Binary.of_bytes_opt implicit_encoding bytes end module Operation = struct diff --git a/etherlink/bin_node/lib_dev/tezlink/tezos_types.mli b/etherlink/bin_node/lib_dev/tezlink/tezos_types.mli index 925fe0baadae..9be1cf7399c5 100644 --- a/etherlink/bin_node/lib_dev/tezlink/tezos_types.mli +++ b/etherlink/bin_node/lib_dev/tezlink/tezos_types.mli @@ -45,7 +45,7 @@ module Contract : sig val of_implicit : Signature.public_key_hash -> t - val of_hex : string -> Signature.public_key_hash tzresult Lwt.t + val of_hex : string -> Signature.public_key_hash option end module Operation : sig diff --git a/etherlink/bin_node/lib_dev/tezlink_services_impl.ml b/etherlink/bin_node/lib_dev/tezlink_services_impl.ml index 863893272c1a..9958be5f46f1 100644 --- a/etherlink/bin_node/lib_dev/tezlink_services_impl.ml +++ b/etherlink/bin_node/lib_dev/tezlink_services_impl.ml @@ -110,8 +110,8 @@ module Make (Backend : Backend) (Block_storage : Tezlink_block_storage_sig.S) : let* contracts_keys = subkeys ~block Tezlink_durable_storage.Path.accounts_index in - let* contracts = - List.map_es Tezlink_durable_storage.contract_of_path contracts_keys + let contracts = + List.filter_map Tezlink_durable_storage.contract_of_path contracts_keys in List.map_es (fun c -> diff --git a/etherlink/tezt/tests/tezlink.ml b/etherlink/tezt/tests/tezlink.ml index 50f41aea78d6..cb56bcb91508 100644 --- a/etherlink/tezt/tests/tezlink.ml +++ b/etherlink/tezt/tests/tezlink.ml @@ -924,6 +924,35 @@ let test_tezlink_reveal = ~error_msg:"Expected %R but got %L") ; unit +let test_tezlink_bootstrap_block_info = + (* This test just makes sure the block info call on block 2 does not fail + catastrophically. We check block 2 in particular because at this level + we mock information to index bootstrap accounts. *) + let contract = Michelson_contracts.concat_hello () in + register_tezlink_test + ~title:"Test of tezlink block info on block 2" + ~tags:["bootstrap"; "block_info"] + ~bootstrap_contracts:[contract] + ~bootstrap_accounts:[Constant.bootstrap1] + @@ fun {sequencer; client; _} _protocol -> + let endpoint = + Client.( + Foreign_endpoint + {(Evm_node.rpc_endpoint_record sequencer) with path = "/tezlink"}) + in + let*@ _ = produce_block sequencer in + let*@ _ = produce_block sequencer in + let* info = + Client.RPC.call ~hooks ~endpoint client @@ RPC.get_chain_block ~block:"2" () + in + Check.( + JSON.(info |-> "header" |-> "level" |> as_int = 2) + int + ~error_msg: + "Expect %R but got %L: we should have been able to get block info for \ + level 2") ; + unit + let test_tezlink_execution = let contract = Michelson_contracts.concat_hello () in register_tezlink_test @@ -1072,4 +1101,5 @@ let () = test_tezlink_block_info [Alpha] ; test_tezlink_storage [Alpha] ; test_tezlink_execution [Alpha] ; + test_tezlink_bootstrap_block_info [Alpha] ; test_tezlink_sandbox () -- GitLab