Commit a88f6398 authored by clabby's avatar clabby Committed by GitHub

chore(op-deployer): Accept existing impl in `DelayedWETH` bootstrap task (#13250)

* chore(op-deployer): Accept existing impl in `DelayedWETH` bootstrap task

* remove check
parent 37d7bda6
......@@ -37,6 +37,7 @@ type DelayedWETHConfig struct {
PrivateKey string
Logger log.Logger
ArtifactsLocator *artifacts2.Locator
DelayedWethImpl common.Address
privateKeyECDSA *ecdsa.PrivateKey
}
......@@ -90,11 +91,13 @@ func NewDelayedWETHConfigFromClI(cliCtx *cli.Context, l log.Logger) (DelayedWETH
if err := artifactsLocator.UnmarshalText([]byte(artifactsURLStr)); err != nil {
return DelayedWETHConfig{}, fmt.Errorf("failed to parse artifacts URL: %w", err)
}
delayedWethImpl := common.HexToAddress(cliCtx.String(DelayedWethImplFlagName))
config := DelayedWETHConfig{
L1RPCUrl: l1RPCUrl,
PrivateKey: privateKey,
Logger: l,
ArtifactsLocator: artifactsLocator,
DelayedWethImpl: delayedWethImpl,
}
return config, nil
}
......@@ -134,10 +137,6 @@ func DelayedWETH(ctx context.Context, cfg DelayedWETHConfig) error {
if err != nil {
return fmt.Errorf("error getting superchain config: %w", err)
}
standardVersionsTOML, err := standard.L1VersionsDataFor(chainIDU64)
if err != nil {
return fmt.Errorf("error getting standard versions TOML: %w", err)
}
proxyAdmin, err := standard.ManagerOwnerAddrFor(chainIDU64)
if err != nil {
return fmt.Errorf("error getting superchain proxy admin: %w", err)
......@@ -210,9 +209,9 @@ func DelayedWETH(ctx context.Context, cfg DelayedWETHConfig) error {
host,
opcm.DeployDelayedWETHInput{
Release: release,
StandardVersionsToml: standardVersionsTOML,
ProxyAdmin: proxyAdmin,
SuperchainConfigProxy: superchainConfigAddr,
DelayedWethImpl: cfg.DelayedWethImpl,
DelayedWethOwner: delayedWethOwner,
DelayedWethDelay: big.NewInt(604800),
},
......
......@@ -26,13 +26,14 @@ const (
SplitDepthFlagName = "split-depth"
ClockExtensionFlagName = "clock-extension"
MaxClockDurationFlagName = "max-clock-duration"
DelayedWethProxyFlagName = "delayed-weth-proxy"
AnchorStateRegistryProxyFlagName = "anchor-state-registry-proxy"
L2ChainIdFlagName = "l2-chain-id"
ProposerFlagName = "proposer"
ChallengerFlagName = "challenger"
PreimageOracleFlagName = "preimage-oracle"
ReleaseFlagName = "release"
DelayedWethProxyFlagName = "delayed-weth-proxy"
DelayedWethImplFlagName = "delayed-weth-impl"
)
var (
......@@ -128,6 +129,12 @@ var (
Usage: "Delayed WETH proxy.",
EnvVars: deployer.PrefixEnvVar("DELAYED_WETH_PROXY"),
}
DelayedWethImplFlag = &cli.StringFlag{
Name: DelayedWethImplFlagName,
Usage: "Delayed WETH implementation.",
EnvVars: deployer.PrefixEnvVar("DELAYED_WETH_IMPL"),
Value: common.Address{}.Hex(),
}
AnchorStateRegistryProxyFlag = &cli.StringFlag{
Name: AnchorStateRegistryProxyFlagName,
Usage: "Anchor state registry proxy.",
......@@ -182,6 +189,7 @@ var DelayedWETHFlags = []cli.Flag{
deployer.L1RPCURLFlag,
deployer.PrivateKeyFlag,
ArtifactsLocatorFlag,
DelayedWethImplFlag,
}
var DisputeGameFlags = []cli.Flag{
......
......@@ -11,9 +11,9 @@ import (
type DeployDelayedWETHInput struct {
Release string
StandardVersionsToml string
ProxyAdmin common.Address
SuperchainConfigProxy common.Address
DelayedWethImpl common.Address
DelayedWethOwner common.Address
DelayedWethDelay *big.Int
}
......
......@@ -5,7 +5,6 @@ import (
"testing"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/broadcaster"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/testutil"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/env"
"github.com/ethereum-optimism/optimism/op-service/testlog"
......@@ -17,6 +16,22 @@ import (
func TestDeployDelayedWETH(t *testing.T) {
_, artifacts := testutil.LocalArtifacts(t)
testCases := []struct {
TestName string
Impl common.Address
}{
{
TestName: "ExistingImpl",
Impl: common.Address{'I'},
},
{
TestName: "NoExistingImpl",
Impl: common.Address{},
},
}
for _, testCase := range testCases {
t.Run(testCase.TestName, func(t *testing.T) {
host, err := env.DefaultScriptHost(
broadcaster.NoopBroadcaster(),
testlog.Logger(t, log.LevelInfo),
......@@ -25,14 +40,11 @@ func TestDeployDelayedWETH(t *testing.T) {
)
require.NoError(t, err)
standardVersionsTOML, err := standard.L1VersionsDataFor(11155111)
require.NoError(t, err)
input := DeployDelayedWETHInput{
Release: "dev",
StandardVersionsToml: standardVersionsTOML,
ProxyAdmin: common.Address{'P'},
SuperchainConfigProxy: common.Address{'S'},
DelayedWethImpl: testCase.Impl,
DelayedWethOwner: common.Address{'O'},
DelayedWethDelay: big.NewInt(100),
}
......@@ -42,4 +54,6 @@ func TestDeployDelayedWETH(t *testing.T) {
require.NotEmpty(t, output.DelayedWethImpl)
require.NotEmpty(t, output.DelayedWethProxy)
})
}
}
......@@ -20,9 +20,9 @@ import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
contract DeployDelayedWETHInput is BaseDeployIO {
/// Required inputs.
string internal _release;
string internal _standardVersionsToml;
address public _proxyAdmin;
ISuperchainConfig public _superchainConfigProxy;
address public _delayedWethImpl;
address public _delayedWethOwner;
uint256 public _delayedWethDelay;
......@@ -45,6 +45,8 @@ contract DeployDelayedWETHInput is BaseDeployIO {
} else if (_sel == this.delayedWethOwner.selector) {
require(_value != address(0), "DeployDelayedWETH: delayedWethOwner cannot be zero address");
_delayedWethOwner = _value;
} else if (_sel == this.delayedWethImpl.selector) {
_delayedWethImpl = _value;
} else {
revert("DeployDelayedWETH: unknown selector");
}
......@@ -54,9 +56,6 @@ contract DeployDelayedWETHInput is BaseDeployIO {
if (_sel == this.release.selector) {
require(!LibString.eq(_value, ""), "DeployDelayedWETH: release cannot be empty");
_release = _value;
} else if (_sel == this.standardVersionsToml.selector) {
require(!LibString.eq(_value, ""), "DeployDelayedWETH: standardVersionsToml cannot be empty");
_standardVersionsToml = _value;
} else {
revert("DeployDelayedWETH: unknown selector");
}
......@@ -67,11 +66,6 @@ contract DeployDelayedWETHInput is BaseDeployIO {
return _release;
}
function standardVersionsToml() public view returns (string memory) {
require(!LibString.eq(_standardVersionsToml, ""), "DeployDelayedWETH: standardVersionsToml not set");
return _standardVersionsToml;
}
function proxyAdmin() public view returns (address) {
require(_proxyAdmin != address(0), "DeployDelayedWETH: proxyAdmin not set");
return _proxyAdmin;
......@@ -82,6 +76,11 @@ contract DeployDelayedWETHInput is BaseDeployIO {
return _superchainConfigProxy;
}
function delayedWethImpl() public view returns (address) {
require(_delayedWethImpl != address(0), "DeployDelayedWETH: delayedWethImpl not set");
return _delayedWethImpl;
}
function delayedWethOwner() public view returns (address) {
require(_delayedWethOwner != address(0), "DeployDelayedWETH: delayedWethOwner not set");
return _delayedWethOwner;
......@@ -166,11 +165,9 @@ contract DeployDelayedWETH is Script {
function deployDelayedWethImpl(DeployDelayedWETHInput _dwi, DeployDelayedWETHOutput _dwo) internal {
string memory release = _dwi.release();
string memory stdVerToml = _dwi.standardVersionsToml();
string memory contractName = "delayed_weth";
IDelayedWETH impl;
address existingImplementation = getReleaseAddress(release, contractName, stdVerToml);
address existingImplementation = _dwi.delayedWethImpl();
if (existingImplementation != address(0)) {
impl = IDelayedWETH(payable(existingImplementation));
} else if (isDevelopRelease(release)) {
......@@ -214,30 +211,6 @@ contract DeployDelayedWETH is Script {
_dwo.set(_dwo.delayedWethProxy.selector, address(proxy));
}
// Zero address is returned if the address is not found in '_standardVersionsToml'.
function getReleaseAddress(
string memory _version,
string memory _contractName,
string memory _standardVersionsToml
)
internal
pure
returns (address addr_)
{
string memory baseKey = string.concat('.releases["', _version, '"].', _contractName);
string memory implAddressKey = string.concat(baseKey, ".implementation_address");
string memory addressKey = string.concat(baseKey, ".address");
try vm.parseTomlAddress(_standardVersionsToml, implAddressKey) returns (address parsedAddr_) {
addr_ = parsedAddr_;
} catch {
try vm.parseTomlAddress(_standardVersionsToml, addressKey) returns (address parsedAddr_) {
addr_ = parsedAddr_;
} catch {
addr_ = address(0);
}
}
}
// A release is considered a 'develop' release if it does not start with 'op-contracts'.
function isDevelopRelease(string memory _release) internal pure returns (bool) {
return !LibString.startsWith(_release, "op-contracts");
......
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