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 6978a97
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 38 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
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
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: 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

0 comments on commit 6978a97

Please sign in to comment.