From a797d08e6f65ff08c266a95edfa671a562134108 Mon Sep 17 00:00:00 2001 From: pikatos Date: Tue, 30 Apr 2024 17:46:55 +0200 Subject: [PATCH 1/4] EVM/Node: add eth_maxPriorityFeePerGas encoding schema --- etherlink/bin_node/lib_dev/rpc_encodings.ml | 17 +++++++++++++++++ etherlink/bin_node/lib_dev/rpc_encodings.mli | 3 +++ 2 files changed, 20 insertions(+) diff --git a/etherlink/bin_node/lib_dev/rpc_encodings.ml b/etherlink/bin_node/lib_dev/rpc_encodings.ml index 5aff0b21f535..96cb9e439328 100644 --- a/etherlink/bin_node/lib_dev/rpc_encodings.ml +++ b/etherlink/bin_node/lib_dev/rpc_encodings.ml @@ -694,6 +694,22 @@ module Durable_state_value = struct type ('input, 'output) method_ += Method : (input, output) method_ end +module Eth_max_priority_fee_per_gas = struct + open Ethereum_types + + type input = unit + + type output = quantity + + let input_encoding = Data_encoding.unit + + let output_encoding = quantity_encoding + + let method_ = "eth_maxPriorityFeePerGas" + + type ('input, 'output) method_ += Method : (input, output) method_ +end + type map_result = | Method : ('input, 'output) method_ @@ -737,6 +753,7 @@ let supported_methods : (module METHOD) list = (module Web3_sha3); (module Produce_block); (module Durable_state_value); + (module Eth_max_priority_fee_per_gas); ] let unsupported_methods : string list = diff --git a/etherlink/bin_node/lib_dev/rpc_encodings.mli b/etherlink/bin_node/lib_dev/rpc_encodings.mli index 03b7eb266855..6cb1651352e1 100644 --- a/etherlink/bin_node/lib_dev/rpc_encodings.mli +++ b/etherlink/bin_node/lib_dev/rpc_encodings.mli @@ -269,6 +269,9 @@ module Durable_state_value : with type input = Durable_storage_path.path and type output = Bytes.t option +module Eth_max_priority_fee_per_gas : + METHOD with type input = unit and type output = Ethereum_types.quantity + type map_result = | Method : ('input, 'output) method_ -- GitLab From ea5e836e8fa413cfd77242f8f422cda62e374a48 Mon Sep 17 00:00:00 2001 From: pikatos Date: Tue, 30 Apr 2024 18:15:54 +0200 Subject: [PATCH 2/4] EVM/node: add eth_maxPriorityFeePerGas implementation --- etherlink/bin_node/lib_dev/services.ml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/etherlink/bin_node/lib_dev/services.ml b/etherlink/bin_node/lib_dev/services.ml index afc10163bbc1..ea643dfb455c 100644 --- a/etherlink/bin_node/lib_dev/services.ml +++ b/etherlink/bin_node/lib_dev/services.ml @@ -397,6 +397,9 @@ let dispatch_request (config : Configuration.t) rpc_ok kernel_root_hash in build ~f module_ parameters + | Method (Eth_max_priority_fee_per_gas.Method, module_) -> + let f (_ : unit option) = rpc_ok @@ Qty Z.zero in + build ~f module_ parameters | _ -> Stdlib.failwith "The pattern matching of methods is not exhaustive" in Lwt.return JSONRPC.{value; id} -- GitLab From ab3b1e747d16260ab4c0972316367fa1073c2a52 Mon Sep 17 00:00:00 2001 From: pikatos Date: Thu, 2 May 2024 09:44:54 +0200 Subject: [PATCH 3/4] evm/tezt: add eth_maxPriorityFeePerGas test --- etherlink/tezt/lib/rpc.ml | 7 +++++++ etherlink/tezt/lib/rpc.mli | 4 ++++ etherlink/tezt/tests/evm_rollup.ml | 22 +++++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/etherlink/tezt/lib/rpc.ml b/etherlink/tezt/lib/rpc.ml index 6b42a6156ad3..0b0fcb3ccb68 100644 --- a/etherlink/tezt/lib/rpc.ml +++ b/etherlink/tezt/lib/rpc.ml @@ -126,6 +126,9 @@ module Request = struct method_ = "eth_getStorageAt"; parameters = `A [`String address; `String pos; block_param_to_json block]; } + + let eth_maxPriorityFeePerGas = + {method_ = "eth_maxPriorityFeePerGas"; parameters = `Null} end let net_version evm_node = @@ -302,3 +305,7 @@ let get_storage_at ~address ?(block = Latest) ~pos evm_node = @@ decode_or_error (fun response -> Evm_node.extract_result response |> JSON.as_string) response + +let get_max_priority_fee_per_gas evm_node = + let* json = Evm_node.call_evm_rpc evm_node Request.eth_maxPriorityFeePerGas in + return JSON.(json |-> "result" |> as_int32) diff --git a/etherlink/tezt/lib/rpc.mli b/etherlink/tezt/lib/rpc.mli index 1c2b6c001577..6d3980a60c1d 100644 --- a/etherlink/tezt/lib/rpc.mli +++ b/etherlink/tezt/lib/rpc.mli @@ -41,6 +41,8 @@ module Request : sig val eth_getCode : address:string -> block:block_param -> Evm_node.request val net_version : Evm_node.request + + val eth_maxPriorityFeePerGas : Evm_node.request end (** [net_version evm_node] calls [net_version]. *) @@ -142,3 +144,5 @@ val get_storage_at : pos:string -> Evm_node.t -> (string, error) result Lwt.t + +val get_max_priority_fee_per_gas : Evm_node.t -> Int32.t Lwt.t diff --git a/etherlink/tezt/tests/evm_rollup.ml b/etherlink/tezt/tests/evm_rollup.ml index 18ced4a47884..19c50fdd245c 100644 --- a/etherlink/tezt/tests/evm_rollup.ml +++ b/etherlink/tezt/tests/evm_rollup.ml @@ -5565,6 +5565,25 @@ let test_whitelist_is_executed = ~error_msg:"found %R expected %L") ; unit +let test_rpc_maxPriorityFeePerGas = + register_both + ~tags:["evm"; "rpc"; "max_priority_fee_per_gas"] + ~title:"RPC methods eth_maxPriorityFeePerGas" + @@ fun ~protocol:_ ~evm_setup:{evm_node; _} -> + let expected_max_priority_fee_per_gas = Wei.of_gwei_string "0" in + let* max_priority_fee_per_gas = + Evm_node.( + let* price = + call_evm_rpc + evm_node + {method_ = "eth_maxPriorityFeePerGas"; parameters = `A []} + in + return JSON.(price |-> "result" |> as_int64 |> Z.of_int64 |> Wei.to_wei_z)) + in + Check.((max_priority_fee_per_gas = expected_max_priority_fee_per_gas) Wei.typ) + ~error_msg:"Expected %R, but got %L" ; + unit + let register_evm_node ~protocols = test_originate_evm_kernel protocols ; test_kernel_root_hash_originate_absent protocols ; @@ -5665,7 +5684,8 @@ let register_evm_node ~protocols = test_tx_pool_timeout protocols ; test_tx_pool_address_boundaries protocols ; test_tx_pool_transaction_size_exceeded protocols ; - test_whitelist_is_executed protocols + test_whitelist_is_executed protocols ; + test_rpc_maxPriorityFeePerGas protocols let protocols = Protocol.all -- GitLab From 8f7035a1c5847c80169b28b43120f7ca3b6551aa Mon Sep 17 00:00:00 2001 From: pikatos Date: Thu, 2 May 2024 14:06:12 +0200 Subject: [PATCH 4/4] EVM/Node: add eth_maxPriorityFeePerGas spec to the changelog --- etherlink/CHANGES_NODE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/etherlink/CHANGES_NODE.md b/etherlink/CHANGES_NODE.md index 49089bf4e6ad..d50a521adfe9 100644 --- a/etherlink/CHANGES_NODE.md +++ b/etherlink/CHANGES_NODE.md @@ -12,6 +12,7 @@ `requireCanonical` field is not yet supported. (!12345) - The RPC `eth_call` supports the default block parameter (https://ethereum.org/en/developers/docs/apis/json-rpc/#default-block). (!13110) +- Support the RPC `eth_maxPriorityFeePerGas`, which always returns 0 wei. (!13161) ### Bug fixes -- GitLab