Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset no longer needed on staking & fix underflow #110

Merged
merged 5 commits into from
Dec 27, 2024

Conversation

danielattilasimon
Copy link
Contributor

Address remaining TODO in _increaseUserVoteTrackers() by eliminating reset requirement.
Fixes #108.

Fix possible underflow in withdrawLQTY().
Fixes #109.

Copy link
Contributor

@bingen bingen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
I think there are some other places where we may update tests to the fact that we don’t need resets on deposit/withdrawal anymore, like:

https://github.com/liquity/V2-gov/blob/main/test/recon/targets/GovernanceTargets.sol#L110
https://github.com/liquity/V2-gov/blob/main/test/recon/targets/GovernanceTargets.sol#L283

But happy to merge this as is, we can fix that later if it’s more convenient.

@@ -203,7 +196,6 @@ contract Governance is MultiDelegateCall, UserProxyFactory, ReentrancyGuard, Own
function withdrawLQTY(uint256 _lqtyAmount, bool _doSendRewards, address _recipient) public nonReentrant {
// check that user has reset before changing lqty balance
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we should remove this comment now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops 😅

This sequence of events was triggering a bug in older version of
`Governance`, which is why the requirement to reset all allocations
before staking/unstaking was introduced.

As we are removing that requirement, it makes sense to add a test
case for this.
@danielattilasimon
Copy link
Contributor Author

I'd fix the invariant tests in a separate PR later, as there are already some broken ones after the voting power refactor.

@danielattilasimon
Copy link
Contributor Author

danielattilasimon commented Dec 27, 2024

On the other hand, I dug up the test case I wrote to demonstrate the bug that was the whole reason for the reset requirement, updated it, and added it to the test suite.

@danielattilasimon danielattilasimon merged commit b5ab005 into main Dec 27, 2024
3 checks passed
@bingen
Copy link
Contributor

bingen commented Dec 29, 2024

Awesome, thanks!!

@danielattilasimon danielattilasimon deleted the address-todo branch January 19, 2025 04:41
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.

CS-V2Gov-050: Possible Underflow in withdrawLQTY CS-V2Gov-041: Remaining ToDos in the Codebase
2 participants