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

feat(conductor)!: rate limit sequencer cometbft requests #1068

Merged
merged 8 commits into from
May 27, 2024

Conversation

SuperFluffy
Copy link
Member

@SuperFluffy SuperFluffy commented May 14, 2024

Summary

Limits the number of requests conductor sends to the Sequencer CometBFT endpoint to 100 per minute.

Background

During sync conductor can DOS Sequencer's CometBFT node by sending too many requests for commits and validator sets. With the batching logic introduced in #1049 there can be dozens (or more) blocks stored in each Celestia blob, each of which needs to be checked separately. With several blobs being fetched at once during, this can quickly spiral into hundreds (if not thousands) requests per minute.

Note that only calls to /commit and /validators are rate limited, because there is currently no way to enforce this at the transport layer, see this issue: informalsystems/tendermint-rs#1420

However, the only other calls are to /genesis (once at startup), and /abci_info (every block-time period, usually every 2 seconds), which is rare enough to not need a rate limit.

Changes

  • Use a tower RateLimit middleware around a tendermint-rs HttpClient only send up to 100 requests per minute.

Breaking changes

  • Adds an environment variable ASTRIA_CONDUCTOR_SEQUENCER_REQUESTS_PER_SECOND to configure rate-limiting of requests sent to the Sequencer CometBFT node for verification of Sequencer block data fetched from Celestia blobs

Testing

This needs to be observed end-to-end, potentially letting conductor run for a very long time with only soft commits, and then turning firm commits on.

Related Issues

closes #1064

@SuperFluffy SuperFluffy requested a review from a team as a code owner May 14, 2024 12:31
@SuperFluffy SuperFluffy requested a review from noot May 14, 2024 12:31
@github-actions github-actions bot added the conductor pertaining to the astria-conductor crate label May 14, 2024
@SuperFluffy SuperFluffy requested review from Fraser999 and joroshiba and removed request for noot May 14, 2024 12:31
@joroshiba joroshiba added the docker-build used to trigger docker builds on PRs label May 14, 2024
Copy link
Contributor

@Fraser999 Fraser999 left a comment

Choose a reason for hiding this comment

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

Looks good - I'd have approved apart from my comment on the chosen rate limit's period.

);
Ok(header)
.inspect_err(|e| {
warn!(
Copy link
Contributor

Choose a reason for hiding this comment

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

This used to be info-level before. Probably better as a warn-level, but just wanted to highlight that.

crates/astria-conductor/src/celestia/verify.rs Outdated Show resolved Hide resolved
crates/astria-conductor/src/celestia/verify.rs Outdated Show resolved Hide resolved
crates/astria-conductor/src/celestia/verify.rs Outdated Show resolved Hide resolved
crates/astria-conductor/src/celestia/verify.rs Outdated Show resolved Hide resolved
crates/astria-conductor/src/celestia/verify.rs Outdated Show resolved Hide resolved
}
});
// XXX: This number is arbitarily set to the same number os the rate-limit. Does that
// make sense? Should the number be set higher?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it probably does make sense since it should be at least the maximum number of concurrent requests the Buffer will see, although I also can't see an issue with setting it higher (within reason).

@SuperFluffy SuperFluffy force-pushed the superfluffy/rate-limit-conductor branch from 50aa548 to f0fecad Compare May 27, 2024 13:01
@SuperFluffy SuperFluffy requested a review from a team as a code owner May 27, 2024 13:01
@github-actions github-actions bot added the cd label May 27, 2024
@SuperFluffy SuperFluffy changed the title feat(conductor): rate limit sequencer cometbft requests feat(conductor)!: rate limit sequencer cometbft requests May 27, 2024
@SuperFluffy
Copy link
Member Author

Rebased on top of main to fetch bump the charts (should have probably just made a merge commit)

Copy link
Member

@joroshiba joroshiba left a comment

Choose a reason for hiding this comment

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

infra approval

@SuperFluffy SuperFluffy added this pull request to the merge queue May 27, 2024
Merged via the queue into main with commit d6b91a8 May 27, 2024
36 of 37 checks passed
@SuperFluffy SuperFluffy deleted the superfluffy/rate-limit-conductor branch May 27, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cd conductor pertaining to the astria-conductor crate docker-build used to trigger docker builds on PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Restrict number of concurrent requests from conductor to sequencer
3 participants