Sliding window rate limiting with escalation, per-tier limits, gossip-propagated blocklists, and token bucket implementation for anti-abuse protection.
The protocol implements a multi-tier rate limiting system that protects against abuse, DoS attacks, and resource exhaustion. Rate limits are enforced locally at each node and violations are propagated across the network via gossip.
Rate limit violations trigger escalating cooldown periods:
| Violation Count | Cooldown Duration |
|---|---|
| 1st violation | 5 minutes |
| 2nd violation | 15 minutes |
| 3rd violation | 60 minutes |
| 4th+ violation | 24 hours + gossip broadcast |
After the 4th violation, the offending identity is broadcast to all nodes via a RATE_LIMIT_VIOLATION gossip event, causing network-wide blocking.
Limits are scoped by identity type and action:
| Tier Key | Scope | Purpose |
|---|---|---|
ip:agent_api | IP address | Agent API endpoint rate limiting |
ip:checkout | IP address | Checkout flow rate limiting |
session:* | Session ID | Per-session action limits |
wallet:* | Wallet address | Per-wallet transaction limits |
global_flood | Entire node | Global request ceiling for flood protection |
Each tier has independently configured request limits and time windows. The global_flood tier acts as a circuit breaker: if total inbound request volume exceeds the threshold, the node begins rejecting all non-authenticated requests.
The core rate limiter (in services/cache) uses a token bucket algorithm:
The token bucket provides smooth rate limiting without the sharp edges of fixed-window counters. Burst traffic is absorbed up to the bucket capacity, but sustained abuse is caught.
When a node detects a severe or repeated violation, it broadcasts a RATE_LIMIT_VIOLATION event via the gossip protocol:
Event: RATE_LIMIT_VIOLATION
Fields:
- offenderType: "ip" | "session" | "wallet"
- offenderIdentity: string (hashed for privacy)
- tier: string
- violationCount: number
- reportingNodeId: string
- timestamp: number
- signature: Ed25519 signature of reporting nodeReceiving nodes add the offender to their local blocklist. The blocklist entry includes the reporting node's signature so that false reports can be traced. A single node's report is sufficient to trigger a temporary block on receiving nodes, but permanent bans require reports from multiple independent nodes.