Commit 387c605e authored by Axel Kingsley's avatar Axel Kingsley Committed by GitHub

Alt-DA: Add aliases to cli for Alt-DA (#10812)

* Alt-DA: Add aliases to cli for Alt-DA

* replace "plasma mode" with "alt-da mode"
parent 81c7aa03
...@@ -297,7 +297,7 @@ def devnet_deploy(paths): ...@@ -297,7 +297,7 @@ def devnet_deploy(paths):
log.info('Bringing up `op-challenger`.') log.info('Bringing up `op-challenger`.')
run_command(['docker', 'compose', 'up', '-d', 'op-challenger'], cwd=paths.ops_bedrock_dir, env=docker_env) run_command(['docker', 'compose', 'up', '-d', 'op-challenger'], cwd=paths.ops_bedrock_dir, env=docker_env)
# Optionally bring up Plasma Mode components. # Optionally bring up Alt-DA Mode components.
if DEVNET_PLASMA: if DEVNET_PLASMA:
log.info('Bringing up `da-server`, `sentinel`.') # TODO(10141): We don't have public sentinel images yet log.info('Bringing up `da-server`, `sentinel`.') # TODO(10141): We don't have public sentinel images yet
run_command(['docker', 'compose', 'up', '-d', 'da-server'], cwd=paths.ops_bedrock_dir, env=docker_env) run_command(['docker', 'compose', 'up', '-d', 'da-server'], cwd=paths.ops_bedrock_dir, env=docker_env)
......
...@@ -248,7 +248,7 @@ func (bs *BatcherService) initChannelConfig(cfg *CLIConfig) error { ...@@ -248,7 +248,7 @@ func (bs *BatcherService) initChannelConfig(cfg *CLIConfig) error {
"channel_timeout", cc.ChannelTimeout, "channel_timeout", cc.ChannelTimeout,
"sub_safety_margin", cc.SubSafetyMargin) "sub_safety_margin", cc.SubSafetyMargin)
if bs.UsePlasma { if bs.UsePlasma {
bs.Log.Warn("Plasma Mode is a Beta feature of the MIT licensed OP Stack. While it has received initial review from core contributors, it is still undergoing testing, and may have bugs or other issues.") bs.Log.Warn("Alt-DA Mode is a Beta feature of the MIT licensed OP Stack. While it has received initial review from core contributors, it is still undergoing testing, and may have bugs or other issues.")
} }
bs.ChannelConfig = cc bs.ChannelConfig = cc
return nil return nil
......
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"strings" "strings"
"testing" "testing"
plasma "github.com/ethereum-optimism/optimism/op-plasma"
opservice "github.com/ethereum-optimism/optimism/op-service" opservice "github.com/ethereum-optimism/optimism/op-service"
"github.com/ethereum-optimism/optimism/op-service/txmgr" "github.com/ethereum-optimism/optimism/op-service/txmgr"
...@@ -57,6 +58,14 @@ func TestBetaFlags(t *testing.T) { ...@@ -57,6 +58,14 @@ func TestBetaFlags(t *testing.T) {
} }
func TestHasEnvVar(t *testing.T) { func TestHasEnvVar(t *testing.T) {
// known exceptions to the number of env vars
expEnvVars := map[string]int{
plasma.EnabledFlagName: 2,
plasma.DaServerAddressFlagName: 2,
plasma.VerifyOnReadFlagName: 2,
plasma.DaServiceFlag: 2,
}
for _, flag := range Flags { for _, flag := range Flags {
flag := flag flag := flag
flagName := flag.Names()[0] flagName := flag.Names()[0]
...@@ -65,9 +74,13 @@ func TestHasEnvVar(t *testing.T) { ...@@ -65,9 +74,13 @@ func TestHasEnvVar(t *testing.T) {
envFlagGetter, ok := flag.(interface { envFlagGetter, ok := flag.(interface {
GetEnvVars() []string GetEnvVars() []string
}) })
envFlags := envFlagGetter.GetEnvVars()
require.True(t, ok, "must be able to cast the flag to an EnvVar interface") require.True(t, ok, "must be able to cast the flag to an EnvVar interface")
require.Equal(t, 1, len(envFlags), "flags should have exactly one env var") envFlags := envFlagGetter.GetEnvVars()
if numEnvVars, ok := expEnvVars[flagName]; ok {
require.Equalf(t, numEnvVars, len(envFlags), "flags should have %d env vars", numEnvVars)
} else {
require.Equal(t, 1, len(envFlags), "flags should have exactly one env var")
}
}) })
} }
} }
...@@ -92,7 +105,6 @@ func TestEnvVarFormat(t *testing.T) { ...@@ -92,7 +105,6 @@ func TestEnvVarFormat(t *testing.T) {
}) })
envFlags := envFlagGetter.GetEnvVars() envFlags := envFlagGetter.GetEnvVars()
require.True(t, ok, "must be able to cast the flag to an EnvVar interface") require.True(t, ok, "must be able to cast the flag to an EnvVar interface")
require.Equal(t, 1, len(envFlags), "flags should have exactly one env var")
expectedEnvVar := opservice.FlagNameToEnvVarName(flagName, "OP_BATCHER") expectedEnvVar := opservice.FlagNameToEnvVarName(flagName, "OP_BATCHER")
require.Equal(t, expectedEnvVar, envFlags[0]) require.Equal(t, expectedEnvVar, envFlags[0])
}) })
......
...@@ -441,10 +441,10 @@ func (d *DeployConfig) Check() error { ...@@ -441,10 +441,10 @@ func (d *DeployConfig) Check() error {
} }
if d.UsePlasma { if d.UsePlasma {
if d.DAChallengeWindow == 0 { if d.DAChallengeWindow == 0 {
return fmt.Errorf("%w: DAChallengeWindow cannot be 0 when using plasma mode", ErrInvalidDeployConfig) return fmt.Errorf("%w: DAChallengeWindow cannot be 0 when using alt-da mode", ErrInvalidDeployConfig)
} }
if d.DAResolveWindow == 0 { if d.DAResolveWindow == 0 {
return fmt.Errorf("%w: DAResolveWindow cannot be 0 when using plasma mode", ErrInvalidDeployConfig) return fmt.Errorf("%w: DAResolveWindow cannot be 0 when using alt-da mode", ErrInvalidDeployConfig)
} }
if !(d.DACommitmentType == plasma.KeccakCommitmentString || d.DACommitmentType == plasma.GenericCommitmentString) { if !(d.DACommitmentType == plasma.KeccakCommitmentString || d.DACommitmentType == plasma.GenericCommitmentString) {
return fmt.Errorf("%w: DACommitmentType must be either KeccakCommtiment or GenericCommitment", ErrInvalidDeployConfig) return fmt.Errorf("%w: DACommitmentType must be either KeccakCommtiment or GenericCommitment", ErrInvalidDeployConfig)
...@@ -520,9 +520,9 @@ func (d *DeployConfig) CheckAddresses() error { ...@@ -520,9 +520,9 @@ func (d *DeployConfig) CheckAddresses() error {
return fmt.Errorf("%w: OptimismPortalProxy cannot be address(0)", ErrInvalidDeployConfig) return fmt.Errorf("%w: OptimismPortalProxy cannot be address(0)", ErrInvalidDeployConfig)
} }
if d.UsePlasma && d.DACommitmentType == plasma.KeccakCommitmentString && d.DAChallengeProxy == (common.Address{}) { if d.UsePlasma && d.DACommitmentType == plasma.KeccakCommitmentString && d.DAChallengeProxy == (common.Address{}) {
return fmt.Errorf("%w: DAChallengeContract cannot be address(0) when using plasma mode", ErrInvalidDeployConfig) return fmt.Errorf("%w: DAChallengeContract cannot be address(0) when using alt-da mode", ErrInvalidDeployConfig)
} else if d.UsePlasma && d.DACommitmentType == plasma.GenericCommitmentString && d.DAChallengeProxy != (common.Address{}) { } else if d.UsePlasma && d.DACommitmentType == plasma.GenericCommitmentString && d.DAChallengeProxy != (common.Address{}) {
return fmt.Errorf("%w: DAChallengeContract must be address(0) when using generic commitments in plasma mode", ErrInvalidDeployConfig) return fmt.Errorf("%w: DAChallengeContract must be address(0) when using generic commitments in alt-da mode", ErrInvalidDeployConfig)
} }
return nil return nil
} }
......
...@@ -19,7 +19,7 @@ import ( ...@@ -19,7 +19,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
// Devnet allocs should have plasma mode enabled for these tests to pass // Devnet allocs should have alt-da mode enabled for these tests to pass
// L2PlasmaDA is a test harness for manipulating plasma DA state. // L2PlasmaDA is a test harness for manipulating plasma DA state.
type L2PlasmaDA struct { type L2PlasmaDA struct {
......
...@@ -25,7 +25,7 @@ const ( ...@@ -25,7 +25,7 @@ const (
SequencerCategory = "3. SEQUENCER" SequencerCategory = "3. SEQUENCER"
OperationsCategory = "4. LOGGING, METRICS, DEBUGGING, AND API" OperationsCategory = "4. LOGGING, METRICS, DEBUGGING, AND API"
P2PCategory = "5. PEER-TO-PEER" P2PCategory = "5. PEER-TO-PEER"
PlasmaCategory = "6. PLASMA (EXPERIMENTAL)" AltDACategory = "6. ALT-DA (EXPERIMENTAL)"
MiscCategory = "7. MISC" MiscCategory = "7. MISC"
) )
...@@ -424,7 +424,7 @@ func init() { ...@@ -424,7 +424,7 @@ func init() {
optionalFlags = append(optionalFlags, oppprof.CLIFlagsWithCategory(EnvVarPrefix, OperationsCategory)...) optionalFlags = append(optionalFlags, oppprof.CLIFlagsWithCategory(EnvVarPrefix, OperationsCategory)...)
optionalFlags = append(optionalFlags, DeprecatedFlags...) optionalFlags = append(optionalFlags, DeprecatedFlags...)
optionalFlags = append(optionalFlags, opflags.CLIFlags(EnvVarPrefix, RollupCategory)...) optionalFlags = append(optionalFlags, opflags.CLIFlags(EnvVarPrefix, RollupCategory)...)
optionalFlags = append(optionalFlags, plasma.CLIFlags(EnvVarPrefix, PlasmaCategory)...) optionalFlags = append(optionalFlags, plasma.CLIFlags(EnvVarPrefix, AltDACategory)...)
Flags = append(requiredFlags, optionalFlags...) Flags = append(requiredFlags, optionalFlags...)
} }
......
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"strings" "strings"
"testing" "testing"
plasma "github.com/ethereum-optimism/optimism/op-plasma"
opservice "github.com/ethereum-optimism/optimism/op-service" opservice "github.com/ethereum-optimism/optimism/op-service"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
...@@ -73,7 +74,11 @@ func TestDeprecatedFlagsAreHidden(t *testing.T) { ...@@ -73,7 +74,11 @@ func TestDeprecatedFlagsAreHidden(t *testing.T) {
func TestHasEnvVar(t *testing.T) { func TestHasEnvVar(t *testing.T) {
// known exceptions to the number of env vars // known exceptions to the number of env vars
expEnvVars := map[string]int{ expEnvVars := map[string]int{
BeaconFallbackAddrs.Name: 2, BeaconFallbackAddrs.Name: 2,
plasma.EnabledFlagName: 2,
plasma.DaServerAddressFlagName: 2,
plasma.VerifyOnReadFlagName: 2,
plasma.DaServiceFlag: 2,
} }
for _, flag := range Flags { for _, flag := range Flags {
......
...@@ -175,7 +175,7 @@ func (cfg *Config) Check() error { ...@@ -175,7 +175,7 @@ func (cfg *Config) Check() error {
return fmt.Errorf("plasma config error: %w", err) return fmt.Errorf("plasma config error: %w", err)
} }
if cfg.Plasma.Enabled { if cfg.Plasma.Enabled {
log.Warn("Plasma Mode is a Beta feature of the MIT licensed OP Stack. While it has received initial review from core contributors, it is still undergoing testing, and may have bugs or other issues.") log.Warn("Alt-DA Mode is a Beta feature of the MIT licensed OP Stack. While it has received initial review from core contributors, it is still undergoing testing, and may have bugs or other issues.")
} }
return nil return nil
} }
...@@ -34,7 +34,7 @@ const finalityDelay = 64 ...@@ -34,7 +34,7 @@ const finalityDelay = 64
// calcFinalityLookback calculates the default finality lookback based on DA challenge window if plasma // calcFinalityLookback calculates the default finality lookback based on DA challenge window if plasma
// mode is activated or L1 finality lookback. // mode is activated or L1 finality lookback.
func calcFinalityLookback(cfg *rollup.Config) uint64 { func calcFinalityLookback(cfg *rollup.Config) uint64 {
// in plasma mode the longest finality lookback is a commitment is challenged on the last block of // in alt-da mode the longest finality lookback is a commitment is challenged on the last block of
// the challenge window in which case it will be both challenge + resolve window. // the challenge window in which case it will be both challenge + resolve window.
if cfg.PlasmaEnabled() { if cfg.PlasmaEnabled() {
lkb := cfg.PlasmaConfig.DAChallengeWindow + cfg.PlasmaConfig.DAResolveWindow + 1 lkb := cfg.PlasmaConfig.DAChallengeWindow + cfg.PlasmaConfig.DAResolveWindow + 1
......
...@@ -32,7 +32,7 @@ func NewPlasmaFinalizer(log log.Logger, cfg *rollup.Config, ...@@ -32,7 +32,7 @@ func NewPlasmaFinalizer(log log.Logger, cfg *rollup.Config,
inner := NewFinalizer(log, cfg, l1Fetcher, ec) inner := NewFinalizer(log, cfg, l1Fetcher, ec)
// In plasma mode, the finalization signal is proxied through the plasma manager. // In alt-da mode, the finalization signal is proxied through the plasma manager.
// Finality signal will come from the DA contract or L1 finality whichever is last. // Finality signal will come from the DA contract or L1 finality whichever is last.
// The plasma module will then call the inner.Finalize function when applicable. // The plasma module will then call the inner.Finalize function when applicable.
backend.OnFinalizedHeadSignal(func(ref eth.L1BlockRef) { backend.OnFinalizedHeadSignal(func(ref eth.L1BlockRef) {
......
...@@ -54,10 +54,10 @@ type PlasmaConfig struct { ...@@ -54,10 +54,10 @@ type PlasmaConfig struct {
DAChallengeAddress common.Address `json:"da_challenge_contract_address,omitempty"` DAChallengeAddress common.Address `json:"da_challenge_contract_address,omitempty"`
// CommitmentType specifies which commitment type can be used. Defaults to Keccak (type 0) if not present // CommitmentType specifies which commitment type can be used. Defaults to Keccak (type 0) if not present
CommitmentType string `json:"da_commitment_type"` CommitmentType string `json:"da_commitment_type"`
// DA challenge window value set on the DAC contract. Used in plasma mode // DA challenge window value set on the DAC contract. Used in alt-da mode
// to compute when a commitment can no longer be challenged. // to compute when a commitment can no longer be challenged.
DAChallengeWindow uint64 `json:"da_challenge_window"` DAChallengeWindow uint64 `json:"da_challenge_window"`
// DA resolve window value set on the DAC contract. Used in plasma mode // DA resolve window value set on the DAC contract. Used in alt-da mode
// to compute when a challenge expires and trigger a reorg if needed. // to compute when a challenge expires and trigger a reorg if needed.
DAResolveWindow uint64 `json:"da_resolve_window"` DAResolveWindow uint64 `json:"da_resolve_window"`
} }
...@@ -132,15 +132,15 @@ type Config struct { ...@@ -132,15 +132,15 @@ type Config struct {
// L1 DataAvailabilityChallenge contract proxy address // L1 DataAvailabilityChallenge contract proxy address
LegacyDAChallengeAddress common.Address `json:"da_challenge_contract_address,omitempty"` LegacyDAChallengeAddress common.Address `json:"da_challenge_contract_address,omitempty"`
// DA challenge window value set on the DAC contract. Used in plasma mode // DA challenge window value set on the DAC contract. Used in alt-da mode
// to compute when a commitment can no longer be challenged. // to compute when a commitment can no longer be challenged.
LegacyDAChallengeWindow uint64 `json:"da_challenge_window,omitempty"` LegacyDAChallengeWindow uint64 `json:"da_challenge_window,omitempty"`
// DA resolve window value set on the DAC contract. Used in plasma mode // DA resolve window value set on the DAC contract. Used in alt-da mode
// to compute when a challenge expires and trigger a reorg if needed. // to compute when a challenge expires and trigger a reorg if needed.
LegacyDAResolveWindow uint64 `json:"da_resolve_window,omitempty"` LegacyDAResolveWindow uint64 `json:"da_resolve_window,omitempty"`
// LegacyUsePlasma is activated when the chain is in plasma mode. // LegacyUsePlasma is activated when the chain is in alt-da mode.
LegacyUsePlasma bool `json:"use_plasma,omitempty"` LegacyUsePlasma bool `json:"use_plasma,omitempty"`
} }
...@@ -326,7 +326,7 @@ func (cfg *Config) Check() error { ...@@ -326,7 +326,7 @@ func (cfg *Config) Check() error {
return nil return nil
} }
// validatePlasmaConfig checks the two approaches to configuring plasma mode. // validatePlasmaConfig checks the two approaches to configuring alt-da mode.
// If the legacy values are set, they are copied to the new location. If both are set, they are check for consistency. // If the legacy values are set, they are copied to the new location. If both are set, they are check for consistency.
func validatePlasmaConfig(cfg *Config) error { func validatePlasmaConfig(cfg *Config) error {
if cfg.LegacyUsePlasma && cfg.PlasmaConfig == nil { if cfg.LegacyUsePlasma && cfg.PlasmaConfig == nil {
...@@ -522,7 +522,7 @@ func (c *Config) PlasmaEnabled() bool { ...@@ -522,7 +522,7 @@ func (c *Config) PlasmaEnabled() bool {
} }
// SyncLookback computes the number of blocks to walk back in order to find the correct L1 origin. // SyncLookback computes the number of blocks to walk back in order to find the correct L1 origin.
// In plasma mode longest possible window is challenge + resolve windows. // In alt-da mode longest possible window is challenge + resolve windows.
func (c *Config) SyncLookback() uint64 { func (c *Config) SyncLookback() uint64 {
if c.PlasmaEnabled() { if c.PlasmaEnabled() {
if win := (c.PlasmaConfig.DAChallengeWindow + c.PlasmaConfig.DAResolveWindow); win > c.SeqWindowSize { if win := (c.PlasmaConfig.DAChallengeWindow + c.PlasmaConfig.DAResolveWindow); win > c.SeqWindowSize {
...@@ -567,7 +567,7 @@ func (c *Config) Description(l2Chains map[string]string) string { ...@@ -567,7 +567,7 @@ func (c *Config) Description(l2Chains map[string]string) string {
// Report the protocol version // Report the protocol version
banner += fmt.Sprintf("Node supports up to OP-Stack Protocol Version: %s\n", OPStackSupport) banner += fmt.Sprintf("Node supports up to OP-Stack Protocol Version: %s\n", OPStackSupport)
if c.PlasmaConfig != nil { if c.PlasmaConfig != nil {
banner += fmt.Sprintf("Node supports Plasma Mode with CommitmentType %v\n", c.PlasmaConfig.CommitmentType) banner += fmt.Sprintf("Node supports Alt-DA Mode with CommitmentType %v\n", c.PlasmaConfig.CommitmentType)
} }
return banner return banner
} }
......
...@@ -7,44 +7,56 @@ import ( ...@@ -7,44 +7,56 @@ import (
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
) )
const ( var (
EnabledFlagName = "plasma.enabled" EnabledFlagName, EnabledFlagAlias = altDAFlags("enabled")
DaServerAddressFlagName = "plasma.da-server" DaServerAddressFlagName, DaServerAddressFlagAlias = altDAFlags("da-server")
VerifyOnReadFlagName = "plasma.verify-on-read" VerifyOnReadFlagName, VerifyOnReadFlagAlias = altDAFlags("verify-on-read")
DaServiceFlag = "plasma.da-service" DaServiceFlag, DaServiceFlagAlias = altDAFlags("da-service")
) )
func plasmaEnv(envprefix, v string) []string { // altDAFlags returns the flag names for altDA, with an Alias for plasma
return []string{envprefix + "_PLASMA_" + v} func altDAFlags(v string) (string, string) {
return "altda." + v,
"plasma." + v
}
func altDAEnvs(envprefix, v string) []string {
return []string{
envprefix + "_ALTDA_" + v,
envprefix + "_PLASMA_" + v}
} }
func CLIFlags(envPrefix string, category string) []cli.Flag { func CLIFlags(envPrefix string, category string) []cli.Flag {
return []cli.Flag{ return []cli.Flag{
&cli.BoolFlag{ &cli.BoolFlag{
Name: EnabledFlagName, Name: EnabledFlagName,
Usage: "Enable plasma mode\nPlasma Mode is a Beta feature of the MIT licensed OP Stack. While it has received initial review from core contributors, it is still undergoing testing, and may have bugs or other issues.", Aliases: []string{EnabledFlagAlias},
Usage: "Enable Alt-DA mode\nAlt-DA Mode is a Beta feature of the MIT licensed OP Stack. While it has received initial review from core contributors, it is still undergoing testing, and may have bugs or other issues.",
Value: false, Value: false,
EnvVars: plasmaEnv(envPrefix, "ENABLED"), EnvVars: altDAEnvs(envPrefix, "ENABLED"),
Category: category, Category: category,
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: DaServerAddressFlagName, Name: DaServerAddressFlagName,
Aliases: []string{DaServerAddressFlagAlias},
Usage: "HTTP address of a DA Server", Usage: "HTTP address of a DA Server",
EnvVars: plasmaEnv(envPrefix, "DA_SERVER"), EnvVars: altDAEnvs(envPrefix, "DA_SERVER"),
Category: category, Category: category,
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: VerifyOnReadFlagName, Name: VerifyOnReadFlagName,
Aliases: []string{VerifyOnReadFlagAlias},
Usage: "Verify input data matches the commitments from the DA storage service", Usage: "Verify input data matches the commitments from the DA storage service",
Value: true, Value: true,
EnvVars: plasmaEnv(envPrefix, "VERIFY_ON_READ"), EnvVars: altDAEnvs(envPrefix, "VERIFY_ON_READ"),
Category: category, Category: category,
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: DaServiceFlag, Name: DaServiceFlag,
Usage: "Use DA service type where commitments are generated by plasma server", Aliases: []string{DaServiceFlagAlias},
Usage: "Use DA service type where commitments are generated by Alt-DA server",
Value: false, Value: false,
EnvVars: plasmaEnv(envPrefix, "DA_SERVICE"), EnvVars: altDAEnvs(envPrefix, "DA_SERVICE"),
Category: category, Category: category,
}, },
} }
......
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