Skip to content

Conversation

@ianhe8x
Copy link
Contributor

@ianhe8x ianhe8x commented Jan 30, 2026

Summary by CodeRabbit

  • New Features

    • Added a public sync function to keep runner overflow status up-to-date.
  • Bug Fixes

    • Ensures overflow status is synchronized before reward calculations for accurate over-allocation time.
    • Prevents allocation moves when a runner is over-allocated. This is the root cause of the issue, previously, when moveAllocation() is called, _removeAllocation set allocateAt to 0, and _addAllocation doesn't reset allocateAt since there is guard before _addAllocation().
    • Corrects reporting of overflow duration when overflow start time was unset.
  • Tests

    • Added tests verifying moveAllocation is blocked during over-allocation.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 30, 2026

📝 Walkthrough

Walkthrough

Adds a runner overflow-status synchronization API and wiring: StakingAllocation.syncOverflowStatus(address) plus internal helpers and refactors; RewardsBooster now calls the sync function before computing over-allocation time in reward collection paths; tests and ABI updated accordingly.

Changes

Cohort / File(s) Summary
Staking allocation core
contracts/StakingAllocation.sol, contracts/interfaces/IStakingAllocation.sol
Adds external syncOverflowStatus(address) to the interface and implementation; extracts overflow-start logic into _startOverAllocation; adds _syncOverflowStatus helper; tightens moveAllocation precondition and adjusts overflow time reporting for edge cases.
Rewards integration
contracts/RewardsBooster.sol
Inserts calls to sa.syncOverflowStatus(_runner) in two _collectAllocationReward paths immediately after computing burnt and before reading total overflow time.
Tests
test/StakingAllocation.test.ts
Adds test blocks asserting moveAllocation reverts with SAL03 when runner is over-allocated; includes duplicated test block and formatting adjustments.
ABI
publish/ABI/StakingAllocation.json
Adds syncOverflowStatus(address) entry to the StakingAllocation ABI.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client
    participant RB as RewardsBooster
    participant SA as StakingAllocation
    participant RS as RunnerStorage

    Client->>RB: trigger reward collection (deploymentId, runner)
    RB->>SA: syncOverflowStatus(runner)
    SA->>RS: read/update runner allocation & overflow state
    RS-->>SA: current allocations, overflowAt, overflowTime
    SA-->>RB: return (sync complete)
    RB->>SA: read totalOverflowTime(runner)
    SA-->>RB: totalOverflowTime
    RB-->>Client: finalize reward calculation
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰
I hopped to check the overflow gate,
Synced each runner — never late,
Before the rewards began to count,
I made the timings right amount,
A tiny thump, a joyful trait.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: preventing over-allocated runners from moving stake (via the moveAllocation precondition) and adding recovery mechanisms (syncOverflowStatus).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-alloc-overflow

Comment @coderabbitai help to get the list of available commands and usage tips.

@ianhe8x ianhe8x merged commit 5b238d9 into develop Jan 31, 2026
3 checks passed
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.

2 participants