From 2d49e1ea0e1b028504ccd1d7086346397e35cfe0 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Cornilleau Date: Mon, 24 Nov 2025 11:31:13 +0100 Subject: [PATCH 1/3] TezosX/L2Node: add tezos bootstrap account to make config command --- etherlink/bin_node/lib_dev/kernel_config.ml | 44 ++++++++++++++++++- etherlink/bin_node/lib_dev/kernel_config.mli | 2 + etherlink/bin_node/main.ml | 12 +++-- .../evm_sequencer.ml/EVM Node- man.out | 8 +++- 4 files changed, 60 insertions(+), 6 deletions(-) diff --git a/etherlink/bin_node/lib_dev/kernel_config.ml b/etherlink/bin_node/lib_dev/kernel_config.ml index 62b8ddb2e7d5..fdda0d7d0317 100644 --- a/etherlink/bin_node/lib_dev/kernel_config.ml +++ b/etherlink/bin_node/lib_dev/kernel_config.ml @@ -256,6 +256,40 @@ let make_l2 ~eth_bootstrap_balance ~tez_bootstrap_balance in Installer_config.to_file (config_instrs @ world_state_instrs) ~output +let make_tezos_bootstrap_instr tez_bootstrap_balance tez_bootstrap_accounts = + let balance = + Tezos_types.Tez.to_mutez_z tez_bootstrap_balance |> Rlp.encode_z + in + let nonce = Rlp.encode_int 0 in + List.map + (fun manager -> + let address = + Signature.Public_key.hash manager + |> Signature.Public_key_hash.to_b58check + in + let public_key = + Data_encoding.Binary.to_bytes_exn Signature.Public_key.encoding manager + in + let (`Hex alias) = + let address = Bytes.of_string address in + let alias = Tezos_crypto.Hacl.Hash.Keccak_256.digest address in + Bytes.sub alias 0 20 |> Hex.of_bytes + in + let payload = + Rlp.( + List [Value balance; Value nonce; Value public_key] + |> encode |> Bytes.to_string) + in + make_instr + ~path_prefix:["evm"; "world_state"; "eth_accounts"; "tezos"; address] + (Some ("info", payload)) + @ make_instr + ~path_prefix: + ["evm"; "world_state"; "eth_accounts"; "tezos"; "names"; "ethereum"] + (Some (alias, address))) + tez_bootstrap_accounts + |> List.flatten + let make ~mainnet_compat ~eth_bootstrap_balance ?l2_chain_ids ?eth_bootstrap_accounts ?kernel_root_hash ?chain_id ?sequencer ?delayed_bridge ?ticketer ?admin ?sequencer_governance ?kernel_governance @@ -266,7 +300,7 @@ let make ~mainnet_compat ~eth_bootstrap_balance ?l2_chain_ids ?enable_revm ?enable_dal ?dal_slots ?enable_fast_withdrawal ?enable_fast_fa_withdrawal ?enable_multichain ?set_account_code ?max_delayed_inbox_blueprint_length ?evm_version ?(with_runtimes = []) - ~output () = + ?tez_bootstrap_accounts ~tez_bootstrap_balance ~output () = let eth_bootstrap_accounts = let open Ethereum_types in match eth_bootstrap_accounts with @@ -281,6 +315,12 @@ let make ~mainnet_compat ~eth_bootstrap_balance ?l2_chain_ids eth_bootstrap_accounts |> List.flatten in + let tez_bootstrap_accounts = + match tez_bootstrap_accounts with + | None -> [] + | Some tez_bootstrap_accounts -> + make_tezos_bootstrap_instr tez_bootstrap_balance tez_bootstrap_accounts + in let set_account_code = match set_account_code with @@ -367,7 +407,7 @@ let make ~mainnet_compat ~eth_bootstrap_balance ?l2_chain_ids @ make_instr ~convert:le_int64_bytes maximum_allowed_ticks @ make_instr ~convert:le_int64_bytes maximum_gas_per_transaction @ make_instr ~convert:le_int64_bytes max_blueprint_lookahead_in_seconds - @ eth_bootstrap_accounts @ set_account_code + @ eth_bootstrap_accounts @ tez_bootstrap_accounts @ set_account_code @ make_instr remove_whitelist @ make_instr ~path_prefix:["evm"; "feature_flags"] enable_fa_bridge @ make_instr diff --git a/etherlink/bin_node/lib_dev/kernel_config.mli b/etherlink/bin_node/lib_dev/kernel_config.mli index a95d8c519992..9ba43fd481d3 100644 --- a/etherlink/bin_node/lib_dev/kernel_config.mli +++ b/etherlink/bin_node/lib_dev/kernel_config.mli @@ -45,6 +45,8 @@ val make : ?max_delayed_inbox_blueprint_length:string * string -> ?evm_version:evm_version -> ?with_runtimes:Tezosx.runtime list -> + ?tez_bootstrap_accounts:Signature.public_key list -> + tez_bootstrap_balance:Tezos_types.Tez.t -> output:string -> unit -> unit tzresult Lwt.t diff --git a/etherlink/bin_node/main.ml b/etherlink/bin_node/main.ml index e9ee6f55bf57..89b065514c2b 100644 --- a/etherlink/bin_node/main.ml +++ b/etherlink/bin_node/main.ml @@ -2469,7 +2469,7 @@ let make_kernel_config_command = (config_key_flag ~name:"enable_fa_bridge") (config_key_flag ~name:"enable_revm") (config_key_arg ~name:"dal_slots" ~placeholder:"0,1,4,6,...")) - (args9 + (args11 (config_key_flag ~name:"enable_dal") (config_key_flag ~name:"enable_multichain") l2_chain_ids_arg @@ -2480,7 +2480,9 @@ let make_kernel_config_command = (config_key_flag ~name:"enable_fast_fa_withdrawal") evm_version_arg set_account_code - enable_runtime_arg)) + enable_runtime_arg + tez_bootstrap_balance_arg + tez_bootstrap_account_arg)) (prefixes ["make"; "kernel"; "installer"; "config"] @@ param ~name:"kernel config file" @@ -2519,7 +2521,9 @@ let make_kernel_config_command = enable_fast_fa_withdrawal, evm_version, set_account_code, - with_runtimes ) ) + with_runtimes, + tez_bootstrap_balance, + tez_bootstrap_accounts ) ) output () -> @@ -2557,6 +2561,8 @@ let make_kernel_config_command = ?enable_fast_withdrawal ?enable_fast_fa_withdrawal ?with_runtimes + ?tez_bootstrap_accounts + ~tez_bootstrap_balance ~output ()) 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 87c5f167bc90..0fa62d76f0ed 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 @@ -1018,7 +1018,8 @@ Kernel commands: [--l2-chain-id <1>] [--max-delayed-inbox-blueprint-length <1000>] [--enable-fast-withdrawal] [--enable-fast-fa-withdrawal] [--evm-version ] [--set-code <0x...,0x....>] - [-r --with-runtime ] + [-r --with-runtime ] [--tez-bootstrap-balance <3800000>] + [--tez-bootstrap-account ] Create a configuration for the kernel installer. : File path where the config will be written to. --mainnet-compat: Generate a configuration compatible with the first @@ -1079,6 +1080,11 @@ Kernel commands: config. -r --with-runtime : Enable a Tezos X experimental runtime alongside the default Ethereum runtime of Etherlink + --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 + installer config. make l2 kernel installer config [--minimum-base-fee-per-gas <111...>] [--da-fee-per-byte <111...>] -- GitLab From 5ff6165cc5bf9da73819193e0d55cfd64e2a0016 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Cornilleau Date: Mon, 24 Nov 2025 20:20:22 +0100 Subject: [PATCH 2/3] TezosX/L2Node: tezos bootstrap accounts in test helpers --- etherlink/tezt/lib/evm_node.ml | 27 +++++++++++++++++++++------ etherlink/tezt/lib/evm_node.mli | 2 ++ etherlink/tezt/lib/setup.ml | 8 ++++++++ etherlink/tezt/lib/test_helpers.ml | 11 +++++++++-- etherlink/tezt/lib/test_helpers.mli | 4 +++- etherlink/tezt/lib/tezosx_runtime.ml | 2 ++ 6 files changed, 45 insertions(+), 9 deletions(-) diff --git a/etherlink/tezt/lib/evm_node.ml b/etherlink/tezt/lib/evm_node.ml index 39e6956e8b25..fedea1251921 100644 --- a/etherlink/tezt/lib/evm_node.ml +++ b/etherlink/tezt/lib/evm_node.ml @@ -1737,12 +1737,12 @@ let ten_years_in_seconds = 3600 * 24 * 365 * 10 |> Int64.of_int let make_kernel_installer_config ?(l2_chain_ids = []) ?max_delayed_inbox_blueprint_length ?(mainnet_compat = false) ?(remove_whitelist = false) ?kernel_root_hash ?chain_id - ?eth_bootstrap_balance ?eth_bootstrap_accounts ?sequencer ?delayed_bridge - ?ticketer ?administrator ?sequencer_governance ?kernel_governance - ?kernel_security_governance ?minimum_base_fee_per_gas - ?(da_fee_per_byte = Wei.zero) ?delayed_inbox_timeout - ?delayed_inbox_min_levels ?sequencer_pool_address ?maximum_allowed_ticks - ?maximum_gas_per_transaction + ?eth_bootstrap_balance ?eth_bootstrap_accounts ?tez_bootstrap_balance + ?tez_bootstrap_accounts ?sequencer ?delayed_bridge ?ticketer ?administrator + ?sequencer_governance ?kernel_governance ?kernel_security_governance + ?minimum_base_fee_per_gas ?(da_fee_per_byte = Wei.zero) + ?delayed_inbox_timeout ?delayed_inbox_min_levels ?sequencer_pool_address + ?maximum_allowed_ticks ?maximum_gas_per_transaction ?(max_blueprint_lookahead_in_seconds = ten_years_in_seconds) ?(set_account_code = []) ?(enable_fa_bridge = false) ?(enable_revm = false) ?(enable_dal = false) ?dal_slots ?(enable_fast_withdrawal = false) @@ -1842,6 +1842,21 @@ let make_kernel_installer_config ?(l2_chain_ids = []) (fun eth_bootstrap_account -> ["--eth-bootstrap-account"; eth_bootstrap_account]) eth_bootstrap_accounts) + @ Cli_arg.optional_arg + "tez-bootstrap-balance" + Tez.to_string + tez_bootstrap_balance + @ (match tez_bootstrap_accounts with + | None -> [] + | Some tez_bootstrap_accounts -> + List.flatten + @@ List.map + (fun tez_bootstrap_account -> + [ + "--tez-bootstrap-account"; + tez_bootstrap_account.Account.public_key; + ]) + tez_bootstrap_accounts) @ with_runtimes in let process = Process.spawn (Uses.path Constant.octez_evm_node) cmd in diff --git a/etherlink/tezt/lib/evm_node.mli b/etherlink/tezt/lib/evm_node.mli index c5a567b92946..4a3a7f91e348 100644 --- a/etherlink/tezt/lib/evm_node.mli +++ b/etherlink/tezt/lib/evm_node.mli @@ -671,6 +671,8 @@ val make_kernel_installer_config : ?chain_id:int -> ?eth_bootstrap_balance:Wei.t -> ?eth_bootstrap_accounts:string list -> + ?tez_bootstrap_balance:Tez.t -> + ?tez_bootstrap_accounts:Account.key list -> ?sequencer:string -> ?delayed_bridge:string -> ?ticketer:string -> diff --git a/etherlink/tezt/lib/setup.ml b/etherlink/tezt/lib/setup.ml index 07062a2d51a3..d64234c0ddfe 100644 --- a/etherlink/tezt/lib/setup.ml +++ b/etherlink/tezt/lib/setup.ml @@ -253,12 +253,18 @@ let run_new_observer_node ?(finalized_view = false) ?(patch_config = Fun.id) let setup_kernel_singlechain ~l1_contracts ?max_delayed_inbox_blueprint_length ~mainnet_compat ?delayed_inbox_timeout ?delayed_inbox_min_levels ?(eth_bootstrap_accounts = Evm_node.eth_default_bootstrap_accounts) + ?(tez_bootstrap_accounts = Evm_node.tez_default_bootstrap_accounts) ?sequencer_pool_address ?da_fee_per_byte ?minimum_base_fee_per_gas ?maximum_allowed_ticks ?maximum_gas_per_transaction ?max_blueprint_lookahead_in_seconds ?enable_fa_bridge ?enable_fast_withdrawal ?enable_fast_fa_withdrawal ~enable_dal ?dal_slots ?evm_version ?with_runtimes ~sequencer ~preimages_dir ~kernel () = let output_config = Temp.file "config.yaml" in + let tez_bootstrap_accounts = + (* Tezos bootstrap accounts are only relevant if the runtime is activated *) + if not Tezosx_runtime.(mem Tezos with_runtimes) then [] + else tez_bootstrap_accounts + in let*! () = Evm_node.make_kernel_installer_config ?max_delayed_inbox_blueprint_length @@ -282,6 +288,7 @@ let setup_kernel_singlechain ~l1_contracts ?max_delayed_inbox_blueprint_length ~enable_multichain:false ?max_blueprint_lookahead_in_seconds ~eth_bootstrap_accounts + ~tez_bootstrap_accounts ~output:output_config ?evm_version ?enable_fa_bridge @@ -460,6 +467,7 @@ let setup_kernel ~enable_multichain ~l2_chains ~l1_contracts ?dal_slots ?max_blueprint_lookahead_in_seconds ?eth_bootstrap_accounts:chain_config.Evm_node.eth_bootstrap_accounts + ?tez_bootstrap_accounts:chain_config.Evm_node.tez_bootstrap_accounts ?enable_fa_bridge ?evm_version ?with_runtimes diff --git a/etherlink/tezt/lib/test_helpers.ml b/etherlink/tezt/lib/test_helpers.ml index 50245df9d479..97abe86510e9 100644 --- a/etherlink/tezt/lib/test_helpers.ml +++ b/etherlink/tezt/lib/test_helpers.ml @@ -507,11 +507,17 @@ let init_sequencer_sandbox ?maximum_gas_per_transaction ?genesis_timestamp ?(eth_bootstrap_accounts = List.map (fun account -> account.Eth_account.address) - (Array.to_list Eth_account.bootstrap_accounts)) ?(sequencer_keys = []) - ?with_runtimes () = + (Array.to_list Eth_account.bootstrap_accounts)) + ?(tez_bootstrap_accounts = Evm_node.tez_default_bootstrap_accounts) + ?(sequencer_keys = []) ?with_runtimes () = let wallet_dir = Temp.dir "wallet" in let output_config = Temp.file "config.yaml" in let preimages_dir = Temp.dir "wasm_2_0_0" in + let tez_bootstrap_accounts = + (* tezos bootstrap accounts only relevant if tezos runtime is activated *) + if not Tezosx_runtime.(mem Tezos with_runtimes) then [] + else tez_bootstrap_accounts + in let*! () = Evm_node.make_kernel_installer_config ?maximum_gas_per_transaction @@ -520,6 +526,7 @@ let init_sequencer_sandbox ?maximum_gas_per_transaction ?genesis_timestamp ?minimum_base_fee_per_gas ~output:output_config ~eth_bootstrap_accounts + ~tez_bootstrap_accounts ?evm_version ?with_runtimes ?sequencer: diff --git a/etherlink/tezt/lib/test_helpers.mli b/etherlink/tezt/lib/test_helpers.mli index 83011b77f291..a0b3ac224dd2 100644 --- a/etherlink/tezt/lib/test_helpers.mli +++ b/etherlink/tezt/lib/test_helpers.mli @@ -267,7 +267,8 @@ val find_and_execute_withdrawal : int Lwt.t (** Runs a sequencer in mode sandbox, with no connection needed to a - rollup node. *) + rollup node. Will setup bootstrap accounts by default, for activated + runtimes (EVM is always active). *) val init_sequencer_sandbox : ?maximum_gas_per_transaction:int64 -> ?genesis_timestamp:Client.timestamp -> @@ -283,6 +284,7 @@ val init_sequencer_sandbox : ?kernel:Uses.t -> ?evm_version:Evm_version.t -> ?eth_bootstrap_accounts:string list -> + ?tez_bootstrap_accounts:Account.key list -> ?sequencer_keys:Account.key list -> ?with_runtimes:Tezosx_runtime.t list -> unit -> diff --git a/etherlink/tezt/lib/tezosx_runtime.ml b/etherlink/tezt/lib/tezosx_runtime.ml index 17c688cb440b..61a3b8b624ca 100644 --- a/etherlink/tezt/lib/tezosx_runtime.ml +++ b/etherlink/tezt/lib/tezosx_runtime.ml @@ -12,3 +12,5 @@ let to_string = function Tezos -> "tezos" let feature_flag = function Tezos -> "/evm/feature_flags/enable_tezos_runtime" let tag t = to_string t ^ "_runtime" + +let mem r with_runtimes = List.mem r @@ Option.value ~default:[] with_runtimes -- GitLab From bd15adf6a24e7a27b8ddb9cd58137f0972afeadb Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Cornilleau Date: Mon, 24 Nov 2025 23:12:31 +0100 Subject: [PATCH 3/3] TezosX/Tezt: check bootstrap account --- etherlink/tezt/tests/tezosx.ml | 76 +++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/etherlink/tezt/tests/tezosx.ml b/etherlink/tezt/tests/tezosx.ml index b65fd6f31a26..20286c1c577c 100644 --- a/etherlink/tezt/tests/tezosx.ml +++ b/etherlink/tezt/tests/tezosx.ml @@ -63,4 +63,78 @@ let test_runtime_feature_flag ~runtime () = (Tezosx_runtime.feature_flag runtime) err.message -let () = test_runtime_feature_flag ~runtime:Tezos () +let check_account sandbox (account : Account.key) = + let open Rpc.Syntax in + let open Evm_node_lib_dev_encoding in + let get_res message = function + | Ok v -> v + | Error _ -> Test.fail ~__LOC__ "%s" message + in + let get_decoded type_ decode bytes = + get_res + (Format.asprintf + "Should have decoded a %s but got %a" + type_ + Rlp.pp + (Value bytes)) + (decode bytes) + in + (* get RLP value in durable storage *) + let path = + sf "/evm/world_state/eth_accounts/tezos/%s/info" account.public_key_hash + in + let*@! value = Rpc.state_value sandbox path in + let state = + match Rlp.decode (`Hex value |> Hex.to_bytes) with + | Ok v -> v + | _ -> + Test.fail + ~__LOC__ + "Failed to decode value at path %s in durable storage" + path + in + (* Check RLP value *) + match state with + | List [Value balance; Value nonce; Value public_key] -> + let balance = get_decoded "z" Rlp.decode_z balance in + let nonce = get_decoded "int" Rlp.decode_int nonce in + let public_key = + get_res "Should have decoded the public key" + @@ Data_encoding.Binary.of_bytes + Tezos_crypto.Signature.Public_key.encoding + public_key + in + Check.((nonce = 0) int ~error_msg:"Expected nonce %R but got %L") ; + Check.( + (Z.to_int64 balance = 3_800_000_000_000L) + int64 + ~error_msg:"Expected balance %R but got %L") ; + Check.( + (Tezos_crypto.Signature.Public_key.to_b58check public_key + = account.public_key) + string + ~error_msg:"Expected public key %R but got %L") ; + unit + | _ -> + Test.fail + ~__LOC__ + "Unexpected value decoded at path %s in durable storage: value = %s, \ + original data = %s" + path + (Format.asprintf "%a" Rlp.pp state) + value + +let test_bootstrap_kernel_config () = + Setup.register_sandbox_test + ~title:"Set tezos bootstrap accounts" + ~tags:["bootstrap"] + ~with_runtimes:[Tezos] + @@ fun sandbox -> + let _ = + List.map (check_account sandbox) Evm_node.tez_default_bootstrap_accounts + in + unit + +let () = + test_bootstrap_kernel_config () ; + test_runtime_feature_flag ~runtime:Tezos () -- GitLab