Commit c820c81
committed
fix(rewards): reorder subtraction in _updateSubgraphRewards to avoid underflow
The old code's two hooks wrote to different fields with inverted semantics:
- onSubgraphSignalUpdate set accRewardsForSubgraph (A) from storage
- onSubgraphAllocationUpdate set accRewardsForSubgraphSnapshot (S) from
a view (storage + pending), so S leads and A lags after allocation updates
After the proxy upgrade, _updateSubgraphRewards computed A.sub(S).add(P)
which underflows on the intermediate A - S when A < S. Rearranging to
A.add(P).sub(S) adds pending rewards first, avoiding the intermediate
underflow. S <= A + P always holds because P covers T1→now (a superset
of the T1→T2 gap S - A).
Observed on Arbitrum Sepolia: A < S by ~7,235 GRT for subgraphs whose
last pre-upgrade interaction was onSubgraphAllocationUpdate. All reward
operations (signal, allocation, claim) reverted permanently.1 parent b5083bd commit c820c81
2 files changed
Lines changed: 444 additions & 7 deletions
File tree
- packages
- contracts-test/tests/unit/rewards
- contracts/contracts/rewards
0 commit comments