Add medalla flag (#7399)

* add --medalla flag for uniformity

* add enforcing testnet flag

* fix

* fix comments

* fix sufficient err msg

* fix shared method

* fix

* fix name

* fix name

* add test

* fix e2e

* fix gofmt

* fix test

* add warning

* fix warning

* fix warning test

* fix

* fix

* fix

* fix

* fix gofmt

* fix refactor to func

* add func description

* fix exported

* fix

* fix

* fix

Co-authored-by: Victor Farazdagi <simple.square@gmail.com>
Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
This commit is contained in:
bidlocode 2020-10-08 05:04:19 +06:00 committed by GitHub
parent 668163d740
commit 7c8492e83f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 87 deletions

View File

@ -37,6 +37,7 @@ type Flags struct {
// Testnet Flags.
AltonaTestnet bool // AltonaTestnet defines the flag through which we can enable the node to run on the Altona testnet.
OnyxTestnet bool // OnyxTestnet defines the flag through which we can enable the node to run on the Onyx testnet.
MedallaTestnet bool // MedallaTestnet defines the flag through which we can enable the node to run on the Medalla testnet.
SpadinaTestnet bool // SpadinaTestnet defines the flag through which we can enable the node to run on the Spadina testnet.
ZinkenTestnet bool // ZinkenTestnet defines the flag through which we can enable the node to run on the Zinken testnet.
@ -123,41 +124,51 @@ func InitWithReset(c *Flags) func() {
return resetFunc
}
// configureTestnet sets the config according to specified testnet flag
func configureTestnet(ctx *cli.Context, cfg *Flags) {
if ctx.Bool(AltonaTestnet.Name) {
log.Warn("Running on Altona Testnet")
params.UseAltonaConfig()
params.UseAltonaNetworkConfig()
cfg.AltonaTestnet = true
} else if ctx.Bool(OnyxTestnet.Name) {
log.Warn("Running on Onyx Testnet")
params.UseOnyxConfig()
params.UseOnyxNetworkConfig()
cfg.OnyxTestnet = true
} else if ctx.Bool(MedallaTestnet.Name) {
log.Warn("Running on Medalla Testnet")
params.UseMedallaConfig()
params.UseMedallaNetworkConfig()
cfg.MedallaTestnet = true
} else if ctx.Bool(SpadinaTestnet.Name) {
log.Warn("Running on Spadina Testnet")
params.UseSpadinaConfig()
params.UseSpadinaNetworkConfig()
cfg.SpadinaTestnet = true
} else if ctx.Bool(ZinkenTestnet.Name) {
log.Warn("Running on Zinken Testnet")
params.UseZinkenConfig()
params.UseZinkenNetworkConfig()
cfg.ZinkenTestnet = true
} else {
log.Warn("--<testnet> flag is not specified (default: Medalla), this will become required from next release! ")
params.UseMedallaConfig()
params.UseMedallaNetworkConfig()
cfg.MedallaTestnet = true
}
}
// ConfigureBeaconChain sets the global config based
// on what flags are enabled for the beacon-chain client.
func ConfigureBeaconChain(ctx *cli.Context) {
// Using Medalla as the default configuration for now.
params.UseMedallaConfig()
complainOnDeprecatedFlags(ctx)
cfg := &Flags{}
if ctx.Bool(devModeFlag.Name) {
enableDevModeFlags(ctx)
}
if ctx.Bool(AltonaTestnet.Name) {
log.Warn("Running Node on Altona Testnet")
params.UseAltonaConfig()
params.UseAltonaNetworkConfig()
cfg.AltonaTestnet = true
}
if ctx.Bool(OnyxTestnet.Name) {
log.Warn("Running Node on Onyx Testnet")
params.UseOnyxConfig()
params.UseOnyxNetworkConfig()
cfg.OnyxTestnet = true
}
if ctx.Bool(SpadinaTestnet.Name) {
log.Warn("Running Node on Spadina Testnet")
params.UseSpadinaConfig()
params.UseSpadinaNetworkConfig()
cfg.SpadinaTestnet = true
}
if ctx.Bool(ZinkenTestnet.Name) {
log.Warn("Running Node on Zinken Testnet")
params.UseZinkenConfig()
params.UseZinkenNetworkConfig()
cfg.ZinkenTestnet = true
}
configureTestnet(ctx, cfg)
if ctx.Bool(writeSSZStateTransitionsFlag.Name) {
log.Warn("Writing SSZ states and blocks after state transitions")
cfg.WriteSSZStateTransitions = true
@ -292,35 +303,10 @@ func ConfigureBeaconChain(ctx *cli.Context) {
// ConfigureSlasher sets the global config based
// on what flags are enabled for the slasher client.
func ConfigureSlasher(ctx *cli.Context) {
// Using Medalla as the default configuration for now.
params.UseMedallaConfig()
complainOnDeprecatedFlags(ctx)
cfg := &Flags{}
if ctx.Bool(AltonaTestnet.Name) {
log.Warn("Running Validator on Altona Testnet")
params.UseAltonaConfig()
params.UseAltonaNetworkConfig()
cfg.AltonaTestnet = true
}
if ctx.Bool(OnyxTestnet.Name) {
log.Warn("Running Node on Onyx Testnet")
params.UseOnyxConfig()
params.UseOnyxNetworkConfig()
cfg.OnyxTestnet = true
}
if ctx.Bool(SpadinaTestnet.Name) {
log.Warn("Running Node on Spadina Testnet")
params.UseSpadinaConfig()
params.UseSpadinaNetworkConfig()
cfg.SpadinaTestnet = true
}
if ctx.Bool(ZinkenTestnet.Name) {
log.Warn("Running Node on Zinken Testnet")
params.UseZinkenConfig()
params.UseZinkenNetworkConfig()
cfg.ZinkenTestnet = true
}
configureTestnet(ctx, cfg)
if ctx.Bool(disableLookbackFlag.Name) {
log.Warn("Disabling slasher lookback")
cfg.DisableLookback = true
@ -331,35 +317,10 @@ func ConfigureSlasher(ctx *cli.Context) {
// ConfigureValidator sets the global config based
// on what flags are enabled for the validator client.
func ConfigureValidator(ctx *cli.Context) {
// Using Medalla as the default configuration for now.
params.UseMedallaConfig()
complainOnDeprecatedFlags(ctx)
cfg := &Flags{}
if ctx.Bool(AltonaTestnet.Name) {
log.Warn("Running Validator on Altona Testnet")
params.UseAltonaConfig()
params.UseAltonaNetworkConfig()
cfg.AltonaTestnet = true
}
if ctx.Bool(OnyxTestnet.Name) {
log.Warn("Running Node on Onyx Testnet")
params.UseOnyxConfig()
params.UseOnyxNetworkConfig()
cfg.OnyxTestnet = true
}
if ctx.Bool(SpadinaTestnet.Name) {
log.Warn("Running Node on Spadina Testnet")
params.UseSpadinaConfig()
params.UseSpadinaNetworkConfig()
cfg.SpadinaTestnet = true
}
if ctx.Bool(ZinkenTestnet.Name) {
log.Warn("Running Node on Zinken Testnet")
params.UseZinkenConfig()
params.UseZinkenNetworkConfig()
cfg.ZinkenTestnet = true
}
configureTestnet(ctx, cfg)
if ctx.Bool(enableLocalProtectionFlag.Name) {
cfg.LocalProtection = true
} else {

View File

@ -15,6 +15,11 @@ var (
Name: "onyx",
Usage: "This defines the flag through which we can run on the Onyx Prysm Testnet",
}
// MedallaTestnet flag for the multiclient eth2 testnet.
MedallaTestnet = &cli.BoolFlag{
Name: "medalla",
Usage: "This defines the flag through which we can run on the Medalla Multiclient Testnet",
}
// SpadinaTestnet flag for the multiclient eth2 testnet.
SpadinaTestnet = &cli.BoolFlag{
Name: "spadina",
@ -514,11 +519,6 @@ var (
Usage: deprecatedUsage,
Hidden: true,
}
deprecatedMedallaTestnet = &cli.BoolFlag{
Name: "medalla",
Usage: deprecatedUsage,
Hidden: true,
}
deprecatedEnableAccountsV2 = &cli.BoolFlag{
Name: "enable-accounts-v2",
Usage: deprecatedUsage,
@ -636,7 +636,6 @@ var deprecatedFlags = []cli.Flag{
deprecatedEnableProtectAttesterFlag,
deprecatedInitSyncVerifyEverythingFlag,
deprecatedSkipRegenHistoricalStates,
deprecatedMedallaTestnet,
deprecatedEnableAccountsV2,
deprecatedCustomGenesisDelay,
deprecatedNewBeaconStateLocks,
@ -657,6 +656,7 @@ var ValidatorFlags = append(deprecatedFlags, []cli.Flag{
waitForSyncedFlag,
AltonaTestnet,
OnyxTestnet,
MedallaTestnet,
SpadinaTestnet,
ZinkenTestnet,
disableAccountsV2,
@ -668,6 +668,7 @@ var SlasherFlags = append(deprecatedFlags, []cli.Flag{
disableLookbackFlag,
AltonaTestnet,
OnyxTestnet,
MedallaTestnet,
SpadinaTestnet,
ZinkenTestnet,
}...)
@ -703,6 +704,7 @@ var BeaconChainFlags = append(deprecatedFlags, []cli.Flag{
disableNewBeaconStateLocks,
AltonaTestnet,
OnyxTestnet,
MedallaTestnet,
SpadinaTestnet,
ZinkenTestnet,
disableBatchBlockVerify,

View File

@ -29,6 +29,7 @@ this command outputs a deposit data string which is required to become a validat
flags.DeprecatedPasswordsDirFlag,
featureconfig.AltonaTestnet,
featureconfig.OnyxTestnet,
featureconfig.MedallaTestnet,
featureconfig.SpadinaTestnet,
featureconfig.ZinkenTestnet,
},
@ -50,6 +51,7 @@ this command outputs a deposit data string which is required to become a validat
flags.DeletePublicKeysFlag,
featureconfig.AltonaTestnet,
featureconfig.OnyxTestnet,
featureconfig.MedallaTestnet,
featureconfig.SpadinaTestnet,
featureconfig.ZinkenTestnet,
},
@ -70,6 +72,7 @@ this command outputs a deposit data string which is required to become a validat
flags.ShowDepositDataFlag,
featureconfig.AltonaTestnet,
featureconfig.OnyxTestnet,
featureconfig.MedallaTestnet,
featureconfig.SpadinaTestnet,
featureconfig.ZinkenTestnet,
flags.DeprecatedPasswordsDirFlag,
@ -96,6 +99,7 @@ this command outputs a deposit data string which is required to become a validat
flags.BackupPasswordFile,
featureconfig.AltonaTestnet,
featureconfig.OnyxTestnet,
featureconfig.MedallaTestnet,
featureconfig.SpadinaTestnet,
featureconfig.ZinkenTestnet,
},
@ -118,6 +122,7 @@ this command outputs a deposit data string which is required to become a validat
flags.ImportPrivateKeyFileFlag,
featureconfig.AltonaTestnet,
featureconfig.OnyxTestnet,
featureconfig.MedallaTestnet,
featureconfig.SpadinaTestnet,
featureconfig.ZinkenTestnet,
flags.DeprecatedPasswordsDirFlag,
@ -146,6 +151,7 @@ this command outputs a deposit data string which is required to become a validat
flags.GrpcRetryDelayFlag,
featureconfig.AltonaTestnet,
featureconfig.OnyxTestnet,
featureconfig.MedallaTestnet,
featureconfig.SpadinaTestnet,
featureconfig.ZinkenTestnet,
},

View File

@ -26,6 +26,7 @@ var WalletCommands = &cli.Command{
flags.WalletPasswordFileFlag,
featureconfig.AltonaTestnet,
featureconfig.OnyxTestnet,
featureconfig.MedallaTestnet,
featureconfig.SpadinaTestnet,
featureconfig.ZinkenTestnet,
flags.DeprecatedPasswordsDirFlag,
@ -49,6 +50,7 @@ var WalletCommands = &cli.Command{
flags.RemoteSignerCACertPathFlag,
featureconfig.AltonaTestnet,
featureconfig.OnyxTestnet,
featureconfig.MedallaTestnet,
featureconfig.SpadinaTestnet,
featureconfig.ZinkenTestnet,
flags.DeprecatedPasswordsDirFlag,
@ -71,6 +73,7 @@ var WalletCommands = &cli.Command{
flags.NumAccountsFlag,
featureconfig.AltonaTestnet,
featureconfig.OnyxTestnet,
featureconfig.MedallaTestnet,
featureconfig.SpadinaTestnet,
featureconfig.ZinkenTestnet,
flags.DeprecatedPasswordsDirFlag,