Description
report_revenue enforcement reads CurrentConcentration defaulting to 0 when none has ever been reported, so an offering with enforce=true and max_bps>0 will pass enforcement even though concentration is genuinely unknown. Add an option to require a fresh report_concentration (staleness window) before allowing reports when enforcement is on, closing a silent bypass.
Requirements and context
- Must be secure, tested, and documented
- Should be efficient and easy to review
- Relevant code:
src/lib.rs (report_revenue concentration branch, report_concentration, set_concentration_limit)
- Track a last-reported timestamp alongside
CurrentConcentration
Suggested execution
- Fork the repo and create a branch
git checkout -b feat/concentration-staleness-guard
- Implement changes
- Persist a
ConcentrationReportedAt timestamp in report_concentration
- Add an optional
max_staleness_secs to ConcentrationLimitConfig or a separate setter
- In
report_revenue, reject with ConcentrationLimitExceeded (or a new error) when data is missing/stale and enforcement is on
- Validate security and correctness assumptions
Test and commit
- Run tests
- Cover edge cases
- No prior report, stale report past window, fresh report, enforce off
- Include test output and security notes
Example commit message
feat: reject report_revenue on stale concentration when enforcement enabled
Guidelines
- Minimum 95 percent test coverage
- Clear documentation
- Timeframe: 96 hours
Description
report_revenueenforcement readsCurrentConcentrationdefaulting to0when none has ever been reported, so an offering withenforce=trueandmax_bps>0will pass enforcement even though concentration is genuinely unknown. Add an option to require a freshreport_concentration(staleness window) before allowing reports when enforcement is on, closing a silent bypass.Requirements and context
src/lib.rs(report_revenueconcentration branch,report_concentration,set_concentration_limit)CurrentConcentrationSuggested execution
git checkout -b feat/concentration-staleness-guardConcentrationReportedAttimestamp inreport_concentrationmax_staleness_secstoConcentrationLimitConfigor a separate setterreport_revenue, reject withConcentrationLimitExceeded(or a new error) when data is missing/stale and enforcement is onTest and commit
cargo testExample commit message
feat: reject report_revenue on stale concentration when enforcement enabledGuidelines