From 2d4b5c0159f1478204a1db275b1788fb7fd82d28 Mon Sep 17 00:00:00 2001 From: kasperpawlowski Date: Fri, 14 Jun 2024 16:18:44 +0100 Subject: [PATCH 1/5] chore: standardize pragmas --- src/Errors.sol | 2 +- src/EthereumVaultConnector.sol | 2 +- src/Events.sol | 2 +- src/ExecutionContext.sol | 2 +- src/Set.sol | 2 +- src/TransientStorage.sol | 2 +- src/interfaces/IERC1271.sol | 2 +- src/interfaces/IEthereumVaultConnector.sol | 2 +- src/interfaces/IVault.sol | 2 +- src/utils/EVCUtil.sol | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Errors.sol b/src/Errors.sol index 6b55a13..bcca114 100644 --- a/src/Errors.sol +++ b/src/Errors.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.8.19; +pragma solidity ^0.8.0; import {IEVC} from "./interfaces/IEthereumVaultConnector.sol"; diff --git a/src/EthereumVaultConnector.sol b/src/EthereumVaultConnector.sol index 49622dc..a7fe4d1 100644 --- a/src/EthereumVaultConnector.sol +++ b/src/EthereumVaultConnector.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.8.19; +pragma solidity ^0.8.0; import {Set, SetStorage} from "./Set.sol"; import {Events} from "./Events.sol"; diff --git a/src/Events.sol b/src/Events.sol index fa32016..a2645eb 100644 --- a/src/Events.sol +++ b/src/Events.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.8.19; +pragma solidity ^0.8.0; /// @title Events /// @custom:security-contact security@euler.xyz diff --git a/src/ExecutionContext.sol b/src/ExecutionContext.sol index bb10ff1..fa89cac 100644 --- a/src/ExecutionContext.sol +++ b/src/ExecutionContext.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.8.19; +pragma solidity ^0.8.0; type EC is uint256; diff --git a/src/Set.sol b/src/Set.sol index a9b5c35..b0426e9 100644 --- a/src/Set.sol +++ b/src/Set.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.8.19; +pragma solidity ^0.8.0; /// @dev Represents the maximum number of elements that can be stored in the set. /// Must not exceed 255 due to the uint8 data type limit. diff --git a/src/TransientStorage.sol b/src/TransientStorage.sol index a11b416..7a6c06b 100644 --- a/src/TransientStorage.sol +++ b/src/TransientStorage.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.8.19; +pragma solidity ^0.8.0; import {ExecutionContext, EC} from "./ExecutionContext.sol"; import {Set, SetStorage} from "./Set.sol"; diff --git a/src/interfaces/IERC1271.sol b/src/interfaces/IERC1271.sol index 6c2e524..cd146f8 100644 --- a/src/interfaces/IERC1271.sol +++ b/src/interfaces/IERC1271.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol) -pragma solidity ^0.8.19; +pragma solidity >=0.8.0; /// @dev Interface of the ERC1271 standard signature validation method for /// contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271]. diff --git a/src/interfaces/IEthereumVaultConnector.sol b/src/interfaces/IEthereumVaultConnector.sol index 1e5a2f2..73cd28a 100644 --- a/src/interfaces/IEthereumVaultConnector.sol +++ b/src/interfaces/IEthereumVaultConnector.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.8.19; +pragma solidity >=0.8.0; /// @title IEVC /// @custom:security-contact security@euler.xyz diff --git a/src/interfaces/IVault.sol b/src/interfaces/IVault.sol index e17e834..c668000 100644 --- a/src/interfaces/IVault.sol +++ b/src/interfaces/IVault.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.8.19; +pragma solidity >=0.8.0; /// @title IVault /// @custom:security-contact security@euler.xyz diff --git a/src/utils/EVCUtil.sol b/src/utils/EVCUtil.sol index e748422..1a45f90 100644 --- a/src/utils/EVCUtil.sol +++ b/src/utils/EVCUtil.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.19; +pragma solidity ^0.8.0; import {IEVC} from "../interfaces/IEthereumVaultConnector.sol"; From 16694deb3af5d662d90e12f6a0828b2c6c4fb3a4 Mon Sep 17 00:00:00 2001 From: kasperpawlowski Date: Fri, 14 Jun 2024 16:18:59 +0100 Subject: [PATCH 2/5] test: fix --- test/unit/EthereumVaultConnector/Permit.t.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/test/unit/EthereumVaultConnector/Permit.t.sol b/test/unit/EthereumVaultConnector/Permit.t.sol index 0556ef5..d97022e 100644 --- a/test/unit/EthereumVaultConnector/Permit.t.sol +++ b/test/unit/EthereumVaultConnector/Permit.t.sol @@ -223,6 +223,7 @@ contract PermitTest is Test { data = abi.encode(keccak256(data)); vm.assume(!evc.haveCommonOwner(alice, address(0)) && alice != address(evc)); + vm.assume(msgSender != address(evc)); vm.assume(nonce > 0 && nonce < type(uint256).max); vm.warp(deadline); From 2aac10a26c06f8e59c4cc84833500e983c7eacbe Mon Sep 17 00:00:00 2001 From: kasperpawlowski Date: Fri, 14 Jun 2024 20:24:41 +0100 Subject: [PATCH 3/5] fix: test --- test/unit/EthereumVaultConnector/SetPermitDisabledMode.t.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/EthereumVaultConnector/SetPermitDisabledMode.t.sol b/test/unit/EthereumVaultConnector/SetPermitDisabledMode.t.sol index a9e88d6..2b0d006 100644 --- a/test/unit/EthereumVaultConnector/SetPermitDisabledMode.t.sol +++ b/test/unit/EthereumVaultConnector/SetPermitDisabledMode.t.sol @@ -74,7 +74,7 @@ contract SetPermitDisabledModeTest is Test { function test_Integration_SetPermitDisabledMode(address alice, address vault, address operator) public { vm.assume(alice != address(0) && !evc.haveCommonOwner(alice, operator) && alice.code.length == 0); vm.assume( - vault != address(0) && vault != alice && vault != operator && vault.code.length == 0 + uint160(vault) > 255 && vault != alice && vault != operator && vault.code.length == 0 && vault != 0xF62849F9A0B5Bf2913b396098F7c7019b51A820a ); vm.assume(operator != address(0) && operator.code.length == 0); From 6b28b1ad2a25a1dbee4e081a7bd9a5c29ad05d58 Mon Sep 17 00:00:00 2001 From: kasperpawlowski Date: Fri, 14 Jun 2024 20:52:18 +0100 Subject: [PATCH 4/5] feat: make an internal function virtual for testing --- src/EthereumVaultConnector.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EthereumVaultConnector.sol b/src/EthereumVaultConnector.sol index a7fe4d1..725a230 100644 --- a/src/EthereumVaultConnector.sol +++ b/src/EthereumVaultConnector.sol @@ -974,7 +974,7 @@ contract EthereumVaultConnector is Events, Errors, TransientStorage, IEVC { /// @param vault The address of the vault to check the status for. /// @return isValid A boolean indicating if the vault status is valid. /// @return result The bytes returned from the vault call, indicating the vault status. - function checkVaultStatusInternal(address vault) internal returns (bool isValid, bytes memory result) { + function checkVaultStatusInternal(address vault) internal virtual returns (bool isValid, bytes memory result) { bool success; (success, result) = vault.call(abi.encodeCall(IVault.checkVaultStatus, ())); From bef8923231e79a8dbc792271d2430f34940a84db Mon Sep 17 00:00:00 2001 From: kasperpawlowski Date: Fri, 14 Jun 2024 20:52:30 +0100 Subject: [PATCH 5/5] test: fix --- test/invariants/EthereumVaultConnector.t.sol | 22 ++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/test/invariants/EthereumVaultConnector.t.sol b/test/invariants/EthereumVaultConnector.t.sol index 5c2030f..de6426f 100644 --- a/test/invariants/EthereumVaultConnector.t.sol +++ b/test/invariants/EthereumVaultConnector.t.sol @@ -257,12 +257,26 @@ contract EthereumVaultConnectorHandler is EthereumVaultConnectorScribble, Test { accountControllers[account].firstElement = firstElementCache; } - function requireAccountStatusCheckInternal(address) internal pure override { - return; + function checkAccountStatusInternal(address account) + internal + view + virtual + override + returns (bool isValid, bytes memory result) + { + SetStorage storage accountControllersStorage = accountControllers[account]; + uint256 numOfControllers = accountControllersStorage.numElements; + + if (numOfControllers == 0) return (true, ""); + else if (numOfControllers > 1) return (false, abi.encodeWithSelector(EVC_ControllerViolation.selector)); + + isValid = true; + result = ""; } - function requireVaultStatusCheckInternal(address) internal pure override { - return; + function checkVaultStatusInternal(address) internal pure override returns (bool isValid, bytes memory result) { + isValid = true; + result = ""; } function exposeAccountCollaterals(address account) external view returns (uint8, address[] memory) {