Commit 7feffce8 authored by Blaine Malone's avatar Blaine Malone Committed by GitHub

Configurable GasLimit for op-deployer (#12224)

* Configurable GasLimit for op-deployer

* fix: OPContractsManager.t.sol fixed.

* fix: OPContractsManagerInterop.sol

* fix: make gas limit configurable.
parent a2653a38
...@@ -35,6 +35,7 @@ type DeployOPChainInput struct { ...@@ -35,6 +35,7 @@ type DeployOPChainInput struct {
L2ChainId *big.Int L2ChainId *big.Int
OpcmProxy common.Address OpcmProxy common.Address
SaltMixer string SaltMixer string
GasLimit uint64
} }
func (input *DeployOPChainInput) InputSet() bool { func (input *DeployOPChainInput) InputSet() bool {
...@@ -124,6 +125,7 @@ type opcmDeployInput struct { ...@@ -124,6 +125,7 @@ type opcmDeployInput struct {
L2ChainId *big.Int L2ChainId *big.Int
StartingAnchorRoots []byte StartingAnchorRoots []byte
SaltMixer string SaltMixer string
GasLimit uint64
} }
// decodeOutputABIJSON defines an ABI for a fake method called "decodeOutput" that returns the // decodeOutputABIJSON defines an ABI for a fake method called "decodeOutput" that returns the
...@@ -243,6 +245,7 @@ func DeployOPChainRaw( ...@@ -243,6 +245,7 @@ func DeployOPChainRaw(
L2ChainId: input.L2ChainId, L2ChainId: input.L2ChainId,
StartingAnchorRoots: input.StartingAnchorRoots(), StartingAnchorRoots: input.StartingAnchorRoots(),
SaltMixer: input.SaltMixer, SaltMixer: input.SaltMixer,
GasLimit: input.GasLimit,
}) })
if err != nil { if err != nil {
return out, fmt.Errorf("failed to pack deploy input: %w", err) return out, fmt.Errorf("failed to pack deploy input: %w", err)
......
...@@ -40,6 +40,7 @@ func DeployOPChain(ctx context.Context, env *Env, artifactsFS foundry.StatDirFs, ...@@ -40,6 +40,7 @@ func DeployOPChain(ctx context.Context, env *Env, artifactsFS foundry.StatDirFs,
L2ChainId: chainID.Big(), L2ChainId: chainID.Big(),
OpcmProxy: st.ImplementationsDeployment.OpcmProxyAddress, OpcmProxy: st.ImplementationsDeployment.OpcmProxyAddress,
SaltMixer: st.Create2Salt.String(), // passing through salt generated at state initialization SaltMixer: st.Create2Salt.String(), // passing through salt generated at state initialization
GasLimit: 30_000_000, // TODO: make this configurable
} }
var dco opcm.DeployOPChainOutput var dco opcm.DeployOPChainOutput
......
...@@ -77,6 +77,7 @@ type L2Config struct { ...@@ -77,6 +77,7 @@ type L2Config struct {
genesis.L2InitializationConfig genesis.L2InitializationConfig
Prefund map[common.Address]*big.Int Prefund map[common.Address]*big.Int
SaltMixer string SaltMixer string
GasLimit uint64
} }
func (c *L2Config) Check(log log.Logger) error { func (c *L2Config) Check(log log.Logger) error {
......
...@@ -208,6 +208,7 @@ func DeployL2ToL1(l1Host *script.Host, superCfg *SuperchainConfig, superDeployme ...@@ -208,6 +208,7 @@ func DeployL2ToL1(l1Host *script.Host, superCfg *SuperchainConfig, superDeployme
L2ChainId: new(big.Int).SetUint64(cfg.L2ChainID), L2ChainId: new(big.Int).SetUint64(cfg.L2ChainID),
OpcmProxy: superDeployment.OpcmProxy, OpcmProxy: superDeployment.OpcmProxy,
SaltMixer: cfg.SaltMixer, SaltMixer: cfg.SaltMixer,
GasLimit: cfg.GasLimit,
}) })
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to deploy L2 OP chain: %w", err) return nil, fmt.Errorf("failed to deploy L2 OP chain: %w", err)
......
...@@ -249,7 +249,9 @@ func InteropL2DevConfig(l1ChainID, l2ChainID uint64, addrs devkeys.Addresses) (* ...@@ -249,7 +249,9 @@ func InteropL2DevConfig(l1ChainID, l2ChainID uint64, addrs devkeys.Addresses) (*
UseAltDA: false, UseAltDA: false,
}, },
}, },
Prefund: make(map[common.Address]*big.Int), Prefund: make(map[common.Address]*big.Int),
SaltMixer: "",
GasLimit: 30_000_000,
} }
// TODO(#11887): consider making the number of prefunded keys configurable. // TODO(#11887): consider making the number of prefunded keys configurable.
......
...@@ -48,6 +48,7 @@ contract DeployOPChainInput is BaseDeployIO { ...@@ -48,6 +48,7 @@ contract DeployOPChainInput is BaseDeployIO {
uint256 internal _l2ChainId; uint256 internal _l2ChainId;
OPContractsManager internal _opcmProxy; OPContractsManager internal _opcmProxy;
string internal _saltMixer; string internal _saltMixer;
uint64 internal _gasLimit;
function set(bytes4 _sel, address _addr) public { function set(bytes4 _sel, address _addr) public {
require(_addr != address(0), "DeployOPChainInput: cannot set zero address"); require(_addr != address(0), "DeployOPChainInput: cannot set zero address");
...@@ -69,6 +70,8 @@ contract DeployOPChainInput is BaseDeployIO { ...@@ -69,6 +70,8 @@ contract DeployOPChainInput is BaseDeployIO {
} else if (_sel == this.l2ChainId.selector) { } else if (_sel == this.l2ChainId.selector) {
require(_value != 0 && _value != block.chainid, "DeployOPChainInput: invalid l2ChainId"); require(_value != 0 && _value != block.chainid, "DeployOPChainInput: invalid l2ChainId");
_l2ChainId = _value; _l2ChainId = _value;
} else if (_sel == this.gasLimit.selector) {
_gasLimit = SafeCast.toUint64(_value);
} else { } else {
revert("DeployOPChainInput: unknown selector"); revert("DeployOPChainInput: unknown selector");
} }
...@@ -156,6 +159,10 @@ contract DeployOPChainInput is BaseDeployIO { ...@@ -156,6 +159,10 @@ contract DeployOPChainInput is BaseDeployIO {
function saltMixer() public view returns (string memory) { function saltMixer() public view returns (string memory) {
return _saltMixer; return _saltMixer;
} }
function gasLimit() public view returns (uint64) {
return _gasLimit;
}
} }
contract DeployOPChainOutput is BaseDeployIO { contract DeployOPChainOutput is BaseDeployIO {
...@@ -374,7 +381,7 @@ contract DeployOPChainOutput is BaseDeployIO { ...@@ -374,7 +381,7 @@ contract DeployOPChainOutput is BaseDeployIO {
require(systemConfig.basefeeScalar() == _doi.basefeeScalar(), "SYSCON-20"); require(systemConfig.basefeeScalar() == _doi.basefeeScalar(), "SYSCON-20");
require(systemConfig.blobbasefeeScalar() == _doi.blobBaseFeeScalar(), "SYSCON-30"); require(systemConfig.blobbasefeeScalar() == _doi.blobBaseFeeScalar(), "SYSCON-30");
require(systemConfig.batcherHash() == bytes32(uint256(uint160(_doi.batcher()))), "SYSCON-40"); require(systemConfig.batcherHash() == bytes32(uint256(uint160(_doi.batcher()))), "SYSCON-40");
require(systemConfig.gasLimit() == uint64(30000000), "SYSCON-50"); // TODO allow other gas limits? require(systemConfig.gasLimit() == uint64(30_000_000), "SYSCON-50");
require(systemConfig.unsafeBlockSigner() == _doi.unsafeBlockSigner(), "SYSCON-60"); require(systemConfig.unsafeBlockSigner() == _doi.unsafeBlockSigner(), "SYSCON-60");
require(systemConfig.scalar() >> 248 == 1, "SYSCON-70"); require(systemConfig.scalar() >> 248 == 1, "SYSCON-70");
...@@ -514,7 +521,8 @@ contract DeployOPChain is Script { ...@@ -514,7 +521,8 @@ contract DeployOPChain is Script {
blobBasefeeScalar: _doi.blobBaseFeeScalar(), blobBasefeeScalar: _doi.blobBaseFeeScalar(),
l2ChainId: _doi.l2ChainId(), l2ChainId: _doi.l2ChainId(),
startingAnchorRoots: _doi.startingAnchorRoots(), startingAnchorRoots: _doi.startingAnchorRoots(),
saltMixer: _doi.saltMixer() saltMixer: _doi.saltMixer(),
gasLimit: _doi.gasLimit()
}); });
vm.broadcast(msg.sender); vm.broadcast(msg.sender);
......
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
"sourceCodeHash": "0xde4df0f9633dc0cdb1c9f634003ea5b0f7c5c1aebc407bc1b2f44c0ecf938649" "sourceCodeHash": "0xde4df0f9633dc0cdb1c9f634003ea5b0f7c5c1aebc407bc1b2f44c0ecf938649"
}, },
"src/L1/OPContractsManager.sol": { "src/L1/OPContractsManager.sol": {
"initCodeHash": "0xa0c1139a01cef2445266c71175eff2d36e4b3a7584b198835ed8cba4f7143704", "initCodeHash": "0xfaab186a660764265a837fac689a6d8602454c6ca9f39b5244282768b8d86b3a",
"sourceCodeHash": "0x67f9846a215d0817a75b4beee50925861d14da2cab1b699bb4e8ae89fa12d01b" "sourceCodeHash": "0x831b7268e1beb93050dbaae1e83e17635385bd101779146a95150084f69d2835"
}, },
"src/L1/OptimismPortal.sol": { "src/L1/OptimismPortal.sol": {
"initCodeHash": "0xbe2c0c81b3459014f287d8c89cdc0d27dde5d1f44e5d024fa1e4773ddc47c190", "initCodeHash": "0xbe2c0c81b3459014f287d8c89cdc0d27dde5d1f44e5d024fa1e4773ddc47c190",
......
...@@ -167,6 +167,11 @@ ...@@ -167,6 +167,11 @@
"internalType": "string", "internalType": "string",
"name": "saltMixer", "name": "saltMixer",
"type": "string" "type": "string"
},
{
"internalType": "uint64",
"name": "gasLimit",
"type": "uint64"
} }
], ],
"internalType": "struct OPContractsManager.DeployInput", "internalType": "struct OPContractsManager.DeployInput",
......
...@@ -167,6 +167,11 @@ ...@@ -167,6 +167,11 @@
"internalType": "string", "internalType": "string",
"name": "saltMixer", "name": "saltMixer",
"type": "string" "type": "string"
},
{
"internalType": "uint64",
"name": "gasLimit",
"type": "uint64"
} }
], ],
"internalType": "struct OPContractsManager.DeployInput", "internalType": "struct OPContractsManager.DeployInput",
......
...@@ -62,6 +62,7 @@ contract OPContractsManager is ISemver, Initializable { ...@@ -62,6 +62,7 @@ contract OPContractsManager is ISemver, Initializable {
bytes startingAnchorRoots; bytes startingAnchorRoots;
// The salt mixer is used as part of making the resulting salt unique. // The salt mixer is used as part of making the resulting salt unique.
string saltMixer; string saltMixer;
uint64 gasLimit;
} }
/// @notice The full set of outputs from deploying a new OP Stack chain. /// @notice The full set of outputs from deploying a new OP Stack chain.
...@@ -124,8 +125,8 @@ contract OPContractsManager is ISemver, Initializable { ...@@ -124,8 +125,8 @@ contract OPContractsManager is ISemver, Initializable {
// -------- Constants and Variables -------- // -------- Constants and Variables --------
/// @custom:semver 1.0.0-beta.17 /// @custom:semver 1.0.0-beta.18
string public constant version = "1.0.0-beta.17"; string public constant version = "1.0.0-beta.18";
/// @notice Represents the interface version so consumers know how to decode the DeployOutput struct /// @notice Represents the interface version so consumers know how to decode the DeployOutput struct
/// that's emitted in the `Deployed` event. Whenever that struct changes, a new version should be used. /// that's emitted in the `Deployed` event. Whenever that struct changes, a new version should be used.
...@@ -467,7 +468,7 @@ contract OPContractsManager is ISemver, Initializable { ...@@ -467,7 +468,7 @@ contract OPContractsManager is ISemver, Initializable {
_input.basefeeScalar, _input.basefeeScalar,
_input.blobBasefeeScalar, _input.blobBasefeeScalar,
bytes32(uint256(uint160(_input.roles.batcher))), // batcherHash bytes32(uint256(uint160(_input.roles.batcher))), // batcherHash
30_000_000, _input.gasLimit,
_input.roles.unsafeBlockSigner, _input.roles.unsafeBlockSigner,
referenceResourceConfig, referenceResourceConfig,
chainIdToBatchInboxAddress(_input.l2ChainId), chainIdToBatchInboxAddress(_input.l2ChainId),
...@@ -486,7 +487,7 @@ contract OPContractsManager is ISemver, Initializable { ...@@ -486,7 +487,7 @@ contract OPContractsManager is ISemver, Initializable {
_input.basefeeScalar, _input.basefeeScalar,
_input.blobBasefeeScalar, _input.blobBasefeeScalar,
bytes32(uint256(uint160(_input.roles.batcher))), // batcherHash bytes32(uint256(uint160(_input.roles.batcher))), // batcherHash
30_000_000, _input.gasLimit,
_input.roles.unsafeBlockSigner, _input.roles.unsafeBlockSigner,
referenceResourceConfig, referenceResourceConfig,
chainIdToBatchInboxAddress(_input.l2ChainId), chainIdToBatchInboxAddress(_input.l2ChainId),
......
...@@ -46,7 +46,7 @@ contract OPContractsManagerInterop is OPContractsManager { ...@@ -46,7 +46,7 @@ contract OPContractsManagerInterop is OPContractsManager {
_input.basefeeScalar, _input.basefeeScalar,
_input.blobBasefeeScalar, _input.blobBasefeeScalar,
bytes32(uint256(uint160(_input.roles.batcher))), // batcherHash bytes32(uint256(uint160(_input.roles.batcher))), // batcherHash
30_000_000, // gasLimit TODO make this configurable? _input.gasLimit,
_input.roles.unsafeBlockSigner, _input.roles.unsafeBlockSigner,
referenceResourceConfig, referenceResourceConfig,
chainIdToBatchInboxAddress(_input.l2ChainId), chainIdToBatchInboxAddress(_input.l2ChainId),
......
...@@ -53,6 +53,7 @@ contract OPContractsManager_Deploy_Test is DeployOPChain_TestBase { ...@@ -53,6 +53,7 @@ contract OPContractsManager_Deploy_Test is DeployOPChain_TestBase {
doi.set(doi.blobBaseFeeScalar.selector, blobBaseFeeScalar); doi.set(doi.blobBaseFeeScalar.selector, blobBaseFeeScalar);
doi.set(doi.l2ChainId.selector, l2ChainId); doi.set(doi.l2ChainId.selector, l2ChainId);
doi.set(doi.opcmProxy.selector, address(opcm)); doi.set(doi.opcmProxy.selector, address(opcm));
doi.set(doi.gasLimit.selector, gasLimit);
} }
// This helper function is used to convert the input struct type defined in DeployOPChain.s.sol // This helper function is used to convert the input struct type defined in DeployOPChain.s.sol
...@@ -71,7 +72,8 @@ contract OPContractsManager_Deploy_Test is DeployOPChain_TestBase { ...@@ -71,7 +72,8 @@ contract OPContractsManager_Deploy_Test is DeployOPChain_TestBase {
blobBasefeeScalar: _doi.blobBaseFeeScalar(), blobBasefeeScalar: _doi.blobBaseFeeScalar(),
l2ChainId: _doi.l2ChainId(), l2ChainId: _doi.l2ChainId(),
startingAnchorRoots: _doi.startingAnchorRoots(), startingAnchorRoots: _doi.startingAnchorRoots(),
saltMixer: _doi.saltMixer() saltMixer: _doi.saltMixer(),
gasLimit: _doi.gasLimit()
}); });
} }
......
...@@ -362,6 +362,7 @@ contract DeployOPChain_TestBase is Test { ...@@ -362,6 +362,7 @@ contract DeployOPChain_TestBase is Test {
AnchorStateRegistry.StartingAnchorRoot[] startingAnchorRoots; AnchorStateRegistry.StartingAnchorRoot[] startingAnchorRoots;
OPContractsManager opcm = OPContractsManager(address(0)); OPContractsManager opcm = OPContractsManager(address(0));
string saltMixer = "defaultSaltMixer"; string saltMixer = "defaultSaltMixer";
uint64 gasLimit = 30_000_000;
function setUp() public virtual { function setUp() public virtual {
// Set defaults for reference types // Set defaults for reference types
...@@ -481,6 +482,7 @@ contract DeployOPChain_Test is DeployOPChain_TestBase { ...@@ -481,6 +482,7 @@ contract DeployOPChain_Test is DeployOPChain_TestBase {
doi.set(doi.l2ChainId.selector, l2ChainId); doi.set(doi.l2ChainId.selector, l2ChainId);
doi.set(doi.opcmProxy.selector, address(opcm)); // Not fuzzed since it must be an actual instance. doi.set(doi.opcmProxy.selector, address(opcm)); // Not fuzzed since it must be an actual instance.
doi.set(doi.saltMixer.selector, saltMixer); doi.set(doi.saltMixer.selector, saltMixer);
doi.set(doi.gasLimit.selector, gasLimit);
deployOPChain.run(doi, doo); deployOPChain.run(doi, doo);
...@@ -497,6 +499,7 @@ contract DeployOPChain_Test is DeployOPChain_TestBase { ...@@ -497,6 +499,7 @@ contract DeployOPChain_Test is DeployOPChain_TestBase {
assertEq(blobBaseFeeScalar, doi.blobBaseFeeScalar(), "800"); assertEq(blobBaseFeeScalar, doi.blobBaseFeeScalar(), "800");
assertEq(l2ChainId, doi.l2ChainId(), "900"); assertEq(l2ChainId, doi.l2ChainId(), "900");
assertEq(saltMixer, doi.saltMixer(), "1000"); assertEq(saltMixer, doi.saltMixer(), "1000");
assertEq(gasLimit, doi.gasLimit(), "1100");
// Assert inputs were properly passed through to the contract initializers. // Assert inputs were properly passed through to the contract initializers.
assertEq(address(doo.opChainProxyAdmin().owner()), opChainProxyAdminOwner, "2100"); assertEq(address(doo.opChainProxyAdmin().owner()), opChainProxyAdminOwner, "2100");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment