Skip to content

Conversation

@iovoid
Copy link
Contributor

@iovoid iovoid commented Nov 3, 2025

Motivation

Currently when fetching a node during tree traversal, we compute it's hash to validate it. This isn't necessary when the trie is consistent.

Description

This adds a checked variant for use in snap sync (which requires reading from inconsistent tries) and removes hash validation from the others.

@github-actions github-actions bot added L1 Ethereum client performance Block execution throughput and performance in general labels Nov 3, 2025
@github-actions
Copy link

github-actions bot commented Nov 3, 2025

Lines of code report

Total lines added: 24
Total lines removed: 0
Total lines changed: 24

Detailed view
+----------------------------------------+-------+------+
| File                                   | Lines | Diff |
+----------------------------------------+-------+------+
| ethrex/crates/common/trie/node.rs      | 249   | +14  |
+----------------------------------------+-------+------+
| ethrex/crates/common/trie/trie.rs      | 972   | +7   |
+----------------------------------------+-------+------+
| ethrex/crates/common/trie/trie_iter.rs | 210   | +3   |
+----------------------------------------+-------+------+

@github-actions
Copy link

github-actions bot commented Nov 3, 2025

Benchmark for 138544e

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 36.2±3.28ms 37.4±2.04ms +3.31%
Trie/cita-trie insert 1k 3.5±0.01ms 3.6±0.10ms +2.86%
Trie/ethrex-trie insert 10k 31.1±0.40ms 32.0±1.00ms +2.89%
Trie/ethrex-trie insert 1k 2.8±0.01ms 2.8±0.01ms 0.00%

@github-actions
Copy link

github-actions bot commented Nov 3, 2025

Benchmark for cbfeb8e

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 38.4±1.88ms 37.6±1.68ms -2.08%
Trie/cita-trie insert 1k 3.5±0.02ms 3.6±0.21ms +2.86%
Trie/ethrex-trie insert 10k 33.4±1.66ms 32.1±1.68ms -3.89%
Trie/ethrex-trie insert 1k 2.8±0.02ms 2.8±0.07ms 0.00%

@github-actions
Copy link

github-actions bot commented Nov 3, 2025

Benchmark for dbf699e

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 34.6±0.27ms 34.7±0.18ms +0.29%
Trie/cita-trie insert 1k 3.5±0.01ms 3.6±0.09ms +2.86%
Trie/ethrex-trie insert 10k 30.6±0.45ms 30.7±0.38ms +0.33%
Trie/ethrex-trie insert 1k 2.8±0.01ms 2.8±0.03ms 0.00%

@github-actions
Copy link

github-actions bot commented Nov 3, 2025

Benchmark for 440276b

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 28.8±0.58ms 29.9±0.52ms +3.82%
Trie/cita-trie insert 1k 2.7±0.01ms 2.8±0.13ms +3.70%
Trie/ethrex-trie insert 10k 26.9±0.69ms 26.6±1.69ms -1.12%
Trie/ethrex-trie insert 1k 2.3±0.03ms 2.2±0.00ms -4.35%

@github-actions
Copy link

github-actions bot commented Nov 3, 2025

Benchmark Block Execution Results Comparison Against Main

Command Mean [s] Min [s] Max [s] Relative
base 336.968 ± 1.480 335.420 340.458 1.00 ± 0.01
head 335.909 ± 0.858 334.726 337.705 1.00

@github-actions
Copy link

github-actions bot commented Nov 3, 2025

Benchmark for 5890549

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 34.9±0.74ms 35.1±0.44ms +0.57%
Trie/cita-trie insert 1k 3.6±0.05ms 3.5±0.02ms -2.78%
Trie/ethrex-trie insert 10k 31.1±0.71ms 30.8±0.76ms -0.96%
Trie/ethrex-trie insert 1k 2.8±0.01ms 2.8±0.16ms 0.00%

@github-actions
Copy link

github-actions bot commented Nov 3, 2025

Benchmark for ac1bb65

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 34.1±0.73ms 34.9±0.82ms +2.35%
Trie/cita-trie insert 1k 3.5±0.02ms 3.6±0.16ms +2.86%
Trie/ethrex-trie insert 10k 31.5±0.99ms 31.2±0.76ms -0.95%
Trie/ethrex-trie insert 1k 2.8±0.06ms 2.8±0.09ms 0.00%

@github-actions
Copy link

github-actions bot commented Nov 3, 2025

Benchmark for 7e6a43f

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 41.4±4.48ms 34.4±3.79ms -16.91%
Trie/cita-trie insert 1k 3.7±0.28ms 3.6±0.03ms -2.70%
Trie/ethrex-trie insert 10k 33.9±2.35ms 35.0±3.06ms +3.24%
Trie/ethrex-trie insert 1k 2.9±0.18ms 2.9±0.22ms 0.00%

@iovoid iovoid marked this pull request as ready for review November 3, 2025 19:49
@iovoid iovoid requested a review from a team as a code owner November 3, 2025 19:50
@ethrex-project-sync ethrex-project-sync bot moved this to In Review in ethrex_l1 Nov 3, 2025
@github-actions
Copy link

github-actions bot commented Nov 3, 2025

Benchmark for 653028a

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 35.3±0.66ms 35.0±1.18ms -0.85%
Trie/cita-trie insert 1k 3.6±0.02ms 3.6±0.20ms 0.00%
Trie/ethrex-trie insert 10k 31.3±0.74ms 30.7±0.58ms -1.92%
Trie/ethrex-trie insert 1k 2.8±0.02ms 2.8±0.06ms 0.00%

}
}

/// Gets a shared reference to the inner node.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to have an explicit doc telling the difference with get_node()

@github-actions
Copy link

github-actions bot commented Nov 4, 2025

Benchmark for 50d3aad

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 35.2±0.56ms 36.1±1.78ms +2.56%
Trie/cita-trie insert 1k 3.5±0.01ms 3.6±0.13ms +2.86%
Trie/ethrex-trie insert 10k 31.3±0.68ms 31.2±0.48ms -0.32%
Trie/ethrex-trie insert 1k 2.8±0.09ms 2.8±0.01ms 0.00%

@github-actions
Copy link

github-actions bot commented Nov 4, 2025

Benchmark for 02d9500

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 35.0±0.68ms 34.9±0.51ms -0.29%
Trie/cita-trie insert 1k 3.6±0.01ms 3.5±0.15ms -2.78%
Trie/ethrex-trie insert 10k 33.0±1.38ms 32.9±1.04ms -0.30%
Trie/ethrex-trie insert 1k 2.8±0.01ms 2.8±0.01ms 0.00%

@jrchatruc jrchatruc enabled auto-merge November 4, 2025 15:24
@jrchatruc jrchatruc added this pull request to the merge queue Nov 4, 2025
Merged via the queue into main with commit 05211ba Nov 4, 2025
40 checks passed
@jrchatruc jrchatruc deleted the avoid_compute_hash branch November 4, 2025 15:54
@github-project-automation github-project-automation bot moved this from In Review to Done in ethrex_l1 Nov 4, 2025
@github-project-automation github-project-automation bot moved this from Todo to Done in ethrex_performance Nov 4, 2025
xqft pushed a commit that referenced this pull request Nov 11, 2025
**Motivation**

Currently when fetching a node during tree traversal, we compute it's
hash to validate it. This isn't necessary when the trie is consistent.

**Description**

This adds a checked variant for use in snap sync (which requires reading
from inconsistent tries) and removes hash validation from the others.

---------

Co-authored-by: Javier Chatruc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L1 Ethereum client performance Block execution throughput and performance in general

Projects

Status: Done
Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants