From 19565dffc7d7773f9e71cd7d8d10c386314686e5 Mon Sep 17 00:00:00 2001 From: Dibassi Brahima Date: Thu, 3 Apr 2025 14:01:36 +0200 Subject: [PATCH] Tezlink/Node/Encodings Add support for Tezos protocol in encoding modules --- etherlink/bin_node/lib_dev/encodings/dune | 3 +- .../bin_node/lib_dev/encodings/tezos_types.ml | 17 ++++++++++ .../lib_dev/encodings/tezos_types.mli | 10 ++++++ manifest/product_etherlink.ml | 31 ++++++++++--------- opam/octez-evm-node-libs.opam | 2 +- 5 files changed, 46 insertions(+), 17 deletions(-) diff --git a/etherlink/bin_node/lib_dev/encodings/dune b/etherlink/bin_node/lib_dev/encodings/dune index 1fda77e6749d..7013d6ffb122 100644 --- a/etherlink/bin_node/lib_dev/encodings/dune +++ b/etherlink/bin_node/lib_dev/encodings/dune @@ -10,7 +10,8 @@ octez-smart-rollup-wasm-debugger-plugin octez-evm-node-libs.websocket re - uuidm) + uuidm + octez-protocol-021-PsQuebec-libs.plugin) (flags (:standard) -open Tezos_base.TzPervasives)) diff --git a/etherlink/bin_node/lib_dev/encodings/tezos_types.ml b/etherlink/bin_node/lib_dev/encodings/tezos_types.ml index 6c5403e5e2fc..5bb632427f0f 100644 --- a/etherlink/bin_node/lib_dev/encodings/tezos_types.ml +++ b/etherlink/bin_node/lib_dev/encodings/tezos_types.ml @@ -40,3 +40,20 @@ let block_from_binary bytes = in {number; hash; timestamp; parent_hash = parent}) else raise (Invalid_argument "Expected a string of length 44") + +(* We don't yet support smart contracts so all addresses are implicit accounts. *) +type address = Signature.V1.public_key_hash + +let address_encoding = + Tezos_protocol_021_PsQuebec.Protocol.Alpha_context.Contract.implicit_encoding + +let address_of_b58check = Signature.V1.Public_key_hash.of_b58check + +let address_of_b58exn = Signature.V1.Public_key_hash.of_b58check_exn + +let address_to_hex_exn address = + let raw_key = Data_encoding.Binary.to_bytes_exn address_encoding address in + let (`Hex key) = Hex.of_bytes raw_key in + key + +module Tez = Tezos_protocol_021_PsQuebec.Protocol.Alpha_context.Tez diff --git a/etherlink/bin_node/lib_dev/encodings/tezos_types.mli b/etherlink/bin_node/lib_dev/encodings/tezos_types.mli index 25a0c2f62add..d3409b11f465 100644 --- a/etherlink/bin_node/lib_dev/encodings/tezos_types.mli +++ b/etherlink/bin_node/lib_dev/encodings/tezos_types.mli @@ -17,3 +17,13 @@ val decode_block_hash : bytes -> Ethereum_types.block_hash val genesis_parent_hash : Ethereum_types.block_hash val block_from_binary : bytes -> block + +type address = Signature.V1.public_key_hash + +val address_of_b58check : string -> address tzresult + +val address_of_b58exn : string -> address + +val address_to_hex_exn : address -> string + +module Tez = Tezos_protocol_021_PsQuebec.Protocol.Alpha_context.Tez diff --git a/manifest/product_etherlink.ml b/manifest/product_etherlink.ml index 0e9ee87b1dfc..6c9d7123fc77 100644 --- a/manifest/product_etherlink.ml +++ b/manifest/product_etherlink.ml @@ -23,6 +23,19 @@ include Product (struct let source = ["etherlink"; "src"] @ Product_websocket.product_source end) +let quebec = + List.find (fun proto -> Protocol.short_hash proto = "PsQuebec") Protocol.all + +let tezlink_protocol_plugin = + match Protocol.plugin quebec with + | Some target -> target + | None -> (* unreachable *) assert false + +let tezlink_protocol_parameters = + match Protocol.parameters quebec with + | Some target -> target + | None -> (* unreachable *) assert false + let tezt_etherlink = private_lib "tezt_etherlink" @@ -222,6 +235,7 @@ let evm_node_lib_dev_encoding = websocket; re; uuidm; + tezlink_protocol_plugin; ] let evm_node_config = @@ -241,19 +255,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" @@ -293,8 +294,8 @@ let evm_node_lib_dev = supported_installers; wasm_runtime; performance_metrics; - plugin; - parameters; + tezlink_protocol_plugin; + tezlink_protocol_parameters; octez_version; octez_shell_services; ] diff --git a/opam/octez-evm-node-libs.opam b/opam/octez-evm-node-libs.opam index 936ce9006061..296734d5ca65 100644 --- a/opam/octez-evm-node-libs.opam +++ b/opam/octez-evm-node-libs.opam @@ -24,6 +24,7 @@ depends: [ "re" { >= "1.10.0" } "octez-smart-rollup-wasm-debugger-plugin" "uuidm" { >= "0.9.9" } + "octez-protocol-021-PsQuebec-libs" "octez-shell-libs" "dream" { >= "1.0.0~alpha7" } "octez-version" @@ -32,7 +33,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: [ -- GitLab