fix: execute blocks in chain.rlp#258
Merged
Merged
Conversation
This was referenced Aug 15, 2024
ElFantasma
approved these changes
Aug 15, 2024
mpaulucci
approved these changes
Aug 16, 2024
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Feb 9, 2026
## Motivation eBPF profiling on a live Hoodi node shows secp256k1 at ~11% of total CPU, with 53% from P2P transaction validation. `Transaction::sender()` recomputes ECDSA public key recovery on every call — when the same transaction has `sender()` called multiple times (mempool checks, block building), each triggers a fresh recovery. ## Description Add `sender_cache: OnceCell<Address>` to all transaction types, following the same pattern as the existing `inner_hash: OnceCell<H256>` cache for `Transaction::hash()`. The first `sender()` call computes and caches; subsequent calls return the cached value. Changes: - Added `sender_cache: OnceCell<Address>` field to all 7 transaction structs (Legacy, EIP2930, EIP1559, EIP4844, EIP7702, PrivilegedL2, FeeToken) - `sender()` now delegates to `get_or_try_init(compute_sender)` — zero behavior change - Field uses `#[rkyv(with=rkyv::with::Skip)]` (same as `inner_hash`) - All construction sites updated (RLPDecode impls + l1_watcher explicit construction) - Sites using `..Default::default()` automatically pick up the new field ## EXPB Benchmark Results **Fast scenario** (vs main baselines #253/#258): | Metric | Main | cache-tx-sender | Change | |--------|------|-----------------|--------| | latency_avg | 26.23 ms | 25.69 ms | **-2.1%** | | mgas_avg | 775.78 | 795.35 | **+2.5%** | **Gigablocks scenario** (vs main #254): | Metric | Main | cache-tx-sender | Change | |--------|------|-----------------|--------| | latency_avg | 754.51 ms | 723.45 ms | **-4.1%** | | mgas_avg | 1547.14 | 1616.66 | **+4.5%** | Fast shows ~2% improvement (noise range). Gigablocks shows a meaningful **4.5% mgas improvement** — more transactions per block means more cache hits. ## How to Test ```bash cargo test -p ethrex-common -p ethrex-blockchain -p ethrex-p2p ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
When we import the chain.rlp we add the blocks to the db but we don't execute the blocks so the accounts never get updated. This PR aims to fix this by executing each block in the chain.
Description
add_blockwithexecute_blockwhen consuming blocks imported from the chain rlp fileCloses None, but makes hive test
eth_getBalance/get-balancepass