diff --git a/etherlink/CHANGES_NODE.md b/etherlink/CHANGES_NODE.md index 4dfcc7bac396591905a7717f2fcd3a82b40850eb..0589a910de0d6ad7099fc455d578a7f8bc2cb5f1 100644 --- a/etherlink/CHANGES_NODE.md +++ b/etherlink/CHANGES_NODE.md @@ -7,6 +7,15 @@ - Adds `full` history mode, where the EVM node keeps all the blocks and transactions, but still prunes state data. (!16584) +#### Experimental + +*No guarantees are provided regarding backward compatibility of experimental +features. They can be modified or removed without any deprecation notices. If +you start using them, you probably want to use `octez-evm-node check config +--config-file PATH` to assert your configuration file is still valid.* + +- Added possibility of configuring multiple l2_chains. The first admissable configuration is their `chain_id` (!16587) + ### Bug Fixes - Advertises the correct history mode on start-up when it is not explicitely diff --git a/etherlink/bin_node/config/configuration.ml b/etherlink/bin_node/config/configuration.ml index b7b40a5f05c14b50c9225a18bf46d256a47c600b..8303988938cf7cf8c0f80212b6a07c4f2f0391ed 100644 --- a/etherlink/bin_node/config/configuration.ml +++ b/etherlink/bin_node/config/configuration.ml @@ -53,6 +53,12 @@ type rpc_server = Resto | Dream type monitor_websocket_heartbeat = {ping_interval : float; ping_timeout : float} +let chain_id network = + Ethereum_types.Chain_id + (Z.of_int (match network with Mainnet -> 0xa729 | Testnet -> 0x1f47b)) + +type l2_chain = {chain_id : Ethereum_types.chain_id} + type experimental_features = { drop_duplicate_on_injection : bool; blueprints_publisher_order_enabled : bool; @@ -62,6 +68,7 @@ type experimental_features = { enable_websocket : bool; max_websocket_message_length : int; monitor_websocket_heartbeat : monitor_websocket_heartbeat option; + l2_chains : l2_chain list option; } type sequencer = { @@ -190,6 +197,8 @@ let default_max_socket_message_length = 4096 * 1024 let default_monitor_websocket_heartbeat = Some {ping_interval = 5.; ping_timeout = 30.} +let default_l2_chains = None + let default_experimental_features = { enable_send_raw_transaction = default_enable_send_raw_transaction; @@ -200,6 +209,7 @@ let default_experimental_features = enable_websocket = false; max_websocket_message_length = default_max_socket_message_length; monitor_websocket_heartbeat = default_monitor_websocket_heartbeat; + l2_chains = default_l2_chains; } let default_data_dir = Filename.concat (Sys.getenv "HOME") ".octez-evm-node" @@ -810,6 +820,16 @@ let opt_monitor_websocket_heartbeat_encoding = Option.some; ] +let l2_chain_encoding : l2_chain Data_encoding.t = + let open Data_encoding in + let open Evm_node_lib_dev_encoding in + conv (fun {chain_id} -> chain_id) (fun chain_id -> {chain_id}) + @@ obj1 + (req + "chain_id" + ~description:"The id of the l2 chain" + Ethereum_types.chain_id_encoding) + let experimental_features_encoding = let open Data_encoding in conv @@ -822,6 +842,7 @@ let experimental_features_encoding = enable_websocket; max_websocket_message_length; monitor_websocket_heartbeat; + l2_chains : l2_chain list option; } -> ( ( drop_duplicate_on_injection, blueprints_publisher_order_enabled, @@ -832,7 +853,8 @@ let experimental_features_encoding = ( rpc_server, enable_websocket, max_websocket_message_length, - monitor_websocket_heartbeat ) )) + monitor_websocket_heartbeat, + l2_chains ) )) (fun ( ( drop_duplicate_on_injection, blueprints_publisher_order_enabled, enable_send_raw_transaction, @@ -842,7 +864,8 @@ let experimental_features_encoding = ( rpc_server, enable_websocket, max_websocket_message_length, - monitor_websocket_heartbeat ) ) -> + monitor_websocket_heartbeat, + l2_chains ) ) -> { drop_duplicate_on_injection; blueprints_publisher_order_enabled; @@ -852,6 +875,7 @@ let experimental_features_encoding = enable_websocket; max_websocket_message_length; monitor_websocket_heartbeat; + l2_chains; }) (merge_objs (obj6 @@ -902,7 +926,7 @@ let experimental_features_encoding = DEPRECATED: You should remove this option from your \ configuration file." bool)) - (obj4 + (obj5 (dft "rpc_server" ~description: @@ -926,7 +950,15 @@ let experimental_features_encoding = "monitor_websocket_heartbeat" ~description:"Parameters to monitor websocket connections" opt_monitor_websocket_heartbeat_encoding - default_monitor_websocket_heartbeat))) + default_monitor_websocket_heartbeat) + (dft + "l2_chains" + ~description: + "Configuration of l2_chains for multisequencing.\n\ + \ If not set, the node will adopt a single \ + chain behaviour." + (option (list l2_chain_encoding)) + default_l2_chains))) let proxy_encoding = let open Data_encoding in @@ -1550,6 +1582,13 @@ module Cli = struct ?native_execution_policy () in + let experimental_features = + match network with + | None -> default_experimental_features + | Some network -> + let l2_chains = Some [{chain_id = chain_id network}] in + {default_experimental_features with l2_chains} + in { public_rpc; private_rpc; @@ -1574,7 +1613,7 @@ module Cli = struct verbose = (if Option.value verbose ~default:default_verbose then Debug else Internal_event.Notice); - experimental_features = default_experimental_features; + experimental_features; fee_history = default_fee_history; finalized_view = Option.value ~default:default_finalized_view finalized_view; diff --git a/etherlink/bin_node/config/configuration.mli b/etherlink/bin_node/config/configuration.mli index 78167f9339de1793614cec952e0ae1dca6f0502e..e1cf612ced605e1cb5091e99c7cd3891faead906 100644 --- a/etherlink/bin_node/config/configuration.mli +++ b/etherlink/bin_node/config/configuration.mli @@ -6,6 +6,8 @@ (* *) (*****************************************************************************) +open Evm_node_lib_dev_encoding + (** A list of network officially supported by the EVM node. *) type supported_network = Mainnet | Testnet @@ -81,6 +83,10 @@ type rpc_server = (** Parameters for monitoring websocket connection heartbeats. *) type monitor_websocket_heartbeat = {ping_interval : float; ping_timeout : float} +val chain_id : supported_network -> Ethereum_types.chain_id + +type l2_chain = {chain_id : Ethereum_types.chain_id} + (** Configuration settings for experimental features, with no backward compatibility guarantees. *) type experimental_features = { @@ -92,6 +98,7 @@ type experimental_features = { enable_websocket : bool; max_websocket_message_length : int; monitor_websocket_heartbeat : monitor_websocket_heartbeat option; + l2_chains : l2_chain list option; } type sequencer = { diff --git a/etherlink/bin_node/config/dune b/etherlink/bin_node/config/dune index 9a70fa912dc2c0df8542a1c9a9a5f00cff85b379..fd07fe76fc7805ad8f8650e9222514e860595e53 100644 --- a/etherlink/bin_node/config/dune +++ b/etherlink/bin_node/config/dune @@ -11,10 +11,12 @@ octez-shell-libs.client-base octez-libs.rpc-http octez-libs.rpc-http-server - octez-libs.stdlib-unix) + octez-libs.stdlib-unix + octez-evm-node-libs.evm_node_lib_dev_encoding) (flags (:standard) -open Tezos_base.TzPervasives -open Tezos_client_base -open Tezos_rpc_http - -open Tezos_stdlib_unix)) + -open Tezos_stdlib_unix + -open Evm_node_lib_dev_encoding)) diff --git a/etherlink/bin_node/lib_dev/constants.ml b/etherlink/bin_node/lib_dev/constants.ml index 6f50c857b7c92292b7be51de746bed31190e2227..c8021c0012419ccb8bdf9755e0cd9a010dfd39c3 100644 --- a/etherlink/bin_node/lib_dev/constants.ml +++ b/etherlink/bin_node/lib_dev/constants.ml @@ -5,8 +5,6 @@ (* *) (*****************************************************************************) -open Ethereum_types - let supported_networks = Configuration.[Mainnet; Testnet] let network_name = function @@ -14,8 +12,7 @@ let network_name = function | Testnet -> "Testnet" let chain_id network = - (match network with Configuration.Mainnet -> 0xa729 | Testnet -> 0x1f47b) - |> Z.of_int |> quantity_of_z + match Configuration.chain_id network with Chain_id x -> Ethereum_types.Qty x let rollup_address network = Tezos_crypto.Hashed.Smart_rollup_address.of_b58check_exn diff --git a/etherlink/bin_node/lib_dev/encodings/ethereum_types.ml b/etherlink/bin_node/lib_dev/encodings/ethereum_types.ml index 3c6690c7499c1743bbf7badc84af21b35fccf09b..500e3fa13741d43837e18bf6b6beee61689a259d 100644 --- a/etherlink/bin_node/lib_dev/encodings/ethereum_types.ml +++ b/etherlink/bin_node/lib_dev/encodings/ethereum_types.ml @@ -115,6 +115,12 @@ let quantity_encoding = let pp_quantity fmt (Qty q) = Z.pp_print fmt q +type chain_id = Chain_id of Z.t + +let chain_id_encoding : chain_id Data_encoding.t = + let open Data_encoding in + conv (fun (Chain_id z) -> z) (fun z -> Chain_id z) z + type block_hash = Block_hash of hex [@@ocaml.unboxed] let pp_block_hash fmt (Block_hash (Hex h)) = Format.pp_print_string fmt h diff --git a/etherlink/bin_node/lib_dev/encodings/ethereum_types.mli b/etherlink/bin_node/lib_dev/encodings/ethereum_types.mli index aa0ebe839211edaed48c66c4a10c82004c8cc8c2..efaf47b67b9c3355c178732d0970fa5a6eefebd1 100644 --- a/etherlink/bin_node/lib_dev/encodings/ethereum_types.mli +++ b/etherlink/bin_node/lib_dev/encodings/ethereum_types.mli @@ -53,6 +53,10 @@ val hex_of_utf8 : string -> hex (** [hex_of_bytes] transforms the [bytes] to hexadecimal. *) val hex_of_bytes : bytes -> hex +type chain_id = Chain_id of Z.t + +val chain_id_encoding : chain_id Data_encoding.t + (** Ethereum block hash (32 bytes) *) type block_hash = Block_hash of hex [@@unboxed] diff --git a/etherlink/tezt/tests/expected/evm_sequencer.ml/Alpha- Configuration RPC.out b/etherlink/tezt/tests/expected/evm_sequencer.ml/Alpha- Configuration RPC.out index 87b5983249ae8b359f1bf80b4b26aedcc918a5ef..92caab5461df15853decb4d50643e113e5b9381e 100644 --- a/etherlink/tezt/tests/expected/evm_sequencer.ml/Alpha- Configuration RPC.out +++ b/etherlink/tezt/tests/expected/evm_sequencer.ml/Alpha- Configuration RPC.out @@ -21,7 +21,8 @@ "monitor_websocket_heartbeat": { "ping_interval": 5, "ping_timeout": 30 - } + }, + "l2_chains": null }, "proxy": { "ignore_block_param": false @@ -78,7 +79,8 @@ "monitor_websocket_heartbeat": { "ping_interval": 5, "ping_timeout": 30 - } + }, + "l2_chains": null }, "proxy": { "ignore_block_param": false @@ -128,7 +130,8 @@ "monitor_websocket_heartbeat": { "ping_interval": 5, "ping_timeout": 30 - } + }, + "l2_chains": null }, "proxy": { "evm_node_endpoint": "hidden", diff --git a/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- describe config.out b/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- describe config.out index f39a80427c61907c6d7fad4f3873317a3b51cf71..943d89ffe1ab25d6ff06eb99360fdc488f15ce60 100644 --- a/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- describe config.out +++ b/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- describe config.out @@ -161,7 +161,15 @@ "ping_timeout": number /* Timeout in seconds after which the connection will be - considered dead and closed. */ } }, + considered dead and closed. */ }, + "l2_chains"?: + /* Configuration of l2_chains for multisequencing. + If not set, the node will adopt a single chain + behaviour. */ + [ { "chain_id": $bignum /* The id of the l2 chain */ } ... ] + /* Some */ + || null + /* None */ }, "proxy"?: { "finalized_view"?: boolean @@ -274,6 +282,10 @@ /* When enabled, the node only expose blocks that are finalized, i.e., the `latest` block parameter becomes a synonym for `finalized`. */, "history"?: $history_mode /* History mode of the EVM node */ } +$bignum: + /* Big number + Decimal representation of a big number */ + string $history_mode: /* Compact notation for the history mode. Can either be `archive` and `rolling:N` with `N` being the number of days to use as the retention diff --git a/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- init config --network mainnet.out b/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- init config --network mainnet.out index 27ef4b10c673f0b5e3bc945b7ed0f4874d8d694f..93d7063e882e4a013bd6dd4aeda77f9b24e8b53f 100644 --- a/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- init config --network mainnet.out +++ b/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- init config --network mainnet.out @@ -1,4 +1,5 @@ { "observer": { "evm_node_endpoint": "https://relay.mainnet.etherlink.com" }, + "experimental_features": { "l2_chains": [ { "chain_id": "42793" } ] }, "kernel_execution": { "preimages_endpoint": "https://snapshots.tzinit.org/etherlink-mainnet/wasm_2_0_0" } } diff --git a/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- init config --network testnet.out b/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- init config --network testnet.out index de6cb3f5e98a8f5c2071847fa783888f9425a5ea..f8b01ad3dae0e0eaf3fc9cca3cec5fdb879b6688 100644 --- a/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- init config --network testnet.out +++ b/etherlink/tezt/tests/expected/evm_sequencer.ml/EVM Node- init config --network testnet.out @@ -1,4 +1,5 @@ { "observer": { "evm_node_endpoint": "https://relay.ghostnet.etherlink.com" }, + "experimental_features": { "l2_chains": [ { "chain_id": "128123" } ] }, "kernel_execution": { "preimages_endpoint": "https://snapshots.tzinit.org/etherlink-ghostnet/wasm_2_0_0" } } diff --git a/manifest/product_etherlink.ml b/manifest/product_etherlink.ml index 64d75e5b6d81cc6dd6041846b3dd554c4270f7fc..f61b59277b228e54522613c78398a35f1972ffed 100644 --- a/manifest/product_etherlink.ml +++ b/manifest/product_etherlink.ml @@ -115,21 +115,6 @@ let evm_node_rust_deps = let tezt ?(deps = []) = tezt ~deps:(bls12_381_archive :: deps) -let evm_node_config = - octez_evm_node_lib - "evm_node_config" - ~path:"etherlink/bin_node/config" - ~synopsis:"Configuration for the EVM node" - ~deps: - [ - octez_base |> open_ ~m:"TzPervasives"; - octez_base_unix; - octez_client_base |> open_; - octez_rpc_http |> open_; - octez_rpc_http_server; - octez_stdlib_unix |> open_; - ] - let wasm_runtime_callbacks = octez_evm_node_lib "wasm_runtime_callbacks" @@ -255,6 +240,22 @@ let evm_node_lib_dev_encoding = uuidm; ] +let evm_node_config = + octez_evm_node_lib + "evm_node_config" + ~path:"etherlink/bin_node/config" + ~synopsis:"Configuration for the EVM node" + ~deps: + [ + octez_base |> open_ ~m:"TzPervasives"; + octez_base_unix; + octez_client_base |> open_; + octez_rpc_http |> open_; + octez_rpc_http_server; + octez_stdlib_unix |> open_; + evm_node_lib_dev_encoding |> open_; + ] + let evm_node_lib_dev = octez_evm_node_lib "evm_node_lib_dev" diff --git a/opam/octez-evm-node-libs.opam b/opam/octez-evm-node-libs.opam index 3a57e37da042d1de1120390a9df8575008d4edcd..ecf84047dd1407f5ac7896a6056300a0eca516f1 100644 --- a/opam/octez-evm-node-libs.opam +++ b/opam/octez-evm-node-libs.opam @@ -17,13 +17,13 @@ depends: [ "cohttp" { >= "5.3.1" } "mirage-crypto-rng" { >= "1.0.0" } "octez-libs" - "octez-shell-libs" "octez-l2-libs" "crunch" { >= "3.3.0" } "caqti-lwt" { >= "2.0.1" } "re" { >= "1.10.0" } "octez-smart-rollup-wasm-debugger-plugin" "uuidm" { >= "0.9.9" } + "octez-shell-libs" "dream" { >= "1.0.0~alpha7" } "octez-version" "lwt-watcher" { = "0.2" }