From 64dc0047c2b772c24893e915f6668a7b1697ffce Mon Sep 17 00:00:00 2001 From: iwueseiter Date: Mon, 30 Sep 2024 15:43:21 +0100 Subject: [PATCH] fix:storage collision in upgradable contract --- apps/blockchain/ethereum/src/Escrow.sol | 5 ++++- apps/blockchain/ethereum/src/Messaging.sol | 5 ++++- apps/blockchain/ethereum/src/State.sol | 5 ++++- apps/blockchain/ethereum/src/UUPSProxied.sol | 4 +++- apps/blockchain/ethereum/src/token/CollectionManager.sol | 4 +++- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/apps/blockchain/ethereum/src/Escrow.sol b/apps/blockchain/ethereum/src/Escrow.sol index c58bce97..dbebc51d 100644 --- a/apps/blockchain/ethereum/src/Escrow.sol +++ b/apps/blockchain/ethereum/src/Escrow.sol @@ -16,6 +16,9 @@ contract StarklaneEscrow is Context { // Mapping (collectionAddres => (tokenId => depositor)). mapping(address => mapping(uint256 => address)) _escrow; + // Storage gaps + uint256[50] private __gap; + /** @notice Deposits the given tokens into escrow. @@ -107,4 +110,4 @@ contract StarklaneEscrow is Context { return _escrow[collection][id] > address(0x0); } -} +} \ No newline at end of file diff --git a/apps/blockchain/ethereum/src/Messaging.sol b/apps/blockchain/ethereum/src/Messaging.sol index 9247407f..8111e19f 100644 --- a/apps/blockchain/ethereum/src/Messaging.sol +++ b/apps/blockchain/ethereum/src/Messaging.sol @@ -33,6 +33,9 @@ contract StarklaneMessaging is Ownable { // The mapping mimics the Starknet messaging with a ref count like status. mapping(bytes32 => uint256) _autoWithdrawn; + // Storage gaps + uint256[50] private __gap; + /** */ event MessageHashAutoWithdrawAdded(bytes32 msgHash); @@ -117,4 +120,4 @@ contract StarklaneMessaging is Ownable { } -} +} \ No newline at end of file diff --git a/apps/blockchain/ethereum/src/State.sol b/apps/blockchain/ethereum/src/State.sol index 1719a27c..2ef4702b 100644 --- a/apps/blockchain/ethereum/src/State.sol +++ b/apps/blockchain/ethereum/src/State.sol @@ -20,6 +20,9 @@ contract StarklaneState is Ownable { // Bridge L2 selector to deposit token from L1. felt252 _starklaneL2Selector; + + // Storage gaps + uint256[50] private __gap; /** @notice Retrieves info about Starklane L2 mapping. @@ -64,4 +67,4 @@ contract StarklaneState is Ownable { } -} +} \ No newline at end of file diff --git a/apps/blockchain/ethereum/src/UUPSProxied.sol b/apps/blockchain/ethereum/src/UUPSProxied.sol index 98918d54..49794a7a 100644 --- a/apps/blockchain/ethereum/src/UUPSProxied.sol +++ b/apps/blockchain/ethereum/src/UUPSProxied.sol @@ -15,6 +15,9 @@ contract UUPSOwnableProxied is Ownable, UUPSUpgradeable { // Mapping for implementations initialization. mapping(address implementation => bool initialized) _initializedImpls; + + // Storage gaps + uint256[50] private __gap; // onlyInit modifier onlyInit() { @@ -56,4 +59,3 @@ contract UUPSOwnableProxied is Ownable, UUPSUpgradeable { revert NotPayableError(); } } - diff --git a/apps/blockchain/ethereum/src/token/CollectionManager.sol b/apps/blockchain/ethereum/src/token/CollectionManager.sol index ec9429aa..01c2b7e8 100644 --- a/apps/blockchain/ethereum/src/token/CollectionManager.sol +++ b/apps/blockchain/ethereum/src/token/CollectionManager.sol @@ -23,6 +23,9 @@ contract CollectionManager { // Mapping between L1<->L2 contracts addresses. mapping(address => snaddress) _l1ToL2Addresses; + // Storage gaps + uint256[50] private __gap; + /** @notice A collection has been deployed due to the first token being bridged from L2. @@ -165,4 +168,3 @@ contract CollectionManager { } } -