Skip to content

Commit

Permalink
fix: compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
GalloDaSballo committed Oct 14, 2024
1 parent 78a4e55 commit 03c5315
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 41 deletions.
2 changes: 0 additions & 2 deletions src/BribeInitiative.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {console} from "forge-std/console.sol";

import {IERC20} from "openzeppelin-contracts/contracts/interfaces/IERC20.sol";
import {SafeERC20} from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";

Expand Down
2 changes: 0 additions & 2 deletions src/Governance.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {console} from "forge-std/console.sol";

import {IERC20} from "openzeppelin-contracts/contracts/interfaces/IERC20.sol";
import {SafeERC20} from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
import {ReentrancyGuard} from "openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol";
Expand Down
58 changes: 29 additions & 29 deletions test/BribeInitiativeAllocate.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 0
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user2, userState, allocation, initiativeState);
}
Expand All @@ -99,7 +99,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 0
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user, userState2, allocation2, initiativeState2);
}
Expand Down Expand Up @@ -132,7 +132,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(1),
averageStakingTimestampVetoLQTY: 0,
counted: 0
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user, userState, allocation, initiativeState);
}
Expand Down Expand Up @@ -171,7 +171,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 0
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user2, userState, allocation, initiativeState);
(uint88 totalLQTYAllocated, uint32 totalAverageTimestamp) =
Expand All @@ -193,7 +193,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 0
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user2, userState, allocation, initiativeState);
(uint88 totalLQTYAllocated, uint32 totalAverageTimestamp) =
Expand Down Expand Up @@ -225,7 +225,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 1,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 0
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user, userState, allocation, initiativeState);
(uint88 totalLQTYAllocated, uint32 totalAverageTimestamp) =
Expand All @@ -247,7 +247,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 1,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 0
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user2, userState, allocation, initiativeState);
(uint88 totalLQTYAllocated, uint32 totalAverageTimestamp) =
Expand Down Expand Up @@ -287,7 +287,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user2, userState, allocation, initiativeState);

Expand All @@ -309,7 +309,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 1000e18,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: uint32(block.timestamp),
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(
governance.epoch(), user, userStateVeto, allocationVeto, initiativeStateVeto
Expand All @@ -335,7 +335,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 1,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: uint32(block.timestamp),
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(
governance.epoch(), user, userStateNewEpoch, allocationNewEpoch, initiativeStateNewEpoch
Expand Down Expand Up @@ -369,7 +369,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(
governance.epoch(), user, userStateNewEpoch3, allocationNewEpoch3, initiativeStateNewEpoch3
Expand Down Expand Up @@ -410,7 +410,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user2, userState, allocation, initiativeState);

Expand All @@ -434,7 +434,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user, userState, allocation, initiativeState);

Expand All @@ -460,7 +460,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user, userState, allocation, initiativeState);

Expand All @@ -486,7 +486,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user, userState, allocation, initiativeState);

Expand Down Expand Up @@ -522,7 +522,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user2, userState, allocation, initiativeState);

Expand All @@ -546,7 +546,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user, userState, allocation, initiativeState);

Expand All @@ -570,7 +570,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user, userState, allocation, initiativeState);

Expand Down Expand Up @@ -616,7 +616,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user2, userState, allocation, initiativeState);

Expand All @@ -640,7 +640,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user, userState, allocation, initiativeState);

Expand All @@ -664,7 +664,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user, userState, allocation, initiativeState);

Expand Down Expand Up @@ -712,7 +712,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user2, userState, allocation, initiativeState);

Expand All @@ -736,7 +736,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user, userState, allocation, initiativeState);

Expand All @@ -760,7 +760,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user, userState, allocation, initiativeState);

Expand All @@ -784,7 +784,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user, userState, allocation, initiativeState);

Expand Down Expand Up @@ -824,7 +824,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user2, userState, allocation, initiativeState);

Expand All @@ -848,7 +848,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user, userState, allocation, initiativeState);

Expand All @@ -872,7 +872,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user, userState, allocation, initiativeState);

Expand All @@ -896,7 +896,7 @@ contract BribeInitiativeAllocateTest is Test {
vetoLQTY: 0,
averageStakingTimestampVoteLQTY: uint32(block.timestamp),
averageStakingTimestampVetoLQTY: 0,
counted: 1
lastEpochClaim: 0
});
bribeInitiative.onAfterAllocateLQTY(governance.epoch(), user, userState, allocation, initiativeState);

Expand Down
4 changes: 2 additions & 2 deletions test/Governance.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1395,15 +1395,15 @@ contract GovernanceTest is Test {
deltaLQTYVetos[1] = 0;

vm.warp(block.timestamp + 365 days);
vm.expectRevert("Governance: insufficient-or-unallocated-lqty");
vm.expectRevert("Governance: insufficient-or-allocated-lqty");
governance.allocateLQTY(initiatives, deltaLQTYVotes, deltaLQTYVetos);

deltaLQTYVotes[0] = 0;
deltaLQTYVotes[1] = 0;
deltaLQTYVetos[0] = 0;
deltaLQTYVetos[1] = type(int88).max;

vm.expectRevert("Governance: insufficient-or-unallocated-lqty");
vm.expectRevert("Governance: insufficient-or-allocated-lqty");
governance.allocateLQTY(initiatives, deltaLQTYVotes, deltaLQTYVetos);

vm.stopPrank();
Expand Down
12 changes: 6 additions & 6 deletions test/GovernanceAttacks.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ contract GovernanceTest is Test {

}

// forge test --match-test test_deposit_attack -vv
// forge test --match-test test_all_revert_attacks_hardcoded -vv
// All calls should never revert due to malicious initiative
function test_all_revert_attacks_hardcoded() public {
uint256 zeroSnapshot = vm.snapshot();
Expand Down Expand Up @@ -145,10 +145,10 @@ contract GovernanceTest is Test {
address[] memory initiatives = new address[](2);
initiatives[0] = address(maliciousInitiative2);
initiatives[1] = address(eoaInitiative);
int176[] memory deltaVoteLQTY = new int176[](2);
int88[] memory deltaVoteLQTY = new int88[](2);
deltaVoteLQTY[0] = 5e17;
deltaVoteLQTY[1] = 5e17;
int176[] memory deltaVetoLQTY = new int176[](2);
int88[] memory deltaVetoLQTY = new int88[](2);

/// === Allocate LQTY REVERTS === ///
uint256 allocateSnapshot = vm.snapshot();
Expand Down Expand Up @@ -208,11 +208,11 @@ contract GovernanceTest is Test {
initiatives[0] = address(maliciousInitiative2);
initiatives[1] = address(eoaInitiative);
initiatives[2] = address(maliciousInitiative1);
deltaVoteLQTY = new int176[](3);
deltaVoteLQTY = new int88[](3);
deltaVoteLQTY[0] = -5e17;
deltaVoteLQTY[1] = -5e17;
deltaVoteLQTY[2] = 5e17;
deltaVetoLQTY = new int176[](3);
deltaVetoLQTY = new int88[](3);
governance.allocateLQTY(initiatives, deltaVoteLQTY, deltaVetoLQTY);

(Governance.VoteSnapshot memory v, Governance.InitiativeVoteSnapshot memory initData) = governance.snapshotVotesForInitiative(address(maliciousInitiative2));
Expand All @@ -222,7 +222,7 @@ contract GovernanceTest is Test {
// Inactive for 4 epochs
// Add another proposal

vm.warp(block.timestamp + governance.EPOCH_DURATION() * 4);
vm.warp(block.timestamp + governance.EPOCH_DURATION() * 5); /// @audit needs 5?
(v, initData) = governance.snapshotVotesForInitiative(address(maliciousInitiative2));
assertEq(initData.lastCountedEpoch, currentEpoch - 1, "Epoch Matches"); /// @audit This fails if you have 0 votes, see QA

Expand Down

0 comments on commit 03c5315

Please sign in to comment.