arkavo-org / arkavo-org/arkavo-node
Add Rate Limiting to Smart Contracts
- Dominant language
- Rust
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
## Overview
Add rate limiting mechanisms to smart contracts to prevent spam and DoS attacks.
## Background
Currently, contracts don't implement any rate limiting. Malicious actors could spam contracts with transactions, potentially causing DoS or excessive storage growth.
## Proposed Solution
Implement rate limiting using block numbers:
```rust
last_action: Mapping,
min_blocks_between_actions: BlockNumber,
fn check_rate_limit(&self, account: AccountId) -> Result<()> {
if let Some(last_block) = self.last_action.get(account) {
let current_block = self.env().block_number();
if current_block - last_block < self.min_blocks_between_actions {
return Err(Error::RateLimitExceeded);
}
}
Ok(())
}
```
## Tasks
- [ ] Design rate limiting strategy (per-contract or global)
- [ ] Implement in access_registry
- [ ] Implement in attribute_store
- [ ] Implement in policy_engine
- [ ] Implement in payment_integration
- [ ] Add tests for rate limit scenarios
- [ ] Document rate limit parameters
## Related
- Code review finding: M3
## Priority
MAJOR - Security enhancement
## Estimated Effort
1-2 days
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the access_registry, attribute_store, policy_engine, and payment_integration smart contracts and review their existing transaction entry points. Resolve whether rate limiting is per-contract or global, then inspect the contract test structure before defining scenarios. Done means all four contracts enforce the chosen block-based limits, rate-limit scenarios pass, and the parameters are documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- blockchain, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100