Commit ef1bf0ac authored by Matt Solomon's avatar Matt Solomon Committed by GitHub

opsm: remove remaining structs (#11854)

* refactor: remove structs from DeployImplementations

* refactor: remove structs from DeployOPChain

* test: fix tests

* Update packages/contracts-bedrock/test/DeployOPChain.t.sol
Co-authored-by: default avatarBlaine Malone <blainemalone01@gmail.com>

* Update packages/contracts-bedrock/test/DeployOPChain.t.sol
Co-authored-by: default avatarBlaine Malone <blainemalone01@gmail.com>

* test: add missing assertions

* fix: update fuzz test timeout

---------
Co-authored-by: default avatarBlaine Malone <blainemalone01@gmail.com>
Co-authored-by: default avatarKelvin Fichter <kelvinfichter@gmail.com>
parent 935de9cb
...@@ -88,7 +88,7 @@ contract DeploySuperchainInput is CommonBase { ...@@ -88,7 +88,7 @@ contract DeploySuperchainInput is CommonBase {
// These `set` methods let each input be set individually. The selector of an input's getter method // These `set` methods let each input be set individually. The selector of an input's getter method
// is used to determine which field to set. // is used to determine which field to set.
function set(bytes4 _sel, address _address) public { function set(bytes4 _sel, address _address) public {
require(_address != address(0), "DeploySuperchainInput: cannot set null address"); require(_address != address(0), "DeploySuperchainInput: cannot set zero address");
if (_sel == this.guardian.selector) _guardian = _address; if (_sel == this.guardian.selector) _guardian = _address;
else if (_sel == this.protocolVersionsOwner.selector) _protocolVersionsOwner = _address; else if (_sel == this.protocolVersionsOwner.selector) _protocolVersionsOwner = _address;
else if (_sel == this.proxyAdminOwner.selector) _proxyAdminOwner = _address; else if (_sel == this.proxyAdminOwner.selector) _proxyAdminOwner = _address;
...@@ -181,6 +181,7 @@ contract DeploySuperchainOutput is CommonBase { ...@@ -181,6 +181,7 @@ contract DeploySuperchainOutput is CommonBase {
// This method lets each field be set individually. The selector of an output's getter method // This method lets each field be set individually. The selector of an output's getter method
// is used to determine which field to set. // is used to determine which field to set.
function set(bytes4 sel, address _address) public { function set(bytes4 sel, address _address) public {
require(_address != address(0), "DeploySuperchainOutput: cannot set zero address");
if (sel == this.superchainProxyAdmin.selector) _superchainProxyAdmin = ProxyAdmin(_address); if (sel == this.superchainProxyAdmin.selector) _superchainProxyAdmin = ProxyAdmin(_address);
else if (sel == this.superchainConfigImpl.selector) _superchainConfigImpl = SuperchainConfig(_address); else if (sel == this.superchainConfigImpl.selector) _superchainConfigImpl = SuperchainConfig(_address);
else if (sel == this.superchainConfigProxy.selector) _superchainConfigProxy = SuperchainConfig(_address); else if (sel == this.superchainConfigProxy.selector) _superchainConfigProxy = SuperchainConfig(_address);
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.15; pragma solidity 0.8.15;
import { Test } from "forge-std/Test.sol"; import { Test, stdStorage, StdStorage } from "forge-std/Test.sol";
import { DeployOPChainInput } from "scripts/DeployOPChain.s.sol"; import { DeployOPChainInput } from "scripts/DeployOPChain.s.sol";
import { DeployOPChain_TestBase } from "test/DeployOPChain.t.sol"; import { DeployOPChain_TestBase } from "test/DeployOPChain.t.sol";
...@@ -32,42 +32,58 @@ contract OPStackManager_Harness is OPStackManager { ...@@ -32,42 +32,58 @@ contract OPStackManager_Harness is OPStackManager {
// we can use its setup to deploy the implementations similarly to how a real deployment would // we can use its setup to deploy the implementations similarly to how a real deployment would
// happen. // happen.
contract OPStackManager_Deploy_Test is DeployOPChain_TestBase { contract OPStackManager_Deploy_Test is DeployOPChain_TestBase {
using stdStorage for StdStorage;
function setUp() public override {
DeployOPChain_TestBase.setUp();
doi.set(doi.opChainProxyAdminOwner.selector, opChainProxyAdminOwner);
doi.set(doi.systemConfigOwner.selector, systemConfigOwner);
doi.set(doi.batcher.selector, batcher);
doi.set(doi.unsafeBlockSigner.selector, unsafeBlockSigner);
doi.set(doi.proposer.selector, proposer);
doi.set(doi.challenger.selector, challenger);
doi.set(doi.basefeeScalar.selector, basefeeScalar);
doi.set(doi.blobBaseFeeScalar.selector, blobBaseFeeScalar);
doi.set(doi.l2ChainId.selector, l2ChainId);
doi.set(doi.opsm.selector, address(opsm));
}
// 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
// to the input struct type defined in OPStackManager.sol. // to the input struct type defined in OPStackManager.sol.
function toOPSMDeployInput(DeployOPChainInput.Input memory input) function toOPSMDeployInput(DeployOPChainInput _doi) internal view returns (OPStackManager.DeployInput memory) {
internal
pure
returns (OPStackManager.DeployInput memory)
{
return OPStackManager.DeployInput({ return OPStackManager.DeployInput({
roles: OPStackManager.Roles({ roles: OPStackManager.Roles({
opChainProxyAdminOwner: input.roles.opChainProxyAdminOwner, opChainProxyAdminOwner: _doi.opChainProxyAdminOwner(),
systemConfigOwner: input.roles.systemConfigOwner, systemConfigOwner: _doi.systemConfigOwner(),
batcher: input.roles.batcher, batcher: _doi.batcher(),
unsafeBlockSigner: input.roles.unsafeBlockSigner, unsafeBlockSigner: _doi.unsafeBlockSigner(),
proposer: input.roles.proposer, proposer: _doi.proposer(),
challenger: input.roles.challenger challenger: _doi.challenger()
}), }),
basefeeScalar: input.basefeeScalar, basefeeScalar: _doi.basefeeScalar(),
blobBasefeeScalar: input.blobBaseFeeScalar, blobBasefeeScalar: _doi.blobBaseFeeScalar(),
l2ChainId: input.l2ChainId l2ChainId: _doi.l2ChainId()
}); });
} }
function test_deploy_l2ChainIdEqualsZero_reverts() public { function test_deploy_l2ChainIdEqualsZero_reverts() public {
deployOPChainInput.l2ChainId = 0; OPStackManager.DeployInput memory deployInput = toOPSMDeployInput(doi);
deployInput.l2ChainId = 0;
vm.expectRevert(OPStackManager.InvalidChainId.selector); vm.expectRevert(OPStackManager.InvalidChainId.selector);
deployImplementationsOutput.opsm.deploy(toOPSMDeployInput(deployOPChainInput)); opsm.deploy(deployInput);
} }
function test_deploy_l2ChainIdEqualsCurrentChainId_reverts() public { function test_deploy_l2ChainIdEqualsCurrentChainId_reverts() public {
deployOPChainInput.l2ChainId = block.chainid; OPStackManager.DeployInput memory deployInput = toOPSMDeployInput(doi);
deployInput.l2ChainId = block.chainid;
vm.expectRevert(OPStackManager.InvalidChainId.selector); vm.expectRevert(OPStackManager.InvalidChainId.selector);
deployImplementationsOutput.opsm.deploy(toOPSMDeployInput(deployOPChainInput)); opsm.deploy(deployInput);
} }
function test_deploy_succeeds() public { function test_deploy_succeeds() public {
deployImplementationsOutput.opsm.deploy(toOPSMDeployInput(deployOPChainInput)); opsm.deploy(toOPSMDeployInput(doi));
} }
} }
......
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