diff --git a/script/deploy/mainnet/M2_Mainnet_Upgrade.s.sol b/script/deploy/mainnet/M2_Mainnet_Upgrade.s.sol index 6cb1b99b5b..47f127b054 100644 --- a/script/deploy/mainnet/M2_Mainnet_Upgrade.s.sol +++ b/script/deploy/mainnet/M2_Mainnet_Upgrade.s.sol @@ -5,6 +5,8 @@ import "../../utils/ExistingDeploymentParser.sol"; import "../../utils/TimelockEncoding.sol"; import "../../utils/Multisend.sol"; +import "../../../src/contracts/interfaces/IPausable.sol"; + /** * @notice Script used for the first deployment of EigenLayer core contracts to Holesky * anvil --fork-url $RPC_MAINNET @@ -292,7 +294,7 @@ contract Queue_M2_Upgrade is M2_Mainnet_Upgrade, TimelockEncoding { // this works because rETH has more than 1 ETH of its own token at its address :) IERC20(rETH).transfer(address(this), amount); IERC20(rETH).approve(address(strategyManager), amount); - cheats.expectRevert("Pausable: index is paused"); + cheats.expectRevert(IPausable.CurrentlyPaused.selector); strategyManager.depositIntoStrategy({ strategy: IStrategy(rETH_Strategy), token: IERC20(rETH), diff --git a/src/contracts/core/DelegationManagerStorage.sol b/src/contracts/core/DelegationManagerStorage.sol index 3af7b64fe6..195c4d21f9 100644 --- a/src/contracts/core/DelegationManagerStorage.sol +++ b/src/contracts/core/DelegationManagerStorage.sol @@ -11,7 +11,7 @@ import "../interfaces/IEigenPodManager.sol"; * @author Layr Labs, Inc. * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service * @notice This storage contract is separate from the logic to simplify the upgrade process. - */ + */ abstract contract DelegationManagerStorage is IDelegationManager { /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = diff --git a/src/test/Delegation.t.sol b/src/test/Delegation.t.sol index 28b031ae10..94b87470dc 100644 --- a/src/test/Delegation.t.sol +++ b/src/test/Delegation.t.sol @@ -174,7 +174,7 @@ contract DelegationTests is EigenLayerTestHelper { } if (expiry < block.timestamp) { - cheats.expectRevert("DelegationManager.delegateToBySignature: staker signature expired"); + cheats.expectRevert(IDelegationManager.SignatureExpired.selector); } ISignatureUtils.SignatureWithExpiry memory signatureWithExpiry = ISignatureUtils.SignatureWithExpiry({ signature: signature, @@ -258,9 +258,7 @@ contract DelegationTests is EigenLayerTestHelper { signature = abi.encodePacked(r, s, v); } - cheats.expectRevert( - bytes("EIP1271SignatureUtils.checkSignature_EIP1271: ERC1271 signature verification failed") - ); + cheats.expectRevert(EIP1271SignatureUtils.InvalidSignatureEIP1271.selector); ISignatureUtils.SignatureWithExpiry memory signatureWithExpiry = ISignatureUtils.SignatureWithExpiry({ signature: signature, expiry: type(uint256).max @@ -345,7 +343,7 @@ contract DelegationTests is EigenLayerTestHelper { stakerOptOutWindowBlocks: 0 }); _testRegisterAsOperator(operator, operatorDetails); - cheats.expectRevert(bytes("DelegationManager.registerAsOperator: caller is already actively delegated")); + cheats.expectRevert(IDelegationManager.AlreadyDelegated.selector); _testRegisterAsOperator(operator, operatorDetails); } @@ -356,7 +354,7 @@ contract DelegationTests is EigenLayerTestHelper { _testDepositStrategies(getOperatorAddress(1), 1e18, 1); _testDepositEigen(getOperatorAddress(1), 1e18); - cheats.expectRevert(bytes("DelegationManager.delegateTo: operator is not registered in EigenLayer")); + cheats.expectRevert(IDelegationManager.OperatorDoesNotExist.selector); cheats.startPrank(getOperatorAddress(1)); ISignatureUtils.SignatureWithExpiry memory signatureWithExpiry; delegation.delegateTo(delegate, signatureWithExpiry, bytes32(0)); @@ -394,7 +392,7 @@ contract DelegationTests is EigenLayerTestHelper { }); string memory emptyStringForMetadataURI; delegation.registerAsOperator(operatorDetails, emptyStringForMetadataURI); - vm.expectRevert("DelegationManager.registerAsOperator: caller is already actively delegated"); + cheats.expectRevert(IDelegationManager.AlreadyDelegated.selector); delegation.registerAsOperator(operatorDetails, emptyStringForMetadataURI); cheats.stopPrank(); } @@ -405,10 +403,10 @@ contract DelegationTests is EigenLayerTestHelper { address _unregisteredoperator ) public fuzzedAddress(_staker) { vm.startPrank(_staker); - cheats.expectRevert(bytes("DelegationManager.delegateTo: operator is not registered in EigenLayer")); + cheats.expectRevert(IDelegationManager.OperatorDoesNotExist.selector); ISignatureUtils.SignatureWithExpiry memory signatureWithExpiry; delegation.delegateTo(_unregisteredoperator, signatureWithExpiry, bytes32(0)); - cheats.expectRevert(bytes("DelegationManager.delegateTo: operator is not registered in EigenLayer")); + cheats.expectRevert(IDelegationManager.OperatorDoesNotExist.selector); delegation.delegateTo(_staker, signatureWithExpiry, bytes32(0)); cheats.stopPrank(); } @@ -436,7 +434,7 @@ contract DelegationTests is EigenLayerTestHelper { // operators cannot undelegate from themselves vm.prank(_operator); - cheats.expectRevert(bytes("DelegationManager.undelegate: operators cannot be undelegated")); + cheats.expectRevert(IDelegationManager.OperatorsCannotUndelegate.selector); delegation.undelegate(_operator); // assert still delegated diff --git a/src/test/DepositWithdraw.t.sol b/src/test/DepositWithdraw.t.sol index 3e2c883703..3a369a7068 100644 --- a/src/test/DepositWithdraw.t.sol +++ b/src/test/DepositWithdraw.t.sol @@ -57,7 +57,7 @@ contract DepositWithdrawTests is EigenLayerTestHelper { strategyManager.addStrategiesToDepositWhitelist(_strategy, _thirdPartyTransfersForbiddenValues); cheats.stopPrank(); - cheats.expectRevert(bytes("StrategyBase.deposit: Can only deposit underlyingToken")); + cheats.expectRevert(IStrategy.OnlyUnderlyingToken.selector); strategyManager.depositIntoStrategy(wethStrat, token, 10); } @@ -108,7 +108,7 @@ contract DepositWithdrawTests is EigenLayerTestHelper { strategyManager.addStrategiesToDepositWhitelist(_strategy, _thirdPartyTransfersForbiddenValues); cheats.stopPrank(); - cheats.expectRevert(bytes("StrategyBase.deposit: newShares cannot be zero")); + cheats.expectRevert(IStrategy.NewSharesZero.selector); strategyManager.depositIntoStrategy(wethStrat, weth, 0); } diff --git a/src/test/Pausable.t.sol b/src/test/Pausable.t.sol index 19c00fd2ff..c946492cf3 100644 --- a/src/test/Pausable.t.sol +++ b/src/test/Pausable.t.sol @@ -40,7 +40,7 @@ contract PausableTests is EigenLayerTestHelper { { cheats.assume(!eigenLayerPauserReg.isPauser(unauthorizedPauser)); cheats.startPrank(unauthorizedPauser); - cheats.expectRevert(bytes("msg.sender is not permissioned as pauser")); + cheats.expectRevert(IPausable.OnlyPauser.selector); strategyManager.pause(type(uint256).max); cheats.stopPrank(); } @@ -64,7 +64,7 @@ contract PausableTests is EigenLayerTestHelper { { cheats.assume(fakePauser != eigenLayerPauserReg.unpauser()); cheats.startPrank(fakePauser); - cheats.expectRevert(bytes("msg.sender is not permissioned as unpauser")); + cheats.expectRevert(IPausable.OnlyUnpauser.selector); eigenLayerPauserReg.setIsPauser(newPauser, true); cheats.stopPrank(); } @@ -84,7 +84,7 @@ contract PausableTests is EigenLayerTestHelper { cheats.assume(notUnpauser != eigenLayerPauserReg.unpauser()); cheats.prank(notUnpauser); - cheats.expectRevert(bytes("msg.sender is not permissioned as unpauser")); + cheats.expectRevert(IPausable.OnlyUnpauser.selector); strategyManager.setPauserRegistry(newPauserRegistry); } } diff --git a/src/test/Strategy.t.sol b/src/test/Strategy.t.sol index 6bcad11ad2..2b54c3ccb5 100644 --- a/src/test/Strategy.t.sol +++ b/src/test/Strategy.t.sol @@ -18,7 +18,7 @@ contract StrategyTests is EigenLayerTestHelper { IERC20 underlyingToken = wethStrat.underlyingToken(); cheats.startPrank(invalidDepositor); - cheats.expectRevert(bytes("StrategyBase.onlyStrategyManager")); + cheats.expectRevert(IStrategy.UnauthorizedCaller.selector); wethStrat.deposit(underlyingToken, 1e18); cheats.stopPrank(); } @@ -34,7 +34,7 @@ contract StrategyTests is EigenLayerTestHelper { IERC20 underlyingToken = wethStrat.underlyingToken(); cheats.startPrank(invalidWithdrawer); - cheats.expectRevert(bytes("StrategyBase.onlyStrategyManager")); + cheats.expectRevert(IStrategy.UnauthorizedCaller.selector); wethStrat.withdraw(depositor, underlyingToken, 1e18); cheats.stopPrank(); } @@ -47,10 +47,7 @@ contract StrategyTests is EigenLayerTestHelper { IERC20 underlyingToken = wethStrat.underlyingToken(); cheats.startPrank(address(strategyManager)); - - cheats.expectRevert( - bytes("StrategyBase.withdraw: amountShares must be less than or equal to totalShares") - ); + cheats.expectRevert(IStrategy.WithdrawalAmountExceedsTotalDeposits.selector); wethStrat.withdraw(depositor, underlyingToken, shares); cheats.stopPrank(); diff --git a/src/test/integration/tests/eigenpod/VerifyWC_StartCP_CompleteCP.t.sol b/src/test/integration/tests/eigenpod/VerifyWC_StartCP_CompleteCP.t.sol index 1681c1791b..9fd6ef2968 100644 --- a/src/test/integration/tests/eigenpod/VerifyWC_StartCP_CompleteCP.t.sol +++ b/src/test/integration/tests/eigenpod/VerifyWC_StartCP_CompleteCP.t.sol @@ -111,7 +111,7 @@ contract Integration_VerifyWC_StartCP_CompleteCP is IntegrationCheckUtils { staker.verifyWithdrawalCredentials(validators); check_VerifyWC_State(staker, validators, beaconBalanceGwei); - cheats.expectRevert("EigenPod._verifyWithdrawalCredentials: validator must be inactive to prove withdrawal credentials"); + cheats.expectRevert(IEigenPod.CredentialsAlreadyVerified.selector); staker.verifyWithdrawalCredentials(validators); } @@ -132,7 +132,7 @@ contract Integration_VerifyWC_StartCP_CompleteCP is IntegrationCheckUtils { staker.startCheckpoint(); check_StartCheckpoint_State(staker); - cheats.expectRevert("EigenPod._startCheckpoint: must finish previous checkpoint before starting another"); + cheats.expectRevert(IEigenPod.CheckpointAlreadyActive.selector); staker.startCheckpoint(); } @@ -157,7 +157,7 @@ contract Integration_VerifyWC_StartCP_CompleteCP is IntegrationCheckUtils { staker.completeCheckpoint(); check_CompleteCheckpoint_State(staker); - cheats.expectRevert("EigenPod._startCheckpoint: cannot checkpoint twice in one block"); + cheats.expectRevert(IEigenPod.CannotCheckpointTwiceInSingleBlock.selector); staker.startCheckpoint(); } @@ -227,7 +227,7 @@ contract Integration_VerifyWC_StartCP_CompleteCP is IntegrationCheckUtils { staker.exitValidators(validators); beaconChain.advanceEpoch_NoRewards(); - cheats.expectRevert("EigenPod._verifyWithdrawalCredentials: validator must not be exiting"); + cheats.expectRevert(IEigenPod.ValidatorIsExitingBeaconChain.selector); staker.verifyWithdrawalCredentials(validators); } @@ -312,7 +312,7 @@ contract Integration_VerifyWC_StartCP_CompleteCP is IntegrationCheckUtils { // Advance epoch, withdrawing slashed validators to pod beaconChain.advanceEpoch_NoRewards(); - cheats.expectRevert("EigenPod._verifyWithdrawalCredentials: validator must not be exiting"); + cheats.expectRevert(IEigenPod.ValidatorIsExitingBeaconChain.selector); staker.verifyWithdrawalCredentials(validators); } diff --git a/src/test/unit/AVSDirectoryUnit.t.sol b/src/test/unit/AVSDirectoryUnit.t.sol index d8b6ab3d13..bd7a135d40 100644 --- a/src/test/unit/AVSDirectoryUnit.t.sol +++ b/src/test/unit/AVSDirectoryUnit.t.sol @@ -176,10 +176,10 @@ contract AVSDirectoryUnitTests_operatorAVSRegisterationStatus is AVSDirectoryUni cheats.prank(pauser); avsDirectory.pause(2 ** PAUSED_OPERATOR_REGISTER_DEREGISTER_TO_AVS); - cheats.expectRevert("Pausable: index is paused"); + cheats.expectRevert(IPausable.CurrentlyPaused.selector); avsDirectory.registerOperatorToAVS(address(0), ISignatureUtils.SignatureWithSaltAndExpiry(abi.encodePacked(""), 0, 0)); - cheats.expectRevert("Pausable: index is paused"); + cheats.expectRevert(IPausable.CurrentlyPaused.selector); avsDirectory.deregisterOperatorFromAVS(address(0)); } @@ -222,7 +222,7 @@ contract AVSDirectoryUnitTests_operatorAVSRegisterationStatus is AVSDirectoryUni ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature = _getOperatorSignature(delegationSignerPrivateKey, operator, defaultAVS, salt, expiry); - cheats.expectRevert("AVSDirectory.registerOperatorToAVS: operator not registered to EigenLayer yet"); + cheats.expectRevert(IAVSDirectory.OperatorDoesNotExist.selector); avsDirectory.registerOperatorToAVS(operator, operatorSignature); } @@ -236,7 +236,7 @@ contract AVSDirectoryUnitTests_operatorAVSRegisterationStatus is AVSDirectoryUni ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature = _getOperatorSignature(delegationSignerPrivateKey, operator, defaultAVS, salt, expiry); - cheats.expectRevert("EIP1271SignatureUtils.checkSignature_EIP1271: signature not from signer"); + cheats.expectRevert(EIP1271SignatureUtils.InvalidSignatureEOA.selector); cheats.prank(operator); avsDirectory.registerOperatorToAVS(operator, operatorSignature); } @@ -248,7 +248,7 @@ contract AVSDirectoryUnitTests_operatorAVSRegisterationStatus is AVSDirectoryUni address operator = cheats.addr(delegationSignerPrivateKey); operatorSignature.expiry = bound(operatorSignature.expiry, 0, block.timestamp - 1); - cheats.expectRevert("AVSDirectory.registerOperatorToAVS: operator signature expired"); + cheats.expectRevert(IAVSDirectory.SignatureExpired.selector); avsDirectory.registerOperatorToAVS(operator, operatorSignature); } @@ -265,7 +265,7 @@ contract AVSDirectoryUnitTests_operatorAVSRegisterationStatus is AVSDirectoryUni cheats.startPrank(defaultAVS); avsDirectory.registerOperatorToAVS(operator, operatorSignature); - cheats.expectRevert("AVSDirectory.registerOperatorToAVS: operator already registered"); + cheats.expectRevert(IAVSDirectory.OperatorAlreadyRegistered.selector); avsDirectory.registerOperatorToAVS(operator, operatorSignature); cheats.stopPrank(); } @@ -310,40 +310,42 @@ contract AVSDirectoryUnitTests_operatorAVSRegisterationStatus is AVSDirectoryUni cheats.prank(operator); avsDirectory.cancelSalt(salt); - cheats.expectRevert("AVSDirectory.registerOperatorToAVS: salt already spent"); + cheats.expectRevert(IAVSDirectory.SignatureSaltSpent.selector); cheats.prank(defaultAVS); avsDirectory.registerOperatorToAVS(operator, operatorSignature); } - /// @notice Verifies that an operator cannot cancel the same salt twice - function testFuzz_revert_whenSaltCancelledTwice(bytes32 salt) public { - address operator = cheats.addr(delegationSignerPrivateKey); - assertFalse(delegationManager.isOperator(operator), "bad test setup"); - _registerOperatorWithBaseDetails(operator); - - cheats.startPrank(operator); - avsDirectory.cancelSalt(salt); - - cheats.expectRevert("AVSDirectory.cancelSalt: cannot cancel spent salt"); - avsDirectory.cancelSalt(salt); - cheats.stopPrank(); - } - - /// @notice Verifies that an operator cannot cancel the same salt twice - function testFuzz_revert_whenCancellingSaltUsedToRegister(bytes32 salt) public { - address operator = cheats.addr(delegationSignerPrivateKey); - assertFalse(delegationManager.isOperator(operator), "bad test setup"); - _registerOperatorWithBaseDetails(operator); - - uint256 expiry = type(uint256).max; - ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature = - _getOperatorSignature(delegationSignerPrivateKey, operator, defaultAVS, salt, expiry); - - cheats.prank(defaultAVS); - avsDirectory.registerOperatorToAVS(operator, operatorSignature); - - cheats.prank(operator); - cheats.expectRevert("AVSDirectory.cancelSalt: cannot cancel spent salt"); - avsDirectory.cancelSalt(salt); - } + // NOTE: This check was removed. + // /// @notice Verifies that an operator cannot cancel the same salt twice + // function testFuzz_revert_whenSaltCancelledTwice(bytes32 salt) public { + // address operator = cheats.addr(delegationSignerPrivateKey); + // assertFalse(delegationManager.isOperator(operator), "bad test setup"); + // _registerOperatorWithBaseDetails(operator); + + // cheats.startPrank(operator); + // avsDirectory.cancelSalt(salt); + + // cheats.expectRevert(IAVSDirectory.SignatureSaltSpent.selector); + // avsDirectory.cancelSalt(salt); + // cheats.stopPrank(); + // } + + // NOTE: This check was removed. + // /// @notice Verifies that an operator cannot cancel the same salt twice + // function testFuzz_revert_whenCancellingSaltUsedToRegister(bytes32 salt) public { + // address operator = cheats.addr(delegationSignerPrivateKey); + // assertFalse(delegationManager.isOperator(operator), "bad test setup"); + // _registerOperatorWithBaseDetails(operator); + + // uint256 expiry = type(uint256).max; + // ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature = + // _getOperatorSignature(delegationSignerPrivateKey, operator, defaultAVS, salt, expiry); + + // cheats.prank(defaultAVS); + // avsDirectory.registerOperatorToAVS(operator, operatorSignature); + + // cheats.prank(operator); + // cheats.expectRevert(IAVSDirectory.SignatureSaltSpent.selector); + // avsDirectory.cancelSalt(salt); + // } } diff --git a/src/test/unit/DelegationUnit.t.sol b/src/test/unit/DelegationUnit.t.sol index 1deb860fce..2975d8ccda 100644 --- a/src/test/unit/DelegationUnit.t.sol +++ b/src/test/unit/DelegationUnit.t.sol @@ -564,7 +564,7 @@ contract DelegationManagerUnitTests_Initialization_Setters is DelegationManagerU cheats.assume(newMinWithdrawalDelayBlocks > delegationManager.MAX_WITHDRAWAL_DELAY_BLOCKS()); // attempt to set the `minWithdrawalDelayBlocks` variable - cheats.expectRevert("DelegationManager._setMinWithdrawalDelayBlocks: _minWithdrawalDelayBlocks cannot be > MAX_WITHDRAWAL_DELAY_BLOCKS"); + cheats.expectRevert(IDelegationManager.WithdrawalDelayExceedsMax.selector); delegationManager.setMinWithdrawalDelayBlocks(newMinWithdrawalDelayBlocks); } @@ -586,9 +586,7 @@ contract DelegationManagerUnitTests_Initialization_Setters is DelegationManagerU // Deploy DelegationManager implmentation and proxy delegationManagerImplementation = new DelegationManager(strategyManagerMock, slasherMock, eigenPodManagerMock); - cheats.expectRevert( - "DelegationManager._setStrategyWithdrawalDelayBlocks: _withdrawalDelayBlocks cannot be > MAX_WITHDRAWAL_DELAY_BLOCKS" - ); + cheats.expectRevert(IDelegationManager.WithdrawalDelayExceedsMax.selector); delegationManager = DelegationManager( address( new TransparentUpgradeableProxy( @@ -615,7 +613,7 @@ contract DelegationManagerUnitTests_RegisterModifyOperator is DelegationManagerU cheats.prank(pauser); delegationManager.pause(2 ** PAUSED_NEW_DELEGATION); - cheats.expectRevert("Pausable: index is paused"); + cheats.expectRevert(IPausable.CurrentlyPaused.selector); delegationManager.registerAsOperator( IDelegationManager.OperatorDetails({ __deprecated_earningsReceiver: defaultOperator, @@ -638,7 +636,7 @@ contract DelegationManagerUnitTests_RegisterModifyOperator is DelegationManagerU delegationManager.registerAsOperator(operatorDetails, emptyStringForMetadataURI); // Expect revert when register again - cheats.expectRevert("DelegationManager.registerAsOperator: caller is already actively delegated"); + cheats.expectRevert(IDelegationManager.AlreadyDelegated.selector); delegationManager.registerAsOperator(operatorDetails, emptyStringForMetadataURI); cheats.stopPrank(); } @@ -653,7 +651,7 @@ contract DelegationManagerUnitTests_RegisterModifyOperator is DelegationManagerU cheats.assume(operatorDetails.stakerOptOutWindowBlocks > delegationManager.MAX_STAKER_OPT_OUT_WINDOW_BLOCKS()); cheats.prank(defaultOperator); - cheats.expectRevert("DelegationManager._setOperatorDetails: stakerOptOutWindowBlocks cannot be > MAX_STAKER_OPT_OUT_WINDOW_BLOCKS"); + cheats.expectRevert(IDelegationManager.StakerOptOutWindowBlocksExceedsMax.selector); delegationManager.registerAsOperator(operatorDetails, emptyStringForMetadataURI); } @@ -717,7 +715,7 @@ contract DelegationManagerUnitTests_RegisterModifyOperator is DelegationManagerU delegationManager.delegateTo(defaultOperator, approverSignatureAndExpiry, emptySalt); // expect revert if attempt to register as operator - cheats.expectRevert("DelegationManager.registerAsOperator: caller is already actively delegated"); + cheats.expectRevert(IDelegationManager.AlreadyDelegated.selector); delegationManager.registerAsOperator(operatorDetails, emptyStringForMetadataURI); cheats.stopPrank(); @@ -742,9 +740,7 @@ contract DelegationManagerUnitTests_RegisterModifyOperator is DelegationManagerU // either it fails for trying to set the stakerOptOutWindowBlocks if (modifiedOperatorDetails.stakerOptOutWindowBlocks > delegationManager.MAX_STAKER_OPT_OUT_WINDOW_BLOCKS()) { - cheats.expectRevert( - "DelegationManager._setOperatorDetails: stakerOptOutWindowBlocks cannot be > MAX_STAKER_OPT_OUT_WINDOW_BLOCKS" - ); + cheats.expectRevert(IDelegationManager.StakerOptOutWindowBlocksExceedsMax.selector); delegationManager.modifyOperatorDetails(modifiedOperatorDetails); // or the transition is allowed, } else if ( @@ -767,7 +763,7 @@ contract DelegationManagerUnitTests_RegisterModifyOperator is DelegationManagerU assertEq(delegationManager.delegatedTo(defaultOperator), defaultOperator, "operator not delegated to self"); // or else the transition is disallowed } else { - cheats.expectRevert("DelegationManager._setOperatorDetails: stakerOptOutWindowBlocks cannot be decreased"); + cheats.expectRevert(IDelegationManager.StakerOptOutWindowBlocksCannotDecrease.selector); delegationManager.modifyOperatorDetails(modifiedOperatorDetails); } @@ -779,7 +775,7 @@ contract DelegationManagerUnitTests_RegisterModifyOperator is DelegationManagerU assertFalse(delegationManager.isOperator(defaultOperator), "bad test setup"); cheats.prank(defaultOperator); - cheats.expectRevert("DelegationManager.updateOperatorMetadataURI: caller must be an operator"); + cheats.expectRevert(IDelegationManager.OperatorDoesNotExist.selector); delegationManager.updateOperatorMetadataURI(emptyStringForMetadataURI); } @@ -791,7 +787,7 @@ contract DelegationManagerUnitTests_RegisterModifyOperator is DelegationManagerU function testFuzz_updateOperatorMetadataUri_revert_notOperator( IDelegationManager.OperatorDetails memory operatorDetails ) public { - cheats.expectRevert("DelegationManager.modifyOperatorDetails: caller must be an operator"); + cheats.expectRevert(IDelegationManager.OperatorDoesNotExist.selector); delegationManager.modifyOperatorDetails(operatorDetails); } @@ -826,7 +822,7 @@ contract DelegationManagerUnitTests_delegateTo is DelegationManagerUnitTests { ISignatureUtils.SignatureWithExpiry memory approverSignatureAndExpiry; cheats.prank(defaultStaker); - cheats.expectRevert("Pausable: index is paused"); + cheats.expectRevert(IPausable.CurrentlyPaused.selector); delegationManager.delegateTo(defaultOperator, approverSignatureAndExpiry, emptySalt); } @@ -849,7 +845,7 @@ contract DelegationManagerUnitTests_delegateTo is DelegationManagerUnitTests { // try to delegate again and check that the call reverts cheats.startPrank(staker); - cheats.expectRevert("DelegationManager.delegateTo: staker is already actively delegated"); + cheats.expectRevert(IDelegationManager.AlreadyDelegated.selector); delegationManager.delegateTo(operator, approverSignatureAndExpiry, salt); cheats.stopPrank(); } @@ -863,7 +859,7 @@ contract DelegationManagerUnitTests_delegateTo is DelegationManagerUnitTests { // try to delegate and check that the call reverts cheats.startPrank(staker); - cheats.expectRevert("DelegationManager.delegateTo: operator is not registered in EigenLayer"); + cheats.expectRevert(IDelegationManager.OperatorDoesNotExist.selector); ISignatureUtils.SignatureWithExpiry memory approverSignatureAndExpiry; delegationManager.delegateTo(operator, approverSignatureAndExpiry, emptySalt); cheats.stopPrank(); @@ -1146,7 +1142,7 @@ contract DelegationManagerUnitTests_delegateTo is DelegationManagerUnitTests { // delegate from the `staker` to the operator cheats.startPrank(staker); - cheats.expectRevert("DelegationManager._delegate: approver signature expired"); + cheats.expectRevert(IDelegationManager.SignatureExpired.selector); delegationManager.delegateTo(defaultOperator, approverSignatureAndExpiry, salt); cheats.stopPrank(); } @@ -1199,7 +1195,7 @@ contract DelegationManagerUnitTests_delegateTo is DelegationManagerUnitTests { "salt somehow spent not spent?" ); delegationManager.undelegate(staker); - cheats.expectRevert("DelegationManager._delegate: approverSalt already spent"); + cheats.expectRevert(IDelegationManager.SignatureSaltSpent.selector); delegationManager.delegateTo(defaultOperator, approverSignatureAndExpiry, salt); cheats.stopPrank(); } @@ -1237,7 +1233,7 @@ contract DelegationManagerUnitTests_delegateTo is DelegationManagerUnitTests { // try to delegate from the `staker` to the operator, and check reversion cheats.startPrank(staker); - cheats.expectRevert("EIP1271SignatureUtils.checkSignature_EIP1271: signature not from signer"); + cheats.expectRevert(EIP1271SignatureUtils.InvalidSignatureEOA.selector); delegationManager.delegateTo(defaultOperator, approverSignatureAndExpiry, emptySalt); cheats.stopPrank(); } @@ -1613,7 +1609,7 @@ contract DelegationManagerUnitTests_delegateTo is DelegationManagerUnitTests { // try to delegate from the `staker` to the operator, and check reversion cheats.startPrank(staker); - cheats.expectRevert("DelegationManager._delegate: approver signature expired"); + cheats.expectRevert(IDelegationManager.SignatureExpired.selector); delegationManager.delegateTo(defaultOperator, approverSignatureAndExpiry, emptySalt); cheats.stopPrank(); } @@ -1652,7 +1648,7 @@ contract DelegationManagerUnitTests_delegateTo is DelegationManagerUnitTests { delegationManager.delegateTo(defaultOperator, approverSignatureAndExpiry, salt); delegationManager.undelegate(staker); // Reusing same signature should revert with salt already being used - cheats.expectRevert("DelegationManager._delegate: approverSalt already spent"); + cheats.expectRevert(IDelegationManager.SignatureSaltSpent.selector); delegationManager.delegateTo(defaultOperator, approverSignatureAndExpiry, salt); cheats.stopPrank(); } @@ -1742,7 +1738,7 @@ contract DelegationManagerUnitTests_delegateTo is DelegationManagerUnitTests { // try to delegate from the `staker` to the operator, and check reversion cheats.startPrank(staker); // Signature should fail as the wallet will not return EIP1271_MAGICVALUE - cheats.expectRevert("EIP1271SignatureUtils.checkSignature_EIP1271: ERC1271 signature verification failed"); + cheats.expectRevert(EIP1271SignatureUtils.InvalidSignatureEIP1271.selector); delegationManager.delegateTo(defaultOperator, approverSignatureAndExpiry, emptySalt); cheats.stopPrank(); } @@ -1845,7 +1841,7 @@ contract DelegationManagerUnitTests_delegateToBySignature is DelegationManagerUn expiry ); ISignatureUtils.SignatureWithExpiry memory approverSignatureAndExpiry; - cheats.expectRevert("Pausable: index is paused"); + cheats.expectRevert(IPausable.CurrentlyPaused.selector); delegationManager.delegateToBySignature( defaultStaker, defaultOperator, @@ -1863,7 +1859,7 @@ contract DelegationManagerUnitTests_delegateToBySignature is DelegationManagerUn bytes memory signature ) public filterFuzzedAddressInputs(staker) filterFuzzedAddressInputs(operator) { expiry = bound(expiry, 0, block.timestamp - 1); - cheats.expectRevert("DelegationManager.delegateToBySignature: staker signature expired"); + cheats.expectRevert(IDelegationManager.SignatureExpired.selector); ISignatureUtils.SignatureWithExpiry memory signatureWithExpiry = ISignatureUtils.SignatureWithExpiry({ signature: signature, expiry: expiry @@ -1888,7 +1884,7 @@ contract DelegationManagerUnitTests_delegateToBySignature is DelegationManagerUn // delegate from the `staker` to the operator, via having the `caller` call `DelegationManager.delegateToBySignature` // Should revert from invalid signature as staker is not set as the address of signer cheats.startPrank(caller); - cheats.expectRevert("EIP1271SignatureUtils.checkSignature_EIP1271: signature not from signer"); + cheats.expectRevert(EIP1271SignatureUtils.InvalidSignatureEOA.selector); // use an empty approver signature input since none is needed / the input is unchecked ISignatureUtils.SignatureWithExpiry memory approverSignatureAndExpiry; delegationManager.delegateToBySignature( @@ -1918,7 +1914,7 @@ contract DelegationManagerUnitTests_delegateToBySignature is DelegationManagerUn // delegate from the `staker` to the operator, via having the `caller` call `DelegationManager.delegateToBySignature` // Should revert from invalid signature as staker is not set as the address of signer cheats.startPrank(caller); - cheats.expectRevert("EIP1271SignatureUtils.checkSignature_EIP1271: ERC1271 signature verification failed"); + cheats.expectRevert(EIP1271SignatureUtils.InvalidSignatureEIP1271.selector); // use an empty approver signature input since none is needed / the input is unchecked ISignatureUtils.SignatureWithExpiry memory approverSignatureAndExpiry; delegationManager.delegateToBySignature( @@ -1949,7 +1945,7 @@ contract DelegationManagerUnitTests_delegateToBySignature is DelegationManagerUn // delegate from the `staker` to the operator, via having the `caller` call `DelegationManager.delegateToBySignature` // Should revert as `staker` has already delegated to `operator` cheats.startPrank(caller); - cheats.expectRevert("DelegationManager.delegateToBySignature: staker is already actively delegated"); + cheats.expectRevert(IDelegationManager.AlreadyDelegated.selector); // use an empty approver signature input since none is needed / the input is unchecked ISignatureUtils.SignatureWithExpiry memory approverSignatureAndExpiry; delegationManager.delegateToBySignature( @@ -1977,7 +1973,7 @@ contract DelegationManagerUnitTests_delegateToBySignature is DelegationManagerUn // delegate from the `staker` to the operator, via having the `caller` call `DelegationManager.delegateToBySignature` // Should revert as `operator` is not registered cheats.startPrank(caller); - cheats.expectRevert("DelegationManager.delegateToBySignature: operator is not registered in EigenLayer"); + cheats.expectRevert(IDelegationManager.OperatorDoesNotExist.selector); // use an empty approver signature input since none is needed / the input is unchecked ISignatureUtils.SignatureWithExpiry memory approverSignatureAndExpiry; delegationManager.delegateToBySignature( @@ -2034,7 +2030,7 @@ contract DelegationManagerUnitTests_delegateToBySignature is DelegationManagerUn // try delegate from the `staker` to the operator, via having the `caller` call `DelegationManager.delegateToBySignature`, and check for reversion cheats.startPrank(caller); - cheats.expectRevert("DelegationManager._delegate: approver signature expired"); + cheats.expectRevert(IDelegationManager.SignatureExpired.selector); delegationManager.delegateToBySignature( defaultStaker, defaultOperator, @@ -2463,7 +2459,7 @@ contract DelegationManagerUnitTests_ShareAdjustment is DelegationManagerUnitTest cheats.assume(invalidCaller != address(eigenPodManagerMock)); cheats.assume(invalidCaller != address(eigenLayerProxyAdmin)); - cheats.expectRevert("DelegationManager: onlyStrategyManagerOrEigenPodManager"); + cheats.expectRevert(IDelegationManager.UnauthorizedCaller.selector); delegationManager.increaseDelegatedShares(invalidCaller, strategyMock, shares); } @@ -2538,7 +2534,7 @@ contract DelegationManagerUnitTests_ShareAdjustment is DelegationManagerUnitTest cheats.assume(invalidCaller != address(eigenPodManagerMock)); cheats.startPrank(invalidCaller); - cheats.expectRevert("DelegationManager: onlyStrategyManagerOrEigenPodManager"); + cheats.expectRevert(IDelegationManager.UnauthorizedCaller.selector); delegationManager.decreaseDelegatedShares(invalidCaller, strategyMock, shares); } @@ -2645,7 +2641,7 @@ contract DelegationManagerUnitTests_Undelegate is DelegationManagerUnitTests { delegationManager.pause(2 ** PAUSED_ENTER_WITHDRAWAL_QUEUE); cheats.prank(staker); - cheats.expectRevert("Pausable: index is paused"); + cheats.expectRevert(IPausable.CurrentlyPaused.selector); delegationManager.undelegate(staker); } @@ -2656,7 +2652,7 @@ contract DelegationManagerUnitTests_Undelegate is DelegationManagerUnitTests { assertFalse(delegationManager.isDelegated(undelegatedStaker), "bad test setup"); cheats.prank(undelegatedStaker); - cheats.expectRevert("DelegationManager.undelegate: staker must be delegated to undelegate"); + cheats.expectRevert(IDelegationManager.NotCurrentlyDelegated.selector); delegationManager.undelegate(undelegatedStaker); } @@ -2665,7 +2661,7 @@ contract DelegationManagerUnitTests_Undelegate is DelegationManagerUnitTests { _registerOperatorWithBaseDetails(operator); cheats.prank(operator); - cheats.expectRevert("DelegationManager.undelegate: operators cannot be undelegated"); + cheats.expectRevert(IDelegationManager.OperatorsCannotUndelegate.selector); delegationManager.undelegate(operator); } @@ -2689,40 +2685,41 @@ contract DelegationManagerUnitTests_Undelegate is DelegationManagerUnitTests { // try to call the `undelegate` function and check for reversion cheats.prank(caller); - cheats.expectRevert("DelegationManager.undelegate: operators cannot be undelegated"); + cheats.expectRevert(IDelegationManager.OperatorsCannotUndelegate.selector); delegationManager.undelegate(defaultOperator); } //TODO: verify that this check is even needed - function test_undelegate_revert_zeroAddress() public { - _registerOperatorWithBaseDetails(defaultOperator); - _delegateToOperatorWhoAcceptsAllStakers(address(0), defaultOperator); - - cheats.prank(address(0)); - cheats.expectRevert("DelegationManager.undelegate: cannot undelegate zero address"); - delegationManager.undelegate(address(0)); - } - - /** - * @notice Verifies that the `undelegate` function has proper access controls (can only be called by the operator who the `staker` has delegated - * to or the operator's `delegationApprover`), or the staker themselves - */ - function testFuzz_undelegate_revert_invalidCaller( - address invalidCaller - ) public filterFuzzedAddressInputs(invalidCaller) { - address staker = address(0x123); - // filter out addresses that are actually allowed to call the function - cheats.assume(invalidCaller != staker); - cheats.assume(invalidCaller != defaultOperator); - cheats.assume(invalidCaller != defaultApprover); + // function test_undelegate_revert_zeroAddress() public { + // _registerOperatorWithBaseDetails(defaultOperator); + // _delegateToOperatorWhoAcceptsAllStakers(address(0), defaultOperator); - _registerOperatorWithDelegationApprover(defaultOperator); - _delegateToOperatorWhoRequiresSig(staker, defaultOperator); + // cheats.prank(address(0)); + // cheats.expectRevert(IDelegationManager.InputAddressZero.selector); + // delegationManager.undelegate(address(0)); + // } - cheats.prank(invalidCaller); - cheats.expectRevert("DelegationManager.undelegate: caller cannot undelegate staker"); - delegationManager.undelegate(staker); - } + //TODO: verify that this check is even needed + // /** + // * @notice Verifies that the `undelegate` function has proper access controls (can only be called by the operator who the `staker` has delegated + // * to or the operator's `delegationApprover`), or the staker themselves + // */ + // function testFuzz_undelegate_revert_invalidCaller( + // address invalidCaller + // ) public filterFuzzedAddressInputs(invalidCaller) { + // address staker = address(0x123); + // // filter out addresses that are actually allowed to call the function + // cheats.assume(invalidCaller != staker); + // cheats.assume(invalidCaller != defaultOperator); + // cheats.assume(invalidCaller != defaultApprover); + + // _registerOperatorWithDelegationApprover(defaultOperator); + // _delegateToOperatorWhoRequiresSig(staker, defaultOperator); + + // cheats.prank(invalidCaller); + // cheats.expectRevert(IDelegationManager.InputAddressZero.selector); + // delegationManager.undelegate(staker); + // } /** * Staker is undelegated from an operator, via a call to `undelegate`, properly originating from the staker's address. @@ -2799,7 +2796,7 @@ contract DelegationManagerUnitTests_queueWithdrawals is DelegationManagerUnitTes strategy: strategyMock, withdrawalAmount: 100 }); - cheats.expectRevert("Pausable: index is paused"); + cheats.expectRevert(IPausable.CurrentlyPaused.selector); delegationManager.queueWithdrawals(queuedWithdrawalParams); } @@ -2817,7 +2814,7 @@ contract DelegationManagerUnitTests_queueWithdrawals is DelegationManagerUnitTes withdrawer: defaultStaker }); - cheats.expectRevert("DelegationManager.queueWithdrawal: input length mismatch"); + cheats.expectRevert(IDelegationManager.InputArrayLengthMismatch.selector); delegationManager.queueWithdrawals(queuedWithdrawalParams); } @@ -2830,7 +2827,7 @@ contract DelegationManagerUnitTests_queueWithdrawals is DelegationManagerUnitTes strategy: strategyMock, withdrawalAmount: 100 }); - cheats.expectRevert("DelegationManager.queueWithdrawal: withdrawer must be staker"); + cheats.expectRevert(IDelegationManager.WithdrawerNotStaker.selector); cheats.prank(defaultStaker); delegationManager.queueWithdrawals(queuedWithdrawalParams); } @@ -2847,7 +2844,7 @@ contract DelegationManagerUnitTests_queueWithdrawals is DelegationManagerUnitTes withdrawer: withdrawer }); - cheats.expectRevert("DelegationManager._removeSharesAndQueueWithdrawal: strategies cannot be empty"); + cheats.expectRevert(IDelegationManager.InputArrayLengthZero.selector); delegationManager.queueWithdrawals(queuedWithdrawalParams); } @@ -3053,7 +3050,7 @@ contract DelegationManagerUnitTests_queueWithdrawals is DelegationManagerUnitTes // if third party transfers were forbidden. Now, withdrawing to a different address is forbidden regardless // of third party transfer status. cheats.expectRevert( - "DelegationManager.queueWithdrawal: withdrawer must be staker" + IDelegationManager.WithdrawerNotStaker.selector ); cheats.prank(staker); delegationManager.queueWithdrawals(queuedWithdrawalParams); @@ -3077,7 +3074,7 @@ contract DelegationManagerUnitTests_completeQueuedWithdrawal is DelegationManage }); _delegateToOperatorWhoAcceptsAllStakers(defaultStaker, defaultOperator); - cheats.expectRevert("Pausable: index is paused"); + cheats.expectRevert(IPausable.CurrentlyPaused.selector); delegationManager.completeQueuedWithdrawal(withdrawal, tokens, 0 /* middlewareTimesIndex */, false); } @@ -3102,7 +3099,7 @@ contract DelegationManagerUnitTests_completeQueuedWithdrawal is DelegationManage assertFalse(delegationManager.pendingWithdrawals(withdrawalRoot), "withdrawalRoot should be completed and marked false now"); cheats.roll(block.number + delegationManager.getWithdrawalDelay(withdrawal.strategies)); - cheats.expectRevert("DelegationManager._completeQueuedWithdrawal: action is not in queue"); + cheats.expectRevert(IDelegationManager.WithdrawalDoesNotExist.selector); cheats.prank(defaultStaker); delegationManager.completeQueuedWithdrawal(withdrawal, tokens, 0 /* middlewareTimesIndex */, false); } @@ -3133,18 +3130,13 @@ contract DelegationManagerUnitTests_completeQueuedWithdrawal is DelegationManage // prank as withdrawer address cheats.startPrank(defaultStaker); - - cheats.expectRevert( - "DelegationManager._completeQueuedWithdrawal: minWithdrawalDelayBlocks period has not yet passed" - ); + cheats.expectRevert(IDelegationManager.WithdrawalDelayNotElapsed.selector); cheats.roll(block.number + minWithdrawalDelayBlocks - 1); delegationManager.completeQueuedWithdrawal(withdrawal, tokens, 0 /* middlewareTimesIndex */, receiveAsTokens); uint256 validBlockNumber = delegationManager.getWithdrawalDelay(withdrawal.strategies); if (validBlockNumber > minWithdrawalDelayBlocks) { - cheats.expectRevert( - "DelegationManager._completeQueuedWithdrawal: withdrawalDelayBlocks period has not yet passed for this strategy" - ); + cheats.expectRevert(IDelegationManager.WithdrawalDelayNotElapsed.selector); cheats.roll(validBlockNumber - 1); delegationManager.completeQueuedWithdrawal(withdrawal, tokens, 0 /* middlewareTimesIndex */, receiveAsTokens); } @@ -3183,16 +3175,14 @@ contract DelegationManagerUnitTests_completeQueuedWithdrawal is DelegationManage // prank as withdrawer address cheats.startPrank(defaultStaker); - cheats.expectRevert( - "DelegationManager._completeQueuedWithdrawal: minWithdrawalDelayBlocks period has not yet passed" - ); + cheats.expectRevert(IDelegationManager.WithdrawalDelayNotElapsed.selector); cheats.roll(block.number + minWithdrawalDelayBlocks - 1); delegationManager.completeQueuedWithdrawal(withdrawal, tokens, 0 /* middlewareTimesIndex */, false); uint256 validBlockNumber = delegationManager.getWithdrawalDelay(withdrawal.strategies); if (validBlockNumber > minWithdrawalDelayBlocks) { cheats.expectRevert( - "DelegationManager._completeQueuedWithdrawal: withdrawalDelayBlocks period has not yet passed for this strategy" + IDelegationManager.WithdrawalDelayNotElapsed.selector ); cheats.roll(validBlockNumber - 1); delegationManager.completeQueuedWithdrawal(withdrawal, tokens, 0 /* middlewareTimesIndex */, false); @@ -3216,7 +3206,7 @@ contract DelegationManagerUnitTests_completeQueuedWithdrawal is DelegationManage _delegateToOperatorWhoAcceptsAllStakers(defaultStaker, defaultOperator); cheats.roll(block.number + delegationManager.getWithdrawalDelay(withdrawal.strategies)); - cheats.expectRevert("DelegationManager._completeQueuedWithdrawal: only withdrawer can complete action"); + cheats.expectRevert(IDelegationManager.UnauthorizedCaller.selector); delegationManager.completeQueuedWithdrawal(withdrawal, tokens, 0 /* middlewareTimesIndex */, false); } @@ -3232,7 +3222,7 @@ contract DelegationManagerUnitTests_completeQueuedWithdrawal is DelegationManage IERC20[] memory tokens = new IERC20[](0); cheats.roll(block.number + delegationManager.getWithdrawalDelay(withdrawal.strategies)); - cheats.expectRevert("DelegationManager._completeQueuedWithdrawal: input length mismatch"); + cheats.expectRevert(IDelegationManager.InputArrayLengthMismatch.selector); cheats.prank(defaultStaker); delegationManager.completeQueuedWithdrawal(withdrawal, tokens, 0 /* middlewareTimesIndex */, true); } diff --git a/src/test/unit/EigenPodManagerUnit.t.sol b/src/test/unit/EigenPodManagerUnit.t.sol index fb490f786a..b86eddb415 100644 --- a/src/test/unit/EigenPodManagerUnit.t.sol +++ b/src/test/unit/EigenPodManagerUnit.t.sol @@ -147,7 +147,7 @@ contract EigenPodManagerUnitTests_CreationTests is EigenPodManagerUnitTests, IEi } function test_createPod_revert_alreadyCreated() public deployPodForStaker(defaultStaker) { - cheats.expectRevert("EigenPodManager.createPod: Sender already has a pod"); + cheats.expectRevert(IEigenPodManager.EigenPodAlreadyExists.selector); eigenPodManager.createPod(); } } @@ -193,20 +193,20 @@ contract EigenPodManagerUnitTests_ShareUpdateTests is EigenPodManagerUnitTests { function testFuzz_addShares_revert_notDelegationManager(address notDelegationManager) public filterFuzzedAddressInputs(notDelegationManager){ cheats.assume(notDelegationManager != address(delegationManagerMock)); cheats.prank(notDelegationManager); - cheats.expectRevert("EigenPodManager.onlyDelegationManager: not the DelegationManager"); + cheats.expectRevert(IEigenPodManager.UnauthorizedCaller.selector); eigenPodManager.addShares(defaultStaker, 0); } function test_addShares_revert_podOwnerZeroAddress() public { cheats.prank(address(delegationManagerMock)); - cheats.expectRevert("EigenPodManager.addShares: podOwner cannot be zero address"); + cheats.expectRevert(IEigenPod.InputAddressZero.selector); eigenPodManager.addShares(address(0), 0); } function testFuzz_addShares_revert_sharesNegative(int256 shares) public { cheats.assume(shares < 0); cheats.prank(address(delegationManagerMock)); - cheats.expectRevert("EigenPodManager.addShares: shares cannot be negative"); + cheats.expectRevert(IEigenPodManager.SharesNegative.selector); eigenPodManager.addShares(defaultStaker, uint256(shares)); } @@ -214,7 +214,7 @@ contract EigenPodManagerUnitTests_ShareUpdateTests is EigenPodManagerUnitTests { cheats.assume(int256(shares) >= 0); cheats.assume(shares % GWEI_TO_WEI != 0); cheats.prank(address(delegationManagerMock)); - cheats.expectRevert("EigenPodManager.addShares: shares must be a whole Gwei amount"); + cheats.expectRevert(IEigenPodManager.SharesNotMultipleOfGwei.selector); eigenPodManager.addShares(defaultStaker, shares); } @@ -239,14 +239,14 @@ contract EigenPodManagerUnitTests_ShareUpdateTests is EigenPodManagerUnitTests { function testFuzz_removeShares_revert_notDelegationManager(address notDelegationManager) public filterFuzzedAddressInputs(notDelegationManager) { cheats.assume(notDelegationManager != address(delegationManagerMock)); cheats.prank(notDelegationManager); - cheats.expectRevert("EigenPodManager.onlyDelegationManager: not the DelegationManager"); + cheats.expectRevert(IEigenPodManager.UnauthorizedCaller.selector); eigenPodManager.removeShares(defaultStaker, 0); } function testFuzz_removeShares_revert_sharesNegative(int256 shares) public { cheats.assume(shares < 0); cheats.prank(address(delegationManagerMock)); - cheats.expectRevert("EigenPodManager.removeShares: shares cannot be negative"); + cheats.expectRevert(IEigenPodManager.SharesNegative.selector); eigenPodManager.removeShares(defaultStaker, uint256(shares)); } @@ -254,7 +254,7 @@ contract EigenPodManagerUnitTests_ShareUpdateTests is EigenPodManagerUnitTests { cheats.assume(int256(shares) >= 0); cheats.assume(shares % GWEI_TO_WEI != 0); cheats.prank(address(delegationManagerMock)); - cheats.expectRevert("EigenPodManager.removeShares: shares must be a whole Gwei amount"); + cheats.expectRevert(IEigenPodManager.SharesNotMultipleOfGwei.selector); eigenPodManager.removeShares(defaultStaker, shares); } @@ -269,7 +269,7 @@ contract EigenPodManagerUnitTests_ShareUpdateTests is EigenPodManagerUnitTests { // Remove shares cheats.prank(address(delegationManagerMock)); - cheats.expectRevert("EigenPodManager.removeShares: cannot result in pod owner having negative shares"); + cheats.expectRevert(IEigenPodManager.SharesNegative.selector); eigenPodManager.removeShares(defaultStaker, sharesRemoved); } @@ -314,20 +314,20 @@ contract EigenPodManagerUnitTests_ShareUpdateTests is EigenPodManagerUnitTests { function test_withdrawSharesAsTokens_revert_podOwnerZeroAddress() public { cheats.prank(address(delegationManagerMock)); - cheats.expectRevert("EigenPodManager.withdrawSharesAsTokens: podOwner cannot be zero address"); + cheats.expectRevert(IEigenPod.InputAddressZero.selector); eigenPodManager.withdrawSharesAsTokens(address(0), address(0), 0); } function test_withdrawSharesAsTokens_revert_destinationZeroAddress() public { cheats.prank(address(delegationManagerMock)); - cheats.expectRevert("EigenPodManager.withdrawSharesAsTokens: destination cannot be zero address"); + cheats.expectRevert(IEigenPod.InputAddressZero.selector); eigenPodManager.withdrawSharesAsTokens(defaultStaker, address(0), 0); } function testFuzz_withdrawSharesAsTokens_revert_sharesNegative(int256 shares) public { cheats.assume(shares < 0); cheats.prank(address(delegationManagerMock)); - cheats.expectRevert("EigenPodManager.withdrawSharesAsTokens: shares cannot be negative"); + cheats.expectRevert(IEigenPodManager.SharesNegative.selector); eigenPodManager.withdrawSharesAsTokens(defaultStaker, defaultStaker, uint256(shares)); } @@ -336,7 +336,7 @@ contract EigenPodManagerUnitTests_ShareUpdateTests is EigenPodManagerUnitTests { cheats.assume(shares % GWEI_TO_WEI != 0); cheats.prank(address(delegationManagerMock)); - cheats.expectRevert("EigenPodManager.withdrawSharesAsTokens: shares must be a whole Gwei amount"); + cheats.expectRevert(IEigenPodManager.SharesNotMultipleOfGwei.selector); eigenPodManager.withdrawSharesAsTokens(defaultStaker, defaultStaker, shares); } @@ -399,21 +399,21 @@ contract EigenPodManagerUnitTests_BeaconChainETHBalanceUpdateTests is EigenPodMa function testFuzz_recordBalanceUpdate_revert_notPod(address invalidCaller) public filterFuzzedAddressInputs(invalidCaller) deployPodForStaker(defaultStaker) { cheats.assume(invalidCaller != address(defaultPod)); cheats.prank(invalidCaller); - cheats.expectRevert("EigenPodManager.onlyEigenPod: not a pod"); + cheats.expectRevert(IEigenPodManager.UnauthorizedCaller.selector); eigenPodManager.recordBeaconChainETHBalanceUpdate(defaultStaker, 0); } function test_recordBalanceUpdate_revert_zeroAddress() public { IEigenPod zeroAddressPod = _deployAndReturnEigenPodForStaker(address(0)); cheats.prank(address(zeroAddressPod)); - cheats.expectRevert("EigenPodManager.recordBeaconChainETHBalanceUpdate: podOwner cannot be zero address"); + cheats.expectRevert(IEigenPod.InputAddressZero.selector); eigenPodManager.recordBeaconChainETHBalanceUpdate(address(0), 0); } function testFuzz_recordBalanceUpdate_revert_nonWholeGweiAmount(int256 sharesDelta) public deployPodForStaker(defaultStaker) { cheats.assume(sharesDelta % int256(GWEI_TO_WEI) != 0); cheats.prank(address(defaultPod)); - cheats.expectRevert("EigenPodManager.recordBeaconChainETHBalanceUpdate: sharesDelta must be a whole Gwei amount"); + cheats.expectRevert(IEigenPodManager.SharesNotMultipleOfGwei.selector); eigenPodManager.recordBeaconChainETHBalanceUpdate(defaultStaker, sharesDelta); } diff --git a/src/test/unit/EigenPodUnit.t.sol b/src/test/unit/EigenPodUnit.t.sol index 8b49ad4291..375c1b3738 100644 --- a/src/test/unit/EigenPodUnit.t.sol +++ b/src/test/unit/EigenPodUnit.t.sol @@ -360,7 +360,7 @@ contract EigenPodUnitTests_Initialization is EigenPodUnitTests { // un-initialize pod cheats.store(address(pod), 0, 0); - cheats.expectRevert("EigenPod.initialize: podOwner cannot be zero address"); + cheats.expectRevert(IEigenPod.InputAddressZero.selector); pod.initialize(address(0)); } @@ -370,7 +370,7 @@ contract EigenPodUnitTests_Initialization is EigenPodUnitTests { cheats.assume(invalidCaller != address(staker)); cheats.prank(invalidCaller); - cheats.expectRevert("EigenPod.onlyEigenPodOwner: not podOwner"); + cheats.expectRevert(IEigenPod.UnauthorizedCaller.selector); pod.setProofSubmitter(invalidCaller); } @@ -405,7 +405,7 @@ contract EigenPodUnitTests_EPMFunctions is EigenPodUnitTests { cheats.deal(invalidCaller, 32 ether); cheats.prank(invalidCaller); - cheats.expectRevert("EigenPod.onlyEigenPodManager: not eigenPodManager"); + cheats.expectRevert(IEigenPod.UnauthorizedCaller.selector); eigenPod.stake{value: 32 ether}(pubkey, signature, depositDataRoot); } @@ -415,7 +415,7 @@ contract EigenPodUnitTests_EPMFunctions is EigenPodUnitTests { cheats.deal(address(eigenPodManagerMock), value); cheats.prank(address(eigenPodManagerMock)); - cheats.expectRevert("EigenPod.stake: must initially stake for any validator with 32 ether"); + cheats.expectRevert(IEigenPod.MsgValueNot32ETH.selector); eigenPod.stake{value: value}(pubkey, signature, depositDataRoot); } @@ -450,7 +450,7 @@ contract EigenPodUnitTests_EPMFunctions is EigenPodUnitTests { // ensure invalid caller causing revert cheats.assume(invalidCaller != address(eigenPodManagerMock)); cheats.prank(invalidCaller); - cheats.expectRevert("EigenPod.onlyEigenPodManager: not eigenPodManager"); + cheats.expectRevert(IEigenPod.UnauthorizedCaller.selector); pod.withdrawRestakedBeaconChainETH(recipient, randAmount); } @@ -469,7 +469,7 @@ contract EigenPodUnitTests_EPMFunctions is EigenPodUnitTests { // ensure amount is not a full gwei randAmount = (randAmount % 1 gwei) + bound(randAmount, 1, 1 gwei - 1); - cheats.expectRevert("EigenPod.withdrawRestakedBeaconChainETH: amountWei must be a whole Gwei amount"); + cheats.expectRevert(IEigenPod.AmountMustBeMultipleOfGwei.selector); cheats.prank(address(eigenPodManagerMock)); pod.withdrawRestakedBeaconChainETH(recipient, randAmount); } @@ -492,9 +492,7 @@ contract EigenPodUnitTests_EPMFunctions is EigenPodUnitTests { uint64 withdrawableRestakedExecutionLayerGwei = pod.withdrawableRestakedExecutionLayerGwei(); randAmountWei = randAmountWei - (randAmountWei % 1 gwei); cheats.assume((randAmountWei / 1 gwei) > withdrawableRestakedExecutionLayerGwei); - cheats.expectRevert( - "EigenPod.withdrawRestakedBeaconChainETH: amountGwei exceeds withdrawableRestakedExecutionLayerGwei" - ); + cheats.expectRevert(IEigenPod.InsufficientWithdrawableBalance.selector); cheats.prank(address(eigenPodManagerMock)); pod.withdrawRestakedBeaconChainETH(recipient, randAmountWei); } @@ -556,7 +554,7 @@ contract EigenPodUnitTests_recoverTokens is EigenPodUnitTests { amounts[0] = 1; cheats.prank(invalidCaller); - cheats.expectRevert("EigenPod.onlyEigenPodOwner: not podOwner"); + cheats.expectRevert(IEigenPod.UnauthorizedCaller.selector); pod.recoverTokens(tokens, amounts, podOwner); } @@ -575,7 +573,7 @@ contract EigenPodUnitTests_recoverTokens is EigenPodUnitTests { eigenPodManagerMock.pause(1 << PAUSED_NON_PROOF_WITHDRAWALS); cheats.prank(podOwner); - cheats.expectRevert("EigenPod.onlyWhenNotPaused: index is paused in EigenPodManager"); + cheats.expectRevert(IEigenPod.CurrentlyPaused.selector); pod.recoverTokens(tokens, amounts, podOwner); } @@ -591,7 +589,7 @@ contract EigenPodUnitTests_recoverTokens is EigenPodUnitTests { amounts[1] = 1; cheats.startPrank(podOwner); - cheats.expectRevert("EigenPod.recoverTokens: tokenList and amountsToWithdraw must be same length"); + cheats.expectRevert(IEigenPod.InputArrayLengthMismatch.selector); pod.recoverTokens(tokens, amounts, podOwner); cheats.stopPrank(); } @@ -638,9 +636,7 @@ contract EigenPodUnitTests_verifyWithdrawalCredentials is EigenPodUnitTests, Pro cheats.assume(invalidCaller != podOwner && invalidCaller != proofSubmitter); cheats.prank(invalidCaller); - cheats.expectRevert( - "EigenPod.onlyOwnerOrProofSubmitter: caller is not pod owner or proof submitter" - ); + cheats.expectRevert(IEigenPod.UnauthorizedCaller.selector); pod.verifyWithdrawalCredentials({ beaconTimestamp: proofs.beaconTimestamp, @@ -659,7 +655,7 @@ contract EigenPodUnitTests_verifyWithdrawalCredentials is EigenPodUnitTests, Pro cheats.prank(pauser); eigenPodManagerMock.pause(2 ** PAUSED_EIGENPODS_VERIFY_CREDENTIALS); - cheats.expectRevert("EigenPod.onlyWhenNotPaused: index is paused in EigenPodManager"); + cheats.expectRevert(IEigenPod.CurrentlyPaused.selector); staker.verifyWithdrawalCredentials(validators); } @@ -679,7 +675,7 @@ contract EigenPodUnitTests_verifyWithdrawalCredentials is EigenPodUnitTests, Pro staker.startCheckpoint(); // Try to verify withdrawal credentials at the current block - cheats.expectRevert("EigenPod.verifyWithdrawalCredentials: specified timestamp is too far in past"); + cheats.expectRevert(IEigenPod.BeaconTimestampTooFarInPast.selector); staker.verifyWithdrawalCredentials(validators); } @@ -695,7 +691,7 @@ contract EigenPodUnitTests_verifyWithdrawalCredentials is EigenPodUnitTests, Pro bytes32[][] memory invalidValidatorFields = new bytes32[][](proofs.validatorFields.length + 1); cheats.startPrank(address(staker)); - cheats.expectRevert("EigenPod.verifyWithdrawalCredentials: validatorIndices and proofs must be same length"); + cheats.expectRevert(IEigenPod.InputArrayLengthMismatch.selector); pod.verifyWithdrawalCredentials({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: proofs.stateRootProof, @@ -704,7 +700,7 @@ contract EigenPodUnitTests_verifyWithdrawalCredentials is EigenPodUnitTests, Pro validatorFields: proofs.validatorFields }); - cheats.expectRevert("EigenPod.verifyWithdrawalCredentials: validatorIndices and proofs must be same length"); + cheats.expectRevert(IEigenPod.InputArrayLengthMismatch.selector); pod.verifyWithdrawalCredentials({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: proofs.stateRootProof, @@ -713,7 +709,7 @@ contract EigenPodUnitTests_verifyWithdrawalCredentials is EigenPodUnitTests, Pro validatorFields: proofs.validatorFields }); - cheats.expectRevert("EigenPod.verifyWithdrawalCredentials: validatorIndices and proofs must be same length"); + cheats.expectRevert(IEigenPod.InputArrayLengthMismatch.selector); pod.verifyWithdrawalCredentials({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: proofs.stateRootProof, @@ -738,9 +734,8 @@ contract EigenPodUnitTests_verifyWithdrawalCredentials is EigenPodUnitTests, Pro proof: proofWithInvalidLength }); - cheats.startPrank(address(staker)); - cheats.expectRevert("BeaconChainProofs.verifyStateRoot: Proof has incorrect length"); + cheats.expectRevert(BeaconChainProofs.InvalidProofLength.selector); pod.verifyWithdrawalCredentials({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: invalidStateRootProof, @@ -754,7 +749,7 @@ contract EigenPodUnitTests_verifyWithdrawalCredentials is EigenPodUnitTests, Pro uint256 proofLength = proofs.stateRootProof.proof.length; uint256 randIndex = bound(rand, 0, proofLength - 1); proofs.stateRootProof.proof[randIndex] = randValue; - cheats.expectRevert("BeaconChainProofs.verifyStateRoot: Invalid state root merkle proof"); + cheats.expectRevert(BeaconChainProofs.InvalidProof.selector); pod.verifyWithdrawalCredentials({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: proofs.stateRootProof, @@ -773,9 +768,7 @@ contract EigenPodUnitTests_verifyWithdrawalCredentials is EigenPodUnitTests, Pro staker.verifyWithdrawalCredentials(validators); // now that validators are ACTIVE, ensure we can't verify them again - cheats.expectRevert( - "EigenPod._verifyWithdrawalCredentials: validator must be inactive to prove withdrawal credentials" - ); + cheats.expectRevert(IEigenPod.CredentialsAlreadyVerified.selector); staker.verifyWithdrawalCredentials(validators); staker.exitValidators(validators); @@ -786,9 +779,7 @@ contract EigenPodUnitTests_verifyWithdrawalCredentials is EigenPodUnitTests, Pro beaconChain.advanceEpoch_NoRewards(); // now that validators are WITHDRAWN, ensure we can't verify them again - cheats.expectRevert( - "EigenPod._verifyWithdrawalCredentials: validator must be inactive to prove withdrawal credentials" - ); + cheats.expectRevert(IEigenPod.CredentialsAlreadyVerified.selector); staker.verifyWithdrawalCredentials(validators); } @@ -803,9 +794,7 @@ contract EigenPodUnitTests_verifyWithdrawalCredentials is EigenPodUnitTests, Pro beaconChain.advanceEpoch(); // now that validators are exited, ensure we can't verify them - cheats.expectRevert( - "EigenPod._verifyWithdrawalCredentials: validator must not be exiting" - ); + cheats.expectRevert(IEigenPod.ValidatorIsExitingBeaconChain.selector); staker.verifyWithdrawalCredentials(validators); } @@ -821,7 +810,7 @@ contract EigenPodUnitTests_verifyWithdrawalCredentials is EigenPodUnitTests, Pro proofs.validatorFields[0][VALIDATOR_WITHDRAWAL_CREDENTIALS_INDEX] = invalidWithdrawalCredentials; cheats.startPrank(address(staker)); - cheats.expectRevert("EigenPod._verifyWithdrawalCredentials: proof is not for this EigenPod"); + cheats.expectRevert(IEigenPod.WithdrawCredentialsNotForEigenPod.selector); pod.verifyWithdrawalCredentials({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: proofs.stateRootProof, @@ -847,7 +836,7 @@ contract EigenPodUnitTests_verifyWithdrawalCredentials is EigenPodUnitTests, Pro proofs.validatorFields[0] = invalidValidatorFields; cheats.startPrank(address(staker)); - cheats.expectRevert("BeaconChainProofs.verifyValidatorFields: Validator fields has incorrect length"); + cheats.expectRevert(BeaconChainProofs.InvalidValidatorFieldsLength.selector); pod.verifyWithdrawalCredentials({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: proofs.stateRootProof, @@ -869,7 +858,7 @@ contract EigenPodUnitTests_verifyWithdrawalCredentials is EigenPodUnitTests, Pro = _toLittleEndianUint64(BeaconChainProofs.FAR_FUTURE_EPOCH); cheats.startPrank(address(staker)); - cheats.expectRevert("EigenPod._verifyWithdrawalCredentials: validator must be in the process of activating"); + cheats.expectRevert(IEigenPod.ValidatorInactiveOnBeaconChain.selector); pod.verifyWithdrawalCredentials({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: proofs.stateRootProof, @@ -891,7 +880,7 @@ contract EigenPodUnitTests_verifyWithdrawalCredentials is EigenPodUnitTests, Pro proofs.validatorFieldsProofs[0] = new bytes(proofs.validatorFieldsProofs[0].length + 32); cheats.startPrank(address(staker)); - cheats.expectRevert("BeaconChainProofs.verifyValidatorFields: Proof has incorrect length"); + cheats.expectRevert(BeaconChainProofs.InvalidProofLength.selector); pod.verifyWithdrawalCredentials({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: proofs.stateRootProof, @@ -914,7 +903,7 @@ contract EigenPodUnitTests_verifyWithdrawalCredentials is EigenPodUnitTests, Pro proofs.validatorFields[0][VALIDATOR_PUBKEY_INDEX] = randPubkey; cheats.startPrank(address(staker)); - cheats.expectRevert("BeaconChainProofs.verifyValidatorFields: Invalid merkle proof"); + cheats.expectRevert(BeaconChainProofs.InvalidProof.selector); pod.verifyWithdrawalCredentials({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: proofs.stateRootProof, @@ -992,9 +981,7 @@ contract EigenPodUnitTests_startCheckpoint is EigenPodUnitTests { cheats.assume(invalidCaller != podOwner && invalidCaller != proofSubmitter); cheats.prank(invalidCaller); - cheats.expectRevert( - "EigenPod.onlyOwnerOrProofSubmitter: caller is not pod owner or proof submitter" - ); + cheats.expectRevert(IEigenPod.UnauthorizedCaller.selector); pod.startCheckpoint({ revertIfNoBalance: false }); } @@ -1007,7 +994,7 @@ contract EigenPodUnitTests_startCheckpoint is EigenPodUnitTests { cheats.prank(pauser); eigenPodManagerMock.pause(2 ** PAUSED_START_CHECKPOINT); - cheats.expectRevert("EigenPod.onlyWhenNotPaused: index is paused in EigenPodManager"); + cheats.expectRevert(IEigenPod.CurrentlyPaused.selector); staker.startCheckpoint(); } @@ -1018,7 +1005,7 @@ contract EigenPodUnitTests_startCheckpoint is EigenPodUnitTests { (uint40[] memory validators,) = staker.startValidators(); staker.verifyWithdrawalCredentials(validators); staker.startCheckpoint(); - cheats.expectRevert("EigenPod._startCheckpoint: must finish previous checkpoint before starting another"); + cheats.expectRevert(IEigenPod.CheckpointAlreadyActive.selector); staker.startCheckpoint(); } @@ -1031,7 +1018,7 @@ contract EigenPodUnitTests_startCheckpoint is EigenPodUnitTests { staker.startCheckpoint(); staker.completeCheckpoint(); - cheats.expectRevert("EigenPod._startCheckpoint: cannot checkpoint twice in one block"); + cheats.expectRevert(IEigenPod.CannotCheckpointTwiceInSingleBlock.selector); staker.startCheckpoint(); } @@ -1045,7 +1032,7 @@ contract EigenPodUnitTests_startCheckpoint is EigenPodUnitTests { beaconChain.advanceEpoch_NoRewards(); cheats.prank(pod.podOwner()); - cheats.expectRevert("EigenPod._startCheckpoint: no balance available to checkpoint"); + cheats.expectRevert(IEigenPod.NoBalanceToCheckpoint.selector); pod.startCheckpoint({ revertIfNoBalance: true }); } @@ -1099,7 +1086,7 @@ contract EigenPodUnitTests_verifyCheckpointProofs is EigenPodUnitTests { cheats.prank(pauser); eigenPodManagerMock.pause(2 ** PAUSED_EIGENPODS_VERIFY_CHECKPOINT_PROOFS); - cheats.expectRevert("EigenPod.onlyWhenNotPaused: index is paused in EigenPodManager"); + cheats.expectRevert(IEigenPod.CurrentlyPaused.selector); pod.verifyCheckpointProofs({ balanceContainerProof: proofs.balanceContainerProof, proofs: proofs.balanceProofs @@ -1117,9 +1104,7 @@ contract EigenPodUnitTests_verifyCheckpointProofs is EigenPodUnitTests { validators, pod.currentCheckpointTimestamp() ); - cheats.expectRevert( - "EigenPod.verifyCheckpointProofs: must have active checkpoint to perform checkpoint proof" - ); + cheats.expectRevert(IEigenPod.NoActiveCheckpoint.selector); pod.verifyCheckpointProofs({ balanceContainerProof: proofs.balanceContainerProof, proofs: proofs.balanceProofs @@ -1143,7 +1128,7 @@ contract EigenPodUnitTests_verifyCheckpointProofs is EigenPodUnitTests { // change the length of balanceContainerProof to cause a revert proofs.balanceContainerProof.proof = new bytes(proofs.balanceContainerProof.proof.length + 1); - cheats.expectRevert("BeaconChainProofs.verifyBalanceContainer: Proof has incorrect length"); + cheats.expectRevert(BeaconChainProofs.InvalidProofLength.selector); pod.verifyCheckpointProofs({ balanceContainerProof: proofs.balanceContainerProof, proofs: proofs.balanceProofs @@ -1169,7 +1154,7 @@ contract EigenPodUnitTests_verifyCheckpointProofs is EigenPodUnitTests { bytes1 randValue = bytes1(keccak256(abi.encodePacked(proofs.balanceContainerProof.proof[0]))); proofs.balanceContainerProof.proof[0] = randValue; - cheats.expectRevert("BeaconChainProofs.verifyBalanceContainer: invalid balance container proof"); + cheats.expectRevert(BeaconChainProofs.InvalidProof.selector); pod.verifyCheckpointProofs({ balanceContainerProof: proofs.balanceContainerProof, proofs: proofs.balanceProofs @@ -1193,7 +1178,7 @@ contract EigenPodUnitTests_verifyCheckpointProofs is EigenPodUnitTests { // change the length of balance proof to cause a revert proofs.balanceProofs[0].proof = new bytes(proofs.balanceProofs[0].proof.length + 1); - cheats.expectRevert("BeaconChainProofs.verifyValidatorBalance: Proof has incorrect length"); + cheats.expectRevert(BeaconChainProofs.InvalidProofLength.selector); pod.verifyCheckpointProofs({ balanceContainerProof: proofs.balanceContainerProof, proofs: proofs.balanceProofs @@ -1218,7 +1203,7 @@ contract EigenPodUnitTests_verifyCheckpointProofs is EigenPodUnitTests { bytes1 randValue = bytes1(keccak256(abi.encodePacked(proofs.balanceProofs[0].proof[0]))); proofs.balanceProofs[0].proof[0] = randValue; - cheats.expectRevert("BeaconChainProofs.verifyValidatorBalance: Invalid merkle proof"); + cheats.expectRevert(BeaconChainProofs.InvalidProof.selector); pod.verifyCheckpointProofs({ balanceContainerProof: proofs.balanceContainerProof, proofs: proofs.balanceProofs @@ -1446,7 +1431,7 @@ contract EigenPodUnitTests_verifyStaleBalance is EigenPodUnitTests { cheats.prank(pauser); eigenPodManagerMock.pause(2 ** PAUSED_VERIFY_STALE_BALANCE); - cheats.expectRevert("EigenPod.onlyWhenNotPaused: index is paused in EigenPodManager"); + cheats.expectRevert(IEigenPod.CurrentlyPaused.selector); pod.verifyStaleBalance({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: proofs.stateRootProof, @@ -1463,7 +1448,7 @@ contract EigenPodUnitTests_verifyStaleBalance is EigenPodUnitTests { cheats.prank(pauser); eigenPodManagerMock.pause(2 ** PAUSED_START_CHECKPOINT); - cheats.expectRevert("EigenPod.onlyWhenNotPaused: index is paused in EigenPodManager"); + cheats.expectRevert(IEigenPod.CurrentlyPaused.selector); pod.verifyStaleBalance({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: proofs.stateRootProof, @@ -1487,7 +1472,7 @@ contract EigenPodUnitTests_verifyStaleBalance is EigenPodUnitTests { uint64 lastCheckpointTimestamp = pod.lastCheckpointTimestamp(); // proof for given beaconTimestamp is not yet stale, this should revert StaleBalanceProofs memory proofs = beaconChain.getStaleBalanceProofs(validator); - cheats.expectRevert("EigenPod.verifyStaleBalance: proof is older than last checkpoint"); + cheats.expectRevert(IEigenPod.BeaconTimestampTooFarInPast.selector); pod.verifyStaleBalance({ beaconTimestamp: lastCheckpointTimestamp, stateRootProof: proofs.stateRootProof, @@ -1508,7 +1493,7 @@ contract EigenPodUnitTests_verifyStaleBalance is EigenPodUnitTests { // proof for given beaconTimestamp is not yet stale, this should revert StaleBalanceProofs memory proofs = beaconChain.getStaleBalanceProofs(validator); - cheats.expectRevert("EigenPod.verifyStaleBalance: proof is older than last checkpoint"); + cheats.expectRevert(IEigenPod.BeaconTimestampTooFarInPast.selector); pod.verifyStaleBalance({ beaconTimestamp: 0, stateRootProof: proofs.stateRootProof, @@ -1529,7 +1514,7 @@ contract EigenPodUnitTests_verifyStaleBalance is EigenPodUnitTests { beaconChain.advanceEpoch(); StaleBalanceProofs memory proofs = beaconChain.getStaleBalanceProofs(validator); - cheats.expectRevert("EigenPod.verifyStaleBalance: validator is not active"); + cheats.expectRevert(IEigenPod.ValidatorNotActiveInPod.selector); pod.verifyStaleBalance({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: proofs.stateRootProof, @@ -1551,7 +1536,7 @@ contract EigenPodUnitTests_verifyStaleBalance is EigenPodUnitTests { beaconChain.advanceEpoch(); StaleBalanceProofs memory proofs = beaconChain.getStaleBalanceProofs(validator); - cheats.expectRevert("EigenPod.verifyStaleBalance: validator must be slashed to be marked stale"); + cheats.expectRevert(IEigenPod.ValidatorNotSlashedOnBeaconChain.selector); pod.verifyStaleBalance({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: proofs.stateRootProof, @@ -1580,7 +1565,7 @@ contract EigenPodUnitTests_verifyStaleBalance is EigenPodUnitTests { proof: proofWithInvalidLength }); - cheats.expectRevert("BeaconChainProofs.verifyStateRoot: Proof has incorrect length"); + cheats.expectRevert(BeaconChainProofs.InvalidProofLength.selector); pod.verifyStaleBalance({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: invalidStateRootProof, @@ -1608,7 +1593,7 @@ contract EigenPodUnitTests_verifyStaleBalance is EigenPodUnitTests { uint256 randIndex = bound(rand, 0, proofLength - 1); proofs.stateRootProof.proof[randIndex] = randValue; - cheats.expectRevert("BeaconChainProofs.verifyStateRoot: Invalid state root merkle proof"); + cheats.expectRevert(BeaconChainProofs.InvalidProof.selector); pod.verifyStaleBalance({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: proofs.stateRootProof, @@ -1639,7 +1624,7 @@ contract EigenPodUnitTests_verifyStaleBalance is EigenPodUnitTests { validatorFields: proofs.validatorProof.validatorFields, proof: invalidProof }); - cheats.expectRevert("BeaconChainProofs.verifyValidatorFields: Proof has incorrect length"); + cheats.expectRevert(BeaconChainProofs.InvalidProofLength.selector); pod.verifyStaleBalance({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: proofs.stateRootProof, @@ -1653,7 +1638,7 @@ contract EigenPodUnitTests_verifyStaleBalance is EigenPodUnitTests { } proofs.validatorProof.validatorFields = validatorFieldsInvalidLength; - cheats.expectRevert("BeaconChainProofs.verifyValidatorFields: Validator fields has incorrect length"); + cheats.expectRevert(BeaconChainProofs.InvalidValidatorFieldsLength.selector); pod.verifyStaleBalance({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: proofs.stateRootProof, @@ -1682,7 +1667,7 @@ contract EigenPodUnitTests_verifyStaleBalance is EigenPodUnitTests { uint256 VALIDATOR_WITHDRAWAL_CREDENTIALS_INDEX = 1; proofs.validatorProof.validatorFields[VALIDATOR_WITHDRAWAL_CREDENTIALS_INDEX] = randWithdrawalCredentials; - cheats.expectRevert("BeaconChainProofs.verifyValidatorFields: Invalid merkle proof"); + cheats.expectRevert(BeaconChainProofs.InvalidProof.selector); pod.verifyStaleBalance({ beaconTimestamp: proofs.beaconTimestamp, stateRootProof: proofs.stateRootProof, diff --git a/src/test/unit/PausableUnit.t.sol b/src/test/unit/PausableUnit.t.sol index f848d98a42..dde98ab98b 100644 --- a/src/test/unit/PausableUnit.t.sol +++ b/src/test/unit/PausableUnit.t.sol @@ -34,14 +34,14 @@ contract PausableUnitTests is Test { } function testCannotReinitialize(address _pauserRegistry, uint256 _initPausedStatus) public { - cheats.expectRevert(bytes("Pausable._initializePauser: _initializePauser() can only be called once")); + cheats.expectRevert(IPausable.InputAddressZero.selector); pausable.initializePauser(PauserRegistry(_pauserRegistry), _initPausedStatus); } function testCannotInitializeWithZeroAddress(uint256 _initPausedStatus) public { address _pauserRegistry = address(0); pausable = new PausableHarness(); - cheats.expectRevert(bytes("Pausable._initializePauser: _initializePauser() can only be called once")); + cheats.expectRevert(IPausable.InputAddressZero.selector); pausable.initializePauser(PauserRegistry(_pauserRegistry), _initPausedStatus); } @@ -70,7 +70,7 @@ contract PausableUnitTests is Test { cheats.assume(notPauser != pauser); cheats.startPrank(notPauser); - cheats.expectRevert(bytes("msg.sender is not permissioned as pauser")); + cheats.expectRevert(IPausable.OnlyPauser.selector); pausable.pause(newPausedStatus); cheats.stopPrank(); } @@ -97,7 +97,7 @@ contract PausableUnitTests is Test { cheats.assume(notPauser != pauser); cheats.startPrank(notPauser); - cheats.expectRevert(bytes("msg.sender is not permissioned as pauser")); + cheats.expectRevert(IPausable.OnlyPauser.selector); pausable.pauseAll(); cheats.stopPrank(); } @@ -115,7 +115,7 @@ contract PausableUnitTests is Test { require(pausable.paused() == previousPausedStatus, "previousPausedStatus not set correctly"); cheats.startPrank(pauser); - cheats.expectRevert(bytes("Pausable.pause: invalid attempt to unpause functionality")); + cheats.expectRevert(IPausable.InvalidNewPausedStatus.selector); pausable.pause(newPausedStatus); cheats.stopPrank(); } @@ -151,7 +151,7 @@ contract PausableUnitTests is Test { cheats.assume(notUnpauser != pausable.pauserRegistry().unpauser()); cheats.startPrank(notUnpauser); - cheats.expectRevert(bytes("msg.sender is not permissioned as unpauser")); + cheats.expectRevert(IPausable.OnlyUnpauser.selector); pausable.unpause(newPausedStatus); cheats.stopPrank(); } @@ -168,7 +168,7 @@ contract PausableUnitTests is Test { require(pausable.paused() == previousPausedStatus, "previousPausedStatus not set correctly"); cheats.startPrank(pausable.pauserRegistry().unpauser()); - cheats.expectRevert(bytes("Pausable.unpause: invalid attempt to pause functionality")); + cheats.expectRevert(IPausable.InvalidNewPausedStatus.selector); pausable.unpause(newPausedStatus); cheats.stopPrank(); } diff --git a/src/test/unit/PauserRegistryUnit.t.sol b/src/test/unit/PauserRegistryUnit.t.sol index 22e54c4493..49e107167a 100644 --- a/src/test/unit/PauserRegistryUnit.t.sol +++ b/src/test/unit/PauserRegistryUnit.t.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.27; import "forge-std/Test.sol"; +import "../../contracts/interfaces/IPausable.sol"; import "../../contracts/permissions/PauserRegistry.sol"; contract PauserRegistryUnitTests is Test { @@ -66,7 +67,7 @@ contract PauserRegistryUnitTests is Test { cheats.assume(newPauser != address(0)); cheats.startPrank(notUnpauser); - cheats.expectRevert(bytes("msg.sender is not permissioned as unpauser")); + cheats.expectRevert(IPausable.OnlyUnpauser.selector); pauserRegistry.setIsPauser(newPauser, true); cheats.stopPrank(); } @@ -76,7 +77,7 @@ contract PauserRegistryUnitTests is Test { cheats.assume(newUnpauser != address(0)); cheats.startPrank(notUnpauser); - cheats.expectRevert(bytes("msg.sender is not permissioned as unpauser")); + cheats.expectRevert(IPausable.OnlyUnpauser.selector); pauserRegistry.setUnpauser(newUnpauser); cheats.stopPrank(); } @@ -85,7 +86,7 @@ contract PauserRegistryUnitTests is Test { address newPauser = address(0); cheats.startPrank(pauserRegistry.unpauser()); - cheats.expectRevert(bytes("PauserRegistry._setPauser: zero address input")); + cheats.expectRevert(IPauserRegistry.InputAddressZero.selector); pauserRegistry.setIsPauser(newPauser, true); cheats.stopPrank(); } @@ -94,7 +95,7 @@ contract PauserRegistryUnitTests is Test { address newUnpauser = address(0); cheats.startPrank(pauserRegistry.unpauser()); - cheats.expectRevert(bytes("PauserRegistry._setUnpauser: zero address input")); + cheats.expectRevert(IPauserRegistry.InputAddressZero.selector); pauserRegistry.setUnpauser(newUnpauser); cheats.stopPrank(); } diff --git a/src/test/unit/RewardsCoordinatorUnit.t.sol b/src/test/unit/RewardsCoordinatorUnit.t.sol index 933dbb6a01..dc4e191be3 100644 --- a/src/test/unit/RewardsCoordinatorUnit.t.sol +++ b/src/test/unit/RewardsCoordinatorUnit.t.sol @@ -386,7 +386,7 @@ contract RewardsCoordinatorUnitTests_createAVSRewardsSubmission is RewardsCoordi cheats.prank(pauser); rewardsCoordinator.pause(2 ** PAUSED_AVS_REWARDS_SUBMISSION); - cheats.expectRevert("Pausable: index is paused"); + cheats.expectRevert(IPausable.CurrentlyPaused.selector); IRewardsCoordinator.RewardsSubmission[] memory rewardsSubmissions; rewardsCoordinator.createAVSRewardsSubmission(rewardsSubmissions); } @@ -456,7 +456,7 @@ contract RewardsCoordinatorUnitTests_createAVSRewardsSubmission is RewardsCoordi // 3. call createAVSRewardsSubmission() with expected revert cheats.prank(avs); - cheats.expectRevert("RewardsCoordinator._validateRewardsSubmission: no strategies set"); + cheats.expectRevert(IRewardsCoordinator.InputArrayLengthZero.selector); rewardsCoordinator.createAVSRewardsSubmission(rewardsSubmissions); } @@ -493,7 +493,7 @@ contract RewardsCoordinatorUnitTests_createAVSRewardsSubmission is RewardsCoordi // 3. Call createAVSRewardsSubmission() with expected revert cheats.prank(avs); - cheats.expectRevert("RewardsCoordinator._validateRewardsSubmission: amount too large"); + cheats.expectRevert(IRewardsCoordinator.AmountExceedsMax.selector); rewardsCoordinator.createAVSRewardsSubmission(rewardsSubmissions); } @@ -534,7 +534,7 @@ contract RewardsCoordinatorUnitTests_createAVSRewardsSubmission is RewardsCoordi // 3. call createAVSRewardsSubmission() with expected revert cheats.prank(avs); cheats.expectRevert( - "RewardsCoordinator._validateRewardsSubmission: strategies must be in ascending order to handle duplicates" + IRewardsCoordinator.StrategiesNotInAscendingOrder.selector ); rewardsCoordinator.createAVSRewardsSubmission(rewardsSubmissions); } @@ -574,7 +574,7 @@ contract RewardsCoordinatorUnitTests_createAVSRewardsSubmission is RewardsCoordi // 3. call createAVSRewardsSubmission() with expected revert cheats.prank(avs); - cheats.expectRevert("RewardsCoordinator._validateRewardsSubmission: duration exceeds MAX_REWARDS_DURATION"); + cheats.expectRevert(IRewardsCoordinator.DurationExceedsMax.selector); rewardsCoordinator.createAVSRewardsSubmission(rewardsSubmissions); } @@ -614,9 +614,7 @@ contract RewardsCoordinatorUnitTests_createAVSRewardsSubmission is RewardsCoordi // 3. call createAVSRewardsSubmission() with expected revert cheats.prank(avs); - cheats.expectRevert( - "RewardsCoordinator._validateRewardsSubmission: duration must be a multiple of CALCULATION_INTERVAL_SECONDS" - ); + cheats.expectRevert(IRewardsCoordinator.InvalidDurationRemainder.selector); rewardsCoordinator.createAVSRewardsSubmission(rewardsSubmissions); } @@ -660,7 +658,7 @@ contract RewardsCoordinatorUnitTests_createAVSRewardsSubmission is RewardsCoordi // 3. call createAVSRewardsSubmission() with expected revert cheats.prank(avs); - cheats.expectRevert("RewardsCoordinator._validateRewardsSubmission: startTimestamp too far in the past"); + cheats.expectRevert(IRewardsCoordinator.StartTimestampTooFarInPast.selector); rewardsCoordinator.createAVSRewardsSubmission(rewardsSubmissions); } @@ -698,7 +696,7 @@ contract RewardsCoordinatorUnitTests_createAVSRewardsSubmission is RewardsCoordi // 3. call createAVSRewardsSubmission() with expected revert cheats.prank(avs); - cheats.expectRevert("RewardsCoordinator._validateRewardsSubmission: startTimestamp too far in the future"); + cheats.expectRevert(IRewardsCoordinator.StartTimestampTooFarInFuture.selector); rewardsCoordinator.createAVSRewardsSubmission(rewardsSubmissions); } @@ -739,7 +737,7 @@ contract RewardsCoordinatorUnitTests_createAVSRewardsSubmission is RewardsCoordi // 3. call createAVSRewardsSubmission() with expected event emitted cheats.prank(avs); - cheats.expectRevert("RewardsCoordinator._validateRewardsSubmission: invalid strategy considered"); + cheats.expectRevert(IRewardsCoordinator.StrategyNotWhitelisted.selector); rewardsCoordinator.createAVSRewardsSubmission(rewardsSubmissions); } @@ -906,7 +904,7 @@ contract RewardsCoordinatorUnitTests_createRewardsForAllSubmission is RewardsCoo cheats.prank(pauser); rewardsCoordinator.pause(2 ** PAUSED_REWARDS_FOR_ALL_SUBMISSION); - cheats.expectRevert("Pausable: index is paused"); + cheats.expectRevert(IPausable.CurrentlyPaused.selector); IRewardsCoordinator.RewardsSubmission[] memory rewardsSubmissions; rewardsCoordinator.createRewardsForAllSubmission(rewardsSubmissions); } @@ -944,7 +942,7 @@ contract RewardsCoordinatorUnitTests_createRewardsForAllSubmission is RewardsCoo ) public filterFuzzedAddressInputs(invalidSubmitter) { cheats.assume(invalidSubmitter != rewardsForAllSubmitter); - cheats.expectRevert("RewardsCoordinator: caller is not a valid createRewardsForAllSubmission submitter"); + cheats.expectRevert(IRewardsCoordinator.UnauthorizedCaller.selector); IRewardsCoordinator.RewardsSubmission[] memory rewardsSubmissions; rewardsCoordinator.createRewardsForAllSubmission(rewardsSubmissions); } @@ -1119,7 +1117,7 @@ contract RewardsCoordinatorUnitTests_createRewardsForAllEarners is RewardsCoordi cheats.prank(pauser); rewardsCoordinator.pause(2 ** PAUSED_REWARD_ALL_STAKERS_AND_OPERATORS); - cheats.expectRevert("Pausable: index is paused"); + cheats.expectRevert(IPausable.CurrentlyPaused.selector); IRewardsCoordinator.RewardsSubmission[] memory rewardsSubmissions; rewardsCoordinator.createRewardsForAllEarners(rewardsSubmissions); } @@ -1157,7 +1155,7 @@ contract RewardsCoordinatorUnitTests_createRewardsForAllEarners is RewardsCoordi ) public filterFuzzedAddressInputs(invalidSubmitter) { cheats.assume(invalidSubmitter != rewardsForAllSubmitter); - cheats.expectRevert("RewardsCoordinator: caller is not a valid createRewardsForAllSubmission submitter"); + cheats.expectRevert(IRewardsCoordinator.UnauthorizedCaller.selector); IRewardsCoordinator.RewardsSubmission[] memory rewardsSubmissions; rewardsCoordinator.createRewardsForAllEarners(rewardsSubmissions); } @@ -1333,7 +1331,7 @@ contract RewardsCoordinatorUnitTests_submitRoot is RewardsCoordinatorUnitTests { ) public filterFuzzedAddressInputs(invalidRewardsUpdater) { cheats.prank(invalidRewardsUpdater); - cheats.expectRevert("RewardsCoordinator: caller is not the rewardsUpdater"); + cheats.expectRevert(IRewardsCoordinator.UnauthorizedCaller.selector); rewardsCoordinator.submitRoot(bytes32(0), 0); } @@ -1341,7 +1339,7 @@ contract RewardsCoordinatorUnitTests_submitRoot is RewardsCoordinatorUnitTests { cheats.prank(pauser); rewardsCoordinator.pause(2 ** PAUSED_SUBMIT_ROOTS); - cheats.expectRevert("Pausable: index is paused"); + cheats.expectRevert(IPausable.CurrentlyPaused.selector); rewardsCoordinator.submitRoot(bytes32(0), 0); } @@ -1681,7 +1679,7 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests cheats.startPrank(claimer); // rootIndex in claim is 0, which is disabled IRewardsCoordinator.RewardsMerkleClaim memory claim; - cheats.expectRevert("RewardsCoordinator._checkClaim: root is disabled"); + cheats.expectRevert(IRewardsCoordinator.RootDisabled.selector); rewardsCoordinator.processClaim(claim, claimer); cheats.stopPrank(); } @@ -1748,9 +1746,7 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests cheats.startPrank(claimer); assertTrue(rewardsCoordinator.checkClaim(claim), "RewardsCoordinator.checkClaim: claim not valid"); - cheats.expectRevert( - "RewardsCoordinator.processClaim: cumulativeEarnings must be gt than cumulativeClaimed" - ); + cheats.expectRevert(IRewardsCoordinator.EarningsNotGreaterThanClaimed.selector); rewardsCoordinator.processClaim(claim, claimer); cheats.stopPrank(); @@ -1788,10 +1784,10 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests // Check claim is not valid from both checkClaim() and processClaim() throwing a revert cheats.startPrank(claimer); - cheats.expectRevert("RewardsCoordinator._verifyTokenClaim: invalid token claim proof"); + cheats.expectRevert(IRewardsCoordinator.InvalidClaimProof.selector); assertFalse(rewardsCoordinator.checkClaim(claim), "RewardsCoordinator.checkClaim: claim not valid"); - cheats.expectRevert("RewardsCoordinator._verifyTokenClaim: invalid token claim proof"); + cheats.expectRevert(IRewardsCoordinator.InvalidClaimProof.selector); rewardsCoordinator.processClaim(claim, claimer); cheats.stopPrank(); @@ -1828,10 +1824,10 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests // Check claim is not valid from both checkClaim() and processClaim() throwing a revert cheats.startPrank(claimer); - cheats.expectRevert("RewardsCoordinator._verifyEarnerClaimProof: invalid earner claim proof"); + cheats.expectRevert(IRewardsCoordinator.InvalidClaimProof.selector); assertFalse(rewardsCoordinator.checkClaim(claim), "RewardsCoordinator.checkClaim: claim not valid"); - cheats.expectRevert("RewardsCoordinator._verifyEarnerClaimProof: invalid earner claim proof"); + cheats.expectRevert(IRewardsCoordinator.InvalidClaimProof.selector); rewardsCoordinator.processClaim(claim, claimer); cheats.stopPrank(); @@ -1871,7 +1867,7 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests .with_key(address(claim.tokenLeaves[0].token)) .checked_write(type(uint256).max); cheats.startPrank(claimer); - cheats.expectRevert("RewardsCoordinator.processClaim: cumulativeEarnings must be gt than cumulativeClaimed"); + cheats.expectRevert(IRewardsCoordinator.EarningsNotGreaterThanClaimed.selector); rewardsCoordinator.processClaim(claim, claimer); cheats.stopPrank(); } @@ -1909,7 +1905,7 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests uint8 proofLength = uint8(claim.tokenTreeProofs[0].length); claim.tokenIndices[0] = claim.tokenIndices[0] | uint32(1 << (numShift + proofLength / 32)); cheats.startPrank(claimer); - cheats.expectRevert("RewardsCoordinator._verifyTokenClaim: invalid tokenLeafIndex"); + cheats.expectRevert(IRewardsCoordinator.InvalidTokenLeafIndex.selector); rewardsCoordinator.processClaim(claim, claimer); cheats.stopPrank(); } @@ -1947,7 +1943,7 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests uint8 proofLength = uint8(claim.earnerTreeProof.length); claim.earnerIndex = claim.earnerIndex | uint32(1 << (numShift + proofLength / 32)); cheats.startPrank(claimer); - cheats.expectRevert("RewardsCoordinator._verifyEarnerClaimProof: invalid earnerLeafIndex"); + cheats.expectRevert(IRewardsCoordinator.InvalidEarnerLeafIndex.selector); rewardsCoordinator.processClaim(claim, claimer); cheats.stopPrank(); } diff --git a/src/test/unit/StrategyBaseTVLLimitsUnit.sol b/src/test/unit/StrategyBaseTVLLimitsUnit.sol index 78bdcefac0..f96770b0dc 100644 --- a/src/test/unit/StrategyBaseTVLLimitsUnit.sol +++ b/src/test/unit/StrategyBaseTVLLimitsUnit.sol @@ -56,7 +56,7 @@ contract StrategyBaseTVLLimitsUnitTests is StrategyBaseUnitTests { cheats.assume(notUnpauser != address(proxyAdmin)); cheats.assume(notUnpauser != unpauser); cheats.startPrank(notUnpauser); - cheats.expectRevert(bytes("msg.sender is not permissioned as unpauser")); + cheats.expectRevert(IPausable.OnlyUnpauser.selector); strategyWithTVLLimits.setTVLLimits(maxPerDepositFuzzedInput, maxTotalDepositsFuzzedInput); cheats.stopPrank(); } @@ -64,7 +64,7 @@ contract StrategyBaseTVLLimitsUnitTests is StrategyBaseUnitTests { function testSetInvalidMaxPerDepositAndMaxDeposits(uint256 maxPerDepositFuzzedInput, uint256 maxTotalDepositsFuzzedInput) public { cheats.assume(maxTotalDepositsFuzzedInput < maxPerDepositFuzzedInput); cheats.startPrank(unpauser); - cheats.expectRevert(bytes("StrategyBaseTVLLimits._setTVLLimits: maxPerDeposit exceeds maxTotalDeposits")); + cheats.expectRevert(IStrategy.MaxPerDepositExceedsMax.selector); strategyWithTVLLimits.setTVLLimits(maxPerDepositFuzzedInput, maxTotalDepositsFuzzedInput); cheats.stopPrank(); } @@ -74,7 +74,7 @@ contract StrategyBaseTVLLimitsUnitTests is StrategyBaseUnitTests { _setTVLLimits(maxPerDepositFuzzedInput, maxTotalDepositsFuzzedInput); cheats.startPrank(address(strategyManager)); - cheats.expectRevert(bytes("StrategyBaseTVLLimits: max per deposit exceeded")); + cheats.expectRevert(IStrategy.MaxPerDepositExceedsMax.selector); strategyWithTVLLimits.deposit(underlyingToken, amount); cheats.stopPrank(); } @@ -98,7 +98,7 @@ contract StrategyBaseTVLLimitsUnitTests is StrategyBaseUnitTests { require(underlyingToken.balanceOf(address(strategyWithTVLLimits)) > maxTotalDeposits, "bad test setup"); cheats.startPrank(address(strategyManager)); - cheats.expectRevert(bytes("StrategyBaseTVLLimits: max deposits exceeded")); + cheats.expectRevert(IStrategy.BalanceExceedsMaxTotalDeposits.selector); strategyWithTVLLimits.deposit(underlyingToken, maxPerDeposit); cheats.stopPrank(); } @@ -172,7 +172,7 @@ contract StrategyBaseTVLLimitsUnitTests is StrategyBaseUnitTests { if (depositAmount > maxPerDepositFuzzedInput) { cheats.startPrank(address(strategyManager)); - cheats.expectRevert("StrategyBaseTVLLimits: max per deposit exceeded"); + cheats.expectRevert(IStrategy.MaxPerDepositExceedsMax.selector); strategyWithTVLLimits.deposit(underlyingToken, depositAmount); cheats.stopPrank(); @@ -185,7 +185,7 @@ contract StrategyBaseTVLLimitsUnitTests is StrategyBaseUnitTests { return true; } else if (underlyingToken.balanceOf(address(strategyWithTVLLimits)) > maxTotalDepositsFuzzedInput) { cheats.startPrank(address(strategyManager)); - cheats.expectRevert("StrategyBaseTVLLimits: max deposits exceeded"); + cheats.expectRevert(IStrategy.MaxPerDepositExceedsMax.selector); strategyWithTVLLimits.deposit(underlyingToken, depositAmount); cheats.stopPrank(); @@ -200,7 +200,7 @@ contract StrategyBaseTVLLimitsUnitTests is StrategyBaseUnitTests { uint256 totalSharesBefore = strategyWithTVLLimits.totalShares(); if (expectedSharesOut == 0) { cheats.startPrank(address(strategyManager)); - cheats.expectRevert("StrategyBase.deposit: newShares cannot be zero"); + cheats.expectRevert(IStrategy.NewSharesZero.selector); strategyWithTVLLimits.deposit(underlyingToken, depositAmount); cheats.stopPrank(); diff --git a/src/test/unit/StrategyBaseUnit.t.sol b/src/test/unit/StrategyBaseUnit.t.sol index 57431326f9..1d1b88ee01 100644 --- a/src/test/unit/StrategyBaseUnit.t.sol +++ b/src/test/unit/StrategyBaseUnit.t.sol @@ -77,7 +77,7 @@ contract StrategyBaseUnitTests is Test { uint256 amountToDeposit = 0; cheats.startPrank(address(strategyManager)); - cheats.expectRevert(bytes("StrategyBase.deposit: newShares cannot be zero")); + cheats.expectRevert(IStrategy.NewSharesZero.selector); strategy.deposit(underlyingToken, amountToDeposit); cheats.stopPrank(); } @@ -134,7 +134,7 @@ contract StrategyBaseUnitTests is Test { uint256 amountToDeposit = 1e18; underlyingToken.transfer(address(strategy), amountToDeposit); - cheats.expectRevert(bytes("Pausable: index is paused")); + cheats.expectRevert(IPausable.CurrentlyPaused.selector); cheats.startPrank(address(strategyManager)); strategy.deposit(underlyingToken, amountToDeposit); cheats.stopPrank(); @@ -147,7 +147,7 @@ contract StrategyBaseUnitTests is Test { uint256 amountToDeposit = 1e18; underlyingToken.transfer(address(strategy), amountToDeposit); - cheats.expectRevert(bytes("StrategyBase.onlyStrategyManager")); + cheats.expectRevert(IStrategy.UnauthorizedCaller.selector); cheats.startPrank(caller); strategy.deposit(underlyingToken, amountToDeposit); cheats.stopPrank(); @@ -158,7 +158,7 @@ contract StrategyBaseUnitTests is Test { uint256 amountToDeposit = 1e18; - cheats.expectRevert(bytes("StrategyBase.deposit: Can only deposit underlyingToken")); + cheats.expectRevert(IStrategy.OnlyUnderlyingToken.selector); cheats.startPrank(address(strategyManager)); strategy.deposit(IERC20(notUnderlyingToken), amountToDeposit); cheats.stopPrank(); @@ -187,7 +187,7 @@ contract StrategyBaseUnitTests is Test { // Deposit cheats.prank(address(strategyManager)); - cheats.expectRevert(bytes("StrategyBase.deposit: totalShares exceeds `MAX_TOTAL_SHARES`")); + cheats.expectRevert(IStrategy.TotalSharesExceedsMax.selector); strategy.deposit(underlyingToken, amountToDeposit); } @@ -262,7 +262,7 @@ contract StrategyBaseUnitTests is Test { uint256 amountToWithdraw = 1e18; - cheats.expectRevert(bytes("Pausable: index is paused")); + cheats.expectRevert(IPausable.CurrentlyPaused.selector); cheats.startPrank(address(strategyManager)); strategy.withdraw(address(this), underlyingToken, amountToWithdraw); cheats.stopPrank(); @@ -276,7 +276,7 @@ contract StrategyBaseUnitTests is Test { uint256 amountToWithdraw = 1e18; - cheats.expectRevert(bytes("StrategyBase.onlyStrategyManager")); + cheats.expectRevert(IStrategy.UnauthorizedCaller.selector); cheats.startPrank(caller); strategy.withdraw(address(this), underlyingToken, amountToWithdraw); cheats.stopPrank(); @@ -287,7 +287,7 @@ contract StrategyBaseUnitTests is Test { uint256 amountToWithdraw = 1e18; - cheats.expectRevert(bytes("StrategyBase.withdraw: Can only withdraw the strategy token")); + cheats.expectRevert(IStrategy.OnlyUnderlyingToken.selector); cheats.startPrank(address(strategyManager)); strategy.withdraw(address(this), IERC20(notUnderlyingToken), amountToWithdraw); cheats.stopPrank(); @@ -302,7 +302,7 @@ contract StrategyBaseUnitTests is Test { // since we are checking strictly greater than in this test cheats.assume(sharesToWithdraw > totalSharesBefore); - cheats.expectRevert(bytes("StrategyBase.withdraw: amountShares must be less than or equal to totalShares")); + cheats.expectRevert(IStrategy.WithdrawalAmountExceedsTotalDeposits.selector); cheats.startPrank(address(strategyManager)); strategy.withdraw(address(this), underlyingToken, sharesToWithdraw); cheats.stopPrank(); @@ -344,7 +344,7 @@ contract StrategyBaseUnitTests is Test { function testDeposit_ZeroAmount() public { cheats.startPrank(address(strategyManager)); - cheats.expectRevert(bytes("StrategyBase.deposit: newShares cannot be zero")); + cheats.expectRevert(IStrategy.NewSharesZero.selector); strategy.deposit(underlyingToken, 0); cheats.stopPrank(); } diff --git a/src/test/unit/StrategyFactoryUnit.t.sol b/src/test/unit/StrategyFactoryUnit.t.sol index 2cefcea191..beb7ac2f3f 100644 --- a/src/test/unit/StrategyFactoryUnit.t.sol +++ b/src/test/unit/StrategyFactoryUnit.t.sol @@ -121,7 +121,7 @@ contract StrategyFactoryUnitTests is EigenLayerUnitTestSetup { function test_deployNewStrategy_revert_StrategyAlreadyExists() public { test_deployNewStrategy(); - cheats.expectRevert("StrategyFactory.deployNewStrategy: Strategy already exists for token"); + cheats.expectRevert(IStrategyFactory.StrategyAlreadyExists.selector); strategyFactory.deployNewStrategy(underlyingToken); } @@ -134,7 +134,7 @@ contract StrategyFactoryUnitTests is EigenLayerUnitTestSetup { emit TokenBlacklisted(token); strategyFactory.blacklistTokens(tokens); - cheats.expectRevert("StrategyFactory.deployNewStrategy: Token is blacklisted"); + cheats.expectRevert(IStrategyFactory.BlacklistedToken.selector); strategyFactory.deployNewStrategy(token); } diff --git a/src/test/unit/StrategyManagerUnit.t.sol b/src/test/unit/StrategyManagerUnit.t.sol index 7f6c7deb3d..7754b48dd9 100644 --- a/src/test/unit/StrategyManagerUnit.t.sol +++ b/src/test/unit/StrategyManagerUnit.t.sol @@ -142,7 +142,7 @@ contract StrategyManagerUnitTests is EigenLayerUnitTestSetup, IStrategyManagerEv address staker, uint256 amount, uint256 expiry, - string memory expectedRevertMessage + bytes4 expectedRevertMessage ) internal returns (bytes memory) { // filter out zero case since it will revert with "StrategyManager._addShares: shares should not be zero!" cheats.assume(amount != 0); @@ -165,16 +165,11 @@ contract StrategyManagerUnitTests is EigenLayerUnitTestSetup, IStrategyManagerEv uint256 sharesBefore = strategyManager.stakerStrategyShares(staker, dummyStrat); - bool expectedRevertMessageIsempty; - { - string memory emptyString; - expectedRevertMessageIsempty = - keccak256(abi.encodePacked(expectedRevertMessage)) == keccak256(abi.encodePacked(emptyString)); - } + bool expectedRevertMessageIsempty = expectedRevertMessage == bytes4(0x00000000); if (!expectedRevertMessageIsempty) { - cheats.expectRevert(bytes(expectedRevertMessage)); + cheats.expectRevert(expectedRevertMessage); } else if (expiry < block.timestamp) { - cheats.expectRevert("StrategyManager.depositIntoStrategyWithSignature: signature expired"); + cheats.expectRevert(IStrategyManager.SignatureExpired.selector); } else { // needed for expecting an event with the right parameters uint256 expectedShares = amount; @@ -330,7 +325,7 @@ contract StrategyManagerUnitTests_depositIntoStrategy is StrategyManagerUnitTest cheats.prank(pauser); strategyManager.pause(1); - cheats.expectRevert("Pausable: index is paused"); + cheats.expectRevert(IPausable.CurrentlyPaused.selector); strategyManager.depositIntoStrategy(dummyStrat, dummyToken, amount); } @@ -468,7 +463,7 @@ contract StrategyManagerUnitTests_depositIntoStrategy is StrategyManagerUnitTest IStrategy strategy = dummyStrat; cheats.prank(staker); - cheats.expectRevert("StrategyManager.onlyStrategiesWhitelistedForDeposit: strategy not whitelisted"); + cheats.expectRevert(IStrategyManager.StrategyNotWhitelisted.selector); strategyManager.depositIntoStrategy(strategy, token, amount); } @@ -494,7 +489,7 @@ contract StrategyManagerUnitTests_depositIntoStrategy is StrategyManagerUnitTest reenterer.prepareReturnData(abi.encode(uint256(0))); cheats.prank(staker); - cheats.expectRevert("StrategyManager._addShares: shares should not be zero!"); + cheats.expectRevert(IStrategyManager.SharesAmountZero.selector); strategyManager.depositIntoStrategy(strategy, token, amount); } } @@ -523,7 +518,7 @@ contract StrategyManagerUnitTests_depositIntoStrategyWithSignature is StrategyMa uint256 sharesBefore = strategyManager.stakerStrategyShares(staker, strategy); - cheats.expectRevert("EIP1271SignatureUtils.checkSignature_EIP1271: signature not from signer"); + cheats.expectRevert(EIP1271SignatureUtils.InvalidSignatureEOA.selector); // call with `notStaker` as input instead of `staker` address address notStaker = address(3333); strategyManager.depositIntoStrategyWithSignature(strategy, token, amount, notStaker, expiry, signature); @@ -541,8 +536,7 @@ contract StrategyManagerUnitTests_depositIntoStrategyWithSignature is StrategyMa address staker = cheats.addr(privateKey); // not expecting a revert, so input an empty string - string memory expectedRevertMessage; - _depositIntoStrategyWithSignature(staker, amount, expiry, expectedRevertMessage); + _depositIntoStrategyWithSignature(staker, amount, expiry, bytes4(0x00000000)); } function testFuzz_Revert_SignatureReplay(uint256 amount, uint256 expiry) public { @@ -554,7 +548,7 @@ contract StrategyManagerUnitTests_depositIntoStrategyWithSignature is StrategyMa // not expecting a revert, so input an empty string bytes memory signature = _depositIntoStrategyWithSignature(staker, amount, expiry, ""); - cheats.expectRevert("EIP1271SignatureUtils.checkSignature_EIP1271: signature not from signer"); + cheats.expectRevert(EIP1271SignatureUtils.InvalidSignatureEOA.selector); strategyManager.depositIntoStrategyWithSignature(dummyStrat, dummyToken, amount, staker, expiry, signature); } @@ -594,7 +588,7 @@ contract StrategyManagerUnitTests_depositIntoStrategyWithSignature is StrategyMa signature = abi.encodePacked(r, s, v); } - cheats.expectRevert("EIP1271SignatureUtils.checkSignature_EIP1271: ERC1271 signature verification failed"); + cheats.expectRevert(EIP1271SignatureUtils.InvalidSignatureEIP1271.selector); strategyManager.depositIntoStrategyWithSignature(strategy, token, amount, staker, expiry, signature); } @@ -665,8 +659,7 @@ contract StrategyManagerUnitTests_depositIntoStrategyWithSignature is StrategyMa staker = address(wallet); // not expecting a revert, so input an empty string - string memory expectedRevertMessage; - _depositIntoStrategyWithSignature(staker, amount, expiry, expectedRevertMessage); + _depositIntoStrategyWithSignature(staker, amount, expiry, bytes4(0x00000000)); } function test_Revert_WhenDepositsPaused() public { @@ -676,8 +669,7 @@ contract StrategyManagerUnitTests_depositIntoStrategyWithSignature is StrategyMa cheats.prank(pauser); strategyManager.pause(1); - string memory expectedRevertMessage = "Pausable: index is paused"; - _depositIntoStrategyWithSignature(staker, 1e18, type(uint256).max, expectedRevertMessage); + _depositIntoStrategyWithSignature(staker, 1e18, type(uint256).max, IPausable.CurrentlyPaused.selector); } /** @@ -765,7 +757,7 @@ contract StrategyManagerUnitTests_depositIntoStrategyWithSignature is StrategyMa uint256 sharesBefore = strategyManager.stakerStrategyShares(staker, strategy); - cheats.expectRevert("StrategyManager.depositIntoStrategyWithSignature: signature expired"); + cheats.expectRevert(IStrategyManager.SignatureExpired.selector); strategyManager.depositIntoStrategyWithSignature(strategy, token, amount, staker, expiry, signature); uint256 sharesAfter = strategyManager.stakerStrategyShares(staker, strategy); @@ -782,9 +774,7 @@ contract StrategyManagerUnitTests_depositIntoStrategyWithSignature is StrategyMa address staker = cheats.addr(privateKey); uint256 amount = 1e18; - string - memory expectedRevertMessage = "StrategyManager.onlyStrategiesWhitelistedForDeposit: strategy not whitelisted"; - _depositIntoStrategyWithSignature(staker, amount, type(uint256).max, expectedRevertMessage); + _depositIntoStrategyWithSignature(staker, amount, type(uint256).max, IStrategyManager.StrategyNotWhitelisted.selector); } function testFuzz_Revert_WhenThirdPartyTransfersForbidden(uint256 amount, uint256 expiry) public { @@ -796,8 +786,7 @@ contract StrategyManagerUnitTests_depositIntoStrategyWithSignature is StrategyMa address staker = cheats.addr(privateKey); // not expecting a revert, so input an empty string - string memory expectedRevertMessage = "StrategyManager.depositIntoStrategyWithSignature: third transfers disabled"; - _depositIntoStrategyWithSignature(staker, amount, expiry, expectedRevertMessage); + _depositIntoStrategyWithSignature(staker, amount, expiry, IStrategyManager.ThirdPartyTransfersDisabled.selector); } } @@ -807,7 +796,7 @@ contract StrategyManagerUnitTests_removeShares is StrategyManagerUnitTests { */ function test_Revert_DelegationManagerModifier() external { DelegationManagerMock invalidDelegationManager = new DelegationManagerMock(); - cheats.expectRevert("StrategyManager.onlyDelegationManager: not the DelegationManager"); + cheats.expectRevert(IStrategyManager.UnauthorizedCaller.selector); invalidDelegationManager.removeShares(strategyManager, address(this), dummyStrat, 1); } @@ -822,7 +811,7 @@ contract StrategyManagerUnitTests_removeShares is StrategyManagerUnitTests { cheats.assume(depositAmount > 0 && depositAmount < dummyToken.totalSupply()); IStrategy strategy = dummyStrat; _depositIntoStrategySuccessfully(strategy, staker, depositAmount); - cheats.expectRevert("StrategyManager._removeShares: shareAmount should not be zero!"); + cheats.expectRevert(IStrategyManager.SharesAmountZero.selector); delegationManagerMock.removeShares(strategyManager, staker, strategy, 0); } @@ -840,7 +829,7 @@ contract StrategyManagerUnitTests_removeShares is StrategyManagerUnitTests { cheats.assume(removeSharesAmount > depositAmount); IStrategy strategy = dummyStrat; _depositIntoStrategySuccessfully(strategy, staker, depositAmount); - cheats.expectRevert("StrategyManager._removeShares: shareAmount too high"); + cheats.expectRevert(IStrategyManager.InsufficientShares.selector); delegationManagerMock.removeShares(strategyManager, staker, strategy, removeSharesAmount); } @@ -1005,18 +994,18 @@ contract StrategyManagerUnitTests_removeShares is StrategyManagerUnitTests { contract StrategyManagerUnitTests_addShares is StrategyManagerUnitTests { function test_Revert_DelegationManagerModifier() external { DelegationManagerMock invalidDelegationManager = new DelegationManagerMock(); - cheats.expectRevert("StrategyManager.onlyDelegationManager: not the DelegationManager"); + cheats.expectRevert(IStrategyManager.UnauthorizedCaller.selector); invalidDelegationManager.addShares(strategyManager, address(this), dummyToken, dummyStrat, 1); } function testFuzz_Revert_StakerZeroAddress(uint256 amount) external { - cheats.expectRevert("StrategyManager._addShares: staker cannot be zero address"); + cheats.expectRevert(IStrategyManager.StakerAddressZero.selector); delegationManagerMock.addShares(strategyManager, address(0), dummyToken, dummyStrat, amount); } function testFuzz_Revert_ZeroShares(address staker) external filterFuzzedAddressInputs(staker) { cheats.assume(staker != address(0)); - cheats.expectRevert("StrategyManager._addShares: shares should not be zero!"); + cheats.expectRevert(IStrategyManager.SharesAmountZero.selector); delegationManagerMock.addShares(strategyManager, staker, dummyToken, dummyStrat, 0); } @@ -1104,10 +1093,10 @@ contract StrategyManagerUnitTests_addShares is StrategyManagerUnitTests { ); cheats.prank(staker); - cheats.expectRevert("StrategyManager._addShares: deposit would exceed MAX_STAKER_STRATEGY_LIST_LENGTH"); + cheats.expectRevert(IStrategyManager.MaxStrategiesExceeded.selector); delegationManagerMock.addShares(strategyManager, staker, dummyToken, strategy, amount); - cheats.expectRevert("StrategyManager._addShares: deposit would exceed MAX_STAKER_STRATEGY_LIST_LENGTH"); + cheats.expectRevert(IStrategyManager.MaxStrategiesExceeded.selector); strategyManager.depositIntoStrategy(strategy, token, amount); } } @@ -1115,7 +1104,7 @@ contract StrategyManagerUnitTests_addShares is StrategyManagerUnitTests { contract StrategyManagerUnitTests_withdrawSharesAsTokens is StrategyManagerUnitTests { function test_Revert_DelegationManagerModifier() external { DelegationManagerMock invalidDelegationManager = new DelegationManagerMock(); - cheats.expectRevert("StrategyManager.onlyDelegationManager: not the DelegationManager"); + cheats.expectRevert(IStrategyManager.UnauthorizedCaller.selector); invalidDelegationManager.removeShares(strategyManager, address(this), dummyStrat, 1); } @@ -1133,7 +1122,7 @@ contract StrategyManagerUnitTests_withdrawSharesAsTokens is StrategyManagerUnitT IStrategy strategy = dummyStrat; IERC20 token = dummyToken; _depositIntoStrategySuccessfully(strategy, staker, depositAmount); - cheats.expectRevert("StrategyBase.withdraw: amountShares must be less than or equal to totalShares"); + cheats.expectRevert(IStrategy.WithdrawalAmountExceedsTotalDeposits.selector); delegationManagerMock.withdrawSharesAsTokens(strategyManager, staker, strategy, sharesAmount, token); } @@ -1189,7 +1178,7 @@ contract StrategyManagerUnitTests_addStrategiesToDepositWhitelist is StrategyMan strategyArray[0] = _strategy; cheats.prank(notStrategyWhitelister); - cheats.expectRevert("StrategyManager.onlyStrategyWhitelister: not the strategyWhitelister"); + cheats.expectRevert(IStrategyManager.UnauthorizedCaller.selector); strategyManager.addStrategiesToDepositWhitelist(strategyArray, thirdPartyTransfersForbiddenValues); } @@ -1241,7 +1230,7 @@ contract StrategyManagerUnitTests_removeStrategiesFromDepositWhitelist is Strate IStrategy[] memory strategyArray = _addStrategiesToWhitelist(1); cheats.prank(notStrategyWhitelister); - cheats.expectRevert("StrategyManager.onlyStrategyWhitelister: not the strategyWhitelister"); + cheats.expectRevert(IStrategyManager.UnauthorizedCaller.selector); strategyManager.removeStrategiesFromDepositWhitelist(strategyArray); }