Skip to content
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
3 changes: 3 additions & 0 deletions op-deployer/pkg/deployer/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ func ApplyPipeline(
opts ApplyPipelineOpts,
) error {
intent := opts.Intent
if err := intent.Check(); err != nil {
return err
}
st := opts.State

progressor := func(curr, total int64) {
Expand Down
6 changes: 1 addition & 5 deletions op-deployer/pkg/deployer/artifacts/locator.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ func (a *Locator) MarshalText() ([]byte, error) {
return []byte(a.URL.String()), nil
}

if a.Tag != "" {
return []byte("tag://" + a.Tag), nil
}

return nil, fmt.Errorf("no URL, path or tag set")
return []byte("tag://" + a.Tag), nil
}

func (a *Locator) IsTag() bool {
Expand Down
15 changes: 14 additions & 1 deletion op-deployer/pkg/deployer/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
OutdirFlagName = "outdir"
PrivateKeyFlagName = "private-key"
DeploymentStrategyFlagName = "deployment-strategy"
IntentConfigTypeFlagName = "intent-config-type"
Comment thread
bitwiseguy marked this conversation as resolved.
)

var (
Expand All @@ -35,7 +36,7 @@ var (
Name: L1ChainIDFlagName,
Usage: "Chain ID of the L1 chain.",
EnvVars: PrefixEnvVar("L1_CHAIN_ID"),
Value: 900,
Value: 11155111,
}
L2ChainIDsFlag = &cli.StringFlag{
Name: L2ChainIDsFlagName,
Expand All @@ -62,6 +63,17 @@ var (
EnvVars: PrefixEnvVar("DEPLOYMENT_STRATEGY"),
Value: string(state.DeploymentStrategyLive),
}
IntentConfigTypeFlag = &cli.StringFlag{
Name: IntentConfigTypeFlagName,
Usage: fmt.Sprintf("Intent config type to use. Options: %s (default), %s, %s, %s, %s",
state.IntentConfigTypeStandard,
state.IntentConfigTypeCustom,
state.IntentConfigTypeStrict,
state.IntentConfigTypeStandardOverrides,
state.IntentConfigTypeStrictOverrides),
EnvVars: PrefixEnvVar("INTENT_CONFIG_TYPE"),
Value: string(state.IntentConfigTypeStandard),
}
)

var GlobalFlags = append([]cli.Flag{}, oplog.CLIFlags(EnvVarPrefix)...)
Expand All @@ -71,6 +83,7 @@ var InitFlags = []cli.Flag{
L2ChainIDsFlag,
WorkdirFlag,
DeploymentStrategyFlag,
IntentConfigTypeFlag,
}

var ApplyFlags = []cli.Flag{
Expand Down
57 changes: 7 additions & 50 deletions op-deployer/pkg/deployer/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ import (
"path"
"strings"

"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/artifacts"

"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/state"

op_service "github.com/ethereum-optimism/optimism/op-service"

"github.com/ethereum-optimism/optimism/op-chain-ops/devkeys"
"github.com/ethereum/go-ethereum/common"
"github.com/urfave/cli/v2"
)

type InitConfig struct {
DeploymentStrategy state.DeploymentStrategy
IntentConfigType state.IntentConfigType
L1ChainID uint64
Outdir string
L2ChainIDs []common.Hash
Expand Down Expand Up @@ -51,6 +49,7 @@ func InitCLI() func(ctx *cli.Context) error {
l1ChainID := ctx.Uint64(L1ChainIDFlagName)
outdir := ctx.String(OutdirFlagName)
l2ChainIDsRaw := ctx.String(L2ChainIDsFlagName)
intentConfigType := ctx.String(IntentConfigTypeFlagName)

if len(l2ChainIDsRaw) == 0 {
return fmt.Errorf("must specify at least one L2 chain ID")
Expand All @@ -68,6 +67,7 @@ func InitCLI() func(ctx *cli.Context) error {

err := Init(InitConfig{
DeploymentStrategy: state.DeploymentStrategy(deploymentStrategy),
IntentConfigType: state.IntentConfigType(intentConfigType),
L1ChainID: l1ChainID,
Outdir: outdir,
L2ChainIDs: l2ChainIDs,
Expand All @@ -86,55 +86,12 @@ func Init(cfg InitConfig) error {
return fmt.Errorf("invalid config for init: %w", err)
}

intent := &state.Intent{
DeploymentStrategy: cfg.DeploymentStrategy,
L1ChainID: cfg.L1ChainID,
FundDevAccounts: true,
L1ContractsLocator: artifacts.DefaultL1ContractsLocator,
L2ContractsLocator: artifacts.DefaultL2ContractsLocator,
}

l1ChainIDBig := intent.L1ChainIDBig()

dk, err := devkeys.NewMnemonicDevKeys(devkeys.TestMnemonic)
intent, err := state.NewIntent(cfg.IntentConfigType, cfg.DeploymentStrategy, cfg.L1ChainID, cfg.L2ChainIDs)
if err != nil {
return fmt.Errorf("failed to create dev keys: %w", err)
}

addrFor := func(key devkeys.Key) common.Address {
// The error below should never happen, so panic if it does.
addr, err := dk.Address(key)
if err != nil {
panic(err)
}
return addr
}
intent.SuperchainRoles = &state.SuperchainRoles{
ProxyAdminOwner: addrFor(devkeys.L1ProxyAdminOwnerRole.Key(l1ChainIDBig)),
ProtocolVersionsOwner: addrFor(devkeys.SuperchainProtocolVersionsOwner.Key(l1ChainIDBig)),
Guardian: addrFor(devkeys.SuperchainConfigGuardianKey.Key(l1ChainIDBig)),
}

for _, l2ChainID := range cfg.L2ChainIDs {
l2ChainIDBig := l2ChainID.Big()
intent.Chains = append(intent.Chains, &state.ChainIntent{
ID: l2ChainID,
BaseFeeVaultRecipient: addrFor(devkeys.BaseFeeVaultRecipientRole.Key(l2ChainIDBig)),
L1FeeVaultRecipient: addrFor(devkeys.L1FeeVaultRecipientRole.Key(l2ChainIDBig)),
SequencerFeeVaultRecipient: addrFor(devkeys.SequencerFeeVaultRecipientRole.Key(l2ChainIDBig)),
Eip1559Denominator: 50,
Eip1559Elasticity: 6,
Roles: state.ChainRoles{
L1ProxyAdminOwner: addrFor(devkeys.L1ProxyAdminOwnerRole.Key(l2ChainIDBig)),
L2ProxyAdminOwner: addrFor(devkeys.L2ProxyAdminOwnerRole.Key(l2ChainIDBig)),
SystemConfigOwner: addrFor(devkeys.SystemConfigOwner.Key(l2ChainIDBig)),
UnsafeBlockSigner: addrFor(devkeys.SequencerP2PRole.Key(l2ChainIDBig)),
Batcher: addrFor(devkeys.BatcherRole.Key(l2ChainIDBig)),
Proposer: addrFor(devkeys.ProposerRole.Key(l2ChainIDBig)),
Challenger: addrFor(devkeys.ChallengerRole.Key(l2ChainIDBig)),
},
})
return err
}
intent.DeploymentStrategy = cfg.DeploymentStrategy
intent.ConfigType = cfg.IntentConfigType

st := &state.State{
Version: 1,
Expand Down
6 changes: 4 additions & 2 deletions op-deployer/pkg/deployer/integration_test/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ func newIntent(
l2Loc *artifacts.Locator,
) (*state.Intent, *state.State) {
intent := &state.Intent{
ConfigType: state.IntentConfigTypeCustom,
DeploymentStrategy: state.DeploymentStrategyLive,
L1ChainID: l1ChainID.Uint64(),
SuperchainRoles: &state.SuperchainRoles{
Expand All @@ -740,8 +741,9 @@ func newChainIntent(t *testing.T, dk *devkeys.MnemonicDevKeys, l1ChainID *big.In
BaseFeeVaultRecipient: addrFor(t, dk, devkeys.BaseFeeVaultRecipientRole.Key(l1ChainID)),
L1FeeVaultRecipient: addrFor(t, dk, devkeys.L1FeeVaultRecipientRole.Key(l1ChainID)),
SequencerFeeVaultRecipient: addrFor(t, dk, devkeys.SequencerFeeVaultRecipientRole.Key(l1ChainID)),
Eip1559Denominator: 50,
Eip1559Elasticity: 6,
Eip1559DenominatorCanyon: standard.Eip1559DenominatorCanyon,
Eip1559Denominator: standard.Eip1559Denominator,
Eip1559Elasticity: standard.Eip1559Elasticity,
Roles: state.ChainRoles{
L1ProxyAdminOwner: addrFor(t, dk, devkeys.L2ProxyAdminOwnerRole.Key(l1ChainID)),
L2ProxyAdminOwner: addrFor(t, dk, devkeys.L2ProxyAdminOwnerRole.Key(l1ChainID)),
Expand Down
4 changes: 2 additions & 2 deletions op-deployer/pkg/deployer/pipeline/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ func displayWarning() error {
####################### WARNING! WARNING WARNING! #######################

You are deploying a tagged release to a chain with no pre-deployed OPCM.
The contracts you are deploying may not be audited, or match a governance
The contracts you are deploying may not be audited, or match a governance
approved release.

USE OF THIS DEPLOYMENT IS NOT RECOMMENDED FOR PRODUCTION. USE AT YOUR OWN
USE OF THIS DEPLOYMENT IS NOT RECOMMENDED FOR PRODUCTION. USE AT YOUR OWN
RISK. BUGS OR LOSS OF FUNDS MAY OCCUR. WE HOPE YOU KNOW WHAT YOU ARE
DOING.

Expand Down
38 changes: 37 additions & 1 deletion op-deployer/pkg/deployer/standard/standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const (
DisputeSplitDepth uint64 = 30
DisputeClockExtension uint64 = 10800
DisputeMaxClockDuration uint64 = 302400
Eip1559DenominatorCanyon uint64 = 250
Eip1559Denominator uint64 = 50
Eip1559Elasticity uint64 = 6

ContractsV160Tag = "op-contracts/v1.6.0"
ContractsV170Beta1L2Tag = "op-contracts/v1.7.0-beta.1+l2-contracts"
Expand Down Expand Up @@ -97,6 +100,28 @@ func L1VersionsFor(chainID uint64) (L1Versions, error) {
}
}

func GuardianAddressFor(chainID uint64) (common.Address, error) {
switch chainID {
case 1:
return common.HexToAddress("0x09f7150D8c019BeF34450d6920f6B3608ceFdAf2"), nil
case 11155111:
return common.HexToAddress("0x7a50f00e8D05b95F98fE38d8BeE366a7324dCf7E"), nil
default:
return common.Address{}, fmt.Errorf("unsupported chain ID: %d", chainID)
}
}

func ChallengerAddressFor(chainID uint64) (common.Address, error) {
switch chainID {
case 1:
return common.HexToAddress("0x9BA6e03D8B90dE867373Db8cF1A58d2F7F006b3A"), nil
case 11155111:
return common.HexToAddress("0xfd1D2e729aE8eEe2E146c033bf4400fE75284301"), nil
default:
return common.Address{}, fmt.Errorf("unsupported chain ID: %d", chainID)
}
}

func SuperchainFor(chainID uint64) (*superchain.Superchain, error) {
switch chainID {
case 1:
Expand All @@ -115,7 +140,7 @@ func ChainNameFor(chainID uint64) (string, error) {
case 11155111:
return "sepolia", nil
default:
return "", fmt.Errorf("unrecognized chain ID: %d", chainID)
return "", fmt.Errorf("unrecognized l1 chain ID: %d", chainID)
}
}

Expand Down Expand Up @@ -173,6 +198,17 @@ func SystemOwnerAddrFor(chainID uint64) (common.Address, error) {
}
}

func L1ProxyAdminOwner(chainID uint64) (common.Address, error) {
switch chainID {
case 1:
return common.HexToAddress("0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A"), nil
case 11155111:
return common.HexToAddress("0x1Eb2fFc903729a0F03966B917003800b145F56E2"), nil
default:
return common.Address{}, fmt.Errorf("unsupported chain ID: %d", chainID)
}
}

func ArtifactsURLForTag(tag string) (*url.URL, error) {
switch tag {
case "op-contracts/v1.6.0":
Expand Down
82 changes: 82 additions & 0 deletions op-deployer/pkg/deployer/state/chain_intent.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package state

import (
"fmt"
"reflect"

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

type ChainIntent struct {
ID common.Hash `json:"id" toml:"id"`
BaseFeeVaultRecipient common.Address `json:"baseFeeVaultRecipient" toml:"baseFeeVaultRecipient"`
L1FeeVaultRecipient common.Address `json:"l1FeeVaultRecipient" toml:"l1FeeVaultRecipient"`
SequencerFeeVaultRecipient common.Address `json:"sequencerFeeVaultRecipient" toml:"sequencerFeeVaultRecipient"`
Eip1559DenominatorCanyon uint64 `json:"eip1559DenominatorCanyon" toml:"eip1559DenominatorCanyon"`
Eip1559Denominator uint64 `json:"eip1559Denominator" toml:"eip1559Denominator"`
Eip1559Elasticity uint64 `json:"eip1559Elasticity" toml:"eip1559Elasticity"`
Roles ChainRoles `json:"roles" toml:"roles"`
DeployOverrides map[string]any `json:"deployOverrides" toml:"deployOverrides"`
DangerousAltDAConfig genesis.AltDADeployConfig `json:"dangerousAltDAConfig,omitempty" toml:"dangerousAltDAConfig,omitempty"`
}

type ChainRoles struct {
L1ProxyAdminOwner common.Address `json:"l1ProxyAdminOwner" toml:"l1ProxyAdminOwner"`
L2ProxyAdminOwner common.Address `json:"l2ProxyAdminOwner" toml:"l2ProxyAdminOwner"`
SystemConfigOwner common.Address `json:"systemConfigOwner" toml:"systemConfigOwner"`
UnsafeBlockSigner common.Address `json:"unsafeBlockSigner" toml:"unsafeBlockSigner"`
Batcher common.Address `json:"batcher" toml:"batcher"`
Proposer common.Address `json:"proposer" toml:"proposer"`
Challenger common.Address `json:"challenger" toml:"challenger"`
}

var ErrChainRoleZeroAddress = fmt.Errorf("ChainRole is set to zero address")
var ErrFeeVaultZeroAddress = fmt.Errorf("chain has a fee vault set to zero address")
var ErrNonStandardValue = fmt.Errorf("chain contains non-standard config value")
var ErrEip1559ZeroValue = fmt.Errorf("eip1559 param is set to zero value")

func (c *ChainIntent) Check() error {
if c.ID == emptyHash {
return fmt.Errorf("id must be set")
}

if err := c.Roles.CheckNoZeroAddresses(); err != nil {
return err
}

if c.Eip1559DenominatorCanyon == 0 ||
c.Eip1559Denominator == 0 ||
c.Eip1559Elasticity == 0 {
return fmt.Errorf("%w: chainId=%s", ErrEip1559ZeroValue, c.ID)
}
if c.BaseFeeVaultRecipient == emptyAddress ||
c.L1FeeVaultRecipient == emptyAddress ||
c.SequencerFeeVaultRecipient == emptyAddress {
return fmt.Errorf("%w: chainId=%s", ErrFeeVaultZeroAddress, c.ID)
}

if c.DangerousAltDAConfig.UseAltDA {
return c.DangerousAltDAConfig.Check(nil)
}

return nil
}

// Returns an error if any fields in ChainRoles is set to common.Address{}
func (cr *ChainRoles) CheckNoZeroAddresses() error {
val := reflect.ValueOf(*cr)
typ := reflect.TypeOf(*cr)

// Iterate through all the fields
for i := 0; i < val.NumField(); i++ {
fieldValue := val.Field(i)
fieldName := typ.Field(i).Name

if fieldValue.Interface() == (common.Address{}) {
return fmt.Errorf("%w: %s", ErrChainRoleZeroAddress, fieldName)
}
}

return nil
}
Loading