From dd120e6aff9e1d1f2417dab6e6997b36b520a6c4 Mon Sep 17 00:00:00 2001 From: skhomuti Date: Fri, 24 Jan 2025 16:46:56 +0500 Subject: [PATCH 1/3] fix all compiler warnings --- foundry.toml | 2 +- script/fork-helpers/NodeOperators.s.sol | 4 +- src/CSModule.sol | 2 +- test/BaseOracle.t.sol | 51 ++++++++-------------- test/CSAccounting.t.sol | 32 ++++++-------- test/CSBondCore.t.sol | 2 +- test/CSBondCurve.t.sol | 20 ++++----- test/CSFeeDistributor.t.sol | 1 - test/CSFeeOracle.t.sol | 2 +- test/CSModule.t.sol | 31 ++++++------- test/CSPerksRegistry.t.sol | 12 ++--- test/GIndex.t.sol | 39 +++++++++-------- test/HashConsensus.t.sol | 6 +-- test/OssifiableProxy.t.sol | 6 +-- test/PausableUntil.t.sol | 8 ++-- test/PermissionlessGate.t.sol | 2 +- test/QueueLib.t.sol | 11 +++-- test/SSZ.t.sol | 32 +++++++------- test/SigningKeys.t.sol | 8 ++-- test/UnstructuredStorage.t.sol | 12 +++-- test/ValidatorCountsReport.t.sol | 6 +-- test/Versioned.t.sol | 10 +++-- test/VettedGate.t.sol | 6 +-- test/fork/deployment/InitialState.t.sol | 8 ++-- test/fork/deployment/PostDeployment.t.sol | 32 +++++++------- test/fork/integration/ClaimInTokens.t.sol | 6 +-- test/fork/integration/CreateAndDeposit.sol | 20 ++++----- test/fork/integration/RecoverTokens.t.sol | 12 ++--- test/fork/invariant/Invariants.t.sol | 18 ++++---- test/fork/voting/StakingRouter.t.sol | 2 +- test/fork/voting/StatePostVote.t.sol | 20 ++++----- test/helpers/Fixtures.sol | 2 +- test/helpers/InvariantAsserts.sol | 14 +++--- test/helpers/Utilities.sol | 20 ++++----- test/helpers/mocks/CSMMock.sol | 10 ++--- test/helpers/mocks/DistributorMock.sol | 10 ++--- test/helpers/mocks/LidoMock.sol | 2 +- 37 files changed, 232 insertions(+), 249 deletions(-) diff --git a/foundry.toml b/foundry.toml index 7649b6d7..9b00f763 100644 --- a/foundry.toml +++ b/foundry.toml @@ -35,7 +35,7 @@ fs_permissions = [ { access = "read", path = "./test/fixtures" }, ] -ignored_warnings_from = ["src/lib/base-oracle/HashConsensus.sol", "test/helpers/mocks/LidoMock.sol", "test/OssifiableProxy.t.sol"] +ignored_warnings_from = ["src/lib/base-oracle/HashConsensus.sol", "test/OssifiableProxy.t.sol"] [profile.ci] verbosity = 3 diff --git a/script/fork-helpers/NodeOperators.s.sol b/script/fork-helpers/NodeOperators.s.sol index 10ec1ede..619b5c68 100644 --- a/script/fork-helpers/NodeOperators.s.sol +++ b/script/fork-helpers/NodeOperators.s.sol @@ -297,7 +297,7 @@ contract NodeOperators is bytes3 moduleId = bytes3(uint24(_getCSMId())); bytes5 nodeOpId = bytes5(uint40(noId)); - bytes8 validatorIndex = bytes8(uint64(validatorIndex)); + bytes8 _validatorIndex = bytes8(uint64(validatorIndex)); (, uint256 refSlot, , ) = vebo.getConsensusReport(); uint256 reportRefSlot = refSlot + 1; @@ -305,7 +305,7 @@ contract NodeOperators is data = abi.encodePacked( moduleId, nodeOpId, - validatorIndex, + _validatorIndex, validatorPubKey ); IVEBO.ReportData memory report = IVEBO.ReportData({ diff --git a/src/CSModule.sol b/src/CSModule.sol index 143ad156..428f7e7c 100644 --- a/src/CSModule.sol +++ b/src/CSModule.sol @@ -541,7 +541,7 @@ contract CSModule is function updateRefundedValidatorsCount( uint256 /* nodeOperatorId */, uint256 /* refundedValidatorsCount */ - ) external onlyRole(STAKING_ROUTER_ROLE) { + ) external view onlyRole(STAKING_ROUTER_ROLE) { revert NotSupported(); } diff --git a/test/BaseOracle.t.sol b/test/BaseOracle.t.sol index 55c4d5bf..5c7b920c 100644 --- a/test/BaseOracle.t.sol +++ b/test/BaseOracle.t.sol @@ -126,23 +126,19 @@ contract BaseOracleTest is Test, Utilities { function test_submitConsensusReport_RevertsIfSenderIsNotConsensusContract() public { - uint256 initialRefSlot = oracle.getTime(); + uint256 refSlot = oracle.getTime(); vm.prank(stranger); vm.expectRevert(BaseOracle.SenderIsNotTheConsensusContract.selector); - oracle.submitConsensusReport( - keccak256("HASH_1"), - initialRefSlot, - initialRefSlot - ); + oracle.submitConsensusReport(keccak256("HASH_1"), refSlot, refSlot); } function test_submitConsensusReport_SubmitsFromConsensusContract() public { - uint256 initialRefSlot = oracle.getTime(); + uint256 refSlot = oracle.getTime(); vm.prank(address(consensus)); oracle.submitConsensusReport( keccak256("HASH_1"), - initialRefSlot, - initialRefSlot + SLOTS_PER_FRAME + refSlot, + refSlot + SLOTS_PER_FRAME ); assertEq(oracle.getConsensusReportLastCall().callCount, 1); } @@ -150,25 +146,25 @@ contract BaseOracleTest is Test, Utilities { function test_discardConsensusReport_RevertsIfSenderIsNotConsensusContract() public { - uint256 initialRefSlot = oracle.getTime(); + uint256 refSlot = oracle.getTime(); vm.prank(stranger); vm.expectRevert(BaseOracle.SenderIsNotTheConsensusContract.selector); - oracle.discardConsensusReport(initialRefSlot); + oracle.discardConsensusReport(refSlot); } function test_discardConsensusReport_DiscardsFromConsensusContract() public { - uint256 initialRefSlot = oracle.getTime(); + uint256 refSlot = oracle.getTime(); vm.prank(address(consensus)); oracle.submitConsensusReport( keccak256("HASH_1"), - initialRefSlot, - initialRefSlot + SLOTS_PER_FRAME + refSlot, + refSlot + SLOTS_PER_FRAME ); assertEq(oracle.getConsensusReportLastCall().callCount, 1); vm.prank(address(consensus)); - oracle.discardConsensusReport(initialRefSlot); + oracle.discardConsensusReport(refSlot); } // consensus tests @@ -392,19 +388,19 @@ contract BaseOracleTest is Test, Utilities { oracle.checkProcessingDeadline(); } - function test_isConsensusMember_ReturnsFalseOnNonMember() public { + function test_isConsensusMember_ReturnsFalseOnNonMember() public view { bool r = oracle.isConsensusMember(notMember); assertFalse(r); } - function test_isConsensusMember_ReturnsTrueOnMember() public { + function test_isConsensusMember_ReturnsTrueOnMember() public view { bool r = oracle.isConsensusMember(member); assertTrue(r); } // consensus report - function test_getConsensusReport_ReturnsEmptyState() public { + function test_getConsensusReport_ReturnsEmptyState() public view { ( bytes32 hash, uint256 refSlot, @@ -820,12 +816,7 @@ contract BaseOracleTest is Test, Utilities { emit BaseOracle.ReportDiscarded(initialRefSlot, keccak256("HASH_1")); oracle.discardConsensusReport(initialRefSlot); - ( - bytes32 hash, - uint256 refSlot, - uint256 processingDeadlineTime, - bool processingStarted - ) = oracle.getConsensusReport(); + (bytes32 hash, , , ) = oracle.getConsensusReport(); assertEq(hash, bytes32(0)); } @@ -842,8 +833,7 @@ contract BaseOracleTest is Test, Utilities { vm.prank(address(consensus)); oracle.discardConsensusReport(initialRefSlot); - (bytes32 hash, uint256 refSlot, uint256 processingDeadlineTime) = oracle - .lastDiscardedReport(); + (bytes32 hash, , ) = oracle.lastDiscardedReport(); assertEq(hash, keccak256("HASH_1")); } @@ -861,12 +851,7 @@ contract BaseOracleTest is Test, Utilities { initialRefSlot, deadline ); - ( - bytes32 hash, - uint256 refSlot, - uint256 processingDeadlineTime, - bool processingStarted - ) = oracle.getConsensusReport(); + (bytes32 hash, , , ) = oracle.getConsensusReport(); assertEq(hash, keccak256("HASH_2")); } @@ -1099,7 +1084,7 @@ contract BaseOracleImpl is BaseOracle { _checkConsensusData(refSlot, consensusVersion, hash); } - function checkProcessingDeadline() external { + function checkProcessingDeadline() external view { _checkProcessingDeadline( _storageConsensusReport().value.processingDeadlineTime ); diff --git a/test/CSAccounting.t.sol b/test/CSAccounting.t.sol index 799fca67..6f3f5e82 100644 --- a/test/CSAccounting.t.sol +++ b/test/CSAccounting.t.sol @@ -357,7 +357,7 @@ contract CSAccountingBaseTest is CSAccountingFixtures { } contract CSAccountingPauseTest is CSAccountingBaseTest { - function test_notPausedByDefault() public { + function test_notPausedByDefault() public view { assertFalse(accounting.isPaused()); } @@ -3108,9 +3108,7 @@ contract CSAccountingDepositStEthTest is CSAccountingBaseTest { function test_depositStETH() public assertInvariants { vm.deal(user, 32 ether); vm.prank(user); - uint256 sharesToDeposit = stETH.submit{ value: 32 ether }({ - _referal: address(0) - }); + uint256 sharesToDeposit = stETH.submit{ value: 32 ether }(address(0)); vm.prank(address(stakingModule)); accounting.depositStETH( @@ -3183,9 +3181,7 @@ contract CSAccountingDepositStEthTest is CSAccountingBaseTest { { vm.deal(user, 32 ether); vm.startPrank(user); - uint256 sharesToDeposit = stETH.submit{ value: 32 ether }({ - _referal: address(0) - }); + uint256 sharesToDeposit = stETH.submit{ value: 32 ether }(address(0)); stETH.approve(address(accounting), type(uint256).max); vm.stopPrank(); @@ -3224,9 +3220,7 @@ contract CSAccountingDepositStEthTest is CSAccountingBaseTest { function test_depositStETH_withPermit() public assertInvariants { vm.deal(user, 32 ether); vm.prank(user); - uint256 sharesToDeposit = stETH.submit{ value: 32 ether }({ - _referal: address(0) - }); + uint256 sharesToDeposit = stETH.submit{ value: 32 ether }(address(0)); vm.prank(address(stakingModule)); vm.expectEmit(true, true, true, true, address(stETH)); @@ -3270,7 +3264,7 @@ contract CSAccountingDepositStEthTest is CSAccountingBaseTest { { vm.deal(user, 32 ether); vm.startPrank(user); - stETH.submit{ value: 32 ether }({ _referal: address(0) }); + stETH.submit{ value: 32 ether }(address(0)); stETH.approve(address(accounting), 1 ether); vm.stopPrank(); @@ -3307,7 +3301,7 @@ contract CSAccountingDepositStEthTest is CSAccountingBaseTest { { vm.deal(user, 32 ether); vm.startPrank(user); - stETH.submit{ value: 32 ether }({ _referal: address(0) }); + stETH.submit{ value: 32 ether }(address(0)); stETH.approve(address(accounting), UINT256_MAX); vm.stopPrank(); @@ -3342,7 +3336,7 @@ contract CSAccountingDepositStEthTest is CSAccountingBaseTest { { vm.deal(user, 32 ether); vm.startPrank(user); - stETH.submit{ value: 32 ether }({ _referal: address(0) }); + stETH.submit{ value: 32 ether }(address(0)); stETH.approve(address(accounting), 32 ether); vm.stopPrank(); @@ -3399,7 +3393,7 @@ contract CSAccountingDepositWstEthTest is CSAccountingBaseTest { function test_depositWstETH() public assertInvariants { vm.deal(user, 32 ether); vm.startPrank(user); - stETH.submit{ value: 32 ether }({ _referal: address(0) }); + stETH.submit{ value: 32 ether }(address(0)); stETH.approve(address(wstETH), UINT256_MAX); uint256 wstETHAmount = wstETH.wrap(32 ether); uint256 sharesToDeposit = stETH.getSharesByPooledEth( @@ -3478,7 +3472,7 @@ contract CSAccountingDepositWstEthTest is CSAccountingBaseTest { { vm.deal(user, 32 ether); vm.startPrank(user); - stETH.submit{ value: 32 ether }({ _referal: address(0) }); + stETH.submit{ value: 32 ether }(address(0)); stETH.approve(address(wstETH), UINT256_MAX); uint256 wstETHAmount = wstETH.wrap(32 ether); uint256 sharesToDeposit = stETH.getSharesByPooledEth( @@ -3522,7 +3516,7 @@ contract CSAccountingDepositWstEthTest is CSAccountingBaseTest { function test_depositWstETH_withPermit() public assertInvariants { vm.deal(user, 32 ether); vm.startPrank(user); - stETH.submit{ value: 32 ether }({ _referal: address(0) }); + stETH.submit{ value: 32 ether }(address(0)); stETH.approve(address(wstETH), UINT256_MAX); uint256 wstETHAmount = wstETH.wrap(32 ether); uint256 sharesToDeposit = stETH.getSharesByPooledEth( @@ -3572,7 +3566,7 @@ contract CSAccountingDepositWstEthTest is CSAccountingBaseTest { { vm.deal(user, 32 ether); vm.startPrank(user); - stETH.submit{ value: 32 ether }({ _referal: address(0) }); + stETH.submit{ value: 32 ether }(address(0)); stETH.approve(address(wstETH), UINT256_MAX); uint256 wstETHAmount = wstETH.wrap(32 ether); wstETH.approve(address(accounting), 1 ether); @@ -3611,7 +3605,7 @@ contract CSAccountingDepositWstEthTest is CSAccountingBaseTest { { vm.deal(user, 32 ether); vm.startPrank(user); - stETH.submit{ value: 32 ether }({ _referal: address(0) }); + stETH.submit{ value: 32 ether }(address(0)); stETH.approve(address(wstETH), UINT256_MAX); uint256 wstETHAmount = wstETH.wrap(32 ether); wstETH.approve(address(accounting), UINT256_MAX); @@ -3646,7 +3640,7 @@ contract CSAccountingDepositWstEthTest is CSAccountingBaseTest { { vm.deal(user, 32 ether); vm.startPrank(user); - stETH.submit{ value: 32 ether }({ _referal: address(0) }); + stETH.submit{ value: 32 ether }(address(0)); stETH.approve(address(wstETH), UINT256_MAX); uint256 wstETHAmount = wstETH.wrap(32 ether); wstETH.approve(address(accounting), 32 ether); diff --git a/test/CSBondCore.t.sol b/test/CSBondCore.t.sol index 380d6107..29f513f7 100644 --- a/test/CSBondCore.t.sol +++ b/test/CSBondCore.t.sol @@ -133,7 +133,7 @@ abstract contract CSBondCoreTestBase is Test, Fixtures, Utilities { } contract CSBondCoreConstructorTest is CSBondCoreTestBase { - function test_constructor() public { + function test_constructor() public view { assertEq(address(bondCore.LIDO_LOCATOR()), address(locator)); assertEq(address(bondCore.LIDO()), locator.lido()); assertEq(address(bondCore.WSTETH()), address(wstETH)); diff --git a/test/CSBondCurve.t.sol b/test/CSBondCurve.t.sol index f6ad6300..1afd96ad 100644 --- a/test/CSBondCurve.t.sol +++ b/test/CSBondCurve.t.sol @@ -66,7 +66,7 @@ contract CSBondCurveTest is Test { bondCurve.initialize(_bondCurve); } - function test_getCurveInfo() public { + function test_getCurveInfo() public view { ICSBondCurve.BondCurve memory curve = bondCurve.getCurveInfo(0); assertEq(curve.points.length, 3); @@ -234,7 +234,7 @@ contract CSBondCurveTest is Test { assertEq(bondCurve.getBondCurveId(noId), 0); } - function test_getKeysCountByBondAmount_default() public { + function test_getKeysCountByBondAmount_default() public view { assertEq(bondCurve.getKeysCountByBondAmount(0, 0), 0); assertEq(bondCurve.getKeysCountByBondAmount(1.9 ether, 0), 0); assertEq(bondCurve.getKeysCountByBondAmount(2 ether, 0), 1); @@ -245,7 +245,7 @@ contract CSBondCurveTest is Test { assertEq(bondCurve.getKeysCountByBondAmount(6 ether, 0), 4); } - function test_getKeysCountByBondAmount_noOverflowWithMaxUint() public { + function test_getKeysCountByBondAmount_noOverflowWithMaxUint() public view { ICSBondCurve.BondCurve memory curve = bondCurve.getBondCurve(0); uint256 len = curve.points.length; uint256 maxCurveAmount = curve.points[len - 1]; @@ -270,7 +270,7 @@ contract CSBondCurveTest is Test { ); } - function test_getBondAmountByKeysCount_default() public { + function test_getBondAmountByKeysCount_default() public view { assertEq(bondCurve.getBondAmountByKeysCount(0, 0), 0); assertEq(bondCurve.getBondAmountByKeysCount(1, 0), 2 ether); assertEq(bondCurve.getBondAmountByKeysCount(2, 0), 4 ether); @@ -278,7 +278,7 @@ contract CSBondCurveTest is Test { assertEq(bondCurve.getBondAmountByKeysCount(4, 0), 6 ether); } - function test_getKeysCountByCurveValue_individual() public { + function test_getKeysCountByCurveValue_individual() public view { ICSBondCurve.BondCurve memory curve; uint256[] memory points = new uint256[](2); points[0] = 1 ether; @@ -300,7 +300,7 @@ contract CSBondCurveTest is Test { assertEq(bondCurve.getKeysCountByBondAmount(5.39 ether, curve), 2); } - function test_getKeysCountByBondAmount_singlePointCurve() public { + function test_getKeysCountByBondAmount_singlePointCurve() public view { ICSBondCurve.BondCurve memory curve; uint256[] memory points = new uint256[](1); points[0] = 2 ether; @@ -315,7 +315,7 @@ contract CSBondCurveTest is Test { assertEq(bondCurve.getKeysCountByBondAmount(5 ether, curve), 2); } - function test_getKeysCountByBondAmount_twoPointsCurve() public { + function test_getKeysCountByBondAmount_twoPointsCurve() public view { ICSBondCurve.BondCurve memory curve; uint256[] memory points = new uint256[](2); points[0] = 2 ether; @@ -333,7 +333,7 @@ contract CSBondCurveTest is Test { assertEq(bondCurve.getKeysCountByBondAmount(6 ether, curve), 3); } - function test_getKeysCountByBondAmount_tenPointsCurve() public { + function test_getKeysCountByBondAmount_tenPointsCurve() public view { ICSBondCurve.BondCurve memory curve; uint256[] memory points = new uint256[](10); points[0] = 1 ether; @@ -361,7 +361,7 @@ contract CSBondCurveTest is Test { } } - function test_getBondAmountByKeysCount_individual() public { + function test_getBondAmountByKeysCount_individual() public view { ICSBondCurve.BondCurve memory curve; uint256[] memory points = new uint256[](2); points[0] = 1 ether; @@ -385,7 +385,7 @@ contract CSBondCurveTest is Test { assertEq(bondCurve.getBondAmountByKeysCount(3, curve), 5.4 ether); } - function test_getBondAmountByKeysCount_bigCurve() public { + function test_getBondAmountByKeysCount_bigCurve() public view { ICSBondCurve.BondCurve memory curve; uint256[] memory points = new uint256[](4); points[0] = 1.5 ether; diff --git a/test/CSFeeDistributor.t.sol b/test/CSFeeDistributor.t.sol index 3502260d..4bd44653 100644 --- a/test/CSFeeDistributor.t.sol +++ b/test/CSFeeDistributor.t.sol @@ -543,7 +543,6 @@ contract CSFeeDistributorTest is CSFeeDistributorTestBase { } function test_processOracleReport_HappyPath() public assertInvariants { - uint256 nodeOperatorId = 42; uint256 shares = 100; uint256 rebate = 10; uint256 refSlot = 154; diff --git a/test/CSFeeOracle.t.sol b/test/CSFeeOracle.t.sol index 1b6196c3..23c2a46e 100644 --- a/test/CSFeeOracle.t.sol +++ b/test/CSFeeOracle.t.sol @@ -487,7 +487,7 @@ contract CSFeeOracleTest is Test, Utilities { } } - function _assertNoReportOnInit() internal { + function _assertNoReportOnInit() internal view { ( bytes32 hash, // refSlot , diff --git a/test/CSModule.t.sol b/test/CSModule.t.sol index fc6c1717..11186002 100644 --- a/test/CSModule.t.sol +++ b/test/CSModule.t.sol @@ -171,7 +171,7 @@ abstract contract CSMFixtures is Test, Fixtures, Utilities, InvariantAsserts { } // Checks that the queue is in the expected state starting from its head. - function _assertQueueState(BatchInfo[] memory exp) internal { + function _assertQueueState(BatchInfo[] memory exp) internal view { (uint128 curr, ) = csm.depositQueue(); // queue.head for (uint256 i = 0; i < exp.length; ++i) { @@ -208,7 +208,7 @@ abstract contract CSMFixtures is Test, Fixtures, Utilities, InvariantAsserts { ); } - function _assertQueueIsEmpty() internal { + function _assertQueueIsEmpty() internal view { (uint128 curr, ) = csm.depositQueue(); // queue.head assertTrue(csm.depositQueueItem(curr).isNil(), "queue should be empty"); } @@ -567,7 +567,7 @@ contract CsmInitialize is CSMCommon { } contract CSMPauseTest is CSMCommon { - function test_notPausedByDefault() public { + function test_notPausedByDefault() public view { assertFalse(csm.isPaused()); } @@ -1574,9 +1574,7 @@ contract CSMDepositStETH is CSMCommon { uint256 preShares = accounting.getBondShares(noId); vm.deal(nodeOperator, 32 ether); vm.startPrank(nodeOperator); - uint256 sharesToDeposit = stETH.submit{ value: 32 ether }({ - _referal: address(0) - }); + uint256 sharesToDeposit = stETH.submit{ value: 32 ether }(address(0)); csm.depositStETH( noId, 32 ether, @@ -1608,7 +1606,7 @@ contract CSMDepositStETH is CSMCommon { uint256 noId = createNodeOperator(); vm.deal(nodeOperator, 32 ether); vm.startPrank(nodeOperator); - stETH.submit{ value: 32 ether }({ _referal: address(0) }); + stETH.submit{ value: 32 ether }(address(0)); vm.expectRevert(ICSModule.NodeOperatorDoesNotExist.selector); csm.depositStETH( noId + 1, @@ -1628,9 +1626,7 @@ contract CSMDepositStETH is CSMCommon { uint256 preShares = accounting.getBondShares(noId); vm.deal(nodeOperator, 32 ether); vm.startPrank(nodeOperator); - uint256 sharesToDeposit = stETH.submit{ value: 32 ether }({ - _referal: address(0) - }); + uint256 sharesToDeposit = stETH.submit{ value: 32 ether }(address(0)); vm.expectEmit(true, true, true, true, address(stETH)); emit StETHMock.Approval(nodeOperator, address(accounting), 32 ether); @@ -1673,7 +1669,7 @@ contract CSMDepositStETH is CSMCommon { vm.deal(nodeOperator, 32 ether); vm.startPrank(nodeOperator); - stETH.submit{ value: 32 ether }({ _referal: address(0) }); + stETH.submit{ value: 32 ether }(address(0)); csm.depositStETH( 0, 32 ether, @@ -1696,7 +1692,7 @@ contract CSMDepositStETH is CSMCommon { vm.deal(nodeOperator, 32 ether); vm.startPrank(nodeOperator); - stETH.submit{ value: 32 ether }({ _referal: address(0) }); + stETH.submit{ value: 32 ether }(address(0)); csm.depositStETH( noId, 32 ether, @@ -1719,7 +1715,7 @@ contract CSMDepositWstETH is CSMCommon { uint256 preShares = accounting.getBondShares(noId); vm.deal(nodeOperator, 32 ether); vm.startPrank(nodeOperator); - stETH.submit{ value: 32 ether }({ _referal: address(0) }); + stETH.submit{ value: 32 ether }(address(0)); stETH.approve(address(wstETH), UINT256_MAX); uint256 wstETHAmount = wstETH.wrap(32 ether); uint256 sharesToDeposit = stETH.getSharesByPooledEth( @@ -1757,7 +1753,7 @@ contract CSMDepositWstETH is CSMCommon { uint256 noId = createNodeOperator(); vm.deal(nodeOperator, 32 ether); vm.startPrank(nodeOperator); - stETH.submit{ value: 32 ether }({ _referal: address(0) }); + stETH.submit{ value: 32 ether }(address(0)); stETH.approve(address(wstETH), UINT256_MAX); uint256 wstETHAmount = wstETH.wrap(32 ether); vm.expectRevert(ICSModule.NodeOperatorDoesNotExist.selector); @@ -1779,7 +1775,7 @@ contract CSMDepositWstETH is CSMCommon { uint256 preShares = accounting.getBondShares(noId); vm.deal(nodeOperator, 32 ether); vm.startPrank(nodeOperator); - stETH.submit{ value: 32 ether }({ _referal: address(0) }); + stETH.submit{ value: 32 ether }(address(0)); stETH.approve(address(wstETH), UINT256_MAX); uint256 wstETHAmount = wstETH.wrap(32 ether); uint256 sharesToDeposit = stETH.getSharesByPooledEth( @@ -1827,7 +1823,7 @@ contract CSMDepositWstETH is CSMCommon { vm.deal(nodeOperator, 32 ether); vm.startPrank(nodeOperator); - stETH.submit{ value: 32 ether }({ _referal: address(0) }); + stETH.submit{ value: 32 ether }(address(0)); stETH.approve(address(wstETH), UINT256_MAX); uint256 wstETHAmount = wstETH.wrap(32 ether); @@ -1853,7 +1849,7 @@ contract CSMDepositWstETH is CSMCommon { vm.deal(nodeOperator, 32 ether); vm.startPrank(nodeOperator); - stETH.submit{ value: 32 ether }({ _referal: address(0) }); + stETH.submit{ value: 32 ether }(address(0)); stETH.approve(address(wstETH), UINT256_MAX); uint256 wstETHAmount = wstETH.wrap(32 ether); @@ -3659,6 +3655,7 @@ contract CsmGetNodeOperatorNonWithdrawnKeys is CSMCommon { function test_getNodeOperatorNonWithdrawnKeys_ZeroWhenNoNodeOperator() public + view { uint256 keys = csm.getNodeOperatorNonWithdrawnKeys(0); assertEq(keys, 0); diff --git a/test/CSPerksRegistry.t.sol b/test/CSPerksRegistry.t.sol index 2e587e37..45bbe653 100644 --- a/test/CSPerksRegistry.t.sol +++ b/test/CSPerksRegistry.t.sol @@ -202,10 +202,7 @@ contract CSPerksRegistryRewardShareDataTest is CSPerksRegistryBaseTest { function test_getRewardShareData_RevertWhen_no_data() public { uint256 curveId = 0; vm.expectRevert(ICSPerksRegistry.NoData.selector); - ( - uint256[] memory keyPivotsOut, - uint256[] memory rewardSharesOut - ) = PerksRegistry.getRewardShareData(curveId); + PerksRegistry.getRewardShareData(curveId); } } @@ -401,10 +398,7 @@ contract CSPerksRegistryPerformanceLeewayDataTest is CSPerksRegistryBaseTest { function test_getPerformanceLeewayData_RevertWhen_no_data() public { uint256 curveId = 0; vm.expectRevert(ICSPerksRegistry.NoData.selector); - ( - uint256[] memory keyPivotsOut, - uint256[] memory performanceLeewaysOut - ) = PerksRegistry.getPerformanceLeewayData(curveId); + PerksRegistry.getPerformanceLeewayData(curveId); } } @@ -447,7 +441,7 @@ contract CSPerksRegistryPriorityQueueLimitTest is CSPerksRegistryBaseTest { assertEq(limitOut, limit); } - function test_getPerformanceLeewayData_default_return() public { + function test_getPerformanceLeewayData_default_return() public view { uint256 curveId = 0; uint256 limitOut = PerksRegistry.getPriorityQueueLimit(curveId); diff --git a/test/GIndex.t.sol b/test/GIndex.t.sol index 45d9549b..cdd5839a 100644 --- a/test/GIndex.t.sol +++ b/test/GIndex.t.sol @@ -39,7 +39,7 @@ contract GIndexTest is Test { lib = new Library(); } - function test_pack() public { + function test_pack() public view { GIndex gI; gI = pack(0x7b426f79504c6a8e9d31415b722f696e705c8a3d9f41, 42); @@ -56,11 +56,11 @@ contract GIndexTest is Test { ); } - function test_isRootTrue() public { + function test_isRootTrue() public view { assertTrue(ROOT.isRoot(), "ROOT is not root gindex"); } - function test_isRootFalse() public { + function test_isRootFalse() public pure { GIndex gI; gI = pack(0, 0); @@ -82,7 +82,7 @@ contract GIndexTest is Test { ); } - function test_isParentOf_Truthy() public { + function test_isParentOf_Truthy() public pure { assertTrue(pack(1024, 0).isParentOf(pack(2048, 0))); assertTrue(pack(1024, 0).isParentOf(pack(2049, 0))); assertTrue(pack(1024, 9).isParentOf(pack(2048, 0))); @@ -93,17 +93,20 @@ contract GIndexTest is Test { assertTrue(pack(1024, 0).isParentOf(pack(4098, 0))); } - function testFuzz_ROOT_isParentOfAnyChild(GIndex rhs) public { + function testFuzz_ROOT_isParentOfAnyChild(GIndex rhs) public view { vm.assume(rhs.index() > 1); assertTrue(ROOT.isParentOf(rhs)); } - function testFuzz_isParentOf_LessThanAnchor(GIndex lhs, GIndex rhs) public { + function testFuzz_isParentOf_LessThanAnchor( + GIndex lhs, + GIndex rhs + ) public pure { vm.assume(rhs.index() < lhs.index()); assertFalse(lhs.isParentOf(rhs)); } - function test_isParentOf_OffTheBranch() public { + function test_isParentOf_OffTheBranch() public pure { assertFalse(pack(1024, 0).isParentOf(pack(2050, 0))); assertFalse(pack(1024, 0).isParentOf(pack(2051, 0))); assertFalse(pack(1024, 0).isParentOf(pack(2047, 0))); @@ -124,7 +127,7 @@ contract GIndexTest is Test { assertFalse(pack(1024, 0).isParentOf(pack(4094, 0))); } - function test_concat() public { + function test_concat() public view { assertEq( pack(2, 99).concat(pack(3, 99)).unwrap(), pack(5, 99).unwrap() @@ -182,7 +185,7 @@ contract GIndexTest is Test { lib.concat(pack(2 ** 200, 0), pack(2 ** 48, 0)); } - function testFuzz_concat_WithRoot(GIndex rhs) public { + function testFuzz_concat_WithRoot(GIndex rhs) public view { vm.assume(rhs.index() > 0); assertEq( ROOT.concat(rhs).unwrap(), @@ -191,7 +194,7 @@ contract GIndexTest is Test { ); } - function testFuzz_concat_isParentOf(GIndex lhs, GIndex rhs) public { + function testFuzz_concat_isParentOf(GIndex lhs, GIndex rhs) public pure { // Left-hand side value can be a root. vm.assume(lhs.index() > 0); // But root.concat(root) will result in a root value again, and root is not a parent for itself. @@ -213,13 +216,13 @@ contract GIndexTest is Test { ); } - function testFuzz_unpack(uint248 index, uint8 pow) public { + function testFuzz_unpack(uint248 index, uint8 pow) public pure { GIndex gI = pack(index, pow); assertEq(gI.index(), index); assertEq(gI.width(), 2 ** pow); } - function test_shr() public { + function test_shr() public pure { GIndex gI; gI = pack(1024, 4); @@ -238,7 +241,7 @@ contract GIndexTest is Test { assertEq(gI.shr(14).unwrap(), pack(2063, 4).unwrap()); } - function test_shr_AfterConcat() public { + function test_shr_AfterConcat() public pure { GIndex gI; GIndex gIParent = pack(5, 4); @@ -300,7 +303,7 @@ contract GIndexTest is Test { lib.shr(lhs.concat(rhs), rhs.width() + shift); } - function test_shl() public { + function test_shl() public pure { GIndex gI; gI = pack(1023, 4); @@ -319,7 +322,7 @@ contract GIndexTest is Test { assertEq(gI.shl(15).unwrap(), pack(2048, 4).unwrap()); } - function test_shl_AfterConcat() public { + function test_shl_AfterConcat() public pure { GIndex gI; GIndex gIParent = pack(5, 4); @@ -376,7 +379,7 @@ contract GIndexTest is Test { lib.shl(lhs.concat(rhs), shift); } - function testFuzz_shl_shr_Idempotent(GIndex gI, uint256 shift) public { + function testFuzz_shl_shr_Idempotent(GIndex gI, uint256 shift) public view { vm.assume(gI.index() > 0); vm.assume(gI.index() >= gI.width()); vm.assume(shift < gI.index() % gI.width()); @@ -384,7 +387,7 @@ contract GIndexTest is Test { assertEq(lib.shr(lib.shl(gI, shift), shift).unwrap(), gI.unwrap()); } - function testFuzz_shr_shl_Idempotent(GIndex gI, uint256 shift) public { + function testFuzz_shr_shl_Idempotent(GIndex gI, uint256 shift) public view { vm.assume(gI.index() > 0); vm.assume(gI.index() >= gI.width()); vm.assume(shift < gI.width() - (gI.index() % gI.width())); @@ -392,7 +395,7 @@ contract GIndexTest is Test { assertEq(lib.shl(lib.shr(gI, shift), shift).unwrap(), gI.unwrap()); } - function test_fls() public { + function test_fls() public pure { for (uint256 i = 1; i < 255; i++) { assertEq(fls((1 << i) - 1), i - 1); assertEq(fls((1 << i)), i); diff --git a/test/HashConsensus.t.sol b/test/HashConsensus.t.sol index c3448398..2a4104fe 100644 --- a/test/HashConsensus.t.sol +++ b/test/HashConsensus.t.sol @@ -162,7 +162,7 @@ contract HashConsensusTestAccessControl is HashConsensusBase { } contract HashConsensusTestDeploy is HashConsensusBase { - function test_getChainConfig() public { + function test_getChainConfig() public view { ( uint256 slotsPerEpoch, uint256 secondsPerSlot, @@ -173,7 +173,7 @@ contract HashConsensusTestDeploy is HashConsensusBase { assertEq(genesisTime, GENESIS_TIME); } - function test_getFrameConfig() public { + function test_getFrameConfig() public view { ( uint256 initialEpoch, uint256 epochsPerFrame, @@ -282,7 +282,7 @@ contract HashConsensusSetFastLaneLengthSlotsTest is HashConsensusBase { } contract HashConsensusFastLaneMembersTest is HashConsensusBase { - function test_initialState() public { + function test_initialState() public view { assertFalse(consensus.getIsFastLaneMember(member1)); assertFalse(consensus.getConsensusStateForMember(member1).isFastLane); assertFalse(consensus.getIsFastLaneMember(member2)); diff --git a/test/OssifiableProxy.t.sol b/test/OssifiableProxy.t.sol index 86479fe3..90090431 100644 --- a/test/OssifiableProxy.t.sol +++ b/test/OssifiableProxy.t.sol @@ -52,15 +52,15 @@ contract OssifiableProxyTest is Test, Utilities { new OssifiableProxy(address(currentImpl), address(0), "0x"); } - function test_getAdmin() public { + function test_getAdmin() public view { assertEq(proxy.proxy__getAdmin(), admin); } - function test_getImplementation() public { + function test_getImplementation() public view { assertEq(proxy.proxy__getImplementation(), address(currentImpl)); } - function test_getIsOssified() public { + function test_getIsOssified() public view { assertFalse(proxy.proxy__getIsOssified()); } diff --git a/test/PausableUntil.t.sol b/test/PausableUntil.t.sol index 9ae3e1b7..cdd675a9 100644 --- a/test/PausableUntil.t.sol +++ b/test/PausableUntil.t.sol @@ -13,7 +13,7 @@ contract PausableUntilTest is Test { pausable = new PausableUntilImpl(); } - function test_PAUSE_INFINITELY() public { + function test_PAUSE_INFINITELY() public view { assertEq(pausable.PAUSE_INFINITELY(), type(uint256).max); } @@ -33,11 +33,11 @@ contract PausableUntilTest is Test { pausable.modifierWhenResumed(); } - function test_whenResumed_DoesNotRevertIfNotPaused() public { + function test_whenResumed_DoesNotRevertIfNotPaused() public view { pausable.modifierWhenResumed(); } - function test_isPaused_ReturnsFalseIfNotPaused() public { + function test_isPaused_ReturnsFalseIfNotPaused() public view { assertFalse(pausable.isPaused()); } @@ -46,7 +46,7 @@ contract PausableUntilTest is Test { assertTrue(pausable.isPaused()); } - function test_getResumeSinceTimestamp_ReturnsZeroIfNotPaused() public { + function test_getResumeSinceTimestamp_ReturnsZeroIfNotPaused() public view { assertEq(pausable.getResumeSinceTimestamp(), 0); } diff --git a/test/PermissionlessGate.t.sol b/test/PermissionlessGate.t.sol index 87e392a2..263ac0ed 100644 --- a/test/PermissionlessGate.t.sol +++ b/test/PermissionlessGate.t.sol @@ -19,7 +19,7 @@ contract PermissionlessGateTest is Test, Utilities { gate = new PermissionlessGate(address(csm)); } - function test_constructor() public { + function test_constructor() public view { assertEq(gate.CURVE_ID(), csm.DEFAULT_BOND_CURVE_ID()); assertEq(address(gate.CSM()), address(csm)); } diff --git a/test/QueueLib.t.sol b/test/QueueLib.t.sol index a0e9494b..8d598f2c 100644 --- a/test/QueueLib.t.sol +++ b/test/QueueLib.t.sol @@ -53,20 +53,25 @@ contract QueueLibTest is Test { q = new Library(); } - function test_createBatch() public { + function test_createBatch() public pure { assertEq( createBatch(0x27489e20a0060b72, 0x3a1748bdff5e4457).unwrap(), 0x27489e20a0060b723a1748bdff5e445700000000000000000000000000000000 ); } - function testFuzz_setKeys(uint64 a, uint64 b, uint64 c) public { + function testFuzz_setKeys(uint64 a, uint64 b, uint64 c) public pure { Batch p = createBatch(a, b); p = p.setKeys(c); assertEq(p.keys(), c); } - function testFuzz_setNext(uint64 a, uint64 b, uint64 c, uint64 d) public { + function testFuzz_setNext( + uint64 a, + uint64 b, + uint64 c, + uint64 d + ) public pure { Batch p0 = createBatch(a, b); Batch p1 = createBatch(c, d); p0 = p0.setNext(p1); diff --git a/test/SSZ.t.sol b/test/SSZ.t.sol index fcfbb25b..fdbbea14 100644 --- a/test/SSZ.t.sol +++ b/test/SSZ.t.sol @@ -31,7 +31,7 @@ contract SSZTest is Utilities, Test { lib = new Library(); } - function test_toLittleEndianUint() public { + function test_toLittleEndianUint() public pure { uint256 v = 0x1234567890ABCDEF; bytes32 expected = bytes32( bytes.concat(hex"EFCDAB9078563412", bytes24(0)) @@ -40,33 +40,33 @@ contract SSZTest is Utilities, Test { assertEq(actual, expected); } - function test_toLittleEndianUintZero() public { + function test_toLittleEndianUintZero() public pure { bytes32 actual = SSZ.toLittleEndian(0); assertEq(actual, bytes32(0)); } - function test_toLittleEndianFalse() public { + function test_toLittleEndianFalse() public pure { bool v = false; bytes32 expected = 0x0000000000000000000000000000000000000000000000000000000000000000; bytes32 actual = SSZ.toLittleEndian(v); assertEq(actual, expected); } - function test_toLittleEndianTrue() public { + function test_toLittleEndianTrue() public pure { bool v = true; bytes32 expected = 0x0100000000000000000000000000000000000000000000000000000000000000; bytes32 actual = SSZ.toLittleEndian(v); assertEq(actual, expected); } - function testFuzz_toLittleEndian_Idempotent(uint256 v) public { + function testFuzz_toLittleEndian_Idempotent(uint256 v) public pure { uint256 n = v; n = uint256(SSZ.toLittleEndian(n)); n = uint256(SSZ.toLittleEndian(n)); assertEq(n, v); } - function test_withdrawalRoot() public { + function test_withdrawalRoot() public pure { Withdrawal memory w = Withdrawal({ index: 15213404, validatorIndex: 429156, @@ -84,7 +84,7 @@ contract SSZTest is Utilities, Test { SSZ.hashTreeRoot(w); } - function test_withdrawalRoot_AllZeroes() public { + function test_withdrawalRoot_AllZeroes() public pure { Withdrawal memory w = Withdrawal({ index: 0, validatorIndex: 0, @@ -96,7 +96,7 @@ contract SSZTest is Utilities, Test { assertEq(actual, expected); } - function test_withdrawalRoot_AllOnes() public { + function test_withdrawalRoot_AllOnes() public pure { Withdrawal memory w = Withdrawal({ index: type(uint64).max, validatorIndex: type(uint64).max, @@ -108,7 +108,7 @@ contract SSZTest is Utilities, Test { assertEq(actual, expected); } - function test_ValidatorRootExitedSlashed() public { + function test_ValidatorRootExitedSlashed() public view { Validator memory v = Validator({ pubkey: hex"91760f8a17729cfcb68bfc621438e5d9dfa831cd648e7b2b7d33540a7cbfda1257e4405e67cd8d3260351ab3ff71b213", withdrawalCredentials: 0x01000000000000000000000006676e8584342cc8b6052cfdf381c3a281f00ac8, @@ -125,7 +125,7 @@ contract SSZTest is Utilities, Test { assertEq(actual, expected); } - function test_ValidatorRootActive() public { + function test_ValidatorRootActive() public view { Validator memory v = Validator({ pubkey: hex"8fb78536e82bcec34e98fff85c907f0a8e6f4b1ccdbf1e8ace26b59eb5a06d16f34e50837f6c490e2ad6a255db8d543b", withdrawalCredentials: 0x0023b9d00bf66e7f8071208a85afde59b3148dea046ee3db5d79244880734881, @@ -142,7 +142,7 @@ contract SSZTest is Utilities, Test { assertEq(actual, expected); } - function test_ValidatorRootExtraBytesInPubkey() public { + function test_ValidatorRootExtraBytesInPubkey() public view { Validator memory v = Validator({ pubkey: hex"8fb78536e82bcec34e98fff85c907f0a8e6f4b1ccdbf1e8ace26b59eb5a06d16f34e50837f6c490e2ad6a255db8d543bDEADBEEFDEADBEEFDEADBEEFDEADBEEF", withdrawalCredentials: 0x0023b9d00bf66e7f8071208a85afde59b3148dea046ee3db5d79244880734881, @@ -159,7 +159,7 @@ contract SSZTest is Utilities, Test { assertEq(actual, expected); } - function test_ValidatorRoot_AllZeroes() public { + function test_ValidatorRoot_AllZeroes() public view { Validator memory v = Validator({ pubkey: hex"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", withdrawalCredentials: 0x0000000000000000000000000000000000000000000000000000000000000000, @@ -176,7 +176,7 @@ contract SSZTest is Utilities, Test { assertEq(actual, expected); } - function test_ValidatorRoot_AllOnes() public { + function test_ValidatorRoot_AllOnes() public view { Validator memory v = Validator({ pubkey: hex"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", withdrawalCredentials: 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, @@ -199,7 +199,7 @@ contract SSZTest is Utilities, Test { SSZ.hashTreeRoot(v); } - function test_BeaconBlockHeaderRoot() public { + function test_BeaconBlockHeaderRoot() public view { // Can be obtained via /eth/v1/beacon/headers/{block_id}. BeaconBlockHeader memory h = BeaconBlockHeader({ slot: Slot.wrap(7472518), @@ -214,7 +214,7 @@ contract SSZTest is Utilities, Test { assertEq(actual, expected); } - function test_BeaconBlockHeaderRoot_AllZeroes() public { + function test_BeaconBlockHeaderRoot_AllZeroes() public view { BeaconBlockHeader memory h = BeaconBlockHeader({ slot: Slot.wrap(0), proposerIndex: 0, @@ -228,7 +228,7 @@ contract SSZTest is Utilities, Test { assertEq(actual, expected); } - function test_BeaconBlockHeaderRoot_AllOnes() public { + function test_BeaconBlockHeaderRoot_AllOnes() public view { BeaconBlockHeader memory h = BeaconBlockHeader({ slot: Slot.wrap(type(uint64).max), proposerIndex: type(uint64).max, diff --git a/test/SigningKeys.t.sol b/test/SigningKeys.t.sol index cda3d873..514c06f3 100644 --- a/test/SigningKeys.t.sol +++ b/test/SigningKeys.t.sol @@ -338,7 +338,7 @@ contract SigningKeysRemoveTest is SigningKeysTestBase { uint256 nodeOperatorId = 154; (bytes memory pubkeys, bytes memory signatures) = keysSignatures(3); - uint256 totalKeysCount = signingKeys.saveKeysSigs({ + signingKeys.saveKeysSigs({ nodeOperatorId: nodeOperatorId, startIndex: 0, keysCount: 3, @@ -528,7 +528,7 @@ contract SigningKeysRemoveTest is SigningKeysTestBase { contract SigningKeysLoadTest is SigningKeysTestBase { using SigningKeys for bytes32; - function test_getKeyOffset() public { + function test_getKeyOffset() public pure { assertEq( uint256( 0xc7224de16f166822b4efb83b0e3edb78754345751aa6411448d7bf241a1dd403 @@ -618,7 +618,7 @@ contract SigningKeysLoadTest is SigningKeysTestBase { uint64 nodeOperatorId, uint32 startIndex, uint32 keysCount - ) public { + ) public view { keysCount = uint32(bound(keysCount, 1, 500)); unchecked { vm.assume(startIndex + keysCount > startIndex); @@ -690,7 +690,7 @@ contract SigningKeysLoadTest is SigningKeysTestBase { uint64 nodeOperatorId, uint32 startIndex, uint32 keysCount - ) public { + ) public view { keysCount = uint32(bound(keysCount, 1, 200)); unchecked { vm.assume(startIndex + keysCount > startIndex); diff --git a/test/UnstructuredStorage.t.sol b/test/UnstructuredStorage.t.sol index ce39db07..a6c31368 100644 --- a/test/UnstructuredStorage.t.sol +++ b/test/UnstructuredStorage.t.sol @@ -15,7 +15,7 @@ contract ExposedUnstructuredStorageTest is Test { unstructuredStorage = new ExposedUnstructuredStorage(); } - function test_getStorageAddress_Uninitialized() public { + function test_getStorageAddress_Uninitialized() public view { bytes32 position = keccak256("FOO"); assertEq(unstructuredStorage.getStorageAddress(position), address(0)); } @@ -25,11 +25,13 @@ contract ExposedUnstructuredStorageTest is Test { * forge-config: default.fuzz.runs = 2048 * forge-config: default.fuzz.max-test-rejects = 0 */ - function testFuzz_getStorageAddress_Uninitialized(bytes32 position) public { + function testFuzz_getStorageAddress_Uninitialized( + bytes32 position + ) public view { assertEq(unstructuredStorage.getStorageAddress(position), address(0)); } - function test_getStorageUint256_Uninitialized() public { + function test_getStorageUint256_Uninitialized() public view { bytes32 position = keccak256("FOO"); uint256 data; assertEq(unstructuredStorage.getStorageUint256(position), data); @@ -40,7 +42,9 @@ contract ExposedUnstructuredStorageTest is Test { * forge-config: default.fuzz.runs = 2048 * forge-config: default.fuzz.max-test-rejects = 0 */ - function testFuzz_getStorageUint256_Uninitialized(bytes32 position) public { + function testFuzz_getStorageUint256_Uninitialized( + bytes32 position + ) public view { uint256 data; assertEq(unstructuredStorage.getStorageUint256(position), data); } diff --git a/test/ValidatorCountsReport.t.sol b/test/ValidatorCountsReport.t.sol index 1ef01d81..7ec142d9 100644 --- a/test/ValidatorCountsReport.t.sol +++ b/test/ValidatorCountsReport.t.sol @@ -75,7 +75,7 @@ contract ValidatorCountsReportTest is Test { caller.safeCountOperators(ids, counts); } - function test_count() public { + function test_count() public view { (bytes memory ids, bytes memory counts) = ( bytes.concat(bytes8(0x0000000000000001)), bytes.concat(bytes16(0x00000000000000000000000000000001)) @@ -84,7 +84,7 @@ contract ValidatorCountsReportTest is Test { assertEq(caller.safeCountOperators(ids, counts), 1); } - function test_next() public { + function test_next() public view { (bytes memory ids, bytes memory counts) = ( bytes.concat(bytes8(0x0000000000000001)), bytes.concat(bytes16(0x00000000000000000000000000000001)) @@ -95,7 +95,7 @@ contract ValidatorCountsReportTest is Test { assertEq(count, 1, "count != 1"); } - function test_nextWithOffset() public { + function test_nextWithOffset() public view { (bytes memory ids, bytes memory counts) = ( bytes.concat( bytes8(0x0000000000000001), diff --git a/test/Versioned.t.sol b/test/Versioned.t.sol index 6878f882..9142504c 100644 --- a/test/Versioned.t.sol +++ b/test/Versioned.t.sol @@ -23,12 +23,13 @@ contract VersionedTest is Test { ); } - function test_constructor_PetrifiesImplementation() public { + function test_constructor_PetrifiesImplementation() public view { assertEq(impl.getContractVersion(), petrifiedVersion); } function test_getContractVersionPosition_ReturnsStorageSlotPosition() public + view { assertEq( consumer.getContractVersionPosition(), @@ -36,11 +37,14 @@ contract VersionedTest is Test { ); } - function test_getPetrifiedVersionMark_ReturnsPetrifiedVersion() public { + function test_getPetrifiedVersionMark_ReturnsPetrifiedVersion() + public + view + { assertEq(consumer.getPetrifiedVersionMark(), petrifiedVersion); } - function test_checkContractVersion_PassesIfVersionsMatch() public { + function test_checkContractVersion_PassesIfVersionsMatch() public view { consumer.checkContractVersion(initialVersion); } diff --git a/test/VettedGate.t.sol b/test/VettedGate.t.sol index 09798035..e2a89a17 100644 --- a/test/VettedGate.t.sol +++ b/test/VettedGate.t.sol @@ -114,14 +114,14 @@ contract VettedGateTest is Test, Utilities { vettedGate.resume(); } - function test_verifyProof() public { + function test_verifyProof() public view { assertTrue( vettedGate.verifyProof(nodeOperator, merkleTree.getProof(0)) ); assertFalse(vettedGate.verifyProof(stranger, merkleTree.getProof(0))); } - function test_hashLeaf() public { + function test_hashLeaf() public view { // keccak256(bytes.concat(keccak256(abi.encode(address(154))))) = 0x0f7ac7a58332324fa3de7b7a4a05de303436d846e292fa579646a7496f0c2c1a assertEq( vettedGate.hashLeaf(address(154)), @@ -129,7 +129,7 @@ contract VettedGateTest is Test, Utilities { ); } - function testFuzz_hashLeaf(address addr) public { + function testFuzz_hashLeaf(address addr) public view { assertEq( vettedGate.hashLeaf(addr), keccak256(bytes.concat(keccak256(abi.encode(addr)))) diff --git a/test/fork/deployment/InitialState.t.sol b/test/fork/deployment/InitialState.t.sol index d016f1f2..7a7cdba0 100644 --- a/test/fork/deployment/InitialState.t.sol +++ b/test/fork/deployment/InitialState.t.sol @@ -22,13 +22,13 @@ contract ContractsInitialStateTest is Test, Utilities, DeploymentFixtures { deployParams = parseDeployParams(env.DEPLOY_CONFIG); } - function test_module_initialState() public { + function test_module_initialState() public view { assertTrue(csm.isPaused()); assertFalse(csm.publicRelease()); assertEq(csm.getNodeOperatorsCount(), 0); } - function test_accounting_initialState() public { + function test_accounting_initialState() public view { assertFalse(accounting.isPaused()); assertEq(accounting.totalBondShares(), 0); assertEq( @@ -37,7 +37,7 @@ contract ContractsInitialStateTest is Test, Utilities, DeploymentFixtures { ); } - function test_feeDistributor_initialState() public { + function test_feeDistributor_initialState() public view { assertEq(feeDistributor.totalClaimableShares(), 0); assertEq(feeDistributor.pendingSharesToDistribute(), 0); assertEq(feeDistributor.treeRoot(), bytes32(0)); @@ -47,7 +47,7 @@ contract ContractsInitialStateTest is Test, Utilities, DeploymentFixtures { ); } - function test_feeOracle_initialState() public { + function test_feeOracle_initialState() public view { assertFalse(oracle.isPaused()); ( bytes32 hash, diff --git a/test/fork/deployment/PostDeployment.t.sol b/test/fork/deployment/PostDeployment.t.sol index 76234b3f..350a3854 100644 --- a/test/fork/deployment/PostDeployment.t.sol +++ b/test/fork/deployment/PostDeployment.t.sol @@ -34,7 +34,7 @@ contract CSModuleDeploymentTest is Test, Utilities, DeploymentFixtures { adminsCount = block.chainid == 1 ? 1 : 2; } - function test_constructor() public { + function test_constructor() public view { assertEq(csm.getType(), deployParams.moduleType); assertEq( csm.INITIAL_SLASHING_PENALTY(), @@ -55,7 +55,7 @@ contract CSModuleDeploymentTest is Test, Utilities, DeploymentFixtures { assertEq(address(csm.LIDO_LOCATOR()), deployParams.lidoLocatorAddress); } - function test_initializer() public { + function test_initializer() public view { assertEq(address(csm.accounting()), address(accounting)); assertEq(csm.keyRemovalCharge(), deployParams.keyRemovalCharge); assertTrue( @@ -64,7 +64,7 @@ contract CSModuleDeploymentTest is Test, Utilities, DeploymentFixtures { assertTrue(csm.getRoleMemberCount(csm.STAKING_ROUTER_ROLE()) == 1); } - function test_roles() public { + function test_roles() public view { assertTrue( csm.hasRole(csm.DEFAULT_ADMIN_ROLE(), deployParams.aragonAgent) ); @@ -130,7 +130,7 @@ contract CSAccountingDeploymentTest is Test, Utilities, DeploymentFixtures { adminsCount = block.chainid == 1 ? 1 : 2; } - function test_constructor() public { + function test_constructor() public view { assertEq(address(accounting.CSM()), address(csm)); assertEq(address(accounting.LIDO_LOCATOR()), address(locator)); assertEq(address(accounting.LIDO()), locator.lido()); @@ -154,7 +154,7 @@ contract CSAccountingDeploymentTest is Test, Utilities, DeploymentFixtures { assertEq(accounting.MAX_CURVE_LENGTH(), deployParams.maxCurveLength); } - function test_initializer() public { + function test_initializer() public view { assertEq( accounting.getCurveInfo(accounting.DEFAULT_BOND_CURVE_ID()).points, deployParams.bondCurve @@ -184,7 +184,7 @@ contract CSAccountingDeploymentTest is Test, Utilities, DeploymentFixtures { ); } - function test_roles() public { + function test_roles() public view { assertTrue( accounting.hasRole( accounting.DEFAULT_ADMIN_ROLE(), @@ -250,13 +250,13 @@ contract CSFeeDistributorDeploymentTest is Test, Utilities, DeploymentFixtures { adminsCount = block.chainid == 1 ? 1 : 2; } - function test_constructor() public { + function test_constructor() public view { assertEq(address(feeDistributor.STETH()), address(lido)); assertEq(feeDistributor.ACCOUNTING(), address(accounting)); assertEq(feeDistributor.ORACLE(), address(oracle)); } - function test_roles() public { + function test_roles() public view { assertTrue( feeDistributor.hasRole( feeDistributor.DEFAULT_ADMIN_ROLE(), @@ -301,12 +301,12 @@ contract CSFeeOracleDeploymentTest is Test, Utilities, DeploymentFixtures { adminsCount = block.chainid == 1 ? 1 : 2; } - function test_constructor() public { + function test_constructor() public view { assertEq(oracle.SECONDS_PER_SLOT(), deployParams.secondsPerSlot); assertEq(oracle.GENESIS_TIME(), deployParams.clGenesisTime); } - function test_initializer() public { + function test_initializer() public view { assertEq(address(oracle.feeDistributor()), address(feeDistributor)); assertEq(oracle.getContractVersion(), 1); assertEq(oracle.getConsensusContract(), address(hashConsensus)); @@ -315,7 +315,7 @@ contract CSFeeOracleDeploymentTest is Test, Utilities, DeploymentFixtures { assertEq(oracle.avgPerfLeewayBP(), deployParams.avgPerfLeewayBP); } - function test_roles() public { + function test_roles() public view { assertTrue( oracle.hasRole( oracle.DEFAULT_ADMIN_ROLE(), @@ -370,7 +370,7 @@ contract HashConsensusDeploymentTest is Test, Utilities, DeploymentFixtures { adminsCount = block.chainid == 1 ? 1 : 2; } - function test_constructor() public { + function test_constructor() public view { ( uint256 slotsPerEpoch, uint256 secondsPerSlot, @@ -387,7 +387,7 @@ contract HashConsensusDeploymentTest is Test, Utilities, DeploymentFixtures { assertEq(hashConsensus.getReportProcessor(), address(oracle)); } - function test_roles() public { + function test_roles() public view { assertTrue( hashConsensus.hasRole( hashConsensus.DEFAULT_ADMIN_ROLE(), @@ -444,7 +444,7 @@ contract VettedGateDeploymentTest is Test, Utilities, DeploymentFixtures { deployParams = parseDeployParams(env.DEPLOY_CONFIG); } - function test_constructor() public { + function test_constructor() public view { assertTrue( csm.hasRole(csm.DEFAULT_ADMIN_ROLE(), deployParams.aragonAgent) ); @@ -472,7 +472,7 @@ contract CSVerifierDeploymentTest is Test, Utilities, DeploymentFixtures { deployParams = parseDeployParams(env.DEPLOY_CONFIG); } - function test_constructor() public { + function test_constructor() public view { assertEq(verifier.WITHDRAWAL_ADDRESS(), locator.withdrawalVault()); assertEq(address(verifier.MODULE()), address(csm)); assertEq(verifier.SLOTS_PER_EPOCH(), deployParams.slotsPerEpoch); @@ -510,7 +510,7 @@ contract CSVerifierDeploymentTest is Test, Utilities, DeploymentFixtures { ); } - function test_roles() public { + function test_roles() public view { assertTrue(verifier.hasRole(verifier.PAUSE_ROLE(), address(gateSeal))); assertEq(verifier.getRoleMemberCount(verifier.PAUSE_ROLE()), 1); assertEq(verifier.getRoleMemberCount(verifier.RESUME_ROLE()), 0); diff --git a/test/fork/integration/ClaimInTokens.t.sol b/test/fork/integration/ClaimInTokens.t.sol index 106effd5..d9197afc 100644 --- a/test/fork/integration/ClaimInTokens.t.sol +++ b/test/fork/integration/ClaimInTokens.t.sol @@ -284,7 +284,7 @@ contract ClaimIntegrationTest is // Supply funds to feeDistributor vm.startPrank(user); vm.deal(user, amount); - uint256 shares = lido.submit{ value: amount }({ _referal: address(0) }); + uint256 shares = lido.submit{ value: amount }(address(0)); lido.transferShares(address(feeDistributor), shares); vm.stopPrank(); @@ -335,7 +335,7 @@ contract ClaimIntegrationTest is // Supply funds to feeDistributor vm.startPrank(user); vm.deal(user, amount); - uint256 shares = lido.submit{ value: amount }({ _referal: address(0) }); + uint256 shares = lido.submit{ value: amount }(address(0)); lido.transferShares(address(feeDistributor), shares); vm.stopPrank(); @@ -400,7 +400,7 @@ contract ClaimIntegrationTest is // Supply funds to feeDistributor vm.startPrank(user); vm.deal(user, amount); - uint256 shares = lido.submit{ value: amount }({ _referal: address(0) }); + uint256 shares = lido.submit{ value: amount }(address(0)); lido.transferShares(address(feeDistributor), shares); vm.stopPrank(); diff --git a/test/fork/integration/CreateAndDeposit.sol b/test/fork/integration/CreateAndDeposit.sol index fa91f755..5c48d448 100644 --- a/test/fork/integration/CreateAndDeposit.sol +++ b/test/fork/integration/CreateAndDeposit.sol @@ -125,7 +125,7 @@ contract PermissionlessCreateNodeOperatorTest is IntegrationTestBase { function test_createNodeOperatorStETH() public assertInvariants { vm.startPrank(nodeOperator); vm.deal(nodeOperator, 32 ether); - lido.submit{ value: 32 ether }({ _referal: address(0) }); + lido.submit{ value: 32 ether }(address(0)); uint256 preTotalShares = accounting.totalBondShares(); @@ -172,7 +172,7 @@ contract PermissionlessCreateNodeOperatorTest is IntegrationTestBase { function test_createNodeOperatorWstETH() public assertInvariants { vm.startPrank(nodeOperator); vm.deal(nodeOperator, 32 ether); - lido.submit{ value: 32 ether }({ _referal: address(0) }); + lido.submit{ value: 32 ether }(address(0)); lido.approve(address(wstETH), type(uint256).max); uint256 preTotalShares = accounting.totalBondShares(); @@ -261,7 +261,7 @@ contract VettedGateCreateNodeOperatorTest is IntegrationTestBase { function test_createNodeOperatorStETH() public assertInvariants { vm.startPrank(nodeOperator); vm.deal(nodeOperator, 32 ether); - lido.submit{ value: 32 ether }({ _referal: address(0) }); + lido.submit{ value: 32 ether }(address(0)); uint256 preTotalShares = accounting.totalBondShares(); @@ -308,7 +308,7 @@ contract VettedGateCreateNodeOperatorTest is IntegrationTestBase { function test_createNodeOperatorWstETH() public assertInvariants { vm.startPrank(nodeOperator); vm.deal(nodeOperator, 32 ether); - lido.submit{ value: 32 ether }({ _referal: address(0) }); + lido.submit{ value: 32 ether }(address(0)); lido.approve(address(wstETH), type(uint256).max); uint256 preTotalShares = accounting.totalBondShares(); wstETH.approve(address(accounting), type(uint256).max); @@ -423,9 +423,7 @@ contract DepositIntegrationTest is IntegrationTestBase { function test_depositStETH() public assertInvariants { vm.startPrank(user); vm.deal(user, 32 ether); - uint256 shares = lido.submit{ value: 32 ether }({ - _referal: address(0) - }); + uint256 shares = lido.submit{ value: 32 ether }(address(0)); uint256 preShares = accounting.getBondShares(defaultNoId); uint256 preTotalShares = accounting.totalBondShares(); @@ -466,7 +464,7 @@ contract DepositIntegrationTest is IntegrationTestBase { function test_depositWstETH() public assertInvariants { vm.startPrank(user); vm.deal(user, 32 ether); - lido.submit{ value: 32 ether }({ _referal: address(0) }); + lido.submit{ value: 32 ether }(address(0)); lido.approve(address(wstETH), type(uint256).max); uint256 wstETHAmount = wstETH.wrap(32 ether); @@ -508,9 +506,7 @@ contract DepositIntegrationTest is IntegrationTestBase { vm.deal(user, 32 ether); vm.startPrank(user); - uint256 shares = lido.submit{ value: 32 ether }({ - _referal: address(0) - }); + uint256 shares = lido.submit{ value: 32 ether }(address(0)); uint256 preShares = accounting.getBondShares(defaultNoId); uint256 preTotalShares = accounting.totalBondShares(); @@ -545,7 +541,7 @@ contract DepositIntegrationTest is IntegrationTestBase { vm.deal(user, 32 ether); vm.startPrank(user); - lido.submit{ value: 32 ether }({ _referal: address(0) }); + lido.submit{ value: 32 ether }(address(0)); lido.approve(address(wstETH), type(uint256).max); uint256 wstETHAmount = wstETH.wrap(32 ether); diff --git a/test/fork/integration/RecoverTokens.t.sol b/test/fork/integration/RecoverTokens.t.sol index a651446f..4e2fc5e5 100644 --- a/test/fork/integration/RecoverTokens.t.sol +++ b/test/fork/integration/RecoverTokens.t.sol @@ -86,7 +86,7 @@ contract RecoverIntegrationTest is uint256 amount = 1 ether; vm.startPrank(user); vm.deal(user, amount); - uint256 shares = lido.submit{ value: amount }({ _referal: address(0) }); + uint256 shares = lido.submit{ value: amount }(address(0)); uint256 amountStETH = lido.getPooledEthByShares(shares); lido.transfer(address(csm), amountStETH); vm.stopPrank(); @@ -117,7 +117,7 @@ contract RecoverIntegrationTest is uint256 amount = 1 ether; vm.startPrank(user); vm.deal(user, amount); - uint256 shares = lido.submit{ value: amount }({ _referal: address(0) }); + uint256 shares = lido.submit{ value: amount }(address(0)); lido.approve(address(wstETH), type(uint256).max); uint256 amountWstETH = wstETH.wrap(lido.getPooledEthByShares(shares)); wstETH.transfer(address(csm), amountWstETH); @@ -135,7 +135,7 @@ contract RecoverIntegrationTest is uint256 amount = 1 ether; vm.startPrank(user); vm.deal(user, amount); - uint256 shares = lido.submit{ value: amount }({ _referal: address(0) }); + uint256 shares = lido.submit{ value: amount }(address(0)); lido.transferShares(address(accounting), shares); vm.stopPrank(); @@ -165,7 +165,7 @@ contract RecoverIntegrationTest is uint256 amount = 1 ether; vm.startPrank(user); vm.deal(user, amount); - uint256 shares = lido.submit{ value: amount }({ _referal: address(0) }); + uint256 shares = lido.submit{ value: amount }(address(0)); lido.approve(address(wstETH), type(uint256).max); uint256 amountWstETH = wstETH.wrap(lido.getPooledEthByShares(shares)); wstETH.transfer(address(accounting), amountWstETH); @@ -197,7 +197,7 @@ contract RecoverIntegrationTest is uint256 amount = 1 ether; vm.startPrank(user); vm.deal(user, amount); - uint256 shares = lido.submit{ value: amount }({ _referal: address(0) }); + uint256 shares = lido.submit{ value: amount }(address(0)); lido.approve(address(wstETH), type(uint256).max); uint256 amountWstETH = wstETH.wrap(lido.getPooledEthByShares(shares)); wstETH.transfer(address(feeDistributor), amountWstETH); @@ -229,7 +229,7 @@ contract RecoverIntegrationTest is uint256 amount = 1 ether; vm.startPrank(user); vm.deal(user, amount); - uint256 shares = lido.submit{ value: amount }({ _referal: address(0) }); + uint256 shares = lido.submit{ value: amount }(address(0)); lido.approve(address(wstETH), type(uint256).max); uint256 amountWstETH = wstETH.wrap(lido.getPooledEthByShares(shares)); wstETH.transfer(address(oracle), amountWstETH); diff --git a/test/fork/invariant/Invariants.t.sol b/test/fork/invariant/Invariants.t.sol index 05a56f55..98a0c1c3 100644 --- a/test/fork/invariant/Invariants.t.sol +++ b/test/fork/invariant/Invariants.t.sol @@ -44,7 +44,7 @@ contract CSModuleInvariants is InvariantsBase { assertCSMMaxKeys(csm); } - function test_roles() public { + function test_roles() public view { assertEq( csm.getRoleMemberCount(csm.DEFAULT_ADMIN_ROLE()), adminsCount, @@ -92,7 +92,7 @@ contract CSAccountingInvariants is InvariantsBase { assertAccountingTotalBondShares(noCount, lido, accounting); } - function test_burnerApproval() public { + function test_burnerApproval() public view { assertAccountingBurnerApproval( lido, address(accounting), @@ -100,7 +100,7 @@ contract CSAccountingInvariants is InvariantsBase { ); } - function test_roles() public { + function test_roles() public view { assertEq( accounting.getRoleMemberCount(accounting.DEFAULT_ADMIN_ROLE()), adminsCount, @@ -147,15 +147,15 @@ contract CSAccountingInvariants is InvariantsBase { } contract CSFeeDistributorInvariants is InvariantsBase { - function test_claimableShares() public { + function test_claimableShares() public view { assertFeeDistributorClaimableShares(lido, feeDistributor); } - function test_tree() public { + function test_tree() public view { assertFeeDistributorTree(feeDistributor); } - function test_roles() public { + function test_roles() public view { assertEq( feeDistributor.getRoleMemberCount( feeDistributor.DEFAULT_ADMIN_ROLE() @@ -172,7 +172,7 @@ contract CSFeeDistributorInvariants is InvariantsBase { } contract CSFeeOracleInvariant is InvariantsBase { - function test_roles() public { + function test_roles() public view { assertEq( oracle.getRoleMemberCount(oracle.DEFAULT_ADMIN_ROLE()), adminsCount, @@ -209,7 +209,7 @@ contract CSFeeOracleInvariant is InvariantsBase { } contract HashConsensusInvariant is InvariantsBase { - function test_roles() public { + function test_roles() public view { assertEq( oracle.getRoleMemberCount(oracle.DEFAULT_ADMIN_ROLE()), adminsCount, @@ -219,7 +219,7 @@ contract HashConsensusInvariant is InvariantsBase { } contract VerifierInvariant is InvariantsBase { - function test_roles() public { + function test_roles() public view { assertEq( verifier.getRoleMemberCount(verifier.PAUSE_ROLE()), 1, diff --git a/test/fork/voting/StakingRouter.t.sol b/test/fork/voting/StakingRouter.t.sol index 5b549696..272b0b4a 100644 --- a/test/fork/voting/StakingRouter.t.sol +++ b/test/fork/voting/StakingRouter.t.sol @@ -155,7 +155,7 @@ contract StakingRouterIntegrationTest is vm.stopPrank(); } - function test_connectCSMToRouter() public { + function test_connectCSMToRouter() public view { IStakingRouter.StakingModule memory module = stakingRouter .getStakingModule(moduleId); assertTrue(module.stakingModuleAddress == address(csm)); diff --git a/test/fork/voting/StatePostVote.t.sol b/test/fork/voting/StatePostVote.t.sol index 8353e4ce..7a9e66db 100644 --- a/test/fork/voting/StatePostVote.t.sol +++ b/test/fork/voting/StatePostVote.t.sol @@ -24,12 +24,12 @@ contract ContractsStateTest is Test, Utilities, DeploymentFixtures { adminsCount = block.chainid == 1 ? 1 : 2; } - function test_moduleState() public { + function test_moduleState() public view { assertFalse(csm.isPaused()); assertFalse(csm.publicRelease()); } - function test_moduleRoles() public { + function test_moduleRoles() public view { assertTrue( csm.hasRole(csm.DEFAULT_ADMIN_ROLE(), deployParams.aragonAgent) ); @@ -68,7 +68,7 @@ contract ContractsStateTest is Test, Utilities, DeploymentFixtures { assertEq(csm.getRoleMemberCount(csm.RECOVERER_ROLE()), 0); } - function test_accountingState() public { + function test_accountingState() public view { assertFalse(accounting.isPaused()); assertEq( accounting.getCurveInfo(vettedGate.CURVE_ID()).points, @@ -82,7 +82,7 @@ contract ContractsStateTest is Test, Utilities, DeploymentFixtures { ); } - function test_accountingRoles() public { + function test_accountingRoles() public view { assertTrue( accounting.hasRole( accounting.DEFAULT_ADMIN_ROLE(), @@ -130,7 +130,7 @@ contract ContractsStateTest is Test, Utilities, DeploymentFixtures { ); } - function test_feeDistributor_roles() public { + function test_feeDistributor_roles() public view { assertTrue( feeDistributor.hasRole( feeDistributor.DEFAULT_ADMIN_ROLE(), @@ -148,21 +148,21 @@ contract ContractsStateTest is Test, Utilities, DeploymentFixtures { ); } - function test_feeOracle_state() public { + function test_feeOracle_state() public view { // NOTE: It assumes the first report has been settled. assertFalse(oracle.isPaused()); ( bytes32 hash, uint256 refSlot, uint256 processingDeadlineTime, - bool processingStarted + ) = oracle.getConsensusReport(); assertFalse(hash == bytes32(0), "expected report hash to be non-zero"); assertGt(refSlot, 0); assertGt(processingDeadlineTime, 0); } - function test_feeOracle_roles() public { + function test_feeOracle_roles() public view { assertTrue( oracle.hasRole( oracle.DEFAULT_ADMIN_ROLE(), @@ -202,7 +202,7 @@ contract ContractsStateTest is Test, Utilities, DeploymentFixtures { ); } - function test_hashConsensus_roles() public { + function test_hashConsensus_roles() public view { assertTrue( hashConsensus.hasRole( hashConsensus.DEFAULT_ADMIN_ROLE(), @@ -255,7 +255,7 @@ contract ContractsStateTest is Test, Utilities, DeploymentFixtures { ); } - function test_verifier_roles() public { + function test_verifier_roles() public view { assertTrue(verifier.hasRole(verifier.PAUSE_ROLE(), address(gateSeal))); assertEq(verifier.getRoleMemberCount(verifier.PAUSE_ROLE()), 1); assertEq(verifier.getRoleMemberCount(verifier.RESUME_ROLE()), 0); diff --git a/test/helpers/Fixtures.sol b/test/helpers/Fixtures.sol index 1d464411..c7e39917 100644 --- a/test/helpers/Fixtures.sol +++ b/test/helpers/Fixtures.sol @@ -193,7 +193,7 @@ contract DeploymentHelpers is Test { function parseUpgradeConfig( string memory config - ) internal view returns (UpgradeConfig memory upgradeConfig) { + ) internal pure returns (UpgradeConfig memory upgradeConfig) { upgradeConfig.permissionlessGate = vm.parseJsonAddress( config, ".PermissionlessGate" diff --git a/test/helpers/InvariantAsserts.sol b/test/helpers/InvariantAsserts.sol index 76ec7679..c646dfa0 100644 --- a/test/helpers/InvariantAsserts.sol +++ b/test/helpers/InvariantAsserts.sol @@ -12,7 +12,7 @@ import { Batch } from "../../src/lib/QueueLib.sol"; import { CSAccounting } from "../../src/CSAccounting.sol"; contract InvariantAsserts is Test { - function assertCSMKeys(CSModule csm) public { + function assertCSMKeys(CSModule csm) public view { uint256 noCount = csm.getNodeOperatorsCount(); NodeOperator memory no; @@ -124,7 +124,7 @@ contract InvariantAsserts is Test { } } - function assertCSMMaxKeys(CSModule csm) public { + function assertCSMMaxKeys(CSModule csm) public view { if (csm.publicRelease()) return; uint256 noCount = csm.getNodeOperatorsCount(); @@ -143,7 +143,7 @@ contract InvariantAsserts is Test { uint256 nodeOperatorsCount, IStETH steth, CSAccounting accounting - ) public { + ) public view { uint256 totalNodeOperatorsShares; for (uint256 noId = 0; noId < nodeOperatorsCount; noId++) { @@ -165,7 +165,7 @@ contract InvariantAsserts is Test { IStETH steth, address accounting, address burner - ) public { + ) public view { assertGe( steth.allowance(accounting, burner), type(uint128).max, @@ -176,7 +176,7 @@ contract InvariantAsserts is Test { function assertFeeDistributorClaimableShares( IStETH lido, CSFeeDistributor feeDistributor - ) public { + ) public view { assertGe( lido.sharesOf(address(feeDistributor)), feeDistributor.totalClaimableShares(), @@ -184,7 +184,9 @@ contract InvariantAsserts is Test { ); } - function assertFeeDistributorTree(CSFeeDistributor feeDistributor) public { + function assertFeeDistributorTree( + CSFeeDistributor feeDistributor + ) public view { if (feeDistributor.treeRoot() == bytes32(0)) { assertEq( feeDistributor.treeCid(), diff --git a/test/helpers/Utilities.sol b/test/helpers/Utilities.sol index 22bad677..9b882013 100644 --- a/test/helpers/Utilities.sol +++ b/test/helpers/Utilities.sol @@ -116,17 +116,17 @@ contract Utilities is CommonBase { } function someCIDv0() public returns (string memory result) { - bytes memory seed = randomBytes(46); + bytes memory CIDSeed = randomBytes(46); - seed[0] = "Q"; - seed[1] = "m"; + CIDSeed[0] = "Q"; + CIDSeed[1] = "m"; - for (uint256 i = 2; i < seed.length; ++i) { - uint256 symIndex = uint8(seed[i]) % 58; - seed[i] = BASE58ALPHABET[symIndex]; + for (uint256 i = 2; i < CIDSeed.length; ++i) { + uint256 symIndex = uint8(CIDSeed[i]) % 58; + CIDSeed[i] = BASE58ALPHABET[symIndex]; } - result = string(seed); + result = string(CIDSeed); } function checkChainId(uint256 chainId) public view { @@ -175,10 +175,10 @@ contract Utilities is CommonBase { bytes memory subject, uint256 offset, uint256 length - ) public pure returns (bytes memory slice) { - slice = new bytes(length); + ) public pure returns (bytes memory result) { + result = new bytes(length); for (uint i; i < length; ++i) { - slice[i] = subject[offset + i]; + result[i] = subject[offset + i]; } } diff --git a/test/helpers/mocks/CSMMock.sol b/test/helpers/mocks/CSMMock.sol index f6c74239..75e8e833 100644 --- a/test/helpers/mocks/CSMMock.sol +++ b/test/helpers/mocks/CSMMock.sol @@ -18,16 +18,16 @@ contract CSMMock { } function getNodeOperator( - uint256 nodeOperatorId + uint256 /* nodeOperatorId */ ) external view returns (NodeOperator memory) { return mockNodeOperator; } function createNodeOperator( - address from, - NodeOperatorManagementProperties memory managementProperties, - address referrer - ) external returns (uint256) { + address /* from */, + NodeOperatorManagementProperties memory /* managementProperties */, + address /* referrer */ + ) external pure returns (uint256) { return 0; } diff --git a/test/helpers/mocks/DistributorMock.sol b/test/helpers/mocks/DistributorMock.sol index 1e3071a2..22ee085e 100644 --- a/test/helpers/mocks/DistributorMock.sol +++ b/test/helpers/mocks/DistributorMock.sol @@ -26,17 +26,17 @@ contract DistributorMock { } function getFeesToDistribute( - uint256 nodeOperatorId, - uint256 shares, - bytes32[] calldata proof + uint256 /* nodeOperatorId */, + uint256 /* shares */, + bytes32[] calldata /* proof */ ) public view returns (uint256 sharesToDistribute) { return STETH.sharesOf(address(this)); } function distributeFees( - uint256 nodeOperatorId, + uint256 /* nodeOperatorId */, uint256 shares, - bytes32[] calldata proof + bytes32[] calldata /* proof */ ) external returns (uint256) { STETH.transferShares(ACCOUNTING, shares); return shares; diff --git a/test/helpers/mocks/LidoMock.sol b/test/helpers/mocks/LidoMock.sol index c190a3c8..101e0f93 100644 --- a/test/helpers/mocks/LidoMock.sol +++ b/test/helpers/mocks/LidoMock.sol @@ -8,7 +8,7 @@ import { StETHMock } from "./StETHMock.sol"; contract LidoMock is StETHMock { constructor(uint256 _totalPooledEther) StETHMock(_totalPooledEther) {} - function submit(address _referal) public payable returns (uint256) { + function submit(address /* _referral */) public payable returns (uint256) { uint256 sharesToMint = getSharesByPooledEth(msg.value); mintShares(msg.sender, sharesToMint); addTotalPooledEther(msg.value); From cc6e6ee0af26e68f29933998037c5a901c4c72e0 Mon Sep 17 00:00:00 2001 From: skhomuti Date: Fri, 24 Jan 2025 16:51:34 +0500 Subject: [PATCH 2/3] up foundry and related libs --- .foundryref | 2 +- .github/workflows/regular-mainnet.yml | 13 +++++++------ .github/workflows/test.yml | 13 +++++++------ package.json | 2 +- test/helpers/Fixtures.sol | 4 ++-- yarn.lock | 10 +++++----- 6 files changed, 23 insertions(+), 21 deletions(-) diff --git a/.foundryref b/.foundryref index 63cae460..d4dfa563 100644 --- a/.foundryref +++ b/.foundryref @@ -1 +1 @@ -03ea54c \ No newline at end of file +v0.3.0 \ No newline at end of file diff --git a/.github/workflows/regular-mainnet.yml b/.github/workflows/regular-mainnet.yml index 1c730e3e..248051fc 100644 --- a/.github/workflows/regular-mainnet.yml +++ b/.github/workflows/regular-mainnet.yml @@ -23,7 +23,6 @@ jobs: cache-path: ${{ steps.cache.outputs.path }} cache-key: ${{ steps.cache.outputs.key }} env: - FORGE_REV: 03ea54c JUST_TAG: 1.24.0 steps: - name: Build cache params @@ -35,7 +34,6 @@ jobs: CACHE_PATH: | ~/.cargo/bin/ KEY_INPUT: | - forge:${{env.FORGE_REV}} just:${{env.JUST_TAG}} - uses: actions/cache@v4 @@ -48,14 +46,12 @@ jobs: run: cargo install "just@$JUST_TAG" if: steps.get-cache.outputs.cache-hit != 'true' - - name: Install forge & anvil - run: cargo install --git https://github.com/foundry-rs/foundry --rev "$FORGE_REV" --profile release --locked forge anvil - if: steps.get-cache.outputs.cache-hit != 'true' - test: name: Integration & Invariant tests runs-on: ubuntu-latest needs: bootstrap + env: + FORGE_REV: v0.3.0 steps: - uses: actions/checkout@v4 with: @@ -66,6 +62,11 @@ jobs: path: ${{ needs.bootstrap.outputs.cache-path }} key: ${{ needs.bootstrap.outputs.cache-key }} + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: ${{ env.FORGE_REV }} + - name: Install node uses: actions/setup-node@v4 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bd47b035..de5f6476 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,6 @@ jobs: cache-path: ${{ steps.cache.outputs.path }} cache-key: ${{ steps.cache.outputs.key }} env: - FORGE_REV: 03ea54c JUST_TAG: 1.24.0 steps: - name: Build cache params @@ -42,7 +41,6 @@ jobs: CACHE_PATH: | ~/.cargo/bin/ KEY_INPUT: | - forge:${{env.FORGE_REV}} just:${{env.JUST_TAG}} - uses: actions/cache@v4 @@ -55,10 +53,6 @@ jobs: run: cargo install "just@$JUST_TAG" if: steps.get-cache.outputs.cache-hit != 'true' - - name: Install forge & anvil - run: cargo install --git https://github.com/foundry-rs/foundry --rev "$FORGE_REV" --profile release --locked forge anvil - if: steps.get-cache.outputs.cache-hit != 'true' - linters: name: Linters runs-on: ubuntu-latest @@ -90,6 +84,8 @@ jobs: name: Foundry project runs-on: ubuntu-latest needs: bootstrap + env: + FORGE_REV: v0.3.0 steps: - uses: actions/checkout@v4 with: @@ -100,6 +96,11 @@ jobs: path: ${{ needs.bootstrap.outputs.cache-path }} key: ${{ needs.bootstrap.outputs.cache-key }} + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: ${{ env.FORGE_REV }} + - name: Install node uses: actions/setup-node@v4 with: diff --git a/package.json b/package.json index b9a0506a..b9975c38 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "@openzeppelin/contracts-upgradeable": "5.0.2", "@openzeppelin/merkle-tree": "^1.0.6", "ds-test": "https://github.com/dapphub/ds-test", - "forge-std": "https://github.com/foundry-rs/forge-std.git#v1.7.6" + "forge-std": "https://github.com/foundry-rs/forge-std.git#v1.9.5" }, "devDependencies": { "husky": "^8.0.3", diff --git a/test/helpers/Fixtures.sol b/test/helpers/Fixtures.sol index c7e39917..457b06ca 100644 --- a/test/helpers/Fixtures.sol +++ b/test/helpers/Fixtures.sol @@ -135,7 +135,7 @@ contract DeploymentHelpers is Test { vm.label(deploymentConfig.csm, "csm"); /// Optional for v1 compatibility (upgrade tests). Removed in v2 - if (vm.keyExists(config, ".CSEarlyAdoption")) { + if (vm.keyExistsJson(config, ".CSEarlyAdoption")) { deploymentConfig.earlyAdoption = vm.parseJsonAddress( config, ".CSEarlyAdoption" @@ -144,7 +144,7 @@ contract DeploymentHelpers is Test { } /// Optional, new in v2. Gates not present in v1 deployment configs - if (vm.keyExists(config, ".PermissionlessGate")) { + if (vm.keyExistsJson(config, ".PermissionlessGate")) { deploymentConfig.permissionlessGate = vm.parseJsonAddress( config, ".PermissionlessGate" diff --git a/yarn.lock b/yarn.lock index 3572db2b..bf853756 100644 --- a/yarn.lock +++ b/yarn.lock @@ -800,7 +800,7 @@ __metadata: "@openzeppelin/contracts-upgradeable": "npm:5.0.2" "@openzeppelin/merkle-tree": "npm:^1.0.6" ds-test: "https://github.com/dapphub/ds-test" - forge-std: "https://github.com/foundry-rs/forge-std.git#v1.7.6" + forge-std: "https://github.com/foundry-rs/forge-std.git#v1.9.5" husky: "npm:^8.0.3" lint-staged: "npm:^14.0.1" prettier: "npm:^3.0.3" @@ -1020,10 +1020,10 @@ __metadata: languageName: node linkType: hard -"forge-std@https://github.com/foundry-rs/forge-std.git#v1.7.6": - version: 1.7.6 - resolution: "forge-std@https://github.com/foundry-rs/forge-std.git#commit=ae570fec082bfe1c1f45b0acca4a2b4f84d345ce" - checksum: 10c0/d1184e67889fdfedb272d550302988fc0da4a962e78000755acf002bba6d13687593db4f09d8ae48087adc27d84fb22de8eb0ea2fefdaafb2478272a73852472 +"forge-std@https://github.com/foundry-rs/forge-std.git#v1.9.5": + version: 1.9.5 + resolution: "forge-std@https://github.com/foundry-rs/forge-std.git#commit=b93cf4bc34ff214c099dc970b153f85ade8c9f66" + checksum: 10c0/8ac6460e4e27993b2695aee5370742f98b61807ea9311f0fc685e8e365b2555a1d6c8062f4d70316d1c6e14e138100dcfe81368b02d4915db7b0c8653860a483 languageName: node linkType: hard From 6ffef3c83235fd9123ffb85698befdbf3216972a Mon Sep 17 00:00:00 2001 From: skhomuti Date: Fri, 24 Jan 2025 18:55:41 +0500 Subject: [PATCH 3/3] try to fix out of gas --- Justfile | 7 ++++--- foundry.toml | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Justfile b/Justfile index 15bf1437..a66683ab 100644 --- a/Justfile +++ b/Justfile @@ -156,9 +156,10 @@ _deploy-prod *args: forge script {{deploy_script_path}} --sig="run(string)" --force --rpc-url ${RPC_URL} {{args}} -- `git rev-parse HEAD` _deploy-impl *args: - forge script {{deploy_impls_script_path}} --sig="deploy(string,string)" \ - --rpc-url {{anvil_rpc_url}} --slow {{args}} \ - -- {{deploy_config_path}} `git rev-parse HEAD` + FOUNDRY_PROFILE=deploy-impl \ + forge script {{deploy_impls_script_path}} --sig="deploy(string,string)" \ + --rpc-url {{anvil_rpc_url}} --slow {{args}} \ + -- {{deploy_config_path}} `git rev-parse HEAD` [confirm("You are about to broadcast deployment transactions to the network. Are you sure?")] deploy-impl-prod *args: diff --git a/foundry.toml b/foundry.toml index 9b00f763..35a12d00 100644 --- a/foundry.toml +++ b/foundry.toml @@ -47,3 +47,8 @@ fuzz = { runs = 10_000, max_test_rejects = 2_000_000 } # due to coverage running with optimizer disabled, we need to increase the gas limit # to fit CSM contract tests in one block block_gas_limit = 60_000_000 + +[profile.deploy-impl] +# unknown problem of too high estimated gas usage in the implementation deployment script +# after upgrading forge-std 1.7.6 -> 1.9.5 +block_gas_limit = 60_000_000