From 4d564ab9c4986847bc98c7f98c3eb33d653cd962 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Mon, 26 May 2025 10:53:21 +0200 Subject: [PATCH 1/2] EVM node: fix tx type encoding --- etherlink/CHANGES_NODE.md | 3 +++ .../bin_node/lib_dev/transaction_object.ml | 24 +++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/etherlink/CHANGES_NODE.md b/etherlink/CHANGES_NODE.md index 76ef0f2eaf38..0c8be814daa9 100644 --- a/etherlink/CHANGES_NODE.md +++ b/etherlink/CHANGES_NODE.md @@ -8,6 +8,9 @@ ### RPCs changes +- Fix transaction type encoding to use a compact hex encoding following the + [standard](https://ethereum.org/en/developers/docs/transactions/#typed-transaction-envelope). (!18132) + ### Metrics changes ### Execution changes diff --git a/etherlink/bin_node/lib_dev/transaction_object.ml b/etherlink/bin_node/lib_dev/transaction_object.ml index db9251cc6696..5b0115ecbba4 100644 --- a/etherlink/bin_node/lib_dev/transaction_object.ml +++ b/etherlink/bin_node/lib_dev/transaction_object.ml @@ -469,14 +469,14 @@ let encoding = (fun o -> Legacy o); case ~title:"eip-2930" - (Tag 1) - (merge_objs (obj1 (req "type" (constant "0x01"))) EIP_2930.encoding) + (Tag 3) + (merge_objs (obj1 (req "type" (constant "0x1"))) EIP_2930.encoding) (function EIP_2930 o -> Some ((), o) | _ -> None) (fun ((), o) -> EIP_2930 o); case ~title:"eip-1559" - (Tag 2) - (merge_objs (obj1 (req "type" (constant "0x02"))) EIP_1559.encoding) + (Tag 4) + (merge_objs (obj1 (req "type" (constant "0x2"))) EIP_1559.encoding) (function EIP_1559 o -> Some ((), o) | _ -> None) (fun ((), o) -> EIP_1559 o); case @@ -485,4 +485,20 @@ let encoding = Ethereum_types.legacy_transaction_object_encoding (function Kernel o -> Some o | _ -> None) (fun o -> Kernel o); + (* The following are incorrect but kept for backward compatibility. See + https://ethereum.org/en/developers/docs/apis/json-rpc/#quantities-encoding + and + https://ethereum.org/en/developers/docs/transactions/#typed-transaction-envelope. *) + case + ~title:"eip-2930-backward-compat" + (Tag 1) + (merge_objs (obj1 (req "type" (constant "0x01"))) EIP_2930.encoding) + (fun _ -> None) + (fun ((), o) -> EIP_2930 o); + case + ~title:"eip-1559-backward-compat" + (Tag 2) + (merge_objs (obj1 (req "type" (constant "0x02"))) EIP_1559.encoding) + (fun _ -> None) + (fun ((), o) -> EIP_1559 o); ] -- GitLab From 923a49bcec91d99ed0d5c12d0b32b2b2ae60dd71 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Mon, 26 May 2025 12:19:10 +0200 Subject: [PATCH 2/2] Tezt: fix transaction object tests --- etherlink/tezt/tests/evm_sequencer.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index f454a6ebe779..0434b640417d 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -12135,12 +12135,12 @@ let test_transaction_object expected_type_ name make_transaction = (type_ = expected_type_) string ~error_msg: - ("Type was expected to be %L (" ^ name ^ "), but the RPC returned %R")) ; + ("Type was expected to be %R (" ^ name ^ "), but the RPC returned %L")) ; unit let test_eip2930_transaction_object = test_transaction_object - "0x01" + "0x1" "eip2930" (Cast.craft_tx ~legacy:true @@ -12159,7 +12159,7 @@ let test_eip2930_transaction_object = let test_eip1559_transaction_object = test_transaction_object - "0x02" + "0x2" "eip1559" (Cast.craft_tx ~legacy:false -- GitLab