From 26e7cfee3169d8276714d667e0b6c50a1fe1b3ad Mon Sep 17 00:00:00 2001 From: 0xDiscotech <131301107+0xDiscotech@users.noreply.github.com> Date: Wed, 4 Sep 2024 00:47:46 -0300 Subject: [PATCH 1/3] fix: add optimism mintable check on assume address helper --- .../test/L2/L2StandardBridgeInterop.t.sol | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/contracts-bedrock/test/L2/L2StandardBridgeInterop.t.sol b/packages/contracts-bedrock/test/L2/L2StandardBridgeInterop.t.sol index d60ceb264a73..9ebd26323020 100644 --- a/packages/contracts-bedrock/test/L2/L2StandardBridgeInterop.t.sol +++ b/packages/contracts-bedrock/test/L2/L2StandardBridgeInterop.t.sol @@ -17,6 +17,8 @@ import { import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import { IOptimismMintableERC20 } from "src/universal/IOptimismMintableERC20.sol"; +import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; +import { ILegacyMintableERC20 } from "src/universal/OptimismMintableERC20.sol"; // TODO: Replace Predeploys.OPTIMISM_SUPERCHAIN_ERC20_FACTORY with optimismSuperchainERC20Factory import { Predeploys } from "src/libraries/Predeploys.sol"; @@ -63,6 +65,11 @@ contract L2StandardBridgeInterop_Test is Bridge_Initializer { /// @notice Assume a valid address for fuzzing function _assumeAddress(address _address) internal { assumeAddressIsNot(_address, AddressType.Precompile, AddressType.ForgeAddress); + // Assume the address doesn't support an optimistic mintable ERC20 interface, so it doesn't mess with the tests + vm.assume( + !(ERC165Checker.supportsInterface(_address, type(ILegacyMintableERC20).interfaceId)) + && ERC165Checker.supportsInterface(_address, type(IOptimismMintableERC20).interfaceId) + ); } } From 3d5b21692e1805893f001e74f683693bf106abaf Mon Sep 17 00:00:00 2001 From: 0xDiscotech <131301107+0xDiscotech@users.noreply.github.com> Date: Wed, 4 Sep 2024 16:33:48 -0300 Subject: [PATCH 2/3] fix: mock interfaces checks --- .../test/L2/L2StandardBridgeInterop.t.sol | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/contracts-bedrock/test/L2/L2StandardBridgeInterop.t.sol b/packages/contracts-bedrock/test/L2/L2StandardBridgeInterop.t.sol index 9ebd26323020..21b4722fb286 100644 --- a/packages/contracts-bedrock/test/L2/L2StandardBridgeInterop.t.sol +++ b/packages/contracts-bedrock/test/L2/L2StandardBridgeInterop.t.sol @@ -65,11 +65,6 @@ contract L2StandardBridgeInterop_Test is Bridge_Initializer { /// @notice Assume a valid address for fuzzing function _assumeAddress(address _address) internal { assumeAddressIsNot(_address, AddressType.Precompile, AddressType.ForgeAddress); - // Assume the address doesn't support an optimistic mintable ERC20 interface, so it doesn't mess with the tests - vm.assume( - !(ERC165Checker.supportsInterface(_address, type(ILegacyMintableERC20).interfaceId)) - && ERC165Checker.supportsInterface(_address, type(IOptimismMintableERC20).interfaceId) - ); } } @@ -87,7 +82,7 @@ contract L2StandardBridgeInterop_LegacyToSuper_Test is L2StandardBridgeInterop_T // Mock `_from` to be a legacy address _mockInterface(_from, type(IERC165).interfaceId, true); - _mockInterface(_from, type(IOptimismMintableERC20).interfaceId, true); + _mockInterface(_from, type(ILegacyMintableERC20).interfaceId, true); } /// @notice Test that the `convert` function with different decimals reverts @@ -237,6 +232,11 @@ contract L2StandardBridgeInterop_SuperToLegacy_Test is L2StandardBridgeInterop_T // Mock same decimals _mockDecimals(_from, 18); _mockDecimals(_to, 18); + + // Mock `_from` so it is not a LegacyMintableERC20 address + _mockInterface(_from, type(IERC165).interfaceId, true); + _mockInterface(_from, type(ILegacyMintableERC20).interfaceId, false); + _mockInterface(_from, type(IOptimismMintableERC20).interfaceId, false); } /// @notice Test that the `convert` function with different decimals reverts From c5679b239aecec60df2342b629a4b2415343544a Mon Sep 17 00:00:00 2001 From: 0xDiscotech <131301107+0xDiscotech@users.noreply.github.com> Date: Wed, 4 Sep 2024 16:34:57 -0300 Subject: [PATCH 3/3] chore: remove unused import --- packages/contracts-bedrock/test/L2/L2StandardBridgeInterop.t.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/contracts-bedrock/test/L2/L2StandardBridgeInterop.t.sol b/packages/contracts-bedrock/test/L2/L2StandardBridgeInterop.t.sol index 21b4722fb286..0fe37f2cf7c2 100644 --- a/packages/contracts-bedrock/test/L2/L2StandardBridgeInterop.t.sol +++ b/packages/contracts-bedrock/test/L2/L2StandardBridgeInterop.t.sol @@ -17,7 +17,6 @@ import { import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import { IOptimismMintableERC20 } from "src/universal/IOptimismMintableERC20.sol"; -import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; import { ILegacyMintableERC20 } from "src/universal/OptimismMintableERC20.sol"; // TODO: Replace Predeploys.OPTIMISM_SUPERCHAIN_ERC20_FACTORY with optimismSuperchainERC20Factory