diff --git a/etherlink/CHANGES_NODE.md b/etherlink/CHANGES_NODE.md index 76ef0f2eaf3821f2a8f47f6c11ce5a1be1ab15ae..0c8be814daa98767e408d3003641b3bd8d48c689 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 db9251cc66962ad43ea1f37f44bd226da1803b83..5b0115ecbba492beb537dcab516ab2843dcf5575 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); ] diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index f454a6ebe77999b2ce5fe8fb16964a63baf6f945..0434b640417d44b12e3aaee0875b1e91101ad40d 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