From 029b326edfc5614ee18ab4246d983ff2d4e8a189 Mon Sep 17 00:00:00 2001 From: arnaud Date: Thu, 22 May 2025 10:42:12 +0200 Subject: [PATCH 1/3] L2/Node: Introduce a function to read block_hash in the store and expose it in block_storage_sig --- etherlink/bin_node/lib_dev/block_storage_sig.ml | 6 ++++-- etherlink/bin_node/lib_dev/evm_ro_context.ml | 11 +++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/etherlink/bin_node/lib_dev/block_storage_sig.ml b/etherlink/bin_node/lib_dev/block_storage_sig.ml index bf97f59ccb07..f0aef9e94a85 100644 --- a/etherlink/bin_node/lib_dev/block_storage_sig.ml +++ b/etherlink/bin_node/lib_dev/block_storage_sig.ml @@ -21,10 +21,12 @@ module type S = sig Z.t -> Transaction_object.t Ethereum_types.block tzresult Lwt.t - (** [tez_nth_block n] returns the [n]th processed and stored tez block. - *) + (** [tez_nth_block n] returns the [n]th processed and stored tez block. *) val tez_nth_block : Z.t -> L2_types.Tezos_block.t tzresult Lwt.t + (** [nth_block_hash n] returns the hash of the [n]th processed and stored block. *) + val nth_block_hash : Z.t -> Ethereum_types.block_hash option tzresult Lwt.t + (** [block_by_hash ~full_transaction_object hash] returns the block with the given [hash]. diff --git a/etherlink/bin_node/lib_dev/evm_ro_context.ml b/etherlink/bin_node/lib_dev/evm_ro_context.ml index a45a186a8a16..e7dcee721239 100644 --- a/etherlink/bin_node/lib_dev/evm_ro_context.ml +++ b/etherlink/bin_node/lib_dev/evm_ro_context.ml @@ -509,6 +509,10 @@ let ro_backend ?evm_node_endpoint ctxt config : (module Services_backend_sig.S) | None -> failwith "Block %a not found" Z.pp_print level | Some block -> return block + let nth_block_hash level = + Evm_store.use ctxt.store @@ fun conn -> + Evm_store.Blocks.find_hash_of_number conn (Qty level) + let block_by_hash ~full_transaction_object hash = let open Lwt_result_syntax in Evm_store.use ctxt.store @@ fun conn -> @@ -582,10 +586,9 @@ let ro_backend ?evm_node_endpoint ctxt config : (module Services_backend_sig.S) need to try to reconstruct the transaction objects. *) return block - let tez_nth_block level = - let open Lwt_result_syntax in - let* block = Block_storage.tez_nth_block level in - return block + let tez_nth_block = Block_storage.tez_nth_block + + let nth_block_hash = Block_storage.nth_block_hash let block_by_hash ~full_transaction_object hash = let open Lwt_result_syntax in -- GitLab From 777e1aeb923d26ddb875c1c4751b1ca8a399a8df Mon Sep 17 00:00:00 2001 From: arnaud Date: Thu, 22 May 2025 10:45:54 +0200 Subject: [PATCH 2/3] L2/Node: Overwrites Tezlink backend to stop using the one that uses the durable_storage --- etherlink/bin_node/lib_dev/evm_ro_context.ml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/etherlink/bin_node/lib_dev/evm_ro_context.ml b/etherlink/bin_node/lib_dev/evm_ro_context.ml index e7dcee721239..a09624d74108 100644 --- a/etherlink/bin_node/lib_dev/evm_ro_context.ml +++ b/etherlink/bin_node/lib_dev/evm_ro_context.ml @@ -555,6 +555,17 @@ let ro_backend ?evm_node_endpoint ctxt config : (module Services_backend_sig.S) failwith "Missing block %a" Ethereum_types.pp_block_hash hash) | param -> block_param_to_block_number param + (* Overwrites Tezlink_backend using the store instead of the durable_storage *) + module Tezlink_backend = Tezlink_services_impl.Make (struct + include Backend.Reader + + let block_param_to_block_number = block_param_to_block_number + + let tez_nth_block = Block_storage.tez_nth_block + + let nth_block_hash = Block_storage.nth_block_hash + end) + include Tracer_sig.Make (Executor) (Block_storage) (Tracer) end) else -- GitLab From 0ae81b8ba91de79bee27b4f2c0e73f7c9bbe4799 Mon Sep 17 00:00:00 2001 From: arnaud Date: Fri, 23 May 2025 15:28:05 +0200 Subject: [PATCH 3/3] Tezlink/Tezt: Modify the header tezt tests to retrieve the block with 'head~1' offset --- etherlink/tezt/tests/evm_sequencer.ml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index 65bf45e13500..c9f71c1568ed 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -748,7 +748,9 @@ let test_tezlink_chain_id = unit let test_tezlink_header = - register_tezlink_test ~title:"Test of the header rpc" ~tags:["rpc"; "header"] + register_tezlink_test + ~title:"Test of the header rpc" + ~tags:["rpc"; "header"; "offset"] @@ fun {sequencer; client; l2_chains; _} _protocol -> let chain_id = match l2_chains with @@ -764,16 +766,16 @@ let test_tezlink_header = let*@ n = Rpc.produce_block sequencer in let* () = Evm_node.wait_for_blueprint_applied sequencer n in - let* block_1 = - Client.RPC.call ~hooks ~endpoint client @@ RPC.get_chain_block_header () - in - let current_timestamp = Tezos_base.Time.( System.now () |> System.to_protocol |> Protocol.to_notation) in let*@ n = Rpc.produce_block ~timestamp:current_timestamp sequencer in let* () = Evm_node.wait_for_blueprint_applied sequencer n in + let* block_1 = + Client.RPC.call ~hooks ~endpoint client + @@ RPC.get_chain_block_header ~block:"head~1" () + in let* block_2 = Client.RPC.call ~hooks ~endpoint client @@ RPC.get_chain_block_header () in -- GitLab