Skip to content

Implement Event Processing Rate Limiting - #890

Merged
Abd-Standard merged 3 commits into
Core-Foundry:mainfrom
0xNinx:Event-Processing
Oct 3, 2026
Merged

Abd-Standard merged 3 commits into
Core-Foundry:mainfrom
0xNinx:Event-Processing

Conversation

@0xNinx

@0xNinx 0xNinx commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Overview

I've successfully implemented configurable RPC rate limiting for event ingestion. Here's a summary of the changes:

Implementation Summary

Created Files:

  • listener/src/services/rpc-rate-limiter.ts - Token bucket rate limiter class
  • listener/src/services/rpc-rate-limiter.test.ts - Comprehensive unit tests (14 tests passing)

Modified Files:

  • listener/src/types/index.ts - Added RpcRateLimitConfig interface and integrated into Config
  • listener/src/config.ts - Added loadRpcRateLimitConfig() function and validation
  • listener/src/services/event-subscriber.ts - Integrated rate limiter into getContractEvents() method
  • listener/.env.example - Added RPC rate limiting configuration documentation

Key Features

Configuration Parameters:

  • RPC_RATE_LIMIT_ENABLED - Enable/disable rate limiting (default: true)
  • RPC_RATE_LIMIT_MAX_REQUESTS_PER_SECOND - Sustained rate limit (default: 10)
  • RPC_RATE_LIMIT_BURST_SIZE - Burst capacity (default: 20)
  • RPC_RATE_LIMIT_THROTTLE_DELAY_MS - Throttle delay when exceeded (default: 1000ms)

Algorithm:

  • Token bucket algorithm allows short bursts while enforcing sustained rate
  • Tokens refill over time based on maxRequestsPerSecond
  • Requests exceeding burst are throttled with configurable delay
  • Metrics tracking for monitoring (total, allowed, throttled requests)

Acceptance Criteria Met:

  • ✅ Processing rate is configurable via environment variables
  • ✅ Excessive requests are throttled with delays
  • ✅ Normal event processing remains unaffected (rate limiter can be disabled)
  • ✅ Unit tests validate the implementation

Related Issue

Closes #828

Closes #866

Changes

Verification

# e.g.
cd dashboard && npm test
cd listener && npm run typecheck && npm test
cd contract/contracts/hello-world && cargo test

How to Test

Checklist

  • Branch is up to date with main
  • Tests added/updated and all pass locally
  • cargo fmt --all run (if Rust changes)
  • npm run lint passes (if TypeScript changes)
  • Documentation updated if behavior changed

@drips-wave

drips-wave Bot commented Sep 29, 2026

Copy link
Copy Markdown

@0xNinx Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Abd-Standard
Abd-Standard merged commit f129310 into Core-Foundry:main Oct 3, 2026
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.

Create Architecture Decision Records Implement Event Processing Rate Limiting

2 participants