implementations.go 2.86 KB
Newer Older
1 2 3 4 5 6
package pipeline

import (
	"fmt"
	"math/big"

7 8
	"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/opcm"
	"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/state"
9 10
)

11
func DeployImplementations(env *Env, intent *state.Intent, st *state.State) error {
12 13 14 15 16 17 18 19 20
	lgr := env.Logger.New("stage", "deploy-implementations")

	if !shouldDeployImplementations(intent, st) {
		lgr.Info("implementations deployment not needed")
		return nil
	}

	lgr.Info("deploying implementations")

21
	var standardVersionsTOML string
22
	var contractsRelease string
23
	var err error
24
	if intent.L1ContractsLocator.IsTag() && intent.DeploymentStrategy == state.DeploymentStrategyLive {
25
		standardVersionsTOML, err = opcm.StandardL1VersionsDataFor(intent.L1ChainID)
26 27 28
		if err != nil {
			return fmt.Errorf("error getting standard versions TOML: %w", err)
		}
29 30 31
		contractsRelease = intent.L1ContractsLocator.Tag
	} else {
		contractsRelease = "dev"
32 33
	}

34
	env.L1ScriptHost.ImportState(st.L1StateDump.Data)
35

36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
	dio, err := opcm.DeployImplementations(
		env.L1ScriptHost,
		opcm.DeployImplementationsInput{
			Salt:                            st.Create2Salt,
			WithdrawalDelaySeconds:          big.NewInt(604800),
			MinProposalSizeBytes:            big.NewInt(126000),
			ChallengePeriodSeconds:          big.NewInt(86400),
			ProofMaturityDelaySeconds:       big.NewInt(604800),
			DisputeGameFinalityDelaySeconds: big.NewInt(302400),
			MipsVersion:                     big.NewInt(1),
			Release:                         contractsRelease,
			SuperchainConfigProxy:           st.SuperchainDeployment.SuperchainConfigProxyAddress,
			ProtocolVersionsProxy:           st.SuperchainDeployment.ProtocolVersionsProxyAddress,
			OpcmProxyOwner:                  st.SuperchainDeployment.ProxyAdminAddress,
			StandardVersionsToml:            standardVersionsTOML,
			UseInterop:                      false,
52 53 54 55 56 57 58
		},
	)
	if err != nil {
		return fmt.Errorf("error deploying implementations: %w", err)
	}

	st.ImplementationsDeployment = &state.ImplementationsDeployment{
59
		OpcmProxyAddress:                        dio.OpcmProxy,
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
		DelayedWETHImplAddress:                  dio.DelayedWETHImpl,
		OptimismPortalImplAddress:               dio.OptimismPortalImpl,
		PreimageOracleSingletonAddress:          dio.PreimageOracleSingleton,
		MipsSingletonAddress:                    dio.MipsSingleton,
		SystemConfigImplAddress:                 dio.SystemConfigImpl,
		L1CrossDomainMessengerImplAddress:       dio.L1CrossDomainMessengerImpl,
		L1ERC721BridgeImplAddress:               dio.L1ERC721BridgeImpl,
		L1StandardBridgeImplAddress:             dio.L1StandardBridgeImpl,
		OptimismMintableERC20FactoryImplAddress: dio.OptimismMintableERC20FactoryImpl,
		DisputeGameFactoryImplAddress:           dio.DisputeGameFactoryImpl,
	}

	return nil
}

func shouldDeployImplementations(intent *state.Intent, st *state.State) bool {
	return st.ImplementationsDeployment == nil
}