Skip to content

Conversation

SDartayet
Copy link
Contributor

@SDartayet SDartayet commented Oct 14, 2025

Motivation

Part of our broader campaign to remove .clone()s from our code

Description

This PR goes over all the clones in the rpc module of the networking crate (and over most of the clones in the l2 rpc module too), removing most and justifying the remaining ones. Some broad changes introduced for this purpose:

  • The parse function for RPC calls consumes the params now (rather than taking an immutable reference). Instead of cloning the values, they're popped in reverse order, with appropriate error handling.
  • The handle function for RPC calls now consumes self (rather than taking an immutable reference). This allows us to consume the attributes rather than clone them; which is fine given handle is at the very end of the request lifecycle.
  • In NewPayload calls, specifically v3 and v4, the validation of payload parameters is now done before turning the payload into a block. This is done so that the payload can be consumed when it's turned into a block, so as to avoid the need to clone it.

Part of #4668

Copy link

github-actions bot commented Oct 14, 2025

Lines of code report

Total lines added: 129
Total lines removed: 32
Total lines changed: 161

Detailed view
+-------------------------------------------------------------------+-------+------+
| File                                                              | Lines | Diff |
+-------------------------------------------------------------------+-------+------+
| ethrex/crates/l2/networking/rpc/l2/transaction.rs                 | 242   | -1   |
+-------------------------------------------------------------------+-------+------+
| ethrex/crates/l2/networking/rpc/rpc.rs                            | 202   | +2   |
+-------------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/admin/mod.rs                         | 82    | -1   |
+-------------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/debug/execution_witness.rs           | 161   | +10  |
+-------------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/engine/exchange_transition_config.rs | 68    | +2   |
+-------------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/engine/fork_choice.rs                | 361   | +5   |
+-------------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/engine/mod.rs                        | 51    | -2   |
+-------------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/engine/payload.rs                    | 716   | +29  |
+-------------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/eth/account.rs                       | 313   | +43  |
+-------------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/eth/block.rs                         | 385   | +23  |
+-------------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/eth/fee_market.rs                    | 236   | +7   |
+-------------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/eth/logs.rs                          | 177   | +2   |
+-------------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/eth/mod.rs                           | 184   | +1   |
+-------------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/eth/transaction.rs                   | 552   | -19  |
+-------------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/rpc.rs                               | 774   | +2   |
+-------------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/tracing.rs                           | 151   | -7   |
+-------------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/types/transaction.rs                 | 94    | -2   |
+-------------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/utils.rs                             | 381   | +3   |
+-------------------------------------------------------------------+-------+------+

@github-actions github-actions bot added the L1 Ethereum client label Oct 15, 2025
@github-actions github-actions bot added the L2 Rollup client label Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L1 Ethereum client L2 Rollup client

Projects

Status: No status
Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant