Conversation
|
Starting to count after the variables of the pre-withdrawal contract (this version https://github.com/gnosischain/deposit-contract/blob/c7217fccac3049901f78547f4024127fa1dcdcd4/contracts/SBCDepositContract.sol) Legacy withdrawal version deployed in chiado New withdrawal version Storage slot at index 1 cannot have collisions because in the new version the slot is computed with |
|
I think that the From my understanding, both the addresses and integers are left padded with zeroes, and it is technically possible to have a clash for these, although not very likely as it would only concern the first I'd say that it's probably fine for Chiado, but not "perfect". |
|
I looked up a git and here are storage layouts:
The most common recommendation about upgrades is to follow the initial storage layout as much as possible (e.g. certik recommendations) I personally see no reason to step aside from initial layout and create additional unsecure/uncertain point which should be 'treated specifically' as we can easily make it in more transparent and straightforward way. // This gap holds out deprecated storage slots.
// New state variables MUST be added AFTER this gap to follow historical storage layout.
uint256[5] private _deprecated_slots_gap;This This approach is more safe, its less likely will make us revisit this topic again in future and also it will make code self descriptive as historical storage changes will be highlighted and explained. |
The chance of this happening within our lifetime is on the order of finding a specific atom in the ocean. So it should not be used as an argument for this case.
This is a very valid reason. However it's annoying to have to pollute such a key contract in the network with a chiado-specific issue. Why don't we do this:
|
As the "broken" withdrawal contract was already deployed to Chiado, it is essential to keep the storage layout intact on the testnet. I propose to keep these changes in a
chiadobranch for now, so that we don't needlessly bloat the mainnet contract.I moved all the variables up to be before the
constructor, because having them sprinkled around the entire contract will make upgrades more complicated.Presumably the
private constantandstructdon't change the storage layout, but confirmation for this would be appreciated (cc @Barichek).This is based on #45 for now but should be kept in sync with
masteronce the former is merged.