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):
log.info('Bringing up `op-challenger`.')
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:
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)
......
......@@ -248,7 +248,7 @@ func (bs *BatcherService) initChannelConfig(cfg *CLIConfig) error {
"channel_timeout", cc.ChannelTimeout,
"sub_safety_margin", cc.SubSafetyMargin)
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
return nil
......
......@@ -5,6 +5,7 @@ import (
"strings"
"testing"
plasma "github.com/ethereum-optimism/optimism/op-plasma"
opservice "github.com/ethereum-optimism/optimism/op-service"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
......@@ -57,6 +58,14 @@ func TestBetaFlags(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 {
flag := flag
flagName := flag.Names()[0]
......@@ -65,9 +74,13 @@ func TestHasEnvVar(t *testing.T) {
envFlagGetter, ok := flag.(interface {
GetEnvVars() []string
})
envFlags := envFlagGetter.GetEnvVars()
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) {
})
envFlags := envFlagGetter.GetEnvVars()
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")
require.Equal(t, expectedEnvVar, envFlags[0])
})
......
......@@ -441,10 +441,10 @@ func (d *DeployConfig) Check() error {
}
if d.UsePlasma {
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 {
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) {
return fmt.Errorf("%w: DACommitmentType must be either KeccakCommtiment or GenericCommitment", ErrInvalidDeployConfig)
......@@ -520,9 +520,9 @@ func (d *DeployConfig) CheckAddresses() error {
return fmt.Errorf("%w: OptimismPortalProxy cannot be address(0)", ErrInvalidDeployConfig)
}
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{}) {
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
}
......
......@@ -19,7 +19,7 @@ import (
"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.
type L2PlasmaDA struct {
......
......@@ -25,7 +25,7 @@ const (
SequencerCategory = "3. SEQUENCER"
OperationsCategory = "4. LOGGING, METRICS, DEBUGGING, AND API"
P2PCategory = "5. PEER-TO-PEER"
PlasmaCategory = "6. PLASMA (EXPERIMENTAL)"
AltDACategory = "6. ALT-DA (EXPERIMENTAL)"
MiscCategory = "7. MISC"
)
......@@ -424,7 +424,7 @@ func init() {
optionalFlags = append(optionalFlags, oppprof.CLIFlagsWithCategory(EnvVarPrefix, OperationsCategory)...)
optionalFlags = append(optionalFlags, DeprecatedFlags...)
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...)
}
......
......@@ -5,6 +5,7 @@ import (
"strings"
"testing"
plasma "github.com/ethereum-optimism/optimism/op-plasma"
opservice "github.com/ethereum-optimism/optimism/op-service"
"github.com/stretchr/testify/require"
......@@ -73,7 +74,11 @@ func TestDeprecatedFlagsAreHidden(t *testing.T) {
func TestHasEnvVar(t *testing.T) {
// known exceptions to the number of env vars
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 {
......
......@@ -175,7 +175,7 @@ func (cfg *Config) Check() error {
return fmt.Errorf("plasma config error: %w", err)
}
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
}
......@@ -34,7 +34,7 @@ const finalityDelay = 64
// calcFinalityLookback calculates the default finality lookback based on DA challenge window if plasma
// mode is activated or L1 finality lookback.
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.
if cfg.PlasmaEnabled() {
lkb := cfg.PlasmaConfig.DAChallengeWindow + cfg.PlasmaConfig.DAResolveWindow + 1
......
......@@ -32,7 +32,7 @@ func NewPlasmaFinalizer(log log.Logger, cfg *rollup.Config,
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.
// The plasma module will then call the inner.Finalize function when applicable.
backend.OnFinalizedHeadSignal(func(ref eth.L1BlockRef) {
......
......@@ -54,10 +54,10 @@ type PlasmaConfig struct {
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 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.
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.
DAResolveWindow uint64 `json:"da_resolve_window"`
}
......@@ -132,15 +132,15 @@ type Config struct {
// L1 DataAvailabilityChallenge contract proxy address
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.
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.
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"`
}
......@@ -326,7 +326,7 @@ func (cfg *Config) Check() error {
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.
func validatePlasmaConfig(cfg *Config) error {
if cfg.LegacyUsePlasma && cfg.PlasmaConfig == nil {
......@@ -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.
// 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 {
if c.PlasmaEnabled() {
if win := (c.PlasmaConfig.DAChallengeWindow + c.PlasmaConfig.DAResolveWindow); win > c.SeqWindowSize {
......@@ -567,7 +567,7 @@ func (c *Config) Description(l2Chains map[string]string) string {
// Report the protocol version
banner += fmt.Sprintf("Node supports up to OP-Stack Protocol Version: %s\n", OPStackSupport)
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
}
......
......@@ -7,44 +7,56 @@ import (
"github.com/urfave/cli/v2"
)
const (
EnabledFlagName = "plasma.enabled"
DaServerAddressFlagName = "plasma.da-server"
VerifyOnReadFlagName = "plasma.verify-on-read"
DaServiceFlag = "plasma.da-service"
var (
EnabledFlagName, EnabledFlagAlias = altDAFlags("enabled")
DaServerAddressFlagName, DaServerAddressFlagAlias = altDAFlags("da-server")
VerifyOnReadFlagName, VerifyOnReadFlagAlias = altDAFlags("verify-on-read")
DaServiceFlag, DaServiceFlagAlias = altDAFlags("da-service")
)
func plasmaEnv(envprefix, v string) []string {
return []string{envprefix + "_PLASMA_" + v}
// altDAFlags returns the flag names for altDA, with an Alias for plasma
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 {
return []cli.Flag{
&cli.BoolFlag{
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,
EnvVars: plasmaEnv(envPrefix, "ENABLED"),
EnvVars: altDAEnvs(envPrefix, "ENABLED"),
Category: category,
},
&cli.StringFlag{
Name: DaServerAddressFlagName,
Aliases: []string{DaServerAddressFlagAlias},
Usage: "HTTP address of a DA Server",
EnvVars: plasmaEnv(envPrefix, "DA_SERVER"),
EnvVars: altDAEnvs(envPrefix, "DA_SERVER"),
Category: category,
},
&cli.BoolFlag{
Name: VerifyOnReadFlagName,
Aliases: []string{VerifyOnReadFlagAlias},
Usage: "Verify input data matches the commitments from the DA storage service",
Value: true,
EnvVars: plasmaEnv(envPrefix, "VERIFY_ON_READ"),
EnvVars: altDAEnvs(envPrefix, "VERIFY_ON_READ"),
Category: category,
},
&cli.BoolFlag{
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,
EnvVars: plasmaEnv(envPrefix, "DA_SERVICE"),
EnvVars: altDAEnvs(envPrefix, "DA_SERVICE"),
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