Skip to content

Conversation

@MegaRedHand
Copy link
Collaborator

@MegaRedHand MegaRedHand commented Nov 27, 2025

Motivation

Receipts computation is ~3% of block execution. It's not much, but it should be easy to optimize, since we didn't touch it much.

Screenshot 2025-11-27 at 19 25 55

Description

This PR changes the receipt bloom computation to use our keccak implementation (before it was using tiny_keccak inside Bloom::accrue). It also adds some preallocation to the receipt encoding, which should account for the smallest transactions, at least.

Copilot AI review requested due to automatic review settings November 27, 2025 22:38
@MegaRedHand MegaRedHand requested a review from a team as a code owner November 27, 2025 22:38
@github-actions github-actions bot added L1 Ethereum client performance Block execution throughput and performance in general labels Nov 27, 2025
@github-actions
Copy link

Lines of code report

Total lines added: 44
Total lines removed: 0
Total lines changed: 44

Detailed view
+---------------------------------------+-------+------+
| File                                  | Lines | Diff |
+---------------------------------------+-------+------+
| ethrex/crates/common/types/receipt.rs | 387   | +44  |
+---------------------------------------+-------+------+

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes receipt bloom computation by switching from tiny_keccak (used internally by BloomInput::Raw) to the codebase's custom keccak implementation. The changes also include preallocation optimization for receipt encoding and improved variable naming.

Key Changes

  • Switched bloom filter computation to use custom keccak_hash function with BloomInput::Hash instead of BloomInput::Raw
  • Added preallocation (512 bytes) to encode_inner_with_bloom to reduce allocations
  • Improved variable naming from encode_buff to encode_buf
  • Added comprehensive test to verify bloom computation correctness

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@MegaRedHand MegaRedHand moved this from Todo to In review in ethrex_performance Nov 28, 2025
@github-project-automation github-project-automation bot moved this to In Review in ethrex_l1 Nov 28, 2025
@github-actions
Copy link

github-actions bot commented Nov 28, 2025

Benchmark Block Execution Results Comparison Against Main

Command Mean [s] Min [s] Max [s] Relative
base 61.100 ± 0.248 60.768 61.540 1.00
head 61.329 ± 0.222 60.963 61.713 1.00 ± 0.01

@MegaRedHand MegaRedHand added this pull request to the merge queue Nov 28, 2025
Merged via the queue into main with commit 46096d1 Nov 28, 2025
43 checks passed
@MegaRedHand MegaRedHand deleted the use-our-keccak-for-receipt-blooms branch November 28, 2025 16:13
@github-project-automation github-project-automation bot moved this from In review to Done in ethrex_performance Nov 28, 2025
@github-project-automation github-project-automation bot moved this from In Review to Done in ethrex_l1 Nov 28, 2025
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