Skip to content

feat: Simplify op-deployer scripts: Switch from legacy to the new scripts for DeploySuperchain & DeployImplementations [17/N] #15551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions op-chain-ops/interopgen/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,26 @@ func Deploy(logger log.Logger, fa *foundry.ArtifactsFS, srcFS *foundry.SourceMap
return nil, nil, fmt.Errorf("failed to enable cheats in L1 state: %w", err)
}

//
// Gather all the deployment scripts
//
// Loading all deployment scripts should happen before we start deploying anything
// and after we have access to the contract artifacts.
//
// If done this way, any errors (such as ABI mismatches) will be caught before the first transaction is sent.
//
opcmScripts, err := opcm.NewScripts(l1Host)
if err != nil {
return nil, nil, fmt.Errorf("failed to load OPCM script: %w", err)
}

l1Deployment, err := PrepareInitialL1(l1Host, cfg.L1)
if err != nil {
return nil, nil, fmt.Errorf("failed to deploy initial L1 content: %w", err)
}
deployments.L1 = l1Deployment

superDeployment, err := DeploySuperchainToL1(l1Host, cfg.Superchain)
superDeployment, err := DeploySuperchainToL1(l1Host, opcmScripts, cfg.Superchain)
if err != nil {
return nil, nil, fmt.Errorf("failed to deploy superchain to L1: %w", err)
}
Expand Down Expand Up @@ -159,10 +172,10 @@ func PrepareInitialL1(l1Host *script.Host, cfg *L1Config) (*L1Deployment, error)
return &L1Deployment{}, nil
}

func DeploySuperchainToL1(l1Host *script.Host, superCfg *SuperchainConfig) (*SuperchainDeployment, error) {
func DeploySuperchainToL1(l1Host *script.Host, opcmScripts *opcm.Scripts, superCfg *SuperchainConfig) (*SuperchainDeployment, error) {
l1Host.SetTxOrigin(superCfg.Deployer)

superDeployment, err := opcm.DeploySuperchain(l1Host, opcm.DeploySuperchainInput{
superDeployment, err := opcmScripts.DeploySuperchain.Run(opcm.DeploySuperchainInput{
SuperchainProxyAdminOwner: superCfg.ProxyAdminOwner,
ProtocolVersionsOwner: superCfg.ProtocolVersionsOwner,
Guardian: superCfg.SuperchainConfigGuardian,
Expand All @@ -174,14 +187,15 @@ func DeploySuperchainToL1(l1Host *script.Host, superCfg *SuperchainConfig) (*Sup
return nil, fmt.Errorf("failed to deploy Superchain contracts: %w", err)
}

implementationsDeployment, err := opcm.DeployImplementations(l1Host, opcm.DeployImplementationsInput{
implementationsDeployment, err := opcmScripts.DeployImplementations.Run(opcm.DeployImplementationsInput{
WithdrawalDelaySeconds: superCfg.Implementations.FaultProof.WithdrawalDelaySeconds,
MinProposalSizeBytes: superCfg.Implementations.FaultProof.MinProposalSizeBytes,
ChallengePeriodSeconds: superCfg.Implementations.FaultProof.ChallengePeriodSeconds,
ProofMaturityDelaySeconds: superCfg.Implementations.FaultProof.ProofMaturityDelaySeconds,
DisputeGameFinalityDelaySeconds: superCfg.Implementations.FaultProof.DisputeGameFinalityDelaySeconds,
MipsVersion: superCfg.Implementations.FaultProof.MipsVersion,
L1ContractsRelease: superCfg.Implementations.L1ContractsRelease,
SuperchainProxyAdmin: superDeployment.SuperchainProxyAdmin,
SuperchainConfigProxy: superDeployment.SuperchainConfigProxy,
ProtocolVersionsProxy: superDeployment.ProtocolVersionsProxy,
UpgradeController: superCfg.ProxyAdminOwner,
Expand Down
10 changes: 10 additions & 0 deletions op-deployer/pkg/deployer/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/ethereum-optimism/optimism/op-chain-ops/script/forking"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/artifacts"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/broadcaster"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/opcm"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/pipeline"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/state"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/env"
Expand Down Expand Up @@ -291,13 +292,22 @@ func ApplyPipeline(
return fmt.Errorf("invalid deployment target: '%s'", opts.DeploymentTarget)
}

// Now that we have the host, we can load the deployment scripts
//
// This step will error out if the ABIs don't match the Go types
opcmScripts, err := opcm.NewScripts(l1Host)
if err != nil {
return fmt.Errorf("failed to load OPCM script: %w", err)
}

pEnv := &pipeline.Env{
StateWriter: opts.StateWriter,
L1ScriptHost: l1Host,
L1Client: l1Client,
Logger: opts.Logger,
Broadcaster: bcaster,
Deployer: deployer,
Scripts: opcmScripts,
}

pline := []pipelineStage{
Expand Down
8 changes: 6 additions & 2 deletions op-deployer/pkg/deployer/bootstrap/implementations.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,12 @@ func Implementations(ctx context.Context, cfg ImplementationsConfig) (opcm.Deplo
return dio, fmt.Errorf("failed to create script host: %w", err)
}

if dio, err = opcm.DeployImplementations(
l1Host,
opcmScripts, err := opcm.NewScripts(l1Host)
if err != nil {
return dio, fmt.Errorf("failed to load OPCM scripts: %w", err)
}

if dio, err = opcmScripts.DeployImplementations.Run(
opcm.DeployImplementationsInput{
WithdrawalDelaySeconds: new(big.Int).SetUint64(cfg.WithdrawalDelaySeconds),
MinProposalSizeBytes: new(big.Int).SetUint64(cfg.MinProposalSizeBytes),
Expand Down
8 changes: 6 additions & 2 deletions op-deployer/pkg/deployer/bootstrap/superchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,12 @@ func Superchain(ctx context.Context, cfg SuperchainConfig) (opcm.DeploySuperchai
return dso, fmt.Errorf("failed to create script host: %w", err)
}

dso, err = opcm.DeploySuperchain(
l1Host,
opcmScripts, err := opcm.NewScripts(l1Host)
if err != nil {
return dso, fmt.Errorf("failed to load OPCM scripts: %w", err)
}

dso, err = opcmScripts.DeploySuperchain.Run(
opcm.DeploySuperchainInput{
SuperchainProxyAdminOwner: cfg.SuperchainProxyAdminOwner,
ProtocolVersionsOwner: cfg.ProtocolVersionsOwner,
Expand Down
2 changes: 2 additions & 0 deletions op-deployer/pkg/deployer/bootstrap/superchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ var networks = []string{"mainnet", "sepolia"}
var versions = []string{"v1.6.0", "v1.8.0-rc.4"}

func TestSuperchain(t *testing.T) {
t.Skipf("The regression tests for the legacy artifacts have been disabled until new artifacts are released")

for _, network := range networks {
for _, version := range versions {
t.Run(network+"-"+version, func(t *testing.T) {
Expand Down
65 changes: 6 additions & 59 deletions op-deployer/pkg/deployer/opcm/implementations.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package opcm

import (
"fmt"
"math/big"

"github.com/ethereum/go-ethereum/common"

"github.com/ethereum-optimism/optimism/op-chain-ops/script"
"github.com/ethereum/go-ethereum/common"
)

type DeployImplementationsInput struct {
Expand All @@ -24,10 +22,6 @@ type DeployImplementationsInput struct {
UpgradeController common.Address
}

func (input *DeployImplementationsInput) InputSet() bool {
return true
}

type DeployImplementationsOutput struct {
Opcm common.Address `json:"opcmAddress"`
OpcmContractsContainer common.Address `json:"opcmContractsContainerAddress"`
Expand All @@ -37,7 +31,7 @@ type DeployImplementationsOutput struct {
OpcmInteropMigrator common.Address `json:"opcmInteropMigratorAddress"`
DelayedWETHImpl common.Address `json:"delayedWETHImplAddress"`
OptimismPortalImpl common.Address `json:"optimismPortalImplAddress"`
ETHLockboxImpl common.Address `json:"ethLockboxImplAddress" evm:"ethLockboxImpl"`
ETHLockboxImpl common.Address `json:"ethLockboxImplAddress" abi:"ethLockboxImpl"`
PreimageOracleSingleton common.Address `json:"preimageOracleSingletonAddress"`
MipsSingleton common.Address `json:"mipsSingletonAddress"`
SystemConfigImpl common.Address `json:"systemConfigImplAddress"`
Expand All @@ -51,56 +45,9 @@ type DeployImplementationsOutput struct {
ProtocolVersionsImpl common.Address `json:"protocolVersionsImplAddress"`
}

func (output *DeployImplementationsOutput) CheckOutput(input common.Address) error {
return nil
}

type DeployImplementationsScript struct {
Run func(input, output common.Address) error
}

func DeployImplementations(
host *script.Host,
input DeployImplementationsInput,
) (DeployImplementationsOutput, error) {
var output DeployImplementationsOutput
inputAddr := host.NewScriptAddress()
outputAddr := host.NewScriptAddress()

cleanupInput, err := script.WithPrecompileAtAddress[*DeployImplementationsInput](host, inputAddr, &input)
if err != nil {
return output, fmt.Errorf("failed to insert DeployImplementationsInput precompile: %w", err)
}
defer cleanupInput()

cleanupOutput, err := script.WithPrecompileAtAddress[*DeployImplementationsOutput](host, outputAddr, &output,
script.WithFieldSetter[*DeployImplementationsOutput])
if err != nil {
return output, fmt.Errorf("failed to insert DeployImplementationsOutput precompile: %w", err)
}
defer cleanupOutput()

implContract := "DeployImplementations"
deployScript, cleanupDeploy, err := script.WithScript[DeployImplementationsScript](host, "DeployImplementations.s.sol", implContract)
if err != nil {
return output, fmt.Errorf("failed to load %s script: %w", implContract, err)
}
defer cleanupDeploy()

opcmContract := "OPContractsManager"
if err := host.RememberOnLabel("OPContractsManager", opcmContract+".sol", opcmContract); err != nil {
return output, fmt.Errorf("failed to link OPContractsManager label: %w", err)
}

// So we can see in detail where the SystemConfig interop initializer fails
sysConfig := "SystemConfig"
if err := host.RememberOnLabel("SystemConfigImpl", sysConfig+".sol", sysConfig); err != nil {
return output, fmt.Errorf("failed to link SystemConfig label: %w", err)
}

if err := deployScript.Run(inputAddr, outputAddr); err != nil {
return output, fmt.Errorf("failed to run %s script: %w", implContract, err)
}
type DeployImplementationsScript script.DeployScriptWithOutput[DeployImplementationsInput, DeployImplementationsOutput]

return output, nil
// NewDeployImplementationsScript loads and validates the DeployImplementations script contract
func NewDeployImplementationsScript(host *script.Host) (DeployImplementationsScript, error) {
return script.NewDeployScriptWithOutputFromFile[DeployImplementationsInput, DeployImplementationsOutput](host, "DeployImplementations.s.sol", "DeployImplementations")
}
53 changes: 0 additions & 53 deletions op-deployer/pkg/deployer/opcm/implementations2.go

This file was deleted.

Loading