Skip to content

Commit

Permalink
Small improvements, cleanup and updates
Browse files Browse the repository at this point in the history
* Remove unused variables in tests to resolve compiler warnings
* Bump the compiler version to 0.8.28 and re-run the gas report
* Turn on Slither in the CI config
  • Loading branch information
apbendi committed Feb 5, 2025
1 parent 2e2870d commit 3f4341e
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 47 deletions.
40 changes: 20 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,23 @@ jobs:
scopelint --version
scopelint check
# slither-analyze:
# runs-on: ubuntu-latest
# permissions:
# contents: read
# security-events: write
# steps:
# - uses: actions/checkout@v3

# - name: Run Slither
# uses: crytic/[email protected]
# id: slither # Required to reference this step in the next step.
# with:
# fail-on: none # Required to avoid failing the CI run regardless of findings.
# sarif: results.sarif
# slither-args: --filter-paths "./lib|./test" --exclude naming-convention,solc-version

# - name: Upload SARIF file
# uses: github/codeql-action/upload-sarif@v2
# with:
# sarif_file: ${{ steps.slither.outputs.sarif }}
slither-analyze:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v3

- name: Run Slither
uses: crytic/[email protected]
id: slither # Required to reference this step in the next step.
with:
fail-on: none # Required to avoid failing the CI run regardless of findings.
sarif: results.sarif
slither-args: --filter-paths "./lib|./test" --exclude naming-convention,solc-version

- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.slither.outputs.sarif }}
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
optimizer = true
optimizer_runs = 10_000_000
remappings = ["openzeppelin/=lib/openzeppelin-contracts/contracts"]
solc_version = "0.8.26"
solc_version = "0.8.28"
verbosity = 3

[profile.ci]
Expand Down
3 changes: 0 additions & 3 deletions src/Staker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol";
import {SafeERC20} from "openzeppelin/token/ERC20/utils/SafeERC20.sol";
import {Multicall} from "openzeppelin/utils/Multicall.sol";
import {SafeCast} from "openzeppelin/utils/math/SafeCast.sol";
import {Nonces} from "openzeppelin/utils/Nonces.sol";
import {SignatureChecker} from "openzeppelin/utils/cryptography/SignatureChecker.sol";
import {EIP712} from "openzeppelin/utils/cryptography/EIP712.sol";

/// @title Staker
/// @author [ScopeLift](https://scopelift.co)
Expand Down
1 change: 0 additions & 1 deletion src/interfaces/IERC20Staking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.23;

import {IERC20Permit} from "openzeppelin/token/ERC20/extensions/IERC20Permit.sol";
import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol";
import {IERC20Delegates} from "src/interfaces/IERC20Delegates.sol";

/// @notice The interface of an ERC20 that supports a governor staker and all of the created
Expand Down
2 changes: 1 addition & 1 deletion src/notifiers/MintRewardNotifier.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.23;

import {INotifiableRewardReceiver, IERC20} from "src/interfaces/INotifiableRewardReceiver.sol";
import {INotifiableRewardReceiver} from "src/interfaces/INotifiableRewardReceiver.sol";
import {IMintable} from "src/interfaces/IMintable.sol";
import {RewardTokenNotifierBase} from "src/notifiers/RewardTokenNotifierBase.sol";
import {Ownable} from "openzeppelin/access/Ownable.sol";
Expand Down
4 changes: 0 additions & 4 deletions test/Staker.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2840,7 +2840,6 @@ contract BumpEarningPower is StakerRewardsTest {
vm.assume(_tipReceiver != address(0) && _tipReceiver != address(govStaker));
_stakeAmount = _boundToRealisticStake(_stakeAmount);
_rewardAmount = _boundToRealisticReward(_rewardAmount);
uint256 _initialTipReceiverBalance = rewardToken.balanceOf(_tipReceiver);
_earningPowerIncrease = uint96(bound(_earningPowerIncrease, 1, type(uint48).max));

// A user deposits staking tokens
Expand All @@ -2863,8 +2862,6 @@ contract BumpEarningPower is StakerRewardsTest {
vm.prank(_bumpCaller);
govStaker.bumpEarningPower(_depositId, _tipReceiver, _requestedTip);

uint256 _tipReceiverBalanceIncrease =
rewardToken.balanceOf(_tipReceiver) - _initialTipReceiverBalance;
assertEq(govStaker.unclaimedReward(_depositId), _unclaimedRewards - _requestedTip);
}

Expand Down Expand Up @@ -3035,7 +3032,6 @@ contract BumpEarningPower is StakerRewardsTest {
_stakeAmount = _boundToRealisticStake(_stakeAmount);
_rewardAmount = bound(_rewardAmount, maxBumpTip + 1, 10_000_000e18);
_earningPowerDecrease = bound(_earningPowerDecrease, 1, _stakeAmount);
uint256 _initialTipReceiverBalance = rewardToken.balanceOf(_tipReceiver);

// A user deposits staking tokens
(, Staker.DepositIdentifier _depositId) =
Expand Down
1 change: 0 additions & 1 deletion test/fakes/FakeMinter.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.23;

import {ERC20} from "openzeppelin/token/ERC20/ERC20.sol";
import {IMintable} from "src/interfaces/IMintable.sol";

contract FakeMinter is IMintable {
Expand Down
2 changes: 1 addition & 1 deletion test/gas-reports/Staker.g.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
pragma solidity ^0.8.23;

import {Vm, Test, stdStorage, StdStorage, console2, stdError} from "forge-std/Test.sol";
import {GasReport} from "test/lib/GasReport.sol";
Expand Down
22 changes: 11 additions & 11 deletions test/gas-reports/gov-staker-gas-report.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"generatedAt": 1734023383,
"generatedAt": 1736548728,
"reportName:": "gov-stakerGasReport",
"results": [
{
Expand All @@ -16,35 +16,35 @@
},
{
"scenarioName": "Stake more after initial stake",
"gasUsed": 101615
"gasUsed": 101547
},
{
"scenarioName": "Alter delegatee with new delegatee",
"gasUsed": 218503
"gasUsed": 218435
},
{
"scenarioName": "Alter delegatee with existing delegatee",
"gasUsed": 86397
"gasUsed": 86329
},
{
"scenarioName": "Alter claimer to a new address",
"gasUsed": 69468
"gasUsed": 69400
},
{
"scenarioName": "Withdraw full stake",
"gasUsed": 110594
"gasUsed": 110554
},
{
"scenarioName": "Withdraw partial stake",
"gasUsed": 124994
"gasUsed": 124954
},
{
"scenarioName": "Claim reward when no reward",
"gasUsed": 46021
},
{
"scenarioName": "Claim reward when reward",
"gasUsed": 164908
"gasUsed": 164840
},
{
"scenarioName": "Notify reward",
Expand All @@ -56,15 +56,15 @@
},
{
"scenarioName": "Bump earning power up no reward",
"gasUsed": 80178
"gasUsed": 80502
},
{
"scenarioName": "Bump earning power down with reward",
"gasUsed": 108922
"gasUsed": 109274
},
{
"scenarioName": "Bump earning power up with reward",
"gasUsed": 108922
"gasUsed": 109274
}
]
}
2 changes: 0 additions & 2 deletions test/harnesses/StakerHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import {StakerOnBehalf} from "src/extensions/StakerOnBehalf.sol";
import {StakerDelegateSurrogateVotes} from "src/extensions/StakerDelegateSurrogateVotes.sol";

import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol";
import {SafeERC20} from "openzeppelin/token/ERC20/utils/SafeERC20.sol";
import {EIP712} from "openzeppelin/utils/cryptography/EIP712.sol";
import {IERC20Staking} from "src/interfaces/IERC20Staking.sol";
import {IERC20Delegates} from "src/interfaces/IERC20Delegates.sol";
import {IEarningPowerCalculator} from "src/interfaces/IEarningPowerCalculator.sol";
import {DelegationSurrogate} from "src/DelegationSurrogate.sol";

Expand Down
2 changes: 1 addition & 1 deletion test/lib/GasReport.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
pragma solidity ^0.8.23;

import {Test, console2} from "forge-std/Test.sol";
import {Vm} from "forge-std/Vm.sol";
Expand Down
1 change: 0 additions & 1 deletion test/mocks/MockERC20Votes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
ERC20, ERC20Permit, IERC20Permit
} from "openzeppelin/token/ERC20/extensions/ERC20Permit.sol";
import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol";
import {IERC20Delegates} from "src/interfaces/IERC20Delegates.sol";
import {IERC20Staking} from "src/interfaces/IERC20Staking.sol";
import {IMintable} from "src/interfaces/IMintable.sol";

Expand Down

0 comments on commit 3f4341e

Please sign in to comment.