Skip to content

Commit

Permalink
Add storage gaps to roles contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
ermyas committed Nov 21, 2023
1 parent 9b665f0 commit 11835ae
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/common/AdaptorRoles.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 3 additions & 0 deletions src/common/BridgeRoles.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion test/integration/child/ChildAxelarBridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
4 changes: 2 additions & 2 deletions test/unit/child/ChildERC20Bridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)));
Expand Down
2 changes: 1 addition & 1 deletion test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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))));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))));

Expand Down
2 changes: 1 addition & 1 deletion test/unit/root/RootERC20Bridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 11835ae

Please sign in to comment.