From 11835aee8b07f24ce0dbb4321adaa189c37ce600 Mon Sep 17 00:00:00 2001 From: Ermyas Abebe Date: Tue, 21 Nov 2023 21:34:03 +1100 Subject: [PATCH] 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);