The veRAACToken::emergencyWithdraw() function does not update _lockState.totalLocked, causing an unchecked increase in its value. Over time, this leads to an overflow, preventing new tokens from being locked and potentially disrupting contract functionality. However, given that emergency withdrawals may indicate the contract is being deprecated or abandoned, this issue is classified as informational unless emergency withdrawals are expected to maintain normal functionality.
The functions veRAACToken::lock() and veRAACToken::increase() correctly update _lockState.totalLocked, ensuring that the total locked balance remains accurate. However, veRAACToken::emergencyWithdraw() only clears user-specific data without adjusting _lockState.totalLocked, leading to a continuously increasing value that could eventually overflow.
Since _lockState.totalLocked is never updated upon withdrawal, its value continues to increase indefinitely.
Comparison with withdraw():
In contrast, the standard withdrawal mechanism ensures _lockState.totalLocked is updated correctly. If emergencyWithdraw() is meant to replace withdraw(), its omission of _lockState.totalLocked updates suggests that emergency withdrawals may be intended as a final measure before contract abandonment.
Add the following test to test/unit/core/tokens/veRAACToken.test.js and execute it:
output:
The output confirms that _lockState.totalLocked continues increasing without a corresponding decrease, diverging from the expected total voting power. Over time, this unchecked growth can lead to an overflow, rendering the contract unusable.
If emergency withdrawals are meant to preserve contract functionality, the unchecked growth of _lockState.totalLocked could lead to an overflow, preventing new tokens from being locked and disrupting normal operations. However, if emergency withdrawals indicate the contract is being deprecated, then this behavior may be intentional.
Manual Review
If emergency withdrawals are intended to allow continued contract operation, modify emergencyWithdraw() to properly update _lockState.totalLocked by subtracting the withdrawn amount,For example:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.