Skip to content

feat: limit per peer per block concurrent requests#1773

Merged
rach-id merged 49 commits intofeature/recoveryfrom
rachid/recovery/limit-concurrent-peer-limit
Apr 29, 2025
Merged

feat: limit per peer per block concurrent requests#1773
rach-id merged 49 commits intofeature/recoveryfrom
rachid/recovery/limit-concurrent-peer-limit

Conversation

@rach-id
Copy link
Copy Markdown
Member

@rach-id rach-id commented Apr 25, 2025

PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments

@rach-id rach-id self-assigned this Apr 25, 2025
@rach-id rach-id requested a review from a team as a code owner April 25, 2025 18:57
@rach-id rach-id requested review from cmwaters and rootulp and removed request for a team April 25, 2025 18:57
@rach-id rach-id added this to core/app Apr 25, 2025
@github-project-automation github-project-automation Bot moved this to Needs Triage in core/app Apr 25, 2025
@rach-id rach-id requested review from Copilot and evan-forbes and removed request for cmwaters and rootulp April 25, 2025 18:57
@celestia-bot celestia-bot requested a review from tzdybal April 25, 2025 18:58
Copy link
Copy Markdown
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 introduces a new mechanism to limit per-peer per-block concurrent requests, refactoring the peer state initialization and request batching logic. Key changes include:

  • Simplifying the global variable declaration for RetryTime.
  • Adding request-related channels and counters to the peer state.
  • Updating the flow for handling haves and want requests with a new concurrent request limit and batching logic.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
consensus/propagation/reactor.go Refactored AddPeer to initialize peer state, start a new sending routine, and adjust the order of processing the compact block.
consensus/propagation/peer_state.go Introduced requestChan, receivedPart channel, and atomic request counter helper functions.
consensus/propagation/have_wants.go Modified logging levels for unknown proposals, implemented per-peer request limiting and batch size calculation, and updated request sending logic.

@rach-id rach-id requested a review from Copilot April 25, 2025 19:00
Copy link
Copy Markdown
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 introduces a mechanism to limit per-peer per-block concurrent requests in order to prevent one peer from overwhelming the network with requests. Key changes include:

  • Refactoring peer initialization and launching a dedicated requests sending routine.
  • Adding atomic counters and channels to manage request state in peer_state.go.
  • Updating request batching logic in have_wants.go to support controlled concurrent requests.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
consensus/propagation/reactor.go Reordered peer state setup and added a dedicated sending routine for requests.
consensus/propagation/peer_state.go Introduced atomic counter management and new functions for request count adjustments.
consensus/propagation/have_wants.go Modified request logic to batch part requests and switch error logging from error to debug.

Comment thread consensus/propagation/have_wants.go Outdated
Comment thread consensus/propagation/peer_state.go Outdated
@rach-id rach-id requested a review from Copilot April 25, 2025 19:28
Copy link
Copy Markdown
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Comment thread consensus/propagation/have_wants.go Outdated
Comment thread consensus/propagation/have_wants.go Outdated
Comment thread consensus/propagation/have_wants.go Outdated
Comment thread consensus/propagation/have_wants.go Outdated
Comment thread consensus/propagation/have_wants.go Outdated
Comment thread consensus/propagation/have_wants.go Outdated
@rach-id rach-id marked this pull request as draft April 27, 2025 21:28
@rach-id rach-id force-pushed the rachid/recovery/limit-concurrent-peer-limit branch from d631fae to 2d14c90 Compare April 28, 2025 10:08
@rach-id rach-id marked this pull request as ready for review April 28, 2025 10:37
@rach-id rach-id requested a review from Copilot April 28, 2025 11:38
Copy link
Copy Markdown
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 implements a per-peer per-block request concurrency limit by tracking and limiting the number of concurrent part requests, and it adjusts the behavior of part request batching and propagation. Key changes include updating comments to reflect parity parts, refactoring global variables and peer state routines to start new sending routines for peers, and adding new functions and tests to manage and validate request count operations.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
consensus/propagation/types/types.go Updated comment to indicate inclusion of parity part set hashes
consensus/propagation/reactor.go Refactored global variable initialization; updated peer handling routines and channel closures
consensus/propagation/peer_state.go Added atomic request count functions for increasing, setting, and decreasing request counts
consensus/propagation/peer_state_test.go New tests for the request count operations
consensus/propagation/have_wants.go Introduced per-peer request limit and updated want sending logic
consensus/propagation/have_want_test.go Added tests covering want and have propagation under concurrent limits
consensus/propagation/catchup_test.go Updated test configuration and helper function for creating compact blocks

Comment thread consensus/propagation/reactor.go Outdated
Comment thread consensus/propagation/peer_state.go Outdated
rach-id and others added 7 commits April 28, 2025 19:36
Closes #1777

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
…gn that requires zero timeouts (#1778)

submitting a quick PR to reduce review rounds 🤞
Comment thread consensus/propagation/peer_state.go Outdated
Comment thread consensus/propagation/peer_state.go Outdated
Closes #1776

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
@rach-id rach-id enabled auto-merge (squash) April 29, 2025 13:58
@rach-id rach-id merged commit 9c7bc4d into feature/recovery Apr 29, 2025
21 of 24 checks passed
@rach-id rach-id deleted the rachid/recovery/limit-concurrent-peer-limit branch April 29, 2025 14:14
@github-project-automation github-project-automation Bot moved this from Needs Triage to Done in core/app Apr 29, 2025
rach-id added a commit that referenced this pull request May 21, 2025
#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Evan Forbes <42654277+evan-forbes@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants