1+ // SPDX-License-Identifier: MIT
2+ pragma solidity 0.8.15 ;
3+
4+ import {SystemConfig} from "@eth-optimism-bedrock/src/L1/SystemConfig.sol " ;
5+ import {
6+ MultisigBuilder,
7+ IMulticall3,
8+ IGnosisSafe
9+ } from "@base-contracts/script/universal/MultisigBuilder.sol " ;
10+ import { Vm } from "forge-std/Vm.sol " ;
11+
12+ abstract contract SetGasLimitBuilder is MultisigBuilder {
13+ address internal SYSTEM_CONFIG_OWNER = vm.envAddress ("SYSTEM_CONFIG_OWNER " );
14+ address internal L1_SYSTEM_CONFIG = vm.envAddress ("L1_SYSTEM_CONFIG_ADDRESS " );
15+
16+ /**
17+ * -----------------------------------------------------------
18+ * Virtual Functions
19+ * -----------------------------------------------------------
20+ */
21+
22+ function _fromGasLimit () internal virtual view returns (uint64 );
23+
24+ function _toGasLimit () internal virtual view returns (uint64 );
25+
26+ function _nonceOffset () internal virtual view returns (uint64 );
27+
28+ /**
29+ * -----------------------------------------------------------
30+ * Implemented Functions
31+ * -----------------------------------------------------------
32+ */
33+
34+ function _postCheck (Vm.AccountAccess[] memory , SimulationPayload memory ) internal override view {
35+ assert (SystemConfig (L1_SYSTEM_CONFIG).gasLimit () == _toGasLimit ());
36+ }
37+
38+ function _buildCalls () internal view override returns (IMulticall3.Call3[] memory ) {
39+ IMulticall3.Call3[] memory calls = new IMulticall3.Call3 [](1 );
40+
41+ calls[0 ] = IMulticall3.Call3 ({
42+ target: L1_SYSTEM_CONFIG,
43+ allowFailure: false ,
44+ callData: abi.encodeCall (SystemConfig.setGasLimit, (_toGasLimit ()))
45+ });
46+
47+ return calls;
48+ }
49+
50+ function _ownerSafe () internal view override returns (address ) {
51+ return SYSTEM_CONFIG_OWNER;
52+ }
53+
54+ function _addOverrides (address _safe ) internal view override returns (SimulationStateOverride memory ) {
55+ IGnosisSafe safe = IGnosisSafe (payable (_safe));
56+ uint256 _nonce = _getNonce (safe) + _nonceOffset ();
57+ return overrideSafeThresholdOwnerAndNonce (_safe, DEFAULT_SENDER, _nonce);
58+ }
59+
60+ // We need to expect that the gas limit will have been updated previously in our simulation
61+ // Use this override to specifically set the gas limit to the expected update value.
62+ function _addGenericOverrides () internal view override returns (SimulationStateOverride memory ) {
63+ SimulationStorageOverride[] memory _stateOverrides = new SimulationStorageOverride [](1 );
64+ _stateOverrides[0 ] = SimulationStorageOverride ({
65+ key: 0x0000000000000000000000000000000000000000000000000000000000000068 , // slot of gas limit
66+ value: bytes32 (uint (_fromGasLimit ()))
67+ });
68+ return SimulationStateOverride ({contractAddress: L1_SYSTEM_CONFIG, overrides: _stateOverrides});
69+ }
70+ }
0 commit comments