Skip to content

feat: avoid rate limit syncing#8166

Merged
wemeetagain merged 5 commits into
peerDASfrom
te/avoid_rate_limit_syncing
Aug 11, 2025
Merged

feat: avoid rate limit syncing#8166
wemeetagain merged 5 commits into
peerDASfrom
te/avoid_rate_limit_syncing

Conversation

@twoeths

@twoeths twoeths commented Aug 9, 2025

Copy link
Copy Markdown
Contributor

Motivation

  • we got a lot of rate limited response from peers during syncing
  • we should be able to control which peers to connect to based on tracked active requests in PeerBalancer

Description

  • enforce no more than MAX_CONCURRENT_REQUESTS per peer in sync
  • limit number of epochs downloaded ahead

part of #8033

Test results on fusaka-devnet-3
was able to sync fusaka-devnet-3 2 times using this branch along with #8150

Screenshot 2025-08-09 at 14 45 32

@twoeths twoeths marked this pull request as ready for review August 9, 2025 07:46
@twoeths twoeths requested a review from a team as a code owner August 9, 2025 07:46
Comment thread packages/beacon-node/src/sync/range/utils/peerBalancer.ts Outdated
@wemeetagain wemeetagain merged commit 38889e2 into peerDAS Aug 11, 2025
5 of 6 checks passed
@wemeetagain wemeetagain deleted the te/avoid_rate_limit_syncing branch August 11, 2025 14:03
wemeetagain pushed a commit that referenced this pull request Aug 11, 2025
**Motivation**

- sync chain was stuck because some peers incorrectly response 0 block
for a batch when they don't have it, see #8147
- batch `n` has 0 block so chain does not process anything (and note
that this is wrong response from peers, most likely peer started from a
`checkpointSyncUrl`
  - batch `n+1` cannot process due to `UNKNOWN_BLOCK_PARENT`
  - then SyncChain stuck
- sometimes other clients throw `ResourceUnavailable` instead, and
that's expected in the spec

**Description**
- set `MAX_BATCH_PROCESSING_ATTEMPTS` to 0, ie if we cannot process a
batch, we remove that sync chain and RangeSync will automatically add a
new one
- do not sync from peers without `earliestAvailableSlot`
- throw error if peers return 0 blocks (peers should have returned
`ResourceUnavailable` error in that case according to [the
spec](https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/p2p-interface.md#responding-side),
we handle just in case. For lodestar, I tracked that in #8149)

Closes #8147

was able to sync `fusaka-devnet-3` 2 times using this branch along with
#8166

<img width="851" height="346" alt="Screenshot 2025-08-09 at 14 45 32"
src="https://github.com/user-attachments/assets/1f3afca0-13a6-4f7a-9c18-51d03cc34793"
/>

---------

Co-authored-by: Tuyen Nguyen <twoeths@users.noreply.github.com>
@twoeths twoeths mentioned this pull request Aug 12, 2025
wemeetagain pushed a commit that referenced this pull request Aug 13, 2025
**Motivation**

- per spec, we should not issue more than 2 requests per protocol per
peer
https://github.com/ethereum/consensus-specs/blob/master/specs/phase0/p2p-interface.md#constants
- we should be able to self detect that and see
`REQUEST_ERROR_RATE_LIMITED` instead of sending requests to peer and get
`RESPONSE_ERROR_RATE_LIMITED`

**Description**

- Implement SelfRateLimiter
  - before sending out a request, call `selfRateLimiter.allows()`
  - after finishing a request, call `selfRateLimiter.requestCompleted()`
- check for disconnected peers automatically, similar to
`RateLimiterGRCA`
- RangeSync already manage active requests and prevent that from
happening, see #8166
- UnknownBlockSync needs to implement the same thing, tracked in #8182

part of #8033

---------

Co-authored-by: Tuyen Nguyen <twoeths@users.noreply.github.com>
@wemeetagain

Copy link
Copy Markdown
Member

🎉 This PR is included in v1.34.0 🎉

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.

2 participants