diff --git a/src/Governance.sol b/src/Governance.sol index 6898a8e..20e4049 100644 --- a/src/Governance.sol +++ b/src/Governance.sol @@ -300,16 +300,6 @@ contract Governance is Multicall, UserProxyFactory, ReentrancyGuard, IGovernance initiativeSnapshot.forEpoch = currentEpoch - 1; - /// @audit Conditional - /// If we meet the threshold then we increase this - /// TODO: Either simplify, or use this for the state machine as well - if( - initiativeSnapshot.votes > initiativeSnapshot.vetos && - initiativeSnapshot.votes >= votingThreshold - ) { - // initiativeSnapshot.lastCountedEpoch = currentEpoch - 1; /// @audit This updating makes it so that we lose track | TODO: Find a better way - } - votesForInitiativeSnapshot[_initiative] = initiativeSnapshot; emit SnapshotVotesForInitiative(_initiative, initiativeSnapshot.votes, initiativeSnapshot.forEpoch); } diff --git a/src/interfaces/IGovernance.sol b/src/interfaces/IGovernance.sol index 146f3da..0ac90ea 100644 --- a/src/interfaces/IGovernance.sol +++ b/src/interfaces/IGovernance.sol @@ -91,7 +91,6 @@ interface IGovernance { struct InitiativeVoteSnapshot { uint224 votes; // Votes at epoch transition uint16 forEpoch; // Epoch for which the votes are counted - uint16 lastCountedEpoch; // Epoch at which which the votes where counted last in the global snapshot uint224 vetos; // Vetos at epoch transition } @@ -103,11 +102,10 @@ interface IGovernance { /// @param _initiative Address of the initiative /// @return votes Number of votes /// @return forEpoch Epoch for which the votes are counted - /// @return lastCountedEpoch Epoch at which which the votes where counted last in the global snapshot function votesForInitiativeSnapshot(address _initiative) external view - returns (uint224 votes, uint16 forEpoch, uint16 lastCountedEpoch, uint224 vetos); + returns (uint224 votes, uint16 forEpoch, uint224 vetos); struct Allocation { uint88 voteLQTY; // LQTY allocated vouching for the initiative diff --git a/test/Governance.t.sol b/test/Governance.t.sol index 84846c8..947dcec 100644 --- a/test/Governance.t.sol +++ b/test/Governance.t.sol @@ -628,23 +628,21 @@ contract GovernanceTest is Test { assertEq(forEpoch, governance.epoch() - 1); IGovernance.InitiativeVoteSnapshot memory initiativeSnapshot = - IGovernance.InitiativeVoteSnapshot(0, governance.epoch() - 1, 0, 0); + IGovernance.InitiativeVoteSnapshot(0, 0, 0); vm.store( address(governance), keccak256(abi.encode(baseInitiative3, uint256(3))), bytes32( abi.encodePacked( - uint16(initiativeSnapshot.lastCountedEpoch), uint16(initiativeSnapshot.forEpoch), uint224(initiativeSnapshot.votes) ) ) ); - (uint224 votes_, uint16 forEpoch_, uint16 lastCountedEpoch, ) = + (uint224 votes_, uint16 forEpoch_, ) = governance.votesForInitiativeSnapshot(baseInitiative3); assertEq(votes_, 0); assertEq(forEpoch_, governance.epoch() - 1); - assertEq(lastCountedEpoch, 0); governance.unregisterInitiative(baseInitiative3); @@ -917,7 +915,7 @@ contract GovernanceTest is Test { // should snapshot the global and initiatives votes if there hasn't been a snapshot in the current epoch yet (, uint16 forEpoch) = governance.votesSnapshot(); assertEq(forEpoch, governance.epoch() - 1); - (, forEpoch, ,) = governance.votesForInitiativeSnapshot(baseInitiative1); + (, forEpoch, ) = governance.votesForInitiativeSnapshot(baseInitiative1); assertEq(forEpoch, governance.epoch() - 1); vm.stopPrank(); @@ -1153,7 +1151,7 @@ contract GovernanceTest is Test { (Governance.InitiativeStatus status, , uint256 claimable) = governance.getInitiativeState(baseInitiative2); console.log("res", uint8(status)); console.log("claimable", claimable); - (uint224 votes, , , uint224 vetos) = governance.votesForInitiativeSnapshot(baseInitiative2); + (uint224 votes, , uint224 vetos) = governance.votesForInitiativeSnapshot(baseInitiative2); console.log("snapshot votes", votes); console.log("snapshot vetos", vetos); @@ -1338,44 +1336,40 @@ contract GovernanceTest is Test { assertEq(forEpoch, governance.epoch() - 1); IGovernance.InitiativeVoteSnapshot memory initiativeSnapshot = - IGovernance.InitiativeVoteSnapshot(1, governance.epoch() - 1, governance.epoch() - 1, 0); + IGovernance.InitiativeVoteSnapshot(1, governance.epoch() - 1, 0); vm.store( address(governance), keccak256(abi.encode(address(mockInitiative), uint256(3))), bytes32( abi.encodePacked( - uint16(initiativeSnapshot.lastCountedEpoch), uint16(initiativeSnapshot.forEpoch), uint224(initiativeSnapshot.votes) ) ) ); - (uint224 votes_, uint16 forEpoch_, uint16 lastCountedEpoch, ) = + (uint224 votes_, uint16 forEpoch_, ) = governance.votesForInitiativeSnapshot(address(mockInitiative)); assertEq(votes_, 1); assertEq(forEpoch_, governance.epoch() - 1); - assertEq(lastCountedEpoch, governance.epoch() - 1); governance.claimForInitiative(address(mockInitiative)); vm.warp(block.timestamp + governance.EPOCH_DURATION()); - initiativeSnapshot = IGovernance.InitiativeVoteSnapshot(0, governance.epoch() - 1, 0, 0); + initiativeSnapshot = IGovernance.InitiativeVoteSnapshot(0, 0, 0); vm.store( address(governance), keccak256(abi.encode(address(mockInitiative), uint256(3))), bytes32( abi.encodePacked( - uint16(initiativeSnapshot.lastCountedEpoch), uint16(initiativeSnapshot.forEpoch), uint224(initiativeSnapshot.votes) ) ) ); - (votes_, forEpoch_, lastCountedEpoch, ) = governance.votesForInitiativeSnapshot(address(mockInitiative)); + (votes_, forEpoch_, ) = governance.votesForInitiativeSnapshot(address(mockInitiative)); assertEq(votes_, 0, "votes"); assertEq(forEpoch_, governance.epoch() - 1, "forEpoch_"); - assertEq(lastCountedEpoch, 0, "lastCountedEpoch"); vm.warp(block.timestamp + governance.EPOCH_DURATION() * 4); diff --git a/zzz_TEMP_TO_FIX.MD b/zzz_TEMP_TO_FIX.MD index ab90ca9..7d5e4ac 100644 --- a/zzz_TEMP_TO_FIX.MD +++ b/zzz_TEMP_TO_FIX.MD @@ -1,5 +1,2 @@ -[FAIL. Reason: revert: Governance: claim-not-met] test_claimForInitiative() (gas: 1198986) - -Fails because of Governance: claim-not-met - -TODO: Discuss if we should return 0 in those scenarios \ No newline at end of file +[FAIL. Reason: assertion failed: 65536 != 1] test_nonReentrant() (gas: 829813) +[FAIL. Reason: assertion failed: 0 != 104] test_unregisterInitiative() (gas: 435924) \ No newline at end of file