Skip to content

Enforce concentration limit on enabled-but-stale concentration data in report_revenue #355

@thlpkee20-wq

Description

@thlpkee20-wq

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
    • cargo test
  • 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions