Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(l2): don't recompute transaction senders when building blocks #2097

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jrchatruc
Copy link
Collaborator

@jrchatruc jrchatruc commented Feb 26, 2025

Motivation

This PR modifies the code so that, when building payloads, we don't recompute the transactions' senders, but rather use the one that was already calculated when added to the mempool.

This represents a roughly 10-15% performance improvement on the build_payload function. For L1 this is mostly irrelevant, as it will almost never build payloads itself; for L2 this matters, as the L2 has to build (sequence) blocks itself.

Requires merging #2090 first

Flamegraph recomputing the address:

without_caching

Flamegraph using the cached value:

with_caching

Note that in the first flamegraph the execute_tx function spends a decent part in the tx_env function, which is where the sender's address is computed. On the second one tx_env is gone.

Description

Closes #issue_number

Copy link

| File                                                               | Lines | Diff |
+--------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/cmd/ethrex_l2/src/cli.rs           | 53    | -3   |
+--------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/cmd/ethrex_l2/src/commands/mod.rs  | 7     | -1   |
+--------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/cmd/ethrex_l2/src/commands/test.rs | 225   | +15  |
+--------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/blockchain/payload.rs       | 572   | +3   |
+--------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/backends/mod.rs          | 286   | +2   |
+--------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/backends/revm_b.rs       | 555   | +1   |
+--------------------------------------------------------------------+-------+------+

Total lines added: +21
Total lines removed: 4
Total lines changed: 25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant