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

Rate Limiting for RPC Service / EVM and Metrics (backoff periods) #2270

Open
wants to merge 4,937 commits into
base: main
Choose a base branch
from

Conversation

dirvine
Copy link
Member

@dirvine dirvine commented Oct 29, 2024

Rate Limiting for RPC Service

Summary

This PR introduces rate limiting to the SafeNode RPC service to prevent potential abuse and ensure service stability. It implements both global and per-IP rate limiting using the governor crate.

Changes

  • Added RateLimiter struct with:
    • Global limit of 100 requests per minute across all clients
    • Per-IP limit of 20 requests per minute
  • Integrated rate limiting checks into RPC endpoints
  • Added proper error handling for rate limit exceeded cases
  • Cleaned up unused metrics buffer implementation
  • Fixed replication manager to use proper error types and concurrency control

Technical Details

  • Uses governor crate for efficient rate limiting
  • Implements thread-safe rate limiting using Tokio's Mutex
  • Memory-efficient implementation that creates per-IP limiters only when needed
  • Proper error propagation using gRPC status codes

Testing

  • Test rate limiting with concurrent requests
  • Verify rate limit error messages
  • Test per-IP limits with multiple clients
  • Test global rate limit enforcement

Related Issues

Closes #XXXX (CPU usage issues)

Future Improvements

  • Make rate limits configurable via node settings
  • Add metrics for rate limiting events
  • Consider implementing more sophisticated rate limiting strategies (e.g., token bucket)

grumbach and others added 30 commits October 15, 2024 08:45
feat: print for peers connected and net size in loud mode
feat(autonomi): implement client events
BREAKING CHANGE: services configured by the node manager are no longer compatible with networks that
are not EVM.

The node manager `add` command now supports the following EVM arguments:

* The subcommand for selecting the network type is appended.
* The `evm-custom` subcommand makes the `--data-payments-address`, `--payment-token-address` and
  `--rpc-url` arguments available.
* The `--rewards-address` argument is provided.

The `CustomNetwork` type was modified to enable it to be serialized in the node manager registry.
…local

feat: adapt node manager `add` command for evm network
…with_network_keys

feat(node): using different storage dir for different network
The `autonomi_cli` binary is renamed to `autonomi` because the `_cli` suffix is not necessary.

The crate is named `autonomi-cli` rather than `autonomi_cli` because we agreed we prefer
underscores.
…_cli2

chore: rename autonomi crate and binary
uses node control flow to exit a node if we consistently detect high CPU
merge the results after we see split record.
Use Quorum::Majority at least (instead of Quorum::One)
this indirectly affects how many close nodes returned and could stymie
the GetRange effectiveness
ie, even if query times out if we have peers, we update

seems like we timeout more due to high K_VALUE
RolandSherwin and others added 30 commits October 25, 2024 14:19
feat(kad): reduce bootstrap interval
feat(autonomi): allow the uploader to work with the new apis
fix(launchpad): update status after resetting
fix(launchpad): rewards address req to start nodes
This is a utility for the user's reference.

The owner name field is removed from the output. It doesn't serve much purpose without the Discord
link.
fix(launchpad): throbber stops after a while
feat: print rewards address in `status --details`
chore(network): logging multiple fetched versions
Revert "feat(autonomi): allow the uploader to work with the new apis"
* Implements per-IP and global rate limiting for RPC endpoints
* Adds resource exhaustion error handling
* Removes unused metrics buffer fields
* Fixes replication manager concurrency control
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.

9 participants