From b932f081f7627b031664bab4f55af03c31bde23b Mon Sep 17 00:00:00 2001 From: Dibassi Brahima Date: Wed, 16 Apr 2025 16:16:21 +0200 Subject: [PATCH 1/7] EVM/Node/KernelConfig : Refactor make_l2 tez_bootstrap_accounts handling to use public keys --- etherlink/bin_node/lib_dev/kernel_config.ml | 24 +++++++++++-------- etherlink/bin_node/lib_dev/kernel_config.mli | 2 +- .../bin_node/lib_dev/tezlink/tezos_types.ml | 7 ++---- .../bin_node/lib_dev/tezlink/tezos_types.mli | 3 +-- etherlink/bin_node/main.ml | 9 ++++--- etherlink/tezt/lib/evm_node.ml | 2 +- .../evm_sequencer.ml/EVM Node- man.out | 4 ++-- 7 files changed, 25 insertions(+), 26 deletions(-) diff --git a/etherlink/bin_node/lib_dev/kernel_config.ml b/etherlink/bin_node/lib_dev/kernel_config.ml index ade3afd22380..472f298a03a8 100644 --- a/etherlink/bin_node/lib_dev/kernel_config.ml +++ b/etherlink/bin_node/lib_dev/kernel_config.ml @@ -110,17 +110,21 @@ let make_l2 ~eth_bootstrap_balance ~tez_bootstrap_balance match tez_bootstrap_accounts with | None -> [] | Some tez_bootstrap_accounts -> + let open Tezos_types in List.map - (fun address -> - make_instr - ~path_prefix: - (Tezlink_services_impl.Path.account address - |> String.split_on_char '/' |> clean_path) - (Some - ( "balance", - Data_encoding.Binary.to_string_exn - Tezos_types.Tez.encoding - tez_bootstrap_balance ))) + (fun manager -> + let make_account_field key value converter = + let path_prefix = + manager |> Signature.V1.Public_key.hash |> Contract.of_implicit + |> Tezlink_services_impl.Path.account + |> String.split_on_char '/' |> clean_path + in + make_instr ~path_prefix (Some (key, converter value)) + in + make_account_field + "balance" + tez_bootstrap_balance + (Data_encoding.Binary.to_string_exn Tez.encoding)) tez_bootstrap_accounts |> List.flatten in diff --git a/etherlink/bin_node/lib_dev/kernel_config.mli b/etherlink/bin_node/lib_dev/kernel_config.mli index 9d2691a63545..9091e37634b7 100644 --- a/etherlink/bin_node/lib_dev/kernel_config.mli +++ b/etherlink/bin_node/lib_dev/kernel_config.mli @@ -54,7 +54,7 @@ val make_l2 : eth_bootstrap_balance:Z.t -> tez_bootstrap_balance:Tezos_types.Tez.t -> ?eth_bootstrap_accounts:Ethereum_types.address list -> - ?tez_bootstrap_accounts:Tezos_types.Contract.t list -> + ?tez_bootstrap_accounts:Signature.V1.Public_key.t list -> ?minimum_base_fee_per_gas:string * string -> ?da_fee_per_byte:string * string -> ?sequencer_pool_address:string * string -> diff --git a/etherlink/bin_node/lib_dev/tezlink/tezos_types.ml b/etherlink/bin_node/lib_dev/tezlink/tezos_types.ml index 899f298bf420..ef04522b581d 100644 --- a/etherlink/bin_node/lib_dev/tezlink/tezos_types.ml +++ b/etherlink/bin_node/lib_dev/tezlink/tezos_types.ml @@ -52,14 +52,11 @@ module Contract = struct let encoding = Tezlink_imports.Alpha_context.Contract.encoding + let of_implicit c = Tezlink_imports.Alpha_context.Contract.Implicit c + let of_b58check s = Tezlink_imports.Imported_env.wrap_tzresult @@ Tezlink_imports.Alpha_context.Contract.of_b58check s - - let to_hex c = - let raw_key = Data_encoding.Binary.to_bytes_exn encoding c in - let (`Hex key) = Hex.of_bytes raw_key in - key end module Tez = struct diff --git a/etherlink/bin_node/lib_dev/tezlink/tezos_types.mli b/etherlink/bin_node/lib_dev/tezlink/tezos_types.mli index 259ff01b38cb..5ad4850ca98e 100644 --- a/etherlink/bin_node/lib_dev/tezlink/tezos_types.mli +++ b/etherlink/bin_node/lib_dev/tezlink/tezos_types.mli @@ -41,8 +41,7 @@ module Contract : sig val of_b58check : string -> t tzresult - (** Convert a contract to a hex string.*) - val to_hex : t -> string + val of_implicit : Signature.V1.public_key_hash -> t end module Tez : sig diff --git a/etherlink/bin_node/main.ml b/etherlink/bin_node/main.ml index 8ef6a2ca2f41..dffb6dd46fc7 100644 --- a/etherlink/bin_node/main.ml +++ b/etherlink/bin_node/main.ml @@ -174,10 +174,9 @@ module Params = struct in return (Evm_node_lib_dev_encoding.Ethereum_types.Address (Hex hex))) - let tez_contract = - Tezos_clic.parameter (fun _ contract -> - Lwt.return - (Evm_node_lib_dev_tezlink.Tezos_types.Contract.of_b58check contract)) + let tez_account = + Tezos_clic.parameter (fun _ public_key -> + Lwt.return (Signature.V1.Public_key.of_b58check public_key)) let l2_level = Tezos_clic.parameter (fun () s -> @@ -1934,7 +1933,7 @@ let tez_bootstrap_account_arg = let doc = Format.sprintf "Add a tezlink bootstrap account in the installer config." in - Tezos_clic.multiple_arg ~long ~doc ~placeholder:"tz1..." Params.tez_contract + Tezos_clic.multiple_arg ~long ~doc ~placeholder:"edp..." Params.tez_account let eth_bootstrap_balance_arg = Tezos_clic.default_arg diff --git a/etherlink/tezt/lib/evm_node.ml b/etherlink/tezt/lib/evm_node.ml index b5e0598936d3..fb1e22635156 100644 --- a/etherlink/tezt/lib/evm_node.ml +++ b/etherlink/tezt/lib/evm_node.ml @@ -1910,7 +1910,7 @@ let make_l2_kernel_installer_config ?chain_id ?chain_family (fun tez_bootstrap_account -> [ "--tez-bootstrap-account"; - tez_bootstrap_account.Account.public_key_hash; + tez_bootstrap_account.Account.public_key; ]) tez_bootstrap_accounts) @ diff --git a/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- man.out b/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- man.out index be842b4c576b..c52c1bafbb6e 100644 --- a/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- man.out +++ b/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- man.out @@ -781,7 +781,7 @@ Kernel commands: [--maximum-gas-per-transaction <30000...>] [--eth-bootstrap-balance <9999000000000000000000>] [--eth-bootstrap-account <0x...>] [--tez-bootstrap-balance <3800000>] - [--tez-bootstrap-account ] [--set-code <0x...,0x....>] + [--tez-bootstrap-account ] [--set-code <0x...,0x....>] [--world-state-path >] [--l2-chain-id <1>] [--l2-chain-family ] Produce a file containing the part of the kernel configuration @@ -803,7 +803,7 @@ Kernel commands: --tez-bootstrap-balance <3800000>: Balance (in tez) of the tezlink bootstrap accounts Defaults to `3800000`. - --tez-bootstrap-account : Add a tezlink bootstrap account in the + --tez-bootstrap-account : Add a tezlink bootstrap account in the installer config. --set-code <0x...,0x....>: Add code to an account in the installer config. -- GitLab From fc92eb79509f107b46e0a17db4dcfb8ee2c9a758 Mon Sep 17 00:00:00 2001 From: Dibassi Brahima Date: Thu, 17 Apr 2025 16:41:14 +0200 Subject: [PATCH 2/7] EVM/Node/KernelConfig : Add manager/counter field to `make_l2` for Tezos bootstrap accounts --- etherlink/bin_node/lib_dev/kernel_config.ml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/etherlink/bin_node/lib_dev/kernel_config.ml b/etherlink/bin_node/lib_dev/kernel_config.ml index 472f298a03a8..89afa3189feb 100644 --- a/etherlink/bin_node/lib_dev/kernel_config.ml +++ b/etherlink/bin_node/lib_dev/kernel_config.ml @@ -110,12 +110,12 @@ let make_l2 ~eth_bootstrap_balance ~tez_bootstrap_balance match tez_bootstrap_accounts with | None -> [] | Some tez_bootstrap_accounts -> - let open Tezos_types in List.map (fun manager -> let make_account_field key value converter = let path_prefix = - manager |> Signature.V1.Public_key.hash |> Contract.of_implicit + manager |> Signature.V1.Public_key.hash + |> Tezos_types.Contract.of_implicit |> Tezlink_services_impl.Path.account |> String.split_on_char '/' |> clean_path in @@ -124,7 +124,16 @@ let make_l2 ~eth_bootstrap_balance ~tez_bootstrap_balance make_account_field "balance" tez_bootstrap_balance - (Data_encoding.Binary.to_string_exn Tez.encoding)) + (Data_encoding.Binary.to_string_exn Tezos_types.Tez.encoding) + @ make_account_field + "manager_key" + manager + (Data_encoding.Binary.to_string_exn + Signature.V1.Public_key.encoding) + @ make_account_field + "counter" + Z.zero + (Data_encoding.Binary.to_string_exn Data_encoding.z)) tez_bootstrap_accounts |> List.flatten in -- GitLab From 0e7dcbbb17a75178634eacc9f2b9053a8ef27246 Mon Sep 17 00:00:00 2001 From: Dibassi Brahima Date: Tue, 22 Apr 2025 16:38:50 +0200 Subject: [PATCH 3/7] Tezlink/Node/RPC : Refactor manager_key RPC --- .../lib_dev/tezlink/tezlink_backend_sig.ml | 14 ++++++++------ .../bin_node/lib_dev/tezlink/tezos_services.ml | 16 +--------------- .../bin_node/lib_dev/tezlink_services_impl.ml | 2 +- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/etherlink/bin_node/lib_dev/tezlink/tezlink_backend_sig.ml b/etherlink/bin_node/lib_dev/tezlink/tezlink_backend_sig.ml index 2d18891bc2fc..b65dbd8bdc60 100644 --- a/etherlink/bin_node/lib_dev/tezlink/tezlink_backend_sig.ml +++ b/etherlink/bin_node/lib_dev/tezlink/tezlink_backend_sig.ml @@ -5,8 +5,6 @@ (* *) (*****************************************************************************) -open Tezos_types - module type S = sig val current_level : [> `Main] -> @@ -18,13 +16,17 @@ module type S = sig [> `Main] -> [> `Head of 'a] -> Tezlink_constants.t tzresult Lwt.t val balance : - [> `Main] -> [> `Head of 'a] -> Contract.t -> Tez.t tzresult Lwt.t + [> `Main] -> + [> `Head of 'a] -> + Tezos_types.Contract.t -> + Tezos_types.Tez.t tzresult Lwt.t val manager_key : [> `Main] -> [> `Head of 'a] -> - Contract.t -> - Signature.public_key option tzresult Lwt.t + Tezos_types.Contract.t -> + Signature.V1.Public_key.t option tzresult Lwt.t - val counter : [> `Main] -> [> `Head of 'a] -> Contract.t -> Z.t tzresult Lwt.t + val counter : + [> `Main] -> [> `Head of 'a] -> Tezos_types.Contract.t -> Z.t tzresult Lwt.t end diff --git a/etherlink/bin_node/lib_dev/tezlink/tezos_services.ml b/etherlink/bin_node/lib_dev/tezlink/tezos_services.ml index 76324a5a460a..07a67b027e6a 100644 --- a/etherlink/bin_node/lib_dev/tezlink/tezos_services.ml +++ b/etherlink/bin_node/lib_dev/tezlink/tezos_services.ml @@ -72,16 +72,6 @@ module Protocol_types = struct ~src:conversion_encoding end - module Public_key = struct - include Tezlink_imports.Imported_env.Signature.Public_key - - let convert : Signature.Public_key.t -> t tzresult = - Tezos_types.convert_using_serialization - ~name:"public_key" - ~dst:encoding - ~src:Signature.Public_key.encoding - end - module Counter = struct type t = Alpha_context.Manager_counter.t @@ -288,14 +278,10 @@ let register_block_services (module Backend : Tezlink_backend_sig.S) base_dir = ~service:Imported_services.balance ~impl:(fun ({chain; block}, contract) _ _ -> Backend.balance chain block contract) - |> register_with_conversion + |> register ~service:Imported_services.manager_key ~impl:(fun ({chain; block}, contract) _ _ -> Backend.manager_key chain block contract) - ~convert_output:(function - | None -> Result.return_none - | Some pk -> - Result.map Option.some @@ Protocol_types.Public_key.convert pk) |> register_with_conversion ~service:Imported_services.counter ~impl:(fun ({block; chain}, contract) () () -> diff --git a/etherlink/bin_node/lib_dev/tezlink_services_impl.ml b/etherlink/bin_node/lib_dev/tezlink_services_impl.ml index a65c5d151c77..ab1f1fcfd83f 100644 --- a/etherlink/bin_node/lib_dev/tezlink_services_impl.ml +++ b/etherlink/bin_node/lib_dev/tezlink_services_impl.ml @@ -46,7 +46,7 @@ let manager_key read chain block c = Durable_storage.inspect_durable_and_decode_opt read (Path.manager_key c) - (Data_encoding.Binary.of_bytes_exn Signature.Public_key.encoding) + (Data_encoding.Binary.of_bytes_exn Signature.V1.Public_key.encoding) let counter read chain block c = (* TODO: #7831 !17664 -- GitLab From 2a9b8e56d0ff86a4ec97d1eaef3ddf4758a8f030 Mon Sep 17 00:00:00 2001 From: Dibassi Brahima Date: Tue, 22 Apr 2025 15:12:14 +0200 Subject: [PATCH 4/7] Tezlink/Tezt : Edit tezlink manager key to check against expected public key --- etherlink/tezt/tests/evm_sequencer.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index 7826aabfcb8a..edbf34eb20bf 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -602,7 +602,7 @@ let test_tezlink_manager_key = @@ fun {sequencer; _} _protocol -> let* res = account_rpc sequencer Constant.bootstrap1 "manager_key" in Check.( - JSON.(res |> as_string_opt = None) + JSON.(res |> as_string_opt = Some Constant.bootstrap1.public_key) (option string) ~error_msg:"Expected %R but got %L") ; unit -- GitLab From 7563e6a802badc4e713df33ab379c9904d8f5166 Mon Sep 17 00:00:00 2001 From: Dibassi Brahima Date: Tue, 22 Apr 2025 15:15:32 +0200 Subject: [PATCH 5/7] Tezlink/Tezt : Edit tezlink counter to check against valid counter instead of default --- etherlink/tezt/tests/evm_sequencer.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index edbf34eb20bf..92e59b7a65a5 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -613,7 +613,7 @@ let test_tezlink_counter = ~tags:["evm"; "rpc"; "counter"] @@ fun {sequencer; _} _protocol -> let* res = account_rpc sequencer Constant.bootstrap1 "counter" in - Check.(JSON.(res |> as_int = 1) int ~error_msg:"Expected %R but got %L") ; + Check.(JSON.(res |> as_int = 0) int ~error_msg:"Expected %R but got %L") ; unit let test_tezlink_version = -- GitLab From 50e2936e45853ce59cb079b426ab2af630bdaee1 Mon Sep 17 00:00:00 2001 From: Dibassi Brahima Date: Tue, 22 Apr 2025 15:04:58 +0200 Subject: [PATCH 6/7] EVM/Node : Update changelog to reflect changes in bootstrap account parameters for `make l2 kernel installer config` --- etherlink/CHANGES_NODE.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/etherlink/CHANGES_NODE.md b/etherlink/CHANGES_NODE.md index 711449a4b523..b803d81b7847 100644 --- a/etherlink/CHANGES_NODE.md +++ b/etherlink/CHANGES_NODE.md @@ -14,6 +14,18 @@ ### Execution changes +### Command-line interface changes + +- Adds `--private-rpc-port` to `run observer` to enable the private RPC server + from command-line. (!17762) + +- Previously when submitting the same transaction multiple times, if + the first fails to be included by the sequencer then all following + will fails. Now when submitting multiple time the same transaction, + the first occurrence that could succeed does. (!17740) + +- Renames `--bootstrap-account` and `--bootstrap-balance` to `--eth-bootstrap-account` and `--eth-bootstrap-balance` for the `make kernel installer config` and `make l2 kernel installer config` commands. The old behavior is conserved (!17710) + ### Storage changes ### Documentation changes -- GitLab From 4116b7659b06b4ffe4d71d1036368e052cb73f0c Mon Sep 17 00:00:00 2001 From: Dibassi Brahima Date: Tue, 29 Apr 2025 16:48:51 +0200 Subject: [PATCH 7/7] Tezlink/Tezt : Test RPCs default cases --- etherlink/tezt/tests/evm_sequencer.ml | 34 +++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index 92e59b7a65a5..316e52a25e21 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -441,7 +441,8 @@ let register_upgrade_all ~title ~tags ~genesis_timestamp protocols) kernels -let register_tezlink_test ~title ~tags scenario protocols = +let register_tezlink_test ~title ~tags ?tez_bootstrap_accounts scenario + protocols = register_all ~enable_tx_queue:Evm_node.(Enable false) (*Tx queue is not yet compatible with tezlink *) @@ -453,6 +454,7 @@ let register_tezlink_test ~title ~tags scenario protocols = { (Evm_node.default_l2_setup ~l2_chain_id:12) with l2_chain_family = "Michelson"; + tez_bootstrap_accounts; }; ] ~use_multichain:Register_with_feature @@ -565,6 +567,7 @@ let test_tezlink_balance = register_tezlink_test ~title:"Test of the balance rpc" ~tags:["rpc"; "balance"] + ~tez_bootstrap_accounts:[Constant.bootstrap1] @@ fun {sequencer; client; _} _protocol -> (* call the balance rpc and parse the result *) let endpoint = @@ -574,11 +577,18 @@ let test_tezlink_balance = {(Evm_node.rpc_endpoint_record sequencer) with path = "/tezlink"}) in - let* res = + let* valid_res = Client.get_balance_for ~endpoint ~account:Constant.bootstrap1.alias client in Check.( - (Tez.to_mutez res = 3800000000000) int ~error_msg:"Expected %R but got %L") ; + (Tez.to_mutez valid_res = 3800000000000) + int + ~error_msg:"Expected %R but got %L") ; + + let* invalid_res = + Client.get_balance_for ~endpoint ~account:Constant.bootstrap2.alias client + in + Check.((Tez.to_mutez invalid_res = 0) int ~error_msg:"Expected %R but got %L") ; unit let account_rpc sequencer account key = @@ -599,10 +609,16 @@ let test_tezlink_manager_key = register_tezlink_test ~title:"Test of the manager_key rpc" ~tags:["rpc"; "manager_key"] + ~tez_bootstrap_accounts:[Constant.bootstrap1] @@ fun {sequencer; _} _protocol -> - let* res = account_rpc sequencer Constant.bootstrap1 "manager_key" in + let* valid_res = account_rpc sequencer Constant.bootstrap1 "manager_key" in Check.( - JSON.(res |> as_string_opt = Some Constant.bootstrap1.public_key) + JSON.(valid_res |> as_string_opt = Some Constant.bootstrap1.public_key) + (option string) + ~error_msg:"Expected %R but got %L") ; + let* invalid_res = account_rpc sequencer Constant.bootstrap2 "manager_key" in + Check.( + JSON.(invalid_res |> as_string_opt = None) (option string) ~error_msg:"Expected %R but got %L") ; unit @@ -611,9 +627,13 @@ let test_tezlink_counter = register_tezlink_test ~title:"Test of the counter rpc" ~tags:["evm"; "rpc"; "counter"] + ~tez_bootstrap_accounts:[Constant.bootstrap1] @@ fun {sequencer; _} _protocol -> - let* res = account_rpc sequencer Constant.bootstrap1 "counter" in - Check.(JSON.(res |> as_int = 0) int ~error_msg:"Expected %R but got %L") ; + let* valid_res = account_rpc sequencer Constant.bootstrap1 "counter" in + Check.(JSON.(valid_res |> as_int = 0) int ~error_msg:"Expected %R but got %L") ; + let* invalid_res = account_rpc sequencer Constant.bootstrap2 "counter" in + Check.( + JSON.(invalid_res |> as_int = 1) int ~error_msg:"Expected %R but got %L") ; unit let test_tezlink_version = -- GitLab