PlumeRewardLogic.calculateRewardsWithCheckpointsView lacking of checking if the validator is inactive but not slashed.
The view function calculateRewardsWithCheckpointsView does not account for validators that are inactive but not slashed, so it may use a stale cumulative reward-per-token value. This can cause dependent functions to misjudge pending rewards and waste gas through unnecessary loop iterations.
Plume Network
Originally disclosed on Immunefi
51988 sc medium plumerewardlogic calculaterewardswithcheckpointsview lacking of checking if the validator is inactive but not slashed
- Report ID: #51988
- Report Type: Smart Contract
- Report severity: Medium
- Target: https://github.com/immunefi-team/attackathon-plume-network/blob/main/plume/src/lib/PlumeRewardLogic.sol
- Submitted on Aug 7th 2025 at 04:05:20 UTC by @jasonxiale for Attackathon | Plume Network: https://immunefi.com/audit-competition/plume-network-attackathon
Description
Brief/Intro
The comments for PlumeRewardLogic.calculateRewardsWithCheckpointsView state that this view function "simulates what the state-changing calculateRewardsWithCheckpoints does" and "must accurately calculate the validator's theoretical cumulative reward per token at the current block timestamp, respecting all historical rate changes."
However, the current implementation of PlumeRewardLogic.calculateRewardsWithCheckpointsView fails to consider the case where a validator is inactive but not slashed, which can lead to using stale cumulative reward-per-token values and therefore incorrect reward calculations.
Relevant source pointers:
- calculateRewardsWithCheckpoints (state-changing): https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/lib/PlumeRewardLogic.sol#L374-L418
- updateRewardPerTokenForValidator: https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/lib/PlumeRewardLogic.sol#L135-L197
- calculateRewardsWithCheckpointsView: https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/lib/PlumeRewardLogic.sol#L862-L917
Vulnerability Details
{% stepper %}
{% step %}
In the state-changing function PlumeRewardLogic.calculateRewardsWithCheckpoints, when the validator is not slashed the function will call PlumeRewardLogic.updateRewardPerTokenForValidator.
Reference: https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/lib/PlumeRewardLogic.sol#L374-L418 {% endstep %}
{% step %}
In PlumeRewardLogic.updateRewardPerTokenForValidator, if the validator is inactive but not slashed, the function returns early (does not update cumulative RPT).
Reference: https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/lib/PlumeRewardLogic.sol#L135-L197 (see L155-L160) {% endstep %}
{% step %}
Because of step 2, the stored value $.validatorRewardPerTokenCumulative[validatorId][token] will not be updated; the subsequent code in the state-changing flow uses this updated value when computing rewards.
Reference: https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/lib/PlumeRewardLogic.sol#L386-L387 {% endstep %}
{% step %}
The view function PlumeRewardLogic.calculateRewardsWithCheckpointsView attempts to simulate cumulative RPT over time. But it only adjusts for slashed validators (it clamps effectiveEndTime to slashedAtTimestamp) and then starts from the stored cumulative value:
Code excerpt:
// calculate effectiveEndTime when the validator is slashed
if (validator.slashedAtTimestamp > 0 && validator.slashedAtTimestamp < effectiveEndTime) {
effectiveEndTime = validator.slashedAtTimestamp;
}
// 2. Start with the last known, stored cumulative value and its timestamp.
uint256 simulatedCumulativeRPT = $.validatorRewardPerTokenCumulative[validatorId][token];
uint256 lastUpdateTime = $.validatorLastUpdateTimes[validatorId][token];
// 3. If time has passed since the last update, simulate the RPT increase segment by segment.
if (effectiveEndTime > lastUpdateTime) {
...
}
// 4. Now that we have the correctly simulated final cumulative RPT, call the core logic.
return _calculateRewardsCore($, user, validatorId, token, userStakedAmount, simulatedCumulativeRPT);
Because the view does not check whether the validator is inactive (but not slashed), it may use a stale simulatedCumulativeRPT when simulating rewards. Reference: https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/lib/PlumeRewardLogic.sol#L862-L917
{% endstep %}
{% endstepper %}
Impact
Because PlumeRewardLogic.calculateRewardsWithCheckpointsView can return an incorrect reward delta for inactive-but-not-slashed validators (using stale cumulative RPT), functions that rely on that view may react incorrectly.
Example: PlumeRewardLogic.clearPendingRewardsFlagIfEmpty uses calculateRewardsWithCheckpointsView. If the view reports that pending rewards are non-empty (when they should be empty) the cleanup function can return early, which forces callers to traverse a loop every time and results in increased/unbounded gas consumption for users.
References:
- clearPendingRewardsFlagIfEmpty: https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/lib/PlumeRewardLogic.sol#L813-L848 (usage at L838-L840)
- Calling path example: StakingFacet -> _calculateAndClaimAllRewardsWithCleanup -> clearPendingRewardsFlagIfEmpty: https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/facets/StakingFacet.sol#L451-L495 and https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/facets/StakingFacet.sol#L953C14-L1003 Overall effect: unnecessary repeated loop iterations, leading to higher gas consumption for users; in worst cases, unbounded gas usage.
Proof of Concept
{% stepper %} {% step %} Trigger flow that leads to cleanup checks:
- Call
StakingFacet.restakeRewards. This invokes_calculateAndClaimAllRewardsWithCleanup. Reference: https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/facets/StakingFacet.sol#L451-L495 and L468 {% endstep %}
{% step %}
Inside _calculateAndClaimAllRewardsWithCleanup, clearPendingRewardsFlagIfEmpty is invoked. Reference: https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/facets/StakingFacet.sol#L953C14-L1003 and L989
{% endstep %}
{% step %}
Because clearPendingRewardsFlagIfEmpty calls PlumeRewardLogic.calculateRewardsWithCheckpointsView, which does not handle inactive-but-not-slashed validators, the view can return incorrect results causing the cleanup function to return early (see L840), forcing repeated loop traversal on subsequent calls and wasting gas. References: clearPendingRewardsFlagIfEmpty: https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/lib/PlumeRewardLogic.sol#L813-L848 and the loop: https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/lib/PlumeRewardLogic.sol#L826-L843
{% endstep %}
{% endstepper %}
References
- PlumeRewardLogic.sol: https://github.com/immunefi-team/attackathon-plume-network/blob/main/plume/src/lib/PlumeRewardLogic.sol
- Specific commit/context used in the report: https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/lib/PlumeRewardLogic.sol
(End of report)
Context
Plume Network is a smart contract project whose staking and reward accounting lives in a library called PlumeRewardLogic. The library tracks, per validator and per token, a cumulative reward-per-token (RPT) figure that grows over time as rewards accrue. Two functions sit at the centre of this report:
calculateRewardsWithCheckpoints, the state-changing function that updates the stored cumulative RPT and computes rewards.calculateRewardsWithCheckpointsView, a read-only function whose own comments say it "simulates what the state-changingcalculateRewardsWithCheckpointsdoes" and "must accurately calculate the validator's theoretical cumulative reward per token at the current block timestamp, respecting all historical rate changes."
The report argues that the view does not honour that contract for one particular validator state: inactive but not slashed. The target is the file plume/src/lib/PlumeRewardLogic.sol in the immunefi-team/attackathon-plume-network repository, at commit [redacted].
Setup
This is a smart contract review, so there are no accounts, sessions or HTTP tooling involved. The relevant preconditions are all on-chain state:
- A validator that has become inactive without being slashed.
- A user with staked amount and pending rewards associated with that validator and token.
- A call path that reaches
calculateRewardsWithCheckpointsView, in the report's example throughStakingFacet.restakeRewards.
The report references three functions in PlumeRewardLogic.sol by line range:
| Function | Lines |
|---|---|
updateRewardPerTokenForValidator |
L135-L197 |
calculateRewardsWithCheckpoints |
L374-L418 |
clearPendingRewardsFlagIfEmpty |
L813-L848 |
calculateRewardsWithCheckpointsView |
L862-L917 |
Finding it
The starting point is the documented intent of the view function. It is meant to mirror the state-changing path exactly, so any branch that the state-changing path takes but the view does not reproduce is a candidate for divergence. The researcher compared the two flows and found that the state-changing path has an early return for inactive-but-not-slashed validators, while the view only accounts for slashed validators.
Exploitation
Step 1: the state-changing path calls the RPT updater
In PlumeRewardLogic.calculateRewardsWithCheckpoints, when the validator is not slashed, the function calls PlumeRewardLogic.updateRewardPerTokenForValidator (L374-L418).
Step 2: the updater returns early for inactive, non-slashed validators
Inside PlumeRewardLogic.updateRewardPerTokenForValidator (L135-L197, specifically L155-L160), if the validator is inactive but not slashed, the function returns early and does not update the cumulative RPT.
Step 3: the stored cumulative value stays stale
Because of step 2, the stored value $.validatorRewardPerTokenCumulative[validatorId][token] is not updated. The subsequent code in the state-changing flow uses this value when computing rewards (L386-L387).
Step 4: the view only clamps for slashing
The view function PlumeRewardLogic.calculateRewardsWithCheckpointsView tries to simulate cumulative RPT over time. It adjusts only for slashed validators, clamping effectiveEndTime to slashedAtTimestamp, and then starts from the stored cumulative value. The excerpt given in the report is:
// calculate effectiveEndTime when the validator is slashed
if (validator.slashedAtTimestamp > 0 && validator.slashedAtTimestamp < effectiveEndTime) {
effectiveEndTime = validator.slashedAtTimestamp;
}
// 2. Start with the last known, stored cumulative value and its timestamp.
uint256 simulatedCumulativeRPT = $.validatorRewardPerTokenCumulative[validatorId][token];
uint256 lastUpdateTime = $.validatorLastUpdateTimes[validatorId][token];
// 3. If time has passed since the last update, simulate the RPT increase segment by segment.
if (effectiveEndTime > lastUpdateTime) {
...
}
// 4. Now that we have the correctly simulated final cumulative RPT, call the core logic.
return _calculateRewardsCore($, user, validatorId, token, userStakedAmount, simulatedCumulativeRPT);
The only guard is the slashing check. There is no equivalent of the early return in updateRewardPerTokenForValidator for the inactive-but-not-slashed case, so the view can simulate an increase on top of a simulatedCumulativeRPT that the state-changing path would have left untouched. The report describes the result as a stale simulatedCumulativeRPT (L862-L917).
Step 5: reaching the view through the staking facet
The proof of concept walks the call path that consumes the view:
- Call
StakingFacet.restakeRewards. This invokes_calculateAndClaimAllRewardsWithCleanup(L451-L495, call at L468). - Inside
_calculateAndClaimAllRewardsWithCleanup,clearPendingRewardsFlagIfEmptyis invoked (L953-L1003, call at L989). clearPendingRewardsFlagIfEmptycallsPlumeRewardLogic.calculateRewardsWithCheckpointsView. Because the view does not handle inactive-but-not-slashed validators, it can return an incorrect result, causing the cleanup function to return early at L840. That forces repeated loop traversal on subsequent calls and wastes gas. The loop in question is at L826-L843 ofPlumeRewardLogic.sol.
Root cause
The two code paths disagree on one branch. updateRewardPerTokenForValidator treats an inactive-but-not-slashed validator as a reason to stop accruing RPT and returns early, leaving $.validatorRewardPerTokenCumulative[validatorId][token] and $.validatorLastUpdateTimes[validatorId][token] as they were. The view reproduces the slashing clamp but not this early return, so it keeps simulating RPT growth from the stored value for a validator whose stored value the state-changing path would never have advanced.
The existing defence, the slashing clamp on effectiveEndTime, covers only the slashed case. It does nothing for a validator that is inactive without having been slashed, which is exactly the state the updater handles separately.
Impact
The view can return an incorrect reward delta for inactive-but-not-slashed validators because it works from a stale cumulative RPT. Functions that rely on the view may then react incorrectly.
The concrete example in the report is PlumeRewardLogic.clearPendingRewardsFlagIfEmpty, which uses calculateRewardsWithCheckpointsView at L838-L840. If the view reports pending rewards as non-empty when they should be empty, the cleanup function returns early. Callers are then forced to traverse the loop every time, which increases gas consumption for users and, in the worst case, means unbounded gas usage.
Fix
The report does not describe a patch or a change that was applied. The correction it implies is to make the view mirror the state-changing path: before simulating RPT growth, calculateRewardsWithCheckpointsView should apply the same inactive-but-not-slashed early-return condition that updateRewardPerTokenForValidator uses at L155-L160, so that the simulation starts from, and stops at, the same cumulative value the state-changing flow would produce.
Variants to test
- Other view/state pairs in the same library. For every
...Viewfunction that claims to simulate a state-changing function, diff the branches. A positive result is a validator or user state that the state-changing function short-circuits but the view does not. - Other early returns in the updater.
updateRewardPerTokenForValidatormay have more than one early exit; check whether the view reproduces each one, not just the slashing clamp. - Consumers of the view. Look for other functions besides
clearPendingRewardsFlagIfEmptythat branch on the view's output, such as cleanup, flag-setting or claim-skipping logic. A positive result is a path where a wrong view result changes control flow rather than just a displayed number. - Gas amplification through loops. Where a wrong view result causes a loop to be re-entered, measure whether the loop bound is attacker-influenced. A positive result is a call whose gas cost grows with state the caller can add to.
Hunting notes
This class of bug hides in duplicated logic: a read-only simulation of a state-changing function is a standing invitation for the two implementations to drift. The signal during review is a comment that promises exact equivalence ("simulates what the state-changing function does", "must accurately calculate"), followed by a comparison of every branch, especially early returns and clamps. Here the divergence was a single missing condition, and the impact was argued through a real consumer, clearPendingRewardsFlagIfEmpty, reached from StakingFacet.restakeRewards, with line-level references for each hop. Showing the full call path from an externally callable function to the faulty view, and naming the concrete consequence (early return, repeated loop traversal, higher gas), is what turns a correctness mismatch into a concrete, argued finding.
What happened, in plain words
Plume Network is a project built on a blockchain, and blockchains run programs called smart contracts. These programs handle money-like things automatically: they keep track of who put what in, and who is owed what back. One part of Plume handles staking: a user locks up some tokens (a digital asset) with a validator (a computer operator that helps run the network), and in return the user earns rewards over time.
To know how many rewards each user has earned, the contract keeps a running number called the reward-per-token (RPT). Think of it like a taxi meter that keeps ticking up: the longer time passes, the higher the number. Each user's share is worked out from that meter.
The contract has two versions of the same calculation:
calculateRewardsWithCheckpoints, which actually changes the stored data on the blockchain (the "real" one).calculateRewardsWithCheckpointsView, which only reads data and tells you what the answer would be, without changing anything (the "preview" one).
The preview function's own comments promise it behaves exactly like the real one. The researcher found that it does not, in one specific situation: when a validator has stopped being active but has not been punished ("slashed"). In that situation the real function stops the meter, but the preview keeps the meter running. So the preview can report rewards that do not exist.
Other parts of the contract trust the preview. One of them, a cleanup function, uses the preview's answer to decide whether it can stop working early. If the preview gives a wrong answer, the cleanup keeps doing unnecessary work, and users pay more in gas (the fee for running code on the blockchain).
The pieces involved
Before the details, here are the main parts of the code the report talks about, all in one file, plume/src/lib/PlumeRewardLogic.sol, in the immunefi-team/attackathon-plume-network repository at commit [redacted]:
| Function | Lines | What it does |
|---|---|---|
updateRewardPerTokenForValidator |
L135-L197 | Moves the reward meter forward for one validator and token |
calculateRewardsWithCheckpoints |
L374-L418 | The real function: updates stored data and computes rewards |
clearPendingRewardsFlagIfEmpty |
L813-L848 | A cleanup function that uses the preview to decide whether to stop |
calculateRewardsWithCheckpointsView |
L862-L917 | The preview function: reads only, changes nothing |
A library here just means a bundle of shared code that other contracts call into, so the same reward maths is not written twice.
What you need for this to happen
This is a code review of a smart contract, not a website attack. There are no logins, cookies or web requests. Everything happens in the blockchain's stored state. The report lists three conditions:
- A validator that has become inactive without being slashed.
- A user who has staked an amount with that validator and token, and who has pending rewards.
- A call path that reaches
calculateRewardsWithCheckpointsView, in the report's example throughStakingFacet.restakeRewards.
A facet is a smaller contract that adds features to a larger one; StakingFacet is the part users interact with for staking actions.
Finding it
The researcher started from the promise written in the preview function's comments: it says it "simulates what the state-changing calculateRewardsWithCheckpoints does" and "must accurately calculate the validator's theoretical cumulative reward per token at the current block timestamp, respecting all historical rate changes."
When two pieces of code are supposed to do the same thing, the way to check is to compare them branch by branch, like comparing two recipes that should produce the same cake. Every "if this, then stop" in one should exist in the other. The researcher found one such stop that exists in the real function but not in the preview: the case of a validator that is inactive but not slashed.
Walking through the bug
Step 1: the real function calls the meter updater
In PlumeRewardLogic.calculateRewardsWithCheckpoints, when the validator is not slashed, the function calls PlumeRewardLogic.updateRewardPerTokenForValidator (L374-L418).
In plain words: before working out anyone's rewards, the real function first asks the meter updater to move the meter forward to the current time. That makes sense: rewards should reflect time that has passed.
Step 2: the updater stops early for inactive, non-slashed validators
Inside PlumeRewardLogic.updateRewardPerTokenForValidator (L135-L197, specifically L155-L160), if the validator is inactive but not slashed, the function returns early and does not update the cumulative RPT.
In plain words: the updater has a rule that says "if this validator is switched off but was never punished, do not move the meter at all." It exits immediately.
Step 3: the stored number stays where it was
Because of step 2, the stored value $.validatorRewardPerTokenCumulative[validatorId][token] is not updated. The subsequent code in the state-changing flow uses this value when computing rewards (L386-L387).
In plain words: $.validatorRewardPerTokenCumulative[validatorId][token] is the saved meter reading, kept separately for each validator and each token. Since the updater exited early, this saved reading is unchanged. The rest of the real function then calculates rewards from that unchanged reading.
Step 4: the preview only handles the slashed case
The preview function PlumeRewardLogic.calculateRewardsWithCheckpointsView tries to simulate cumulative RPT over time. It adjusts only for slashed validators, clamping effectiveEndTime to slashedAtTimestamp, and then starts from the stored cumulative value. The excerpt given in the report is:
// calculate effectiveEndTime when the validator is slashed
if (validator.slashedAtTimestamp > 0 && validator.slashedAtTimestamp < effectiveEndTime) {
effectiveEndTime = validator.slashedAtTimestamp;
}
// 2. Start with the last known, stored cumulative value and its timestamp.
uint256 simulatedCumulativeRPT = $.validatorRewardPerTokenCumulative[validatorId][token];
uint256 lastUpdateTime = $.validatorLastUpdateTimes[validatorId][token];
// 3. If time has passed since the last update, simulate the RPT increase segment by segment.
if (effectiveEndTime > lastUpdateTime) {
...
}
// 4. Now that we have the correctly simulated final cumulative RPT, call the core logic.
return _calculateRewardsCore($, user, validatorId, token, userStakedAmount, simulatedCumulativeRPT);
Line by line, in plain words:
- The first block checks whether the validator was slashed, and if the slashing happened before the end time being simulated, it moves the end time back to the moment of slashing. This is the clamp: it stops the simulation at the point the validator was punished.
effectiveEndTimeis simply "the latest moment we are willing to simulate up to". simulatedCumulativeRPTcopies the saved meter reading into a working variable. This is the starting point for the simulation.lastUpdateTimecopies the saved timestamp of when that reading was last written.- The
if (effectiveEndTime > lastUpdateTime)block is where the simulation would add growth for the time between the last update and the end time. The...stands for code the report does not reproduce. - The final line hands the simulated meter reading to
_calculateRewardsCore, the shared maths that turns a meter reading into a reward amount for a user.
The problem: the only guard is the slashing check. There is no equivalent of the early return from step 2 for the inactive-but-not-slashed case. So the preview can add growth on top of a meter reading that the real function would have left untouched. The report calls the result a stale simulatedCumulativeRPT (L862-L917).
Step 5: how the wrong preview gets used
The proof of concept follows the chain of calls that ends up using the preview:
- Call
StakingFacet.restakeRewards. This invokes_calculateAndClaimAllRewardsWithCleanup(L451-L495, call at L468). - Inside
_calculateAndClaimAllRewardsWithCleanup,clearPendingRewardsFlagIfEmptyis invoked (L953-L1003, call at L989). clearPendingRewardsFlagIfEmptycallsPlumeRewardLogic.calculateRewardsWithCheckpointsView. Because the view does not handle inactive-but-not-slashed validators, it can return an incorrect result, causing the cleanup function to return early at L840. That forces repeated loop traversal on subsequent calls and wastes gas. The loop in question is at L826-L843 ofPlumeRewardLogic.sol.
In plain words: restakeRewards is a user action that puts earned rewards back into staking. That action triggers a helper that recalculates and claims rewards, and that helper runs a cleanup step. The cleanup step asks the preview "are there any pending rewards left?" If the preview wrongly says yes, the cleanup returns early. Next time, the same loop runs again, and again, and the user pays gas each time. Gas is the fee charged for computation on the blockchain, so wasted computation means wasted money.
Why it happens
The two code paths disagree on one branch. updateRewardPerTokenForValidator treats an inactive-but-not-slashed validator as a reason to stop accruing RPT and returns early, leaving $.validatorRewardPerTokenCumulative[validatorId][token] and $.validatorLastUpdateTimes[validatorId][token] as they were. The view reproduces the slashing clamp but not this early return, so it keeps simulating RPT growth from the stored value for a validator whose stored value the real path would never have advanced.
The existing defence, the slashing clamp on effectiveEndTime, covers only the slashed case. It does nothing for a validator that is inactive without having been slashed, which is exactly the state the updater handles separately.
What it means in practice
The view can return an incorrect reward delta for inactive-but-not-slashed validators because it works from a stale cumulative RPT. Functions that rely on the view may then react incorrectly.
The concrete example in the report is PlumeRewardLogic.clearPendingRewardsFlagIfEmpty, which uses calculateRewardsWithCheckpointsView at L838-L840. If the view reports pending rewards as non-empty when they should be empty, the cleanup function returns early. Callers are then forced to traverse the loop every time, which increases gas consumption for users and, in the worst case, means unbounded gas usage. The report rates this medium severity.
The fix
The report does not describe a patch or a change that was applied. The correction it implies is to make the view mirror the real function: before simulating RPT growth, calculateRewardsWithCheckpointsView should apply the same inactive-but-not-slashed early-return condition that updateRewardPerTokenForValidator uses at L155-L160, so that the simulation starts from, and stops at, the same cumulative value the real flow would produce.
Other places to look
- Other preview/real pairs in the same library. For every
...Viewfunction that claims to simulate a state-changing function, compare the branches. A positive result is a validator or user state that the real function short-circuits but the view does not. - Other early returns in the updater.
updateRewardPerTokenForValidatormay have more than one early exit; check whether the view reproduces each one, not just the slashing clamp. - Consumers of the view. Look for other functions besides
clearPendingRewardsFlagIfEmptythat branch on the view's output, such as cleanup, flag-setting or claim-skipping logic. A positive result is a path where a wrong view result changes control flow rather than just a displayed number. - Gas amplification through loops. Where a wrong view result causes a loop to be re-entered, measure whether the loop bound is attacker-influenced. A positive result is a call whose gas cost grows with state the caller can add to.
How to spot this kind of bug
This class of bug hides in duplicated logic: a read-only simulation of a state-changing function is a standing invitation for the two implementations to drift apart. The signal during review is a comment that promises exact equivalence ("simulates what the state-changing function does", "must accurately calculate"), followed by a comparison of every branch, especially early returns and clamps. Here the divergence was a single missing condition, and the impact was argued through a real consumer, clearPendingRewardsFlagIfEmpty, reached from StakingFacet.restakeRewards, with line-level references for each hop. Showing the full call path from an externally callable function to the faulty view, and naming the concrete consequence (early return, repeated loop traversal, higher gas), is what turns a correctness mismatch into a concrete, argued finding.
Glossary
- Blockchain: a shared record of transactions kept by many computers, where programs called smart contracts run automatically.
- Smart contract: a program stored on a blockchain that runs by itself when called, with no human in the middle.
- Staking: locking up tokens with a validator in exchange for rewards over time.
- Token: a digital asset tracked on the blockchain.
- Validator: an operator that helps run the network; users can stake with it.
- Reward: tokens earned for staking.
- Reward-per-token (RPT): a running number that grows over time and is used to work out each user's share of rewards; the report calls it a meter.
- Cumulative RPT: the total of that running number up to a given moment.
- State-changing function: a function that writes new data to the blockchain, which costs gas.
- View function: a read-only function that returns an answer without changing stored data and costs no gas when called from outside.
- Library: a bundle of shared code that other contracts call into.
- Facet: a smaller contract that adds features to a larger contract;
StakingFacethandles staking actions. - Slashed: punished by the network, for example by losing part of the stake.
- Inactive validator: a validator that has stopped taking part, without having been slashed.
- Early return: leaving a function before the end, skipping the rest of its work.
- Clamp: limiting a value to a maximum, here stopping the simulation at the slashing time.
- Stale value: a saved number that is out of date because it was not updated when it should have been.
- Gas: the fee paid for computation on the blockchain; more computation means more gas.
- Unbounded gas usage: a cost that can keep growing with no fixed limit.
- Commit: a fixed snapshot of a code repository, identified by a long code such as
[redacted]. - Severity: how serious a finding is judged to be; here medium.
- Proof of concept (PoC): a step-by-step demonstration that the problem can actually occur.
- Call path: the chain of function calls from the action a user takes down to the function where the problem lives.