Skip to content

Commit

Permalink
evm: wipe slots with warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
djb15 committed Dec 22, 2023
1 parent f32f514 commit a59d8a4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
16 changes: 16 additions & 0 deletions evm/src/contracts/CircleIntegration/Implementation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ contract Implementation is Logic {
function initialize() public virtual initializer {
// This function needs to be exposed for an upgrade to pass. Any additional logic can be
// placed here.

/**
* WARNING: This snippet should be removed for any following contract upgrades
* We are using the below snippet to reset storage slots that are no longer being used
* for safety and to free them up for future use. We don't want to inadvertantly wipe
* the same slots on future upgrades. See Storage.sol for reasoning.
*/
assembly ("memory-safe") {
sstore(0x0, 0x0)
sstore(0x1, 0x0)
sstore(0x2, 0x0)
sstore(0x3, 0x0)
sstore(0x4, 0x0)
sstore(0xA, 0x0)
}

}

modifier initializer() {
Expand Down
9 changes: 9 additions & 0 deletions evm/src/contracts/CircleIntegration/Storage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

pragma solidity ^0.8.22;


/**
* WARNING: This is the state layout of V0 before the first upgrade.
* Slots 0 -> 4 inclusive and slot 10 will be wiped to 0 on initialisation of the new
* implementation and will be safe to use again in the future. We are no longer
* using those variables in state, but they are instead immutables in the new implementation.
* If using those slots again, ensure the slots are not being wiped to 0 in the
* initialiser in future upgrades.
*/
/**
* struct State {
* // state.slot := 0x0
Expand Down

0 comments on commit a59d8a4

Please sign in to comment.