Skip to content

Conversation

@MegaRedHand
Copy link
Collaborator

Motivation

When we added RPC metrics for success/error rates in #5335, we found that we were returning "Internal error" in the engine_getPayloadBodiesByRange method. This was related to changes done in #2430, which turned missing payloads into a DB error. The spec says we should return nulls for any missing payloads, so this deviates from the spec.

Description

This PR fixes the spec deviation by changing the batch-GET methods from the Store API to return None on missing values instead of failing.

Closes #5403

@github-actions github-actions bot added the L1 Ethereum client label Nov 22, 2025
@MegaRedHand MegaRedHand marked this pull request as ready for review November 22, 2025 23:36
@MegaRedHand MegaRedHand requested a review from a team as a code owner November 22, 2025 23:36
Copilot AI review requested due to automatic review settings November 22, 2025 23:36
@ethrex-project-sync ethrex-project-sync bot moved this to In Review in ethrex_l1 Nov 22, 2025
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 fixes a spec deviation in the engine_getPayloadBodiesByRange RPC method by changing batch-GET methods in the Store API to return None for missing payloads instead of returning database errors.

Key changes:

  • Modified read_bulk_async to return Vec<Option<V>> instead of failing on missing keys
  • Updated get_block_bodies, get_block_bodies_by_hash, and read_fullsync_batch methods across the storage trait and implementations
  • Adjusted RPC handler to work with the new signature (removing double-wrapping of Options)

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/storage/api.rs Updated trait method signatures to return Vec<Option<T>> instead of Vec<T>
crates/storage/store.rs Updated method signatures to match the trait changes
crates/storage/store_db/in_memory.rs Implemented the new behavior to return None for missing values instead of skipping them
crates/storage/store_db/rocksdb.rs Modified read_bulk_async to return None for missing keys and updated get_block_bodies with complex logic to handle missing hashes/bodies
crates/networking/rpc/engine/payload.rs Simplified the RPC handler by removing the double-wrapping of Options since the storage layer now returns the correct format
crates/networking/p2p/sync.rs Added error handling to convert None values to MissingFullsyncBatch errors where missing data is unexpected during sync

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

@github-actions
Copy link

github-actions bot commented Nov 22, 2025

Lines of code report

Total lines added: 22
Total lines removed: 11
Total lines changed: 33

Detailed view
+---------------------------------------------+-------+------+
| File                                        | Lines | Diff |
+---------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/sync.rs        | 1368  | +8   |
+---------------------------------------------+-------+------+
| ethrex/crates/storage/store_db/in_memory.rs | 622   | -11  |
+---------------------------------------------+-------+------+
| ethrex/crates/storage/store_db/rocksdb.rs   | 1725  | +14  |
+---------------------------------------------+-------+------+

Copy link
Collaborator

@rodrigo-o rodrigo-o left a comment

Choose a reason for hiding this comment

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

LGTM, this has been running for 3 hours without any internal error. That said we should address Copilot's comment

Copy link
Contributor

@Oppen Oppen left a comment

Choose a reason for hiding this comment

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

Fun fact: I've been working in something related the last few days, though I didn't know if it would be correct to change the read_fullsync_batch part. Can you do the same for the GetBlockBodies RLPx message? With this change it should have the same behavior, and batching the reads should help its performance (we can use batched_multiget, BTW).

@MegaRedHand MegaRedHand added this pull request to the merge queue Nov 25, 2025
Merged via the queue into main with commit 16192b4 Nov 25, 2025
41 checks passed
@MegaRedHand MegaRedHand deleted the fix-engine_getPayloadBodiesByRange branch November 25, 2025 15:22
@github-project-automation github-project-automation bot moved this from In Review to Done in ethrex_l1 Nov 25, 2025
LeanSerra pushed a commit that referenced this pull request Nov 26, 2025
…5408)

**Motivation**

When we added RPC metrics for success/error rates in #5335, we found
that we were returning "Internal error" in the
`engine_getPayloadBodiesByRange` method. This was related to changes
done in #2430, which turned missing payloads into a DB error. The spec
says we should return `null`s for any missing payloads, so this deviates
from the spec.

**Description**

This PR fixes the spec deviation by changing the batch-GET methods from
the Store API to return `None` on missing values instead of failing.

Closes #5403

---------

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

Labels

L1 Ethereum client

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Check high error rate for engine_getPayloadBodiesByRangeV1 on hoodi

5 participants