diff --git a/etherlink/bin_node/index.mld b/etherlink/bin_node/index.mld index ac40407dade2ec527081f1f9087f27c7aeddd6f8..45079fbaf577ca07c96f5f0d106d235dcab131a7 100644 --- a/etherlink/bin_node/index.mld +++ b/etherlink/bin_node/index.mld @@ -8,6 +8,7 @@ It contains the following libraries: - {{!module-Evm_node_lib_dev}Evm_node_lib_dev}: An implementation of a subset of Ethereum JSON-RPC API for the EVM rollup [dev version] - {{!module-Evm_node_lib_dev_client}Evm_node_lib_dev_client}: Client library for communicating with an EVM node - {{!module-Evm_node_lib_dev_encoding}Evm_node_lib_dev_encoding}: EVM encodings for the EVM node and plugin for the WASM Debugger [dev version] +- {{!module-Evm_node_lib_dev_tezlink}Evm_node_lib_dev_tezlink}: Tezlink dependencies for the EVM node - {{!module-Evm_node_migrations}Evm_node_migrations}: SQL migrations for the EVM node store - {{!module-Evm_node_rust_deps}Evm_node_rust_deps}: WASM runtime foreign archive - {{!module-Evm_node_supported_installers}Evm_node_supported_installers}: Collections of embedded installers binaries diff --git a/etherlink/bin_node/lib_dev/dune b/etherlink/bin_node/lib_dev/dune index 2720e12bfb7fe7525df39d11c83ba1ba4488f090..d027c1e0d87a6354e19b3a74e86662bb78bea717 100644 --- a/etherlink/bin_node/lib_dev/dune +++ b/etherlink/bin_node/lib_dev/dune @@ -16,6 +16,7 @@ octez-version.value octez-libs.stdlib-unix octez-evm-node-libs.evm_node_lib_dev_encoding + octez-evm-node-libs.evm_node_lib_dev_tezlink lwt-watcher lwt-exit octez-l2-libs.sqlite @@ -37,8 +38,6 @@ octez-evm-node-libs.evm_node_supported_installers octez-evm-node-libs.evm_node_wasm_runtime octez-performance-metrics - octez-protocol-021-PsQuebec-libs.plugin - tezos-protocol-021-PsQuebec.parameters octez-libs.version octez-shell-libs.shell-services) (flags @@ -48,6 +47,7 @@ -open Tezos_workers -open Tezos_stdlib_unix -open Evm_node_lib_dev_encoding + -open Evm_node_lib_dev_tezlink -open Octez_sqlite -open Tezos_client_base -open Evm_node_config diff --git a/etherlink/bin_node/lib_dev/encodings/l2_types.ml b/etherlink/bin_node/lib_dev/encodings/l2_types.ml index d4fac8bf6a6b0de4de4a97554f44432a9389ce77..88720aa321c72c23e990209ffa2dfe6560bf94df 100644 --- a/etherlink/bin_node/lib_dev/encodings/l2_types.ml +++ b/etherlink/bin_node/lib_dev/encodings/l2_types.ml @@ -47,7 +47,45 @@ module Chain_family = struct let pp fmt cf = Format.fprintf fmt "%s" (to_string cf) end -type 'a block = Eth of 'a Ethereum_types.block | Tez of Tezos_types.block +(* WIP: Minimal Block Tezos (should be equal to shell_block header) *) +module Tezos_block = struct + type block = { + number : Ethereum_types.quantity; + hash : Ethereum_types.block_hash; + timestamp : Ethereum_types.quantity; + parent_hash : Ethereum_types.block_hash; + } + + let decode_block_hash = Ethereum_types.decode_block_hash + + let genesis_parent_hash = + (* This Hex comes from this b58 hash 'BLockGenesisGenesisGenesisGenesisGenesis1db77eJNeJ9' *) + (* That is the ghostnet genesis hash according to 'devtools/get_contracts/config.ml' *) + Ethereum_types.Block_hash + (Hex "8fcf233671b6a04fcf679d2a381c2544ea6c1ea29ba6157776ed8423e7c02934") + + (* This function may be replaced in the future by an already existing function *) + (* When Tezos block will be complete *) + let block_from_binary bytes = + if Bytes.length bytes = 44 then ( + let number = Bytes.make 4 '\000' in + Bytes.blit bytes 0 number 0 4 ; + let number = Ethereum_types.Qty (Helpers.decode_z_be number) in + let previous_hash = Bytes.make 32 '\000' in + Bytes.blit bytes 4 previous_hash 0 32 ; + let parent = Ethereum_types.decode_block_hash previous_hash in + let timestamp = Bytes.make 8 '\000' in + Bytes.blit bytes 36 timestamp 0 8 ; + let timestamp = Ethereum_types.Qty (Helpers.decode_z_le timestamp) in + let block_hash = Block_hash.hash_bytes [bytes] in + let hash = + Ethereum_types.decode_block_hash (Block_hash.to_bytes block_hash) + in + {number; hash; timestamp; parent_hash = parent}) + else raise (Invalid_argument "Expected a string of length 44") +end + +type 'a block = Eth of 'a Ethereum_types.block | Tez of Tezos_block.block let block_hash block = match block with Eth block -> block.hash | Tez block -> block.hash @@ -72,12 +110,12 @@ let block_parent block = let decode_block_hash ~chain_family bytes = match chain_family with | EVM -> Ethereum_types.decode_block_hash bytes - | Michelson -> Tezos_types.decode_block_hash bytes + | Michelson -> Tezos_block.decode_block_hash bytes let genesis_parent_hash ~chain_family = match chain_family with | EVM -> Ethereum_types.genesis_parent_hash - | Michelson -> Tezos_types.genesis_parent_hash + | Michelson -> Tezos_block.genesis_parent_hash let block_from_bytes ~chain_family bytes = match chain_family with @@ -85,5 +123,5 @@ let block_from_bytes ~chain_family bytes = let eth_block = Ethereum_types.block_from_rlp bytes in Eth eth_block | Michelson -> - let tez_block = Tezos_types.block_from_binary bytes in + let tez_block = Tezos_block.block_from_binary bytes in Tez tez_block diff --git a/etherlink/bin_node/lib_dev/encodings/l2_types.mli b/etherlink/bin_node/lib_dev/encodings/l2_types.mli index c2d664f097ce3437a41a03e519e923cc4a5e73ce..d8428193679acf29fd80f46fbc7da34c1e532e42 100644 --- a/etherlink/bin_node/lib_dev/encodings/l2_types.mli +++ b/etherlink/bin_node/lib_dev/encodings/l2_types.mli @@ -44,7 +44,22 @@ module Chain_family : sig val pp : Format.formatter -> chain_family -> unit end -type 'a block = Eth of 'a Ethereum_types.block | Tez of Tezos_types.block +module Tezos_block : sig + type block = { + number : Ethereum_types.quantity; + hash : Ethereum_types.block_hash; + timestamp : Ethereum_types.quantity; + parent_hash : Ethereum_types.block_hash; + } + + val decode_block_hash : bytes -> Ethereum_types.block_hash + + val genesis_parent_hash : Ethereum_types.block_hash + + val block_from_binary : bytes -> block +end + +type 'a block = Eth of 'a Ethereum_types.block | Tez of Tezos_block.block val block_hash : 'a block -> Ethereum_types.block_hash diff --git a/etherlink/bin_node/lib_dev/encodings/tezos_types.ml b/etherlink/bin_node/lib_dev/encodings/tezos_types.ml deleted file mode 100644 index 6c5403e5e2fc38c4145a4b827bec807e92026809..0000000000000000000000000000000000000000 --- a/etherlink/bin_node/lib_dev/encodings/tezos_types.ml +++ /dev/null @@ -1,42 +0,0 @@ -(*****************************************************************************) -(* *) -(* SPDX-License-Identifier: MIT *) -(* Copyright (c) 2025 Functori *) -(* *) -(*****************************************************************************) - -(* WIP: Minimal Block Tezos (should be equal to shell_block header) *) -type block = { - number : Ethereum_types.quantity; - hash : Ethereum_types.block_hash; - timestamp : Ethereum_types.quantity; - parent_hash : Ethereum_types.block_hash; -} - -let decode_block_hash = Ethereum_types.decode_block_hash - -let genesis_parent_hash = - (* This Hex comes from this b58 hash 'BLockGenesisGenesisGenesisGenesisGenesis1db77eJNeJ9' *) - (* That is the ghostnet genesis hash according to 'devtools/get_contracts/config.ml' *) - Ethereum_types.Block_hash - (Hex "8fcf233671b6a04fcf679d2a381c2544ea6c1ea29ba6157776ed8423e7c02934") - -(* This function may be replaced in the future by an already existing function *) -(* When Tezos block will be complete *) -let block_from_binary bytes = - if Bytes.length bytes = 44 then ( - let number = Bytes.make 4 '\000' in - Bytes.blit bytes 0 number 0 4 ; - let number = Ethereum_types.Qty (Helpers.decode_z_be number) in - let previous_hash = Bytes.make 32 '\000' in - Bytes.blit bytes 4 previous_hash 0 32 ; - let parent = Ethereum_types.decode_block_hash previous_hash in - let timestamp = Bytes.make 8 '\000' in - Bytes.blit bytes 36 timestamp 0 8 ; - let timestamp = Ethereum_types.Qty (Helpers.decode_z_le timestamp) in - let block_hash = Block_hash.hash_bytes [bytes] in - let hash = - Ethereum_types.decode_block_hash (Block_hash.to_bytes block_hash) - in - {number; hash; timestamp; parent_hash = parent}) - else raise (Invalid_argument "Expected a string of length 44") diff --git a/etherlink/bin_node/lib_dev/tezlink/dune b/etherlink/bin_node/lib_dev/tezlink/dune new file mode 100644 index 0000000000000000000000000000000000000000..200c00f192a71ea38ca036e9cd8f0bd5a0fdf573 --- /dev/null +++ b/etherlink/bin_node/lib_dev/tezlink/dune @@ -0,0 +1,14 @@ +; This file was automatically generated, do not edit. +; Edit file manifest/main.ml instead. + +(library + (name evm_node_lib_dev_tezlink) + (public_name octez-evm-node-libs.evm_node_lib_dev_tezlink) + (instrumentation (backend bisect_ppx)) + (libraries + octez-protocol-021-PsQuebec-libs.plugin + tezos-protocol-021-PsQuebec.parameters + octez-libs.base) + (flags + (:standard) + -open Tezos_base.TzPervasives)) diff --git a/etherlink/bin_node/lib_dev/tezlink/tezos_types.ml b/etherlink/bin_node/lib_dev/tezlink/tezos_types.ml new file mode 100644 index 0000000000000000000000000000000000000000..3dd32129b9e030ed479e9d57338dc06fd0e1b231 --- /dev/null +++ b/etherlink/bin_node/lib_dev/tezlink/tezos_types.ml @@ -0,0 +1,6 @@ +(*****************************************************************************) +(* *) +(* SPDX-License-Identifier: MIT *) +(* Copyright (c) 2025 Functori *) +(* *) +(*****************************************************************************) diff --git a/etherlink/bin_node/lib_dev/encodings/tezos_types.mli b/etherlink/bin_node/lib_dev/tezlink/tezos_types.mli similarity index 59% rename from etherlink/bin_node/lib_dev/encodings/tezos_types.mli rename to etherlink/bin_node/lib_dev/tezlink/tezos_types.mli index 25a0c2f62add9fa5a2af99a3cea20f09ab7c42f7..3dd32129b9e030ed479e9d57338dc06fd0e1b231 100644 --- a/etherlink/bin_node/lib_dev/encodings/tezos_types.mli +++ b/etherlink/bin_node/lib_dev/tezlink/tezos_types.mli @@ -4,16 +4,3 @@ (* Copyright (c) 2025 Functori *) (* *) (*****************************************************************************) - -type block = { - number : Ethereum_types.quantity; - hash : Ethereum_types.block_hash; - timestamp : Ethereum_types.quantity; - parent_hash : Ethereum_types.block_hash; -} - -val decode_block_hash : bytes -> Ethereum_types.block_hash - -val genesis_parent_hash : Ethereum_types.block_hash - -val block_from_binary : bytes -> block diff --git a/manifest/product_etherlink.ml b/manifest/product_etherlink.ml index 71c42125bb9227bee4f37cb4a75ba89f14bd03cc..130a369b30cca4f518cbb531cba69c82765929bf 100644 --- a/manifest/product_etherlink.ml +++ b/manifest/product_etherlink.ml @@ -225,6 +225,31 @@ let evm_node_lib_dev_encoding = uuidm; ] +let evm_node_lib_dev_tezlink = + let quebec = + List.find (fun proto -> Protocol.short_hash proto = "PsQuebec") Protocol.all + in + let tezlink_protocol_plugin = + match Protocol.plugin quebec with + | Some target -> target + | None -> (* unreachable *) assert false + in + let tezlink_protocol_parameters = + match Protocol.parameters quebec with + | Some target -> target + | None -> (* unreachable *) assert false + in + octez_evm_node_lib + "evm_node_lib_dev_tezlink" + ~path:"etherlink/bin_node/lib_dev/tezlink" + ~synopsis:"Tezlink dependencies for the EVM node" + ~deps: + [ + tezlink_protocol_plugin; + tezlink_protocol_parameters; + octez_base |> open_ ~m:"TzPervasives"; + ] + let evm_node_config = octez_evm_node_lib "evm_node_config" @@ -242,19 +267,6 @@ let evm_node_config = ] let evm_node_lib_dev = - let quebec = - List.find (fun proto -> Protocol.short_hash proto = "PsQuebec") Protocol.all - in - let plugin = - match Protocol.plugin quebec with - | Some target -> target - | None -> (* unreachable *) assert false - in - let parameters = - match Protocol.parameters quebec with - | Some target -> target - | None -> (* unreachable *) assert false - in octez_evm_node_lib "evm_node_lib_dev" ~path:"etherlink/bin_node/lib_dev" @@ -273,6 +285,7 @@ let evm_node_lib_dev = octez_version_value; octez_stdlib_unix |> open_; evm_node_lib_dev_encoding |> open_; + evm_node_lib_dev_tezlink |> open_; lwt_watcher; lwt_exit; octez_sqlite |> open_; @@ -294,8 +307,6 @@ let evm_node_lib_dev = supported_installers; wasm_runtime; performance_metrics; - plugin; - parameters; octez_version; octez_shell_services; ] diff --git a/opam/octez-evm-node-libs.opam b/opam/octez-evm-node-libs.opam index 936ce90060615b53c19402d587bfc67340f47517..281ea762e75465c1f1a299fac1e75b6c968ae0a7 100644 --- a/opam/octez-evm-node-libs.opam +++ b/opam/octez-evm-node-libs.opam @@ -24,6 +24,8 @@ depends: [ "re" { >= "1.10.0" } "octez-smart-rollup-wasm-debugger-plugin" "uuidm" { >= "0.9.9" } + "octez-protocol-021-PsQuebec-libs" + "tezos-protocol-021-PsQuebec" "octez-shell-libs" "dream" { >= "1.0.0~alpha7" } "octez-version" @@ -32,8 +34,6 @@ depends: [ "octez-smart-rollup-wasm-debugger-lib" "tezos-dal-node-services" "octez-performance-metrics" - "octez-protocol-021-PsQuebec-libs" - "tezos-protocol-021-PsQuebec" ] conflicts: [ "websocket" diff --git a/tobi/config b/tobi/config index 6ee73ad79dd72415173cd31483d34b4e336d1344..7d062929c2f0b5277c7d683ba77efa1e9ee7d116 100644 --- a/tobi/config +++ b/tobi/config @@ -64,7 +64,7 @@ octez-dal-node: src/bin_dal_node octez-distributed-internal: src/lib_distributed_internal/src octez-distributed-lwt-internal: src/lib_distributed_internal/lwt octez-evm-node: etherlink/bin_node -octez-evm-node-libs: etherlink/bin_node/config, etherlink/bin_node/installers, etherlink/bin_node/lib_dev, etherlink/bin_node/lib_dev/client, etherlink/bin_node/lib_dev/encodings, etherlink/bin_node/migrations, etherlink/lib_wasm_runtime, etherlink/lib_wasm_runtime/ocaml-api, etherlink/lib_wasm_runtime_callbacks, websocket/core, websocket/lwt +octez-evm-node-libs: etherlink/bin_node/config, etherlink/bin_node/installers, etherlink/bin_node/lib_dev, etherlink/bin_node/lib_dev/client, etherlink/bin_node/lib_dev/encodings, etherlink/bin_node/lib_dev/tezlink, etherlink/bin_node/migrations, etherlink/lib_wasm_runtime, etherlink/lib_wasm_runtime/ocaml-api, etherlink/lib_wasm_runtime_callbacks, websocket/core, websocket/lwt octez-evm-node-tests: etherlink/bin_node/test octez-evm-wasm-runtime-tests: etherlink/lib_wasm_runtime_callbacks/test octez-injector: src/lib_injector