From 4973f38ebfed5057c14650aa15bef8e2ddeab0e5 Mon Sep 17 00:00:00 2001 From: Ermyas Abebe Date: Tue, 21 Nov 2023 16:50:51 +1100 Subject: [PATCH 1/5] Change flow rate code license to Apache 2 --- src/root/flowrate/FlowRateDetection.sol | 2 +- src/root/flowrate/FlowRateWithdrawalQueue.sol | 2 +- src/test/root/MockERC20.sol | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/root/flowrate/FlowRateDetection.sol b/src/root/flowrate/FlowRateDetection.sol index c3e790a8..8fe72281 100644 --- a/src/root/flowrate/FlowRateDetection.sol +++ b/src/root/flowrate/FlowRateDetection.sol @@ -1,5 +1,5 @@ // Copyright Immutable Pty Ltd 2018 - 2023 -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: Apache 2.0 pragma solidity 0.8.19; /** diff --git a/src/root/flowrate/FlowRateWithdrawalQueue.sol b/src/root/flowrate/FlowRateWithdrawalQueue.sol index 9aa1b9fc..240f11a3 100644 --- a/src/root/flowrate/FlowRateWithdrawalQueue.sol +++ b/src/root/flowrate/FlowRateWithdrawalQueue.sol @@ -1,5 +1,5 @@ // Copyright Immutable Pty Ltd 2018 - 2023 -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: Apache 2.0 pragma solidity 0.8.19; import { diff --git a/src/test/root/MockERC20.sol b/src/test/root/MockERC20.sol index 78896627..802f324e 100644 --- a/src/test/root/MockERC20.sol +++ b/src/test/root/MockERC20.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: Apache 2.0 pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol"; From 170f6bd98bf175e44bf46344680f81c61769eae2 Mon Sep 17 00:00:00 2001 From: Ermyas Abebe Date: Tue, 21 Nov 2023 20:59:05 +1100 Subject: [PATCH 2/5] Move mocks to test directory --- .github/workflows/coverage.yml | 4 ++-- script/DeployRootContracts.s.sol | 2 +- src/{test/root => lib}/WETH.sol | 2 +- test/integration/child/ChildAxelarBridge.t.sol | 4 ++-- .../child/withdrawals/ChildAxelarBridgeWithdraw.t.sol | 4 ++-- .../child/withdrawals/ChildAxelarBridgeWithdrawETH.t.sol | 5 ++--- .../withdrawals/ChildAxelarBridgeWithdrawETHTo.t.sol | 5 ++--- .../child/withdrawals/ChildAxelarBridgeWithdrawIMX.t.sol | 4 ++-- .../child/withdrawals/ChildAxelarBridgeWithdrawTo.t.sol | 4 ++-- .../withdrawals/ChildAxelarBridgeWithdrawToIMX.t.sol | 4 ++-- .../withdrawals/ChildAxelarBridgeWithdrawWIMX.t.sol | 4 ++-- .../withdrawals/ChildAxelarBridgeWithdrawWIMXTo.t.sol | 5 ++--- test/integration/root/RootERC20BridgeFlowRate.t.sol | 5 ++--- .../withdrawals/RootERC20BridgeFlowRateWithdraw.t.sol | 7 ++----- {src/test => test/mocks}/child/ChildERC20FailOnBurn.sol | 4 ++-- .../mocks}/child/MockChildAxelarGasService.sol | 0 .../test => test/mocks}/child/MockChildAxelarGateway.sol | 0 {src/test => test/mocks}/child/MockChildERC20Bridge.sol | 0 {src/test => test/mocks}/root/MockAdaptor.sol | 0 {src/test => test/mocks}/root/MockAxelarGasService.sol | 0 {src/test => test/mocks}/root/MockAxelarGateway.sol | 0 {src/test => test/mocks}/root/MockERC20.sol | 0 {src/test => test/mocks}/root/StubRootBridge.sol | 0 test/unit/child/ChildAxelarBridgeAdaptor.t.sol | 6 +++--- .../child/withdrawals/ChildERC20BridgeWithdraw.t.sol | 2 +- .../child/withdrawals/ChildERC20BridgeWithdrawETH.t.sol | 2 +- .../withdrawals/ChildERC20BridgeWithdrawETHTo.t.sol | 2 +- .../child/withdrawals/ChildERC20BridgeWithdrawIMX.t.sol | 2 +- .../withdrawals/ChildERC20BridgeWithdrawIMXTo.t.sol | 2 +- .../child/withdrawals/ChildERC20BridgeWithdrawTo.t.sol | 2 +- .../child/withdrawals/ChildERC20BridgeWithdrawWIMX.t.sol | 2 +- .../withdrawals/ChildERC20BridgeWithdrawWIMXTo.t.sol | 2 +- test/unit/root/RootAxelarBridgeAdaptor.t.sol | 6 +++--- test/unit/root/RootERC20Bridge.t.sol | 7 +++---- test/unit/root/flowrate/RootERC20BridgeFlowRate.t.sol | 9 ++++----- .../withdrawals/RootAxelarBridgeAdaptorWithdraw.t.sol | 6 +++--- test/unit/root/withdrawals/RootERC20BridgeWithdraw.t.sol | 6 +++--- test/utils.t.sol | 5 ++--- 38 files changed, 57 insertions(+), 67 deletions(-) rename src/{test/root => lib}/WETH.sol (98%) rename {src/test => test/mocks}/child/ChildERC20FailOnBurn.sol (92%) rename {src/test => test/mocks}/child/MockChildAxelarGasService.sol (100%) rename {src/test => test/mocks}/child/MockChildAxelarGateway.sol (100%) rename {src/test => test/mocks}/child/MockChildERC20Bridge.sol (100%) rename {src/test => test/mocks}/root/MockAdaptor.sol (100%) rename {src/test => test/mocks}/root/MockAxelarGasService.sol (100%) rename {src/test => test/mocks}/root/MockAxelarGateway.sol (100%) rename {src/test => test/mocks}/root/MockERC20.sol (100%) rename {src/test => test/mocks}/root/StubRootBridge.sol (100%) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 16c69cf6..c1ba6d25 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -35,8 +35,8 @@ jobs: # `forge coverage` doesn't have an `exclude-path` flag. # See open issue: https://github.com/foundry-rs/foundry/issues/2988 - # We manually exclude output for the src/test directory, as well as - # the 'Total' row which would be askew with out the full data set. + # We manually exclude output for the test/ directory, as well as + # the 'Total' row which would be askew without the full data set. - name: Run Forge coverage run: | forge coverage --report summary | grep -v "test/" | grep -v "| Total" > ./coverage.out diff --git a/script/DeployRootContracts.s.sol b/script/DeployRootContracts.s.sol index 24e543eb..f58e14f0 100644 --- a/script/DeployRootContracts.s.sol +++ b/script/DeployRootContracts.s.sol @@ -13,7 +13,7 @@ import {RootAxelarBridgeAdaptor} from "../src/root/RootAxelarBridgeAdaptor.sol"; import {ChildERC20Bridge} from "../src/child/ChildERC20Bridge.sol"; import {ChildAxelarBridgeAdaptor} from "../src/child/ChildAxelarBridgeAdaptor.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; -import {WETH} from "../src/test/root/WETH.sol"; +import {WETH} from "../src/lib/WETH.sol"; // TODO update private key usage to be more secure: https://book.getfoundry.sh/reference/forge/forge-script#wallet-options---raw diff --git a/src/test/root/WETH.sol b/src/lib/WETH.sol similarity index 98% rename from src/test/root/WETH.sol rename to src/lib/WETH.sol index 363c6018..4bdf6c15 100644 --- a/src/test/root/WETH.sol +++ b/src/lib/WETH.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.19; -import {IWETH} from "../../interfaces/root/IWETH.sol"; +import {IWETH} from "../interfaces/root/IWETH.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; /** diff --git a/test/integration/child/ChildAxelarBridge.t.sol b/test/integration/child/ChildAxelarBridge.t.sol index 36aeb2e7..e5c618b4 100644 --- a/test/integration/child/ChildAxelarBridge.t.sol +++ b/test/integration/child/ChildAxelarBridge.t.sol @@ -12,8 +12,8 @@ import { IChildERC20BridgeErrors } from "../../../src/child/ChildERC20Bridge.sol"; import {IChildERC20, ChildERC20} from "../../../src/child/ChildERC20.sol"; -import {MockChildAxelarGateway} from "../../../src/test/child/MockChildAxelarGateway.sol"; -import {MockChildAxelarGasService} from "../../../src/test/child/MockChildAxelarGasService.sol"; +import {MockChildAxelarGateway} from "../../mocks/child/MockChildAxelarGateway.sol"; +import {MockChildAxelarGasService} from "../../mocks/child/MockChildAxelarGasService.sol"; import {Utils} from "../../utils.t.sol"; contract ChildERC20BridgeIntegrationTest is Test, IChildERC20BridgeEvents, IChildERC20BridgeErrors, Utils { diff --git a/test/integration/child/withdrawals/ChildAxelarBridgeWithdraw.t.sol b/test/integration/child/withdrawals/ChildAxelarBridgeWithdraw.t.sol index 9f69c2d2..646a727a 100644 --- a/test/integration/child/withdrawals/ChildAxelarBridgeWithdraw.t.sol +++ b/test/integration/child/withdrawals/ChildAxelarBridgeWithdraw.t.sol @@ -2,8 +2,8 @@ pragma solidity 0.8.19; import {Test} from "forge-std/Test.sol"; -import {MockAxelarGateway} from "../../../../src/test/root/MockAxelarGateway.sol"; -import {MockAxelarGasService} from "../../../../src/test/root/MockAxelarGasService.sol"; +import {MockAxelarGateway} from "../../../mocks/root/MockAxelarGateway.sol"; +import {MockAxelarGasService} from "../../../mocks/root/MockAxelarGasService.sol"; import {ChildERC20Bridge, IChildERC20BridgeEvents} from "../../../../src/child/ChildERC20Bridge.sol"; import { ChildAxelarBridgeAdaptor, diff --git a/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawETH.t.sol b/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawETH.t.sol index bf1ba464..a6ddd227 100644 --- a/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawETH.t.sol +++ b/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawETH.t.sol @@ -5,8 +5,8 @@ import {Test, console2} from "forge-std/Test.sol"; import {ERC20PresetMinterPauser} from "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol"; import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; -import {MockAxelarGateway} from "../../../../src/test/root/MockAxelarGateway.sol"; -import {MockAxelarGasService} from "../../../../src/test/root/MockAxelarGasService.sol"; +import {MockAxelarGateway} from "../../../mocks/root/MockAxelarGateway.sol"; +import {MockAxelarGasService} from "../../../mocks/root/MockAxelarGasService.sol"; import {ChildERC20Bridge, IChildERC20BridgeEvents} from "../../../../src/child/ChildERC20Bridge.sol"; import { ChildAxelarBridgeAdaptor, @@ -14,7 +14,6 @@ import { IChildAxelarBridgeAdaptorErrors } from "../../../../src/child/ChildAxelarBridgeAdaptor.sol"; import {Utils} from "../../../utils.t.sol"; -import {WETH} from "../../../../src/test/root/WETH.sol"; import {WIMX} from "../../../../src/child/WIMX.sol"; import {ChildERC20} from "../../../../src/child/ChildERC20.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; diff --git a/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawETHTo.t.sol b/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawETHTo.t.sol index 18e2966b..f3243522 100644 --- a/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawETHTo.t.sol +++ b/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawETHTo.t.sol @@ -5,8 +5,8 @@ import {Test, console2} from "forge-std/Test.sol"; import {ERC20PresetMinterPauser} from "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol"; import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; -import {MockAxelarGateway} from "../../../../src/test/root/MockAxelarGateway.sol"; -import {MockAxelarGasService} from "../../../../src/test/root/MockAxelarGasService.sol"; +import {MockAxelarGateway} from "../../../mocks/root/MockAxelarGateway.sol"; +import {MockAxelarGasService} from "../../../mocks/root/MockAxelarGasService.sol"; import {ChildERC20Bridge, IChildERC20BridgeEvents} from "../../../../src/child/ChildERC20Bridge.sol"; import { ChildAxelarBridgeAdaptor, @@ -14,7 +14,6 @@ import { IChildAxelarBridgeAdaptorErrors } from "../../../../src/child/ChildAxelarBridgeAdaptor.sol"; import {Utils} from "../../../utils.t.sol"; -import {WETH} from "../../../../src/test/root/WETH.sol"; import {WIMX} from "../../../../src/child/WIMX.sol"; import {ChildERC20} from "../../../../src/child/ChildERC20.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; diff --git a/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawIMX.t.sol b/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawIMX.t.sol index 45d0538b..c08ed389 100644 --- a/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawIMX.t.sol +++ b/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawIMX.t.sol @@ -3,8 +3,8 @@ pragma solidity 0.8.19; import {Test} from "forge-std/Test.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; -import {MockAxelarGateway} from "../../../../src/test/root/MockAxelarGateway.sol"; -import {MockAxelarGasService} from "../../../../src/test/root/MockAxelarGasService.sol"; +import {MockAxelarGateway} from "../../../mocks/root/MockAxelarGateway.sol"; +import {MockAxelarGasService} from "../../../mocks/root/MockAxelarGasService.sol"; import {ChildERC20Bridge, IChildERC20BridgeEvents} from "../../../../src/child/ChildERC20Bridge.sol"; import { ChildAxelarBridgeAdaptor, diff --git a/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawTo.t.sol b/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawTo.t.sol index 69ece184..a5344353 100644 --- a/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawTo.t.sol +++ b/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawTo.t.sol @@ -2,8 +2,8 @@ pragma solidity 0.8.19; import {Test} from "forge-std/Test.sol"; -import {MockAxelarGateway} from "../../../../src/test/root/MockAxelarGateway.sol"; -import {MockAxelarGasService} from "../../../../src/test/root/MockAxelarGasService.sol"; +import {MockAxelarGateway} from "../../../mocks/root/MockAxelarGateway.sol"; +import {MockAxelarGasService} from "../../../mocks/root/MockAxelarGasService.sol"; import {ChildERC20Bridge, IChildERC20BridgeEvents} from "../../../../src/child/ChildERC20Bridge.sol"; import { ChildAxelarBridgeAdaptor, diff --git a/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawToIMX.t.sol b/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawToIMX.t.sol index 09bcb88e..7fd11b04 100644 --- a/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawToIMX.t.sol +++ b/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawToIMX.t.sol @@ -4,8 +4,8 @@ pragma solidity 0.8.19; import {Test} from "forge-std/Test.sol"; import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; -import {MockAxelarGateway} from "../../../../src/test/root/MockAxelarGateway.sol"; -import {MockAxelarGasService} from "../../../../src/test/root/MockAxelarGasService.sol"; +import {MockAxelarGateway} from "../../../mocks/root/MockAxelarGateway.sol"; +import {MockAxelarGasService} from "../../../mocks/root/MockAxelarGasService.sol"; import {ChildERC20Bridge, IChildERC20BridgeEvents} from "../../../../src/child/ChildERC20Bridge.sol"; import { ChildAxelarBridgeAdaptor, diff --git a/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawWIMX.t.sol b/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawWIMX.t.sol index 590164f1..f3dc6ad3 100644 --- a/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawWIMX.t.sol +++ b/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawWIMX.t.sol @@ -2,8 +2,8 @@ pragma solidity ^0.8.19; import {Test} from "forge-std/Test.sol"; -import {MockAxelarGateway} from "../../../../src/test/root/MockAxelarGateway.sol"; -import {MockAxelarGasService} from "../../../../src/test/root/MockAxelarGasService.sol"; +import {MockAxelarGateway} from "../../../mocks/root/MockAxelarGateway.sol"; +import {MockAxelarGasService} from "../../../mocks/root/MockAxelarGasService.sol"; import {ChildERC20Bridge, IChildERC20BridgeEvents} from "../../../../src/child/ChildERC20Bridge.sol"; import { ChildAxelarBridgeAdaptor, diff --git a/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawWIMXTo.t.sol b/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawWIMXTo.t.sol index 2e165710..9be8cf84 100644 --- a/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawWIMXTo.t.sol +++ b/test/integration/child/withdrawals/ChildAxelarBridgeWithdrawWIMXTo.t.sol @@ -5,8 +5,8 @@ import {Test} from "forge-std/Test.sol"; import {ERC20PresetMinterPauser} from "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol"; import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; -import {MockAxelarGateway} from "../../../../src/test/root/MockAxelarGateway.sol"; -import {MockAxelarGasService} from "../../../../src/test/root/MockAxelarGasService.sol"; +import {MockAxelarGateway} from "../../../mocks/root/MockAxelarGateway.sol"; +import {MockAxelarGasService} from "../../../mocks/root/MockAxelarGasService.sol"; import {ChildERC20Bridge, IChildERC20BridgeEvents} from "../../../../src/child/ChildERC20Bridge.sol"; import { ChildAxelarBridgeAdaptor, @@ -14,7 +14,6 @@ import { IChildAxelarBridgeAdaptorErrors } from "../../../../src/child/ChildAxelarBridgeAdaptor.sol"; import {Utils} from "../../../utils.t.sol"; -import {WETH} from "../../../../src/test/root/WETH.sol"; import {WIMX} from "../../../../src/child/WIMX.sol"; import {ChildERC20} from "../../../../src/child/ChildERC20.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; diff --git a/test/integration/root/RootERC20BridgeFlowRate.t.sol b/test/integration/root/RootERC20BridgeFlowRate.t.sol index b356ff7d..da95a453 100644 --- a/test/integration/root/RootERC20BridgeFlowRate.t.sol +++ b/test/integration/root/RootERC20BridgeFlowRate.t.sol @@ -5,13 +5,12 @@ import {Test, console2} from "forge-std/Test.sol"; import {ERC20PresetMinterPauser} from "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol"; import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; -import {MockAxelarGateway} from "../../../src/test/root/MockAxelarGateway.sol"; -import {MockAxelarGasService} from "../../../src/test/root/MockAxelarGasService.sol"; +import {MockAxelarGateway} from "../../mocks/root/MockAxelarGateway.sol"; +import {MockAxelarGasService} from "../../mocks/root/MockAxelarGasService.sol"; import {RootERC20Bridge, IRootERC20BridgeEvents, IERC20Metadata} from "../../../src/root/RootERC20Bridge.sol"; import {RootERC20BridgeFlowRate} from "../../../src/root/flowrate/RootERC20BridgeFlowRate.sol"; import {RootAxelarBridgeAdaptor, IRootAxelarBridgeAdaptorEvents} from "../../../src/root/RootAxelarBridgeAdaptor.sol"; import {Utils} from "../../utils.t.sol"; -import {WETH} from "../../../src/test/root/WETH.sol"; contract RootERC20BridgeFlowRateIntegrationTest is Test, diff --git a/test/integration/root/withdrawals/RootERC20BridgeFlowRateWithdraw.t.sol b/test/integration/root/withdrawals/RootERC20BridgeFlowRateWithdraw.t.sol index 4e578108..2da6803a 100644 --- a/test/integration/root/withdrawals/RootERC20BridgeFlowRateWithdraw.t.sol +++ b/test/integration/root/withdrawals/RootERC20BridgeFlowRateWithdraw.t.sol @@ -5,8 +5,8 @@ import {Test, console2} from "forge-std/Test.sol"; import {ERC20PresetMinterPauser} from "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol"; import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; -import {MockAxelarGateway} from "../../../../src/test/root/MockAxelarGateway.sol"; -import {MockAxelarGasService} from "../../../../src/test/root/MockAxelarGasService.sol"; +import {MockAxelarGateway} from "../../../mocks/root/MockAxelarGateway.sol"; +import {MockAxelarGasService} from "../../../mocks/root/MockAxelarGasService.sol"; import { RootERC20Bridge, IRootERC20BridgeEvents, @@ -19,7 +19,6 @@ import { RootAxelarBridgeAdaptor, IRootAxelarBridgeAdaptorEvents } from "../../../../src/root/RootAxelarBridgeAdaptor.sol"; import {Utils} from "../../../utils.t.sol"; -import {WETH} from "../../../../src/test/root/WETH.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; contract RootERC20BridgeFlowRateWithdrawIntegrationTest is @@ -52,8 +51,6 @@ contract RootERC20BridgeFlowRateWithdrawIntegrationTest is function setUp() public { console2.log("root withdraw setUp"); - deployCodeTo("WETH.sol", abi.encode("Wrapped ETH", "WETH"), WRAPPED_ETH); - RootIntegration memory integration = rootIntegrationSetup( CHILD_BRIDGE, CHILD_BRIDGE_ADAPTOR, diff --git a/src/test/child/ChildERC20FailOnBurn.sol b/test/mocks/child/ChildERC20FailOnBurn.sol similarity index 92% rename from src/test/child/ChildERC20FailOnBurn.sol rename to test/mocks/child/ChildERC20FailOnBurn.sol index 8d86b6e9..99654fcb 100644 --- a/src/test/child/ChildERC20FailOnBurn.sol +++ b/test/mocks/child/ChildERC20FailOnBurn.sol @@ -2,8 +2,7 @@ // Adapted from OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol) pragma solidity 0.8.19; -import "../../child/ChildERC20.sol"; - +import "../../../src/child/ChildERC20.sol"; /** * @title ChildERC20FailOnBurn * @author Immutable (@Benjimmutable) @@ -11,6 +10,7 @@ import "../../child/ChildERC20.sol"; * @dev USED FOR TESTING */ // solhint-disable reason-string + contract ChildERC20FailOnBurn is ChildERC20 { function burn(address, /*account*/ uint256 /*amount*/ ) public virtual override returns (bool) { return false; diff --git a/src/test/child/MockChildAxelarGasService.sol b/test/mocks/child/MockChildAxelarGasService.sol similarity index 100% rename from src/test/child/MockChildAxelarGasService.sol rename to test/mocks/child/MockChildAxelarGasService.sol diff --git a/src/test/child/MockChildAxelarGateway.sol b/test/mocks/child/MockChildAxelarGateway.sol similarity index 100% rename from src/test/child/MockChildAxelarGateway.sol rename to test/mocks/child/MockChildAxelarGateway.sol diff --git a/src/test/child/MockChildERC20Bridge.sol b/test/mocks/child/MockChildERC20Bridge.sol similarity index 100% rename from src/test/child/MockChildERC20Bridge.sol rename to test/mocks/child/MockChildERC20Bridge.sol diff --git a/src/test/root/MockAdaptor.sol b/test/mocks/root/MockAdaptor.sol similarity index 100% rename from src/test/root/MockAdaptor.sol rename to test/mocks/root/MockAdaptor.sol diff --git a/src/test/root/MockAxelarGasService.sol b/test/mocks/root/MockAxelarGasService.sol similarity index 100% rename from src/test/root/MockAxelarGasService.sol rename to test/mocks/root/MockAxelarGasService.sol diff --git a/src/test/root/MockAxelarGateway.sol b/test/mocks/root/MockAxelarGateway.sol similarity index 100% rename from src/test/root/MockAxelarGateway.sol rename to test/mocks/root/MockAxelarGateway.sol diff --git a/src/test/root/MockERC20.sol b/test/mocks/root/MockERC20.sol similarity index 100% rename from src/test/root/MockERC20.sol rename to test/mocks/root/MockERC20.sol diff --git a/src/test/root/StubRootBridge.sol b/test/mocks/root/StubRootBridge.sol similarity index 100% rename from src/test/root/StubRootBridge.sol rename to test/mocks/root/StubRootBridge.sol diff --git a/test/unit/child/ChildAxelarBridgeAdaptor.t.sol b/test/unit/child/ChildAxelarBridgeAdaptor.t.sol index af0463fe..6b50dbb9 100644 --- a/test/unit/child/ChildAxelarBridgeAdaptor.t.sol +++ b/test/unit/child/ChildAxelarBridgeAdaptor.t.sol @@ -5,9 +5,9 @@ import {Test} from "forge-std/Test.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; import {ERC20PresetMinterPauser} from "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol"; import {ChildAxelarBridgeAdaptor} from "../../../src/child/ChildAxelarBridgeAdaptor.sol"; -import {MockChildERC20Bridge} from "../../../src/test/child/MockChildERC20Bridge.sol"; -import {MockChildAxelarGateway} from "../../../src/test/child/MockChildAxelarGateway.sol"; -import {MockChildAxelarGasService} from "../../../src/test/child/MockChildAxelarGasService.sol"; +import {MockChildERC20Bridge} from "../../mocks/child/MockChildERC20Bridge.sol"; +import {MockChildAxelarGateway} from "../../mocks/child/MockChildAxelarGateway.sol"; +import {MockChildAxelarGasService} from "../../mocks/child/MockChildAxelarGasService.sol"; import { IChildAxelarBridgeAdaptorErrors, IChildAxelarBridgeAdaptorEvents, diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol index 8fe14902..15a2820c 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol @@ -10,7 +10,7 @@ import { IChildERC20BridgeErrors } from "../../../../src/child/ChildERC20Bridge.sol"; import {IChildERC20, ChildERC20} from "../../../../src/child/ChildERC20.sol"; -import {MockAdaptor} from "../../../../src/test/root/MockAdaptor.sol"; +import {MockAdaptor} from "../../../mocks/root/MockAdaptor.sol"; import {Utils, IPausable} from "../../../utils.t.sol"; contract ChildERC20BridgeWithdrawUnitTest is Test, IChildERC20BridgeEvents, IChildERC20BridgeErrors, Utils { diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETH.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETH.t.sol index 3a834454..15e7dabb 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETH.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETH.t.sol @@ -11,7 +11,7 @@ import { } from "../../../../src/child/ChildERC20Bridge.sol"; import {IChildERC20} from "../../../../src/interfaces/child/IChildERC20.sol"; import {ChildERC20} from "../../../../src/child/ChildERC20.sol"; -import {MockAdaptor} from "../../../../src/test/root/MockAdaptor.sol"; +import {MockAdaptor} from "../../../mocks/root/MockAdaptor.sol"; import {Utils, IPausable} from "../../../utils.t.sol"; contract ChildERC20BridgeWithdrawETHUnitTest is Test, IChildERC20BridgeEvents, IChildERC20BridgeErrors, Utils { diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETHTo.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETHTo.t.sol index 54a8e9d6..a9ee0538 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETHTo.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETHTo.t.sol @@ -13,7 +13,7 @@ import { } from "../../../../src/child/ChildERC20Bridge.sol"; import {IChildERC20} from "../../../../src/interfaces/child/IChildERC20.sol"; import {ChildERC20} from "../../../../src/child/ChildERC20.sol"; -import {MockAdaptor} from "../../../../src/test/root/MockAdaptor.sol"; +import {MockAdaptor} from "../../../mocks/root/MockAdaptor.sol"; import {Utils, IPausable} from "../../../utils.t.sol"; contract ChildERC20BridgeWithdrawETHToUnitTest is Test, IChildERC20BridgeEvents, IChildERC20BridgeErrors, Utils { diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawIMX.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawIMX.t.sol index 82912ff1..6f75801c 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawIMX.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawIMX.t.sol @@ -10,7 +10,7 @@ import { IChildERC20BridgeErrors } from "../../../../src/child/ChildERC20Bridge.sol"; import {ChildERC20} from "../../../../src/child/ChildERC20.sol"; -import {MockAdaptor} from "../../../../src/test/root/MockAdaptor.sol"; +import {MockAdaptor} from "../../../mocks/root/MockAdaptor.sol"; import {Utils, IPausable} from "../../../utils.t.sol"; contract ChildERC20BridgeWithdrawIMXUnitTest is Test, IChildERC20BridgeEvents, IChildERC20BridgeErrors, Utils { diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawIMXTo.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawIMXTo.t.sol index 28d9d8c1..fc55abb4 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawIMXTo.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawIMXTo.t.sol @@ -10,7 +10,7 @@ import { IChildERC20BridgeErrors } from "../../../../src/child/ChildERC20Bridge.sol"; import {ChildERC20} from "../../../../src/child/ChildERC20.sol"; -import {MockAdaptor} from "../../../../src/test/root/MockAdaptor.sol"; +import {MockAdaptor} from "../../../mocks/root/MockAdaptor.sol"; import {Utils, IPausable} from "../../../utils.t.sol"; contract ChildERC20BridgeWithdrawIMXToUnitTest is Test, IChildERC20BridgeEvents, IChildERC20BridgeErrors, Utils { diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawTo.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawTo.t.sol index 28345273..cf11c621 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawTo.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawTo.t.sol @@ -10,7 +10,7 @@ import { IChildERC20BridgeErrors } from "../../../../src/child/ChildERC20Bridge.sol"; import {IChildERC20, ChildERC20} from "../../../../src/child/ChildERC20.sol"; -import {MockAdaptor} from "../../../../src/test/root/MockAdaptor.sol"; +import {MockAdaptor} from "../../../mocks/root/MockAdaptor.sol"; import {Utils, IPausable} from "../../../utils.t.sol"; contract ChildERC20BridgeWithdrawToUnitTest is Test, IChildERC20BridgeEvents, IChildERC20BridgeErrors, Utils { diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMX.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMX.t.sol index facabe50..b6df68f9 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMX.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMX.t.sol @@ -10,7 +10,7 @@ import { IChildERC20BridgeErrors } from "../../../../src/child/ChildERC20Bridge.sol"; import {ChildERC20} from "../../../../src/child/ChildERC20.sol"; -import {MockAdaptor} from "../../../../src/test/root/MockAdaptor.sol"; +import {MockAdaptor} from "../../../mocks/root/MockAdaptor.sol"; import {Utils, IPausable} from "../../../utils.t.sol"; import {WIMX} from "../../../../src/child/WIMX.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMXTo.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMXTo.t.sol index 2bd0cf7b..213a9a60 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMXTo.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMXTo.t.sol @@ -10,7 +10,7 @@ import { IChildERC20BridgeErrors } from "../../../../src/child/ChildERC20Bridge.sol"; import {ChildERC20} from "../../../../src/child/ChildERC20.sol"; -import {MockAdaptor} from "../../../../src/test/root/MockAdaptor.sol"; +import {MockAdaptor} from "../../../mocks/root/MockAdaptor.sol"; import {Utils, IPausable} from "../../../utils.t.sol"; import {WIMX} from "../../../../src/child/WIMX.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; diff --git a/test/unit/root/RootAxelarBridgeAdaptor.t.sol b/test/unit/root/RootAxelarBridgeAdaptor.t.sol index f9827f80..55a0d6c8 100644 --- a/test/unit/root/RootAxelarBridgeAdaptor.t.sol +++ b/test/unit/root/RootAxelarBridgeAdaptor.t.sol @@ -5,15 +5,15 @@ import {Test, console2} from "forge-std/Test.sol"; import {ERC20PresetMinterPauser} from "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; -import {MockAxelarGateway} from "../../../src/test/root/MockAxelarGateway.sol"; -import {MockAxelarGasService} from "../../../src/test/root/MockAxelarGasService.sol"; +import {MockAxelarGateway} from "../../mocks/root/MockAxelarGateway.sol"; +import {MockAxelarGasService} from "../../mocks/root/MockAxelarGasService.sol"; import { RootAxelarBridgeAdaptor, IRootAxelarBridgeAdaptorEvents, IRootAxelarBridgeAdaptorErrors, IRootAxelarBridgeAdaptor } from "../../../src/root/RootAxelarBridgeAdaptor.sol"; -import {StubRootBridge} from "../../../src/test/root/StubRootBridge.sol"; +import {StubRootBridge} from "../../mocks/root/StubRootBridge.sol"; import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; contract RootAxelarBridgeAdaptorTest is Test, IRootAxelarBridgeAdaptorEvents, IRootAxelarBridgeAdaptorErrors { diff --git a/test/unit/root/RootERC20Bridge.t.sol b/test/unit/root/RootERC20Bridge.t.sol index 7e061e54..c6c146fe 100644 --- a/test/unit/root/RootERC20Bridge.t.sol +++ b/test/unit/root/RootERC20Bridge.t.sol @@ -13,11 +13,10 @@ import { IRootERC20BridgeErrors, IRootERC20Bridge } from "../../../src/root/RootERC20Bridge.sol"; -import {MockAxelarGateway} from "../../../src/test/root/MockAxelarGateway.sol"; -import {MockAxelarGasService} from "../../../src/test/root/MockAxelarGasService.sol"; -import {MockAdaptor} from "../../../src/test/root/MockAdaptor.sol"; +import {MockAxelarGateway} from "../../mocks/root/MockAxelarGateway.sol"; +import {MockAxelarGasService} from "../../mocks/root/MockAxelarGasService.sol"; +import {MockAdaptor} from "../../mocks/root/MockAdaptor.sol"; import {Utils, IPausable} from "../../utils.t.sol"; -import {WETH} from "../../../src/test/root/WETH.sol"; contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20BridgeErrors, Utils { bytes32 constant ADAPTOR_MANAGER_ROLE = keccak256("ADAPTOR_MANAGER_ROLE"); diff --git a/test/unit/root/flowrate/RootERC20BridgeFlowRate.t.sol b/test/unit/root/flowrate/RootERC20BridgeFlowRate.t.sol index 0b03e983..0a8327c6 100644 --- a/test/unit/root/flowrate/RootERC20BridgeFlowRate.t.sol +++ b/test/unit/root/flowrate/RootERC20BridgeFlowRate.t.sol @@ -18,12 +18,11 @@ import { } from "../../../../src/root/flowrate/FlowRateWithdrawalQueue.sol"; import {IRootERC20BridgeEvents, IRootERC20BridgeErrors} from "../../../../src/root/RootERC20Bridge.sol"; import {FlowRateWithdrawalQueue} from "../../../../src/root/flowrate/FlowRateWithdrawalQueue.sol"; -import {MockAxelarGateway} from "../../../../src/test/root/MockAxelarGateway.sol"; -import {MockAxelarGasService} from "../../../../src/test/root/MockAxelarGasService.sol"; -import {MockAdaptor} from "../../../../src/test/root/MockAdaptor.sol"; +import {MockAxelarGateway} from "../../../mocks/root/MockAxelarGateway.sol"; +import {MockAxelarGasService} from "../../../mocks/root/MockAxelarGasService.sol"; +import {MockAdaptor} from "../../../mocks/root/MockAdaptor.sol"; import {Utils} from "../../../utils.t.sol"; -import {WETH} from "../../../../src/test/root/WETH.sol"; -import {MockERC20} from "../../../../src/test/root/MockERC20.sol"; +import {MockERC20} from "../../../mocks/root/MockERC20.sol"; contract ReentrancyAttackERC20 is MockERC20 { RootERC20BridgeFlowRate bridge; diff --git a/test/unit/root/withdrawals/RootAxelarBridgeAdaptorWithdraw.t.sol b/test/unit/root/withdrawals/RootAxelarBridgeAdaptorWithdraw.t.sol index 3630d460..9216aed0 100644 --- a/test/unit/root/withdrawals/RootAxelarBridgeAdaptorWithdraw.t.sol +++ b/test/unit/root/withdrawals/RootAxelarBridgeAdaptorWithdraw.t.sol @@ -4,15 +4,15 @@ pragma solidity 0.8.19; import {Test, console2} from "forge-std/Test.sol"; import {ERC20PresetMinterPauser} from "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; -import {MockAxelarGateway} from "../../../../src/test/root/MockAxelarGateway.sol"; -import {MockAxelarGasService} from "../../../../src/test/root/MockAxelarGasService.sol"; +import {MockAxelarGateway} from "../../../mocks/root/MockAxelarGateway.sol"; +import {MockAxelarGasService} from "../../../mocks/root/MockAxelarGasService.sol"; import { RootAxelarBridgeAdaptor, IRootAxelarBridgeAdaptorEvents, IRootAxelarBridgeAdaptorErrors, IRootAxelarBridgeAdaptor } from "../../../../src/root/RootAxelarBridgeAdaptor.sol"; -import {StubRootBridge} from "../../../../src/test/root/StubRootBridge.sol"; +import {StubRootBridge} from "../../../mocks/root/StubRootBridge.sol"; contract RootAxelarBridgeWithdrawAdaptorTest is Test, IRootAxelarBridgeAdaptorEvents, IRootAxelarBridgeAdaptorErrors { address constant CHILD_BRIDGE = address(3); diff --git a/test/unit/root/withdrawals/RootERC20BridgeWithdraw.t.sol b/test/unit/root/withdrawals/RootERC20BridgeWithdraw.t.sol index bc0ae773..7acc8d7b 100644 --- a/test/unit/root/withdrawals/RootERC20BridgeWithdraw.t.sol +++ b/test/unit/root/withdrawals/RootERC20BridgeWithdraw.t.sol @@ -10,9 +10,9 @@ import { IRootERC20BridgeErrors, IRootERC20Bridge } from "../../../../src/root/RootERC20Bridge.sol"; -import {MockAxelarGateway} from "../../../../src/test/root/MockAxelarGateway.sol"; -import {MockAxelarGasService} from "../../../../src/test/root/MockAxelarGasService.sol"; -import {MockAdaptor} from "../../../../src/test/root/MockAdaptor.sol"; +import {MockAxelarGateway} from "../../../mocks/root/MockAxelarGateway.sol"; +import {MockAxelarGasService} from "../../../mocks/root/MockAxelarGasService.sol"; +import {MockAdaptor} from "../../../mocks/root/MockAdaptor.sol"; import {Utils} from "../../../utils.t.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; diff --git a/test/utils.t.sol b/test/utils.t.sol index 0d3a1c72..935740aa 100644 --- a/test/utils.t.sol +++ b/test/utils.t.sol @@ -4,13 +4,12 @@ pragma solidity 0.8.19; import {Test, console2} from "forge-std/Test.sol"; import {ERC20PresetMinterPauser} from "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; -import {MockAxelarGateway} from "../src/test/root/MockAxelarGateway.sol"; -import {MockAxelarGasService} from "../src/test/root/MockAxelarGasService.sol"; +import {MockAxelarGateway} from "./mocks/root/MockAxelarGateway.sol"; +import {MockAxelarGasService} from "./mocks/root/MockAxelarGasService.sol"; import {RootERC20Bridge, IERC20Metadata} from "../src/root/RootERC20Bridge.sol"; import {RootERC20BridgeFlowRate} from "../src/root//flowrate/RootERC20BridgeFlowRate.sol"; import {ChildERC20Bridge, IChildERC20Bridge} from "../src/child/ChildERC20Bridge.sol"; import {ChildAxelarBridgeAdaptor, IChildAxelarBridgeAdaptor} from "../src/child/ChildAxelarBridgeAdaptor.sol"; -import {WETH} from "../src/test/root/WETH.sol"; import {IWETH} from "../src/interfaces/root/IWETH.sol"; import {WIMX} from "../src/child/WIMX.sol"; From 9b665f0f9c6d60f17f595d56b99d82fdc053e4cb Mon Sep 17 00:00:00 2001 From: Ermyas Abebe Date: Tue, 21 Nov 2023 21:11:08 +1100 Subject: [PATCH 3/5] Remove slither warning disabling comment --- src/root/RootERC20Bridge.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/src/root/RootERC20Bridge.sol b/src/root/RootERC20Bridge.sol index d11293b9..cf4d4476 100644 --- a/src/root/RootERC20Bridge.sol +++ b/src/root/RootERC20Bridge.sol @@ -504,7 +504,6 @@ contract RootERC20Bridge is BridgeRoles, IRootERC20Bridge, IRootERC20BridgeEvent IERC20Metadata(rootToken).safeTransfer(receiver, amount); emit RootChainERC20Withdraw(rootToken, childToken, withdrawer, receiver, amount); } - // slither-disable-next-line reentrancy-events } // slither-disable-next-line unused-state,naming-convention From 11835aee8b07f24ce0dbb4321adaa189c37ce600 Mon Sep 17 00:00:00 2001 From: Ermyas Abebe Date: Tue, 21 Nov 2023 21:34:03 +1100 Subject: [PATCH 4/5] Add storage gaps to roles contracts --- src/common/AdaptorRoles.sol | 3 +++ src/common/BridgeRoles.sol | 3 +++ test/integration/child/ChildAxelarBridge.t.sol | 2 +- test/unit/child/ChildERC20Bridge.t.sol | 4 ++-- test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol | 2 +- test/unit/child/withdrawals/ChildERC20BridgeWithdrawTo.t.sol | 2 +- test/unit/root/RootERC20Bridge.t.sol | 2 +- 7 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/common/AdaptorRoles.sol b/src/common/AdaptorRoles.sol index 630620c1..b0ddc688 100644 --- a/src/common/AdaptorRoles.sol +++ b/src/common/AdaptorRoles.sol @@ -63,4 +63,7 @@ abstract contract AdaptorRoles is AccessControlUpgradeable { function revokeTargetMangaerRole(address account) external onlyRole(DEFAULT_ADMIN_ROLE) { revokeRole(TARGET_MANAGER_ROLE, account); } + + // slither-disable-next-line unused-state,naming-convention + uint256[50] private __gapAdaptorRoles; } diff --git a/src/common/BridgeRoles.sol b/src/common/BridgeRoles.sol index 58239054..c2d8e45d 100644 --- a/src/common/BridgeRoles.sol +++ b/src/common/BridgeRoles.sol @@ -81,4 +81,7 @@ abstract contract BridgeRoles is AccessControlUpgradeable, PausableUpgradeable { function unpause() external onlyRole(UNPAUSER_ROLE) { _unpause(); } + + // slither-disable-next-line unused-state,naming-convention + uint256[50] private __gapBridgeRoles; } diff --git a/test/integration/child/ChildAxelarBridge.t.sol b/test/integration/child/ChildAxelarBridge.t.sol index e5c618b4..6dfd7c0c 100644 --- a/test/integration/child/ChildAxelarBridge.t.sol +++ b/test/integration/child/ChildAxelarBridge.t.sol @@ -317,7 +317,7 @@ contract ChildERC20BridgeIntegrationTest is Test, IChildERC20BridgeEvents, IChil address rootAddress = address(0x123); { // Found by running `forge inspect src/child/ChildERC20Bridge.sol:ChildERC20Bridge storageLayout | grep -B3 -A5 -i "rootTokenToChildToken"` - uint256 rootTokenToChildTokenMappingSlot = 201; + uint256 rootTokenToChildTokenMappingSlot = 251; address childAddress = address(444444); bytes32 slot = getMappingStorageSlotFor(rootAddress, rootTokenToChildTokenMappingSlot); bytes32 data = bytes32(uint256(uint160(childAddress))); diff --git a/test/unit/child/ChildERC20Bridge.t.sol b/test/unit/child/ChildERC20Bridge.t.sol index b6782bf8..d7d24400 100644 --- a/test/unit/child/ChildERC20Bridge.t.sol +++ b/test/unit/child/ChildERC20Bridge.t.sol @@ -64,7 +64,7 @@ contract ChildERC20BridgeUnitTest is Test, IChildERC20BridgeEvents, IChildERC20B address caller = address(0x123a); payable(caller).transfer(2 ether); // forge inspect src/child/ChildERC20Bridge.sol:ChildERC20Bridge storageLayout | grep -B3 -A5 -i "wIMXToken" - uint256 wIMXStorageSlot = 208; + uint256 wIMXStorageSlot = 258; vm.store(address(childBridge), bytes32(wIMXStorageSlot), bytes32(uint256(uint160(caller)))); vm.startPrank(caller); @@ -664,7 +664,7 @@ contract ChildERC20BridgeUnitTest is Test, IChildERC20BridgeEvents, IChildERC20B address rootAddress = address(0x123); { // Found by running `forge inspect src/child/ChildERC20Bridge.sol:ChildERC20Bridge storageLayout | grep -B3 -A5 -i "rootTokenToChildToken"` - uint256 rootTokenToChildTokenMappingSlot = 201; + uint256 rootTokenToChildTokenMappingSlot = 251; address childAddress = address(444444); bytes32 slot = getMappingStorageSlotFor(rootAddress, rootTokenToChildTokenMappingSlot); bytes32 data = bytes32(uint256(uint160(childAddress))); diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol index 15a2820c..66444daa 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol @@ -114,7 +114,7 @@ contract ChildERC20BridgeWithdrawUnitTest is Test, IChildERC20BridgeEvents, IChi // Slot is 2 because of the Ownable, Initializable contracts coming first. // Found by running `forge inspect src/child/ChildERC20Bridge.sol:ChildERC20Bridge storageLayout | grep -B3 -A5 -i "rootTokenToChildToken"` - uint256 rootTokenToChildTokenMappingSlot = 201; + uint256 rootTokenToChildTokenMappingSlot = 251; bytes32 slot = getMappingStorageSlotFor(address(0), rootTokenToChildTokenMappingSlot); bytes32 data = bytes32(uint256(uint160(address(childToken)))); diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawTo.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawTo.t.sol index cf11c621..2d293748 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawTo.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawTo.t.sol @@ -120,7 +120,7 @@ contract ChildERC20BridgeWithdrawToUnitTest is Test, IChildERC20BridgeEvents, IC /* Then, set rootTokenToChildToken[address(0)] to the child token (to bypass the NotMapped check) */ // Found by running `forge inspect src/child/ChildERC20Bridge.sol:ChildERC20Bridge storageLayout | grep -B3 -A5 -i "rootTokenToChildToken"` - uint256 rootTokenToChildTokenMappingSlot = 201; + uint256 rootTokenToChildTokenMappingSlot = 251; bytes32 slot = getMappingStorageSlotFor(address(0), rootTokenToChildTokenMappingSlot); bytes32 data = bytes32(uint256(uint160(address(childToken)))); diff --git a/test/unit/root/RootERC20Bridge.t.sol b/test/unit/root/RootERC20Bridge.t.sol index c6c146fe..2d8c3ae4 100644 --- a/test/unit/root/RootERC20Bridge.t.sol +++ b/test/unit/root/RootERC20Bridge.t.sol @@ -90,7 +90,7 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid address caller = address(0x123a); payable(caller).transfer(2 ether); // forge inspect src/root/RootERC20Bridge.sol:RootERC20Bridge storageLayout | grep -B3 -A5 -i "rootWETHToken" - uint256 wETHStorageSlot = 208; + uint256 wETHStorageSlot = 258; vm.store(address(rootBridge), bytes32(wETHStorageSlot), bytes32(uint256(uint160(caller)))); vm.startPrank(caller); From 009cd3cd3c76f7905cacc7cb31868d0b50cbd2df Mon Sep 17 00:00:00 2001 From: Ermyas Abebe Date: Wed, 22 Nov 2023 06:57:50 +1100 Subject: [PATCH 5/5] Document the need for receive() in bridge contracts --- src/child/ChildERC20Bridge.sol | 6 +++++- src/root/RootERC20Bridge.sol | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/child/ChildERC20Bridge.sol b/src/child/ChildERC20Bridge.sol index 2b19c5de..22124e0a 100644 --- a/src/child/ChildERC20Bridge.sol +++ b/src/child/ChildERC20Bridge.sol @@ -132,7 +132,11 @@ contract ChildERC20Bridge is BridgeRoles, IChildERC20BridgeErrors, IChildERC20Br } /** - * @notice Fallback function on receiving native IMX from WIMX contract. + * @notice Method to receive IMX back from the WIMX contract when it is unwrapped + * @dev When a user deposits wIMX, it must first be unwrapped. + * This allows the bridge to store the underlying native IMX, rather than the wrapped version. + * The unwrapping is done through the WIMX contract's `withdraw()` function, which sends the native IMX to this bridge contract. + * The only reason this `receive()` function is needed is for this process, hence the validation ensures that the sender is the WIMX contract. */ receive() external payable whenNotPaused { // Revert if sender is not the WIMX token address diff --git a/src/root/RootERC20Bridge.sol b/src/root/RootERC20Bridge.sol index cf4d4476..96e66c14 100644 --- a/src/root/RootERC20Bridge.sol +++ b/src/root/RootERC20Bridge.sol @@ -235,7 +235,11 @@ contract RootERC20Bridge is BridgeRoles, IRootERC20Bridge, IRootERC20BridgeEvent } /** - * @notice method to receive the ETH back from the WETH contract when it is unwrapped + * @notice Method to receive ETH back from the WETH contract when it is unwrapped + * @dev When a user deposits wETH, it must first be unwrapped. + * This allows the bridge to store the underlying native ETH, rather than the wrapped version. + * The unwrapping is done through the WETH contract's `withdraw()` function, which sends the native ETH to this bridge contract. + * The only reason this `receive()` function is needed is for this process, hence the validation ensures that the sender is the WETH contract. */ receive() external payable whenNotPaused { // Revert if sender is not the WETH token address