Skip to content

Commit aa1dc04

Browse files
authored
fpac: reserve spacer slot in OptimismPortal2 (ethereum-optimism#10279)
* fpac: reserve spacer slot in OptimismPortal2 Allows for merging of `OptimismPortal` that supports custom gas token and also `OptimismPortal2` that has a modified storage layout. The `OptimismPortal` has spacers to account for the storage layout changes in `OptimismPortal2` and it adds its new storage slot at the location that the spacer is added in. This faciliates the ability to merge the portal codebases in the future. * tests: fixup * semver-lock: update
1 parent 344d919 commit aa1dc04

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

packages/contracts-bedrock/scripts/ChainAssertions.sol

+3
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,9 @@ library ChainAssertions {
352352
require(address(portal.superchainConfig()) == address(0));
353353
require(portal.l2Sender() == Constants.DEFAULT_L2_SENDER);
354354
}
355+
// This slot is the custom gas token _balance and this check ensures
356+
// that it stays unset for forwards compatibility with custom gas token.
357+
require(vm.load(address(portal), bytes32(uint256(61))) == bytes32(0));
355358
}
356359

357360
/// @notice Asserts that the ProtocolVersions is setup correctly

packages/contracts-bedrock/semver-lock.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
},
3838
"src/L1/OptimismPortal2.sol": {
3939
"initCodeHash": "0x34432a932e5deaebb856320d6e5d243a3db5d9a8e5e572915346875923ba70be",
40-
"sourceCodeHash": "0x16ac8757439b3045a08476d7486a420ff6ed53db519b0191442a6dff8cd1ed79"
40+
"sourceCodeHash": "0xe90774d3f89f937c56439fb7d567106bef0be0fc298fe07bbbc74f2b08445aa5"
4141
},
4242
"src/L1/ProtocolVersions.sol": {
4343
"initCodeHash": "0x72cd467e8bcf019c02675d72ab762e088bcc9cc0f1a4e9f587fa4589f7fdd1b8",

packages/contracts-bedrock/snapshots/storageLayout/OptimismPortal2.json

+7
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,12 @@
117117
"offset": 0,
118118
"slot": "60",
119119
"type": "mapping(bytes32 => address[])"
120+
},
121+
{
122+
"bytes": "32",
123+
"label": "spacer_61_0_32",
124+
"offset": 0,
125+
"slot": "61",
126+
"type": "bytes32"
120127
}
121128
]

packages/contracts-bedrock/src/L1/OptimismPortal2.sol

+4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
9494
/// @notice Mapping of withdrawal hashes to addresses that have submitted a proof for the withdrawal.
9595
mapping(bytes32 => address[]) public proofSubmitters;
9696

97+
/// @custom:spacer _balance (custom gas token)
98+
/// @notice Spacer for forwards compatibility.
99+
bytes32 private spacer_61_0_32;
100+
97101
/// @notice Emitted when a transaction is deposited from L1 to L2.
98102
/// The parameters of this event are read by the rollup node and used to derive deposit
99103
/// transactions on L2.

0 commit comments

Comments
 (0)