From 9259605ce4f7db330e10a4d60ac2b49554a464c4 Mon Sep 17 00:00:00 2001 From: Rodi-Can Bozman Date: Mon, 15 Apr 2024 10:40:08 +0200 Subject: [PATCH 1/8] EVM/Node: fix deserialization functions The behaviour for EIP-1559 & EIP-2930 were swapped to match the **actual** specification. --- .../lib_dev/encodings/ethereum_types.ml | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/etherlink/bin_node/lib_dev/encodings/ethereum_types.ml b/etherlink/bin_node/lib_dev/encodings/ethereum_types.ml index 7a937739d271..a9f152aad2db 100644 --- a/etherlink/bin_node/lib_dev/encodings/ethereum_types.ml +++ b/etherlink/bin_node/lib_dev/encodings/ethereum_types.ml @@ -1026,19 +1026,19 @@ let transaction_nonce bytes = if String.starts_with ~prefix:"01" bytes then (* EIP-2930: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2930.md*) match bytes |> String.to_bytes |> Rlp.decode with - | Ok (Rlp.List [_; Value nonce; _; _; _; _; _; _; _]) - | Ok (Rlp.List [_; Value nonce; _; _; _; _; _; _; _; _; _; _]) -> + | Ok (Rlp.List [_; Value nonce; _; _; _; _; _; _]) + | Ok (Rlp.List [_; Value nonce; _; _; _; _; _; _; _; _; _]) -> let+ nonce = Rlp.decode_z nonce in nonce - | _ -> tzfail (Rlp.Rlp_decoding_error "Expected a list of 9 or 12 elements") + | _ -> tzfail (Rlp.Rlp_decoding_error "Expected a list of 8 or 11 elements") else if String.starts_with ~prefix:"02" bytes then (* EIP-1559: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md *) match bytes |> String.to_bytes |> Rlp.decode with - | Ok (Rlp.List [_; Value nonce; _; _; _; _; _; _]) - | Ok (Rlp.List [_; Value nonce; _; _; _; _; _; _; _; _; _]) -> + | Ok (Rlp.List [_; Value nonce; _; _; _; _; _; _; _]) + | Ok (Rlp.List [_; Value nonce; _; _; _; _; _; _; _; _; _; _]) -> let+ nonce = Rlp.decode_z nonce in nonce - | _ -> tzfail (Rlp.Rlp_decoding_error "Expected a list of 8 or 11 elements") + | _ -> tzfail (Rlp.Rlp_decoding_error "Expected a list of 9 or 12 elements") else (* Legacy: https://eips.ethereum.org/EIPS/eip-2972 *) match bytes |> String.to_bytes |> Rlp.decode with @@ -1053,19 +1053,19 @@ let transaction_gas_limit bytes = if String.starts_with ~prefix:"01" bytes then (* EIP-2930: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2930.md*) match bytes |> String.to_bytes |> Rlp.decode with - | Ok (Rlp.List [_; _; _; Value gas_limit; _; _; _; _; _]) - | Ok (Rlp.List [_; _; _; Value gas_limit; _; _; _; _; _; _; _; _]) -> + | Ok (Rlp.List [_; _; _; Value gas_limit; _; _; _; _]) + | Ok (Rlp.List [_; _; _; Value gas_limit; _; _; _; _; _; _; _]) -> let+ gas_limit = Rlp.decode_z gas_limit in gas_limit - | _ -> tzfail (Rlp.Rlp_decoding_error "Expected a list of 9 or 12 elements") + | _ -> tzfail (Rlp.Rlp_decoding_error "Expected a list of 8 or 11 elements") else if String.starts_with ~prefix:"02" bytes then (* EIP-1559: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md *) match bytes |> String.to_bytes |> Rlp.decode with - | Ok (Rlp.List [_; _; _; _; Value gas_limit; _; _; _]) - | Ok (Rlp.List [_; _; _; _; Value gas_limit; _; _; _; _; _; _]) -> + | Ok (Rlp.List [_; _; _; _; Value gas_limit; _; _; _; _]) + | Ok (Rlp.List [_; _; _; _; Value gas_limit; _; _; _; _; _; _; _]) -> let+ gas_limit = Rlp.decode_z gas_limit in gas_limit - | _ -> tzfail (Rlp.Rlp_decoding_error "Expected a list of 8 or 11 elements") + | _ -> tzfail (Rlp.Rlp_decoding_error "Expected a list of 9 or 12 elements") else (* Legacy: https://eips.ethereum.org/EIPS/eip-2972 *) match bytes |> String.to_bytes |> Rlp.decode with @@ -1081,16 +1081,16 @@ let transaction_gas_price bytes = if String.starts_with ~prefix:"01" bytes then (* EIP-2930: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2930.md*) match bytes |> String.to_bytes |> Rlp.decode with - | Ok (Rlp.List [_; _; Value gas_price; _; _; _; _; _; _]) - | Ok (Rlp.List [_; _; Value gas_price; _; _; _; _; _; _; _; _; _]) -> + | Ok (Rlp.List [_; _; Value gas_price; _; _; _; _; _]) + | Ok (Rlp.List [_; _; Value gas_price; _; _; _; _; _; _; _; _]) -> let* gas_price = Rlp.decode_z gas_price in return gas_price - | _ -> tzfail (Rlp.Rlp_decoding_error "Expected a list of 9 or 12 elements") + | _ -> tzfail (Rlp.Rlp_decoding_error "Expected a list of 8 or 11 elements") else if String.starts_with ~prefix:"02" bytes then (* EIP-1559: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md *) match bytes |> String.to_bytes |> Rlp.decode with - | Ok (Rlp.List [_; _; _; Value max_fee_per_gas; _; _; _; _]) - | Ok (Rlp.List [_; _; _; Value max_fee_per_gas; _; _; _; _; _; _; _]) -> + | Ok (Rlp.List [_; _; _; Value max_fee_per_gas; _; _; _; _; _]) + | Ok (Rlp.List [_; _; _; Value max_fee_per_gas; _; _; _; _; _; _; _; _]) -> (* Normally, max_priority_fee_per_gas would also be a fee paid per gas in addition to base fee per gas. This would incentivise miners to include the transaction. @@ -1101,7 +1101,7 @@ let transaction_gas_price bytes = the data availability fee. *) let* max_fee_per_gas = Rlp.decode_z max_fee_per_gas in return max_fee_per_gas - | _ -> tzfail (Rlp.Rlp_decoding_error "Expected a list of 8 or 11 elements") + | _ -> tzfail (Rlp.Rlp_decoding_error "Expected a list of 9 or 12 elements") else (* Legacy: https://eips.ethereum.org/EIPS/eip-2972 *) match bytes |> String.to_bytes |> Rlp.decode with -- GitLab From 61454e535e14de3a97a21bac4941741438d9fc9e Mon Sep 17 00:00:00 2001 From: Rodi-Can Bozman Date: Tue, 9 Apr 2024 17:00:34 +0200 Subject: [PATCH 2/8] EVM/Node: add a deserialization function for data from raw transactions --- .../lib_dev/encodings/ethereum_types.ml | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/etherlink/bin_node/lib_dev/encodings/ethereum_types.ml b/etherlink/bin_node/lib_dev/encodings/ethereum_types.ml index a9f152aad2db..a7a915397de8 100644 --- a/etherlink/bin_node/lib_dev/encodings/ethereum_types.ml +++ b/etherlink/bin_node/lib_dev/encodings/ethereum_types.ml @@ -1024,7 +1024,7 @@ let hash_raw_tx str = let transaction_nonce bytes = let open Result_syntax in if String.starts_with ~prefix:"01" bytes then - (* EIP-2930: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2930.md*) + (* EIP-2930: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2930.md *) match bytes |> String.to_bytes |> Rlp.decode with | Ok (Rlp.List [_; Value nonce; _; _; _; _; _; _]) | Ok (Rlp.List [_; Value nonce; _; _; _; _; _; _; _; _; _]) -> @@ -1047,11 +1047,34 @@ let transaction_nonce bytes = nonce | _ -> tzfail (Rlp.Rlp_decoding_error "Expected a list of 9 elements") +(** [transaction_data bytes] returns the data of a given raw transaction. *) +let transaction_data bytes = + let open Result_syntax in + if String.starts_with ~prefix:"01" bytes then + (* EIP-2930: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2930.md *) + match bytes |> String.to_bytes |> Rlp.decode with + | Ok (Rlp.List [_; _; _; _; _; _; Value data; _]) + | Ok (Rlp.List [_; _; _; _; _; _; Value data; _; _; _; _]) -> + return data + | _ -> tzfail (Rlp.Rlp_decoding_error "Expected a list of 8 or 11 elements") + else if String.starts_with ~prefix:"02" bytes then + (* EIP-1559: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md *) + match bytes |> String.to_bytes |> Rlp.decode with + | Ok (Rlp.List [_; _; _; _; _; _; _; Value data; _]) + | Ok (Rlp.List [_; _; _; _; _; _; _; Value data; _; _; _; _]) -> + return data + | _ -> tzfail (Rlp.Rlp_decoding_error "Expected a list of 9 or 12 elements") + else + (* Legacy: https://eips.ethereum.org/EIPS/eip-2972 *) + match bytes |> String.to_bytes |> Rlp.decode with + | Ok (Rlp.List [_; _; _; _; _; Value data; _; _; _]) -> return data + | _ -> tzfail (Rlp.Rlp_decoding_error "Expected a list of 9 elements") + (** [transaction_gas_limit bytes] returns the gas limit of a given raw transaction. *) let transaction_gas_limit bytes = let open Result_syntax in if String.starts_with ~prefix:"01" bytes then - (* EIP-2930: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2930.md*) + (* EIP-2930: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2930.md *) match bytes |> String.to_bytes |> Rlp.decode with | Ok (Rlp.List [_; _; _; Value gas_limit; _; _; _; _]) | Ok (Rlp.List [_; _; _; Value gas_limit; _; _; _; _; _; _; _]) -> @@ -1079,7 +1102,7 @@ let transaction_gas_limit bytes = let transaction_gas_price bytes = let open Result_syntax in if String.starts_with ~prefix:"01" bytes then - (* EIP-2930: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2930.md*) + (* EIP-2930: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2930.md *) match bytes |> String.to_bytes |> Rlp.decode with | Ok (Rlp.List [_; _; Value gas_price; _; _; _; _; _]) | Ok (Rlp.List [_; _; Value gas_price; _; _; _; _; _; _; _; _]) -> -- GitLab From 336851a0afd1d4ece830f014417bd82a26c00b20 Mon Sep 17 00:00:00 2001 From: Rodi-Can Bozman Date: Thu, 11 Apr 2024 14:42:26 +0200 Subject: [PATCH 3/8] EVM/Test: add a unit test to check the data transaction deserialization position invariance --- etherlink/bin_node/test/test_rlp.ml | 43 +++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/etherlink/bin_node/test/test_rlp.ml b/etherlink/bin_node/test/test_rlp.ml index ab040d694bc3..89ef3b5e6c19 100644 --- a/etherlink/bin_node/test/test_rlp.ml +++ b/etherlink/bin_node/test/test_rlp.ml @@ -2,6 +2,7 @@ (* *) (* Open Source License *) (* Copyright (c) 2023 Nomadic Labs *) +(* Copyright (c) 2024 Functori *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -26,7 +27,7 @@ (** Testing ------- Component: Bin_evm_node - Invocation: dune exec etherlink/bin_evm_node/test/main.exe -- --file test_rlp.ml + Invocation: dune exec etherlink/bin_node/test/main.exe -- --file test_rlp.ml Subject: Tests for the RLP encoder/decoder *) @@ -137,6 +138,31 @@ let test_canonical_invalid_vectors () = let valid_tests = read_test_vector "invalidRLPTest.json" in List.iter (fun (testname, rlp, bytes) -> check testname rlp bytes) valid_tests +let test_transaction_data_decoding_pos_invariance _ () = + let bs = Bytes.of_string in + let expected_data = bs "\x05" in + let encoded_data = + Rlp.encode + @@ Rlp.List + [ + Value (bs "\x00"); + Value (bs "\x00"); + Value (bs "\x00"); + Value (bs "\x00"); + Value (bs "\x00"); + Value expected_data; + Value (bs "\x00"); + Value (bs "\x00"); + Value (bs "\x00"); + ] + in + let data = + Ethereum_types.transaction_data (Bytes.to_string encoded_data) + |> Result.value_f ~default:(fun () -> Test.fail "Decoding failed") + in + Alcotest.(check bytes) "Expected data should coincide" expected_data data ; + Lwt.return_unit + let tests = [ ( "RLP", @@ -149,4 +175,17 @@ let tests = ] ); ] -let () = Alcotest.run ~__FILE__ "Test RLP encoding" tests +let lwt_tests = + [ + ( "RLP", + [ + Alcotest_lwt.test_case + "test transaction data decoding" + `Quick + test_transaction_data_decoding_pos_invariance; + ] ); + ] + +let () = + Alcotest.run ~__FILE__ "Test RLP encoding" tests ; + Lwt_main.run @@ Alcotest_lwt.run ~__FILE__ "Test RLP decoding" lwt_tests -- GitLab From 8cb2aaed598abce4f7125518fb4735c7c69305af Mon Sep 17 00:00:00 2001 From: Rodi-Can Bozman Date: Tue, 9 Apr 2024 17:07:45 +0200 Subject: [PATCH 4/8] EVM/Node: add an event to notify the tx data size reached limit --- etherlink/bin_node/lib_dev/tx_pool_events.ml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/etherlink/bin_node/lib_dev/tx_pool_events.ml b/etherlink/bin_node/lib_dev/tx_pool_events.ml index a3f853446bf9..aa8fe59141d0 100644 --- a/etherlink/bin_node/lib_dev/tx_pool_events.ml +++ b/etherlink/bin_node/lib_dev/tx_pool_events.ml @@ -55,6 +55,14 @@ module Event = struct ("address", Data_encoding.string) ~pp1:Format.pp_print_string + let tx_data_size_limit_reached = + declare_0 + ~section + ~name:"tx_data_size_limit_reached" + ~msg:"The transaction data size is beyond the allowed threshold." + ~level:Info + () + let transaction_injected = declare_1 ~section @@ -111,6 +119,9 @@ let users_threshold_reached = let txs_per_user_threshold_reached ~address = Internal_event.Simple.emit Event.txs_per_user_threshold_reached address +let tx_data_size_limit_reached = + Internal_event.Simple.emit Event.tx_data_size_limit_reached + let transaction_injection_failed trace = Internal_event.Simple.emit Event.transaction_injection_failed trace -- GitLab From ede299e66142c030850bdf0e24f9565610843fad Mon Sep 17 00:00:00 2001 From: Rodi-Can Bozman Date: Wed, 10 Apr 2024 11:08:55 +0200 Subject: [PATCH 5/8] EVM/Node: parametrize the transaction pool by number of allowed chunked per l1 level --- etherlink/bin_node/lib_dev/observer.ml | 1 + etherlink/bin_node/lib_dev/proxy.ml | 1 + etherlink/bin_node/lib_dev/sequencer.ml | 4 ++++ etherlink/bin_node/lib_dev/tx_pool.ml | 4 ++++ etherlink/bin_node/lib_dev/tx_pool.mli | 3 +++ 5 files changed, 13 insertions(+) diff --git a/etherlink/bin_node/lib_dev/observer.ml b/etherlink/bin_node/lib_dev/observer.ml index 816f6b19ba39..7ed8e31ddbb4 100644 --- a/etherlink/bin_node/lib_dev/observer.ml +++ b/etherlink/bin_node/lib_dev/observer.ml @@ -262,6 +262,7 @@ let main ?kernel_path ~rollup_node_endpoint ~evm_node_endpoint ~data_dir tx_pool_addr_limit = Int64.to_int config.tx_pool_addr_limit; tx_pool_tx_per_addr_limit = Int64.to_int config.tx_pool_tx_per_addr_limit; + max_number_of_chunks = None; } in diff --git a/etherlink/bin_node/lib_dev/proxy.ml b/etherlink/bin_node/lib_dev/proxy.ml index 400541f786d9..075d67feb90b 100644 --- a/etherlink/bin_node/lib_dev/proxy.ml +++ b/etherlink/bin_node/lib_dev/proxy.ml @@ -113,6 +113,7 @@ let main (config : Configuration.t) ~keep_alive ~rollup_node_endpoint = tx_pool_addr_limit = Int64.to_int config.tx_pool_addr_limit; tx_pool_tx_per_addr_limit = Int64.to_int config.tx_pool_tx_per_addr_limit; + max_number_of_chunks = None; } in let () = Rollup_node_follower.start ~proxy:true ~rollup_node_endpoint in diff --git a/etherlink/bin_node/lib_dev/sequencer.ml b/etherlink/bin_node/lib_dev/sequencer.ml index 56e6172761fb..39967658be00 100644 --- a/etherlink/bin_node/lib_dev/sequencer.ml +++ b/etherlink/bin_node/lib_dev/sequencer.ml @@ -247,6 +247,10 @@ let main ~data_dir ~rollup_node_endpoint ~max_blueprints_lag tx_pool_addr_limit = Int64.to_int configuration.tx_pool_addr_limit; tx_pool_tx_per_addr_limit = Int64.to_int configuration.tx_pool_tx_per_addr_limit; + max_number_of_chunks = + (match configuration.sequencer with + | Some {max_number_of_chunks; _} -> Some max_number_of_chunks + | None -> None); } in let* () = diff --git a/etherlink/bin_node/lib_dev/tx_pool.ml b/etherlink/bin_node/lib_dev/tx_pool.ml index ca2498f5c423..d24a6a2d670f 100644 --- a/etherlink/bin_node/lib_dev/tx_pool.ml +++ b/etherlink/bin_node/lib_dev/tx_pool.ml @@ -127,6 +127,7 @@ type parameters = { tx_timeout_limit : int64; tx_pool_addr_limit : int; tx_pool_tx_per_addr_limit : int; + max_number_of_chunks : int option; } module Types = struct @@ -138,6 +139,7 @@ module Types = struct tx_timeout_limit : int64; tx_pool_addr_limit : int; tx_pool_tx_per_addr_limit : int; + max_number_of_chunks : int option; mutable locked : bool; } @@ -521,6 +523,7 @@ module Handlers = struct tx_timeout_limit; tx_pool_addr_limit; tx_pool_tx_per_addr_limit; + max_number_of_chunks; } : Types.parameters) = let state = @@ -533,6 +536,7 @@ module Handlers = struct tx_timeout_limit; tx_pool_addr_limit; tx_pool_tx_per_addr_limit; + max_number_of_chunks; locked = false; } in diff --git a/etherlink/bin_node/lib_dev/tx_pool.mli b/etherlink/bin_node/lib_dev/tx_pool.mli index 9663e6145b6e..8b1cc5121e0d 100644 --- a/etherlink/bin_node/lib_dev/tx_pool.mli +++ b/etherlink/bin_node/lib_dev/tx_pool.mli @@ -16,6 +16,9 @@ type parameters = { tx_pool_addr_limit : int; (** Maximum allowed addresses inside the pool. *) tx_pool_tx_per_addr_limit : int; (** Maximum allowed transactions per address inside the pool. *) + max_number_of_chunks : int option; + (** Maximum allowed number of chunks to be sent (relevant for the + sequencer). *) } (** [start parameters] starts the tx-pool *) -- GitLab From 308a8d5ae852a39c0e27780923bf08a5c9af688f Mon Sep 17 00:00:00 2001 From: Rodi-Can Bozman Date: Tue, 9 Apr 2024 17:20:57 +0200 Subject: [PATCH 6/8] EVM/Node: tx data that exceed the allowed size are rejected --- etherlink/bin_node/lib_dev/tx_pool.ml | 62 +++++++++++++++++---------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/etherlink/bin_node/lib_dev/tx_pool.ml b/etherlink/bin_node/lib_dev/tx_pool.ml index d24a6a2d670f..9e7e40c7abb0 100644 --- a/etherlink/bin_node/lib_dev/tx_pool.ml +++ b/etherlink/bin_node/lib_dev/tx_pool.ml @@ -28,9 +28,8 @@ module Pool = struct let empty : t = {transactions = Pkey_map.empty; global_index = Int64.zero} (** Add a transaction to the pool. *) - let add t pkey raw_tx = + let add {transactions; global_index} pkey raw_tx = let open Result_syntax in - let {transactions; global_index} = t in let* nonce = Ethereum_types.transaction_nonce raw_tx in let* gas_price = Ethereum_types.transaction_gas_price raw_tx in let* gas_limit = Ethereum_types.transaction_gas_limit raw_tx in @@ -249,6 +248,18 @@ module Worker = Worker.MakeSingle (Name) (Request) (Types) type worker = Worker.infinite Worker.queue Worker.t +let tx_data_size_limit_reached ~max_number_of_chunks ~tx_data = + let maximum_chunks_per_l1_level = + Option.value + ~default:Sequencer_blueprint.maximum_chunks_per_l1_level + max_number_of_chunks + in + Bytes.length tx_data + > Sequencer_blueprint.maximum_usable_space_in_blueprint + (* Minus one so that the "rest" of the raw transaction can + be contained within one of the chunks. *) + (maximum_chunks_per_l1_level - 1) + let check_address_boundaries ~pool ~address ~tx_pool_addr_limit ~tx_pool_tx_per_addr_limit = let open Lwt_result_syntax in @@ -284,11 +295,11 @@ let on_normal_transaction state tx_raw = pool; tx_pool_addr_limit; tx_pool_tx_per_addr_limit; + max_number_of_chunks; _; } = state in - let* is_valid = Rollup_node.is_tx_valid tx_raw in match is_valid with | Error err -> @@ -298,28 +309,33 @@ let on_normal_transaction state tx_raw = in return (Error err) | Ok {address} -> - let* address_boundaries_are_reached, error_msg = - check_address_boundaries - ~pool - ~address - ~tx_pool_addr_limit - ~tx_pool_tx_per_addr_limit - in - if address_boundaries_are_reached then return @@ Error error_msg + let*? tx_data = Ethereum_types.transaction_data tx_raw in + if tx_data_size_limit_reached ~max_number_of_chunks ~tx_data then + let*! () = Tx_pool_events.tx_data_size_limit_reached () in + return @@ Error "Transaction data exceeded the allowed size." else - (* Add the tx to the pool*) - let*? pool = Pool.add pool address tx_raw in - (* compute the hash *) - let tx_hash = Ethereum_types.hash_raw_tx tx_raw in - let hash = - Ethereum_types.hash_of_string Hex.(of_string tx_hash |> show) - in - let*! () = - Tx_pool_events.add_transaction - ~transaction:(Ethereum_types.hash_to_string hash) + let* address_boundaries_are_reached, error_msg = + check_address_boundaries + ~pool + ~address + ~tx_pool_addr_limit + ~tx_pool_tx_per_addr_limit in - state.pool <- pool ; - return (Ok hash) + if address_boundaries_are_reached then return @@ Error error_msg + else + (* Add the transaction to the pool *) + let*? pool = Pool.add pool address tx_raw in + (* Compute the hash *) + let tx_hash = Ethereum_types.hash_raw_tx tx_raw in + let hash = + Ethereum_types.hash_of_string Hex.(of_string tx_hash |> show) + in + let*! () = + Tx_pool_events.add_transaction + ~transaction:(Ethereum_types.hash_to_string hash) + in + state.pool <- pool ; + return (Ok hash) (** Checks that [balance] is enough to pay up to the maximum [gas_limit] the sender defined parametrized by the [gas_price]. *) -- GitLab From 2206d2c0073182576ac9f6f263e9bc2cd020923f Mon Sep 17 00:00:00 2001 From: Rodi-Can Bozman Date: Wed, 10 Apr 2024 10:18:26 +0200 Subject: [PATCH 7/8] EVM/Tezt: test transaction size limit on the tx pool --- etherlink/tezt/tests/evm_rollup.ml | 73 ++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 4 deletions(-) diff --git a/etherlink/tezt/tests/evm_rollup.ml b/etherlink/tezt/tests/evm_rollup.ml index 522802d57b7a..9ce1c8e54515 100644 --- a/etherlink/tezt/tests/evm_rollup.ml +++ b/etherlink/tezt/tests/evm_rollup.ml @@ -285,8 +285,8 @@ let setup_evm_kernel ?(setup_kernel_root_hash = true) ?config ?(with_administrator = true) ?da_fee_per_byte ?minimum_base_fee_per_gas ~admin ?sequencer_admin ?commitment_period ?challenge_window ?timestamp ?tx_pool_timeout_limit ?tx_pool_addr_limit ?tx_pool_tx_per_addr_limit - ?(setup_mode = Setup_proxy {devmode = true}) ?(force_install_kernel = true) - protocol = + ?max_number_of_chunks ?(setup_mode = Setup_proxy {devmode = true}) + ?(force_install_kernel = true) protocol = let* node, client = setup_l1 ?commitment_period ?challenge_window ?timestamp protocol in @@ -407,7 +407,7 @@ let setup_evm_kernel ?(setup_kernel_root_hash = true) ?config max_blueprints_ahead = None; max_blueprints_catchup = None; catchup_cooldown = None; - max_number_of_chunks = None; + max_number_of_chunks; devmode; wallet_dir = Some (Client.base_dir client); tx_pool_timeout_limit; @@ -5410,6 +5410,70 @@ let test_tx_pool_address_boundaries = ~error_msg:"Expected transaction hash is %R, got %L" ; unit +let test_tx_pool_transaction_size_exceeded = + Protocol.register_test + ~__FILE__ + ~tags:["evm"; "tx_pool"; "max"; "transaction"; "size"] + ~title: + "Check that a transaction that exceed the data size limit will be \ + rejected." + ~uses:(fun _protocol -> + [ + Constant.octez_smart_rollup_node; + Constant.octez_evm_node; + Constant.smart_rollup_installer; + Constant.WASM.evm_kernel; + ]) + @@ fun protocol -> + let sequencer_admin = Constant.bootstrap1 in + let admin = Some Constant.bootstrap3 in + let setup_mode = + Setup_sequencer + { + time_between_blocks = Some Nothing; + sequencer = sequencer_admin; + devmode = true; + } + in + let* {evm_node = sequencer_node; _} = + setup_evm_kernel + ~sequencer_admin + ~admin + ~minimum_base_fee_per_gas:base_fee_for_hardcoded_tx + ~max_number_of_chunks:1 + ~setup_mode + protocol + in + let tx = + (* { + "chainId": "1337", + "type": "LegacyTransaction", + "valid": true, + "hash": "0xb4c823c72996be6f4767997f21dac443568f3d0a1cd24f3b29eeb66cb5aca2f8", + "nonce": "0", + "gasPrice": "21000", + "gasLimit": "23300", + "from": "0x6ce4d79d4E77402e1ef3417Fdda433aA744C6e1c", + "to": "0xb53dc01974176e5dff2298c5a94343c2585e3c54", + "v": "0a96", + "r": "f333e35786005f6d2c0a351d7bb42950c0236a800be8c2e0b5878af9f8c86fec", + "s": "620a8fc5b904363a9ce8af6f4fceba432f671c1e809894bf911e0176ab8e7b1c", + "value": "0", + "data": "01" + } *) + "f86380825208825b0494b53dc01974176e5dff2298c5a94343c2585e3c548001820a96a0f333e35786005f6d2c0a351d7bb42950c0236a800be8c2e0b5878af9f8c86feca0620a8fc5b904363a9ce8af6f4fceba432f671c1e809894bf911e0176ab8e7b1c" + in + (* Limitation on size of the transaction *) + let*@? rejected_transaction = + Rpc.send_raw_transaction ~raw_tx:tx sequencer_node + in + Check.( + (rejected_transaction.message + = "Transaction data exceeded the allowed size.") + string) + ~error_msg:"This transaction should be rejected with error msg %R not %L" ; + unit + let register_evm_node ~protocols = test_originate_evm_kernel protocols ; test_kernel_root_hash_originate_absent protocols ; @@ -5506,7 +5570,8 @@ let register_evm_node ~protocols = test_outbox_size_limit_resilience ~slow:true protocols ; test_outbox_size_limit_resilience ~slow:false protocols ; test_tx_pool_timeout protocols ; - test_tx_pool_address_boundaries protocols + test_tx_pool_address_boundaries protocols ; + test_tx_pool_transaction_size_exceeded protocols let protocols = Protocol.all -- GitLab From 53e260033ff7277fab621331a9c4577b5b18cc3f Mon Sep 17 00:00:00 2001 From: Rodi-Can Bozman Date: Tue, 9 Apr 2024 17:21:57 +0200 Subject: [PATCH 8/8] EVM/Logs: add an entry in features --- etherlink/CHANGES_NODE.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/etherlink/CHANGES_NODE.md b/etherlink/CHANGES_NODE.md index 000b2e181e3b..dd4cc6b0b8e9 100644 --- a/etherlink/CHANGES_NODE.md +++ b/etherlink/CHANGES_NODE.md @@ -10,6 +10,8 @@ (4000 by default). (!12749) - The transaction pool has a threshold of simultaneous transactions allowed per user (16 by default). (!12749) +- The transaction pool will reject transactions that can not be contained within + the size of a blueprint. (!12834) ### Bug fixes -- GitLab