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

Fix BlocksByRange RPC requests when count is 0 #8341

Merged

Conversation

StefanBratanov
Copy link
Contributor

@StefanBratanov StefanBratanov commented May 28, 2024

PR Description

We had an error processing RPC blocks by range request when count is set to 0

Unhandled error while processing request /eth2/beacon_chain/req/beacon_blocks_by_range/2/ssz_snappy","throwable":" java.lang.ArithmeticException: uint64 underflow
 tech.pegasys.teku.infrastructure.unsigned.UInt64.minus(UInt64.java:203)
tech.pegasys.teku.infrastructure.unsigned.UInt64.minus(UInt64.java:157)
tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.BeaconBlocksByRangeRequestMessage.getMaxSlot(BeaconBlocksByRangeRequestMessage.java:70)

We technically should be able to handle such requests even if they are deemed useless. We have requests limiting so we are not prone to DOS attacks.

Had to also fix BlobSidecarsByRange since maxSlot was not calculated correctly for count == 0

Added tests for both blocks and blob sidecars to ensure they both work.

Did some other small refactors along the way.

Fixed Issue(s)

N/A

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.

Changelog

  • I thought about adding a changelog entry, and added one if I deemed necessary.

@StefanBratanov StefanBratanov force-pushed the rpc_requests_improvement branch from 4f597ca to 2d0c4f7 Compare May 29, 2024 08:25
@StefanBratanov StefanBratanov changed the title Reject ByRange RPC requests when count is 0 Handle ByRange RPC requests when count is 0 May 29, 2024
@StefanBratanov StefanBratanov changed the title Handle ByRange RPC requests when count is 0 Fix BeaconBlocksByRange RPC requests when count is 0 May 29, 2024
@StefanBratanov
Copy link
Contributor Author

StefanBratanov commented May 29, 2024

@gfukushima after some discussion with Enrico and Mehdi, we decided to change the logic to be able to handle such requests, just letting you know

@StefanBratanov StefanBratanov force-pushed the rpc_requests_improvement branch from c8054b0 to 1c5d436 Compare May 29, 2024 09:46
@StefanBratanov StefanBratanov changed the title Fix BeaconBlocksByRange RPC requests when count is 0 Fix BlocksByRange RPC requests when count is 0 May 29, 2024
Copy link
Contributor

@mehdi-aouadi mehdi-aouadi left a comment

Choose a reason for hiding this comment

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

LGTM

@StefanBratanov StefanBratanov enabled auto-merge (squash) May 29, 2024 11:59
@StefanBratanov StefanBratanov merged commit 015f7bd into Consensys:master May 29, 2024
16 checks passed
@StefanBratanov StefanBratanov deleted the rpc_requests_improvement branch May 29, 2024 12:58
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.

3 participants