Fix Custom Delay Flag (#5026)

* fix flag
* Merge refs/heads/master into fixFlag
* Merge refs/heads/master into fixFlag
* Merge refs/heads/master into fixFlag
* Merge refs/heads/master into fixFlag
* Merge refs/heads/master into fixFlag
* fix config
* Merge branch 'fixFlag' of https://github.com/prysmaticlabs/geth-sharding into fixFlag
This commit is contained in:
Nishant Das 2020-03-07 11:52:40 +08:00 committed by GitHub
parent d1fea430d6
commit 345ec1bf8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 30 deletions

View File

@ -5,11 +5,6 @@ import (
)
var (
// NoCustomConfigFlag determines whether to launch a beacon chain using real parameters or demo parameters.
NoCustomConfigFlag = cli.BoolFlag{
Name: "no-custom-config",
Usage: "Run the beacon chain with the real parameters from phase 0.",
}
// HTTPWeb3ProviderFlag provides an HTTP access endpoint to an ETH 1.0 RPC.
HTTPWeb3ProviderFlag = cli.StringFlag{
Name: "http-web3provider",

View File

@ -24,7 +24,6 @@ import (
)
var appFlags = []cli.Flag{
flags.NoCustomConfigFlag,
flags.DepositContractFlag,
flags.Web3ProviderFlag,
flags.HTTPWeb3ProviderFlag,

View File

@ -83,25 +83,11 @@ func NewBeaconNode(ctx *cli.Context) (*BeaconNode, error) {
); err != nil {
return nil, err
}
featureconfig.ConfigureBeaconChain(ctx)
flags.ConfigureGlobalFlags(ctx)
registry := shared.NewServiceRegistry()
// Use custom config values if the --no-custom-config flag is not set.
if !ctx.GlobalBool(flags.NoCustomConfigFlag.Name) {
if featureconfig.Get().MinimalConfig {
log.WithField(
"config", "minimal-spec",
).Info("Using custom chain parameters")
params.UseMinimalConfig()
} else {
log.WithField(
"config", "demo",
).Info("Using custom chain parameters")
params.UseDemoBeaconConfig()
}
}
beacon := &BeaconNode{
ctx: ctx,
services: registry,

View File

@ -76,7 +76,6 @@ var appHelpFlagGroups = []flagGroup{
{
Name: "beacon-chain",
Flags: []cli.Flag{
flags.NoCustomConfigFlag,
flags.InteropMockEth1DataVotesFlag,
flags.InteropGenesisStateFlag,
flags.DepositContractFlag,

View File

@ -28,6 +28,7 @@ var log = logrus.WithField("prefix", "flags")
// Flags is a struct to represent which features the client will perform on runtime.
type Flags struct {
NoCustomConfig bool // NoCustomConfigFlag determines whether to launch a beacon chain using real parameters or demo parameters.
CustomGenesisDelay uint64 // CustomGenesisDelay signals how long of a delay to set to start the chain.
MinimalConfig bool // MinimalConfig as defined in the spec.
WriteSSZStateTransitions bool // WriteSSZStateTransitions to tmp directory.
@ -80,15 +81,13 @@ func Init(c *Flags) {
func ConfigureBeaconChain(ctx *cli.Context) {
complainOnDeprecatedFlags(ctx)
cfg := &Flags{}
delay := ctx.GlobalUint64(customGenesisDelayFlag.Name)
if delay != params.BeaconConfig().MinGenesisDelay {
cfg = configureConfig(ctx, cfg)
delay := params.BeaconConfig().MinGenesisDelay
if ctx.GlobalIsSet(customGenesisDelayFlag.Name) {
delay = ctx.GlobalUint64(customGenesisDelayFlag.Name)
log.Warnf("Starting ETH2 with genesis delay of %d seconds", delay)
}
cfg.CustomGenesisDelay = delay
if ctx.GlobalBool(minimalConfigFlag.Name) {
log.Warn("Using minimal config")
cfg.MinimalConfig = true
}
if ctx.GlobalBool(writeSSZStateTransitionsFlag.Name) {
log.Warn("Writing SSZ states and blocks after state transitions")
cfg.WriteSSZStateTransitions = true
@ -197,3 +196,29 @@ func complainOnDeprecatedFlags(ctx *cli.Context) {
}
}
}
func configureConfig(ctx *cli.Context, cfg *Flags) *Flags {
if ctx.GlobalBool(noCustomConfigFlag.Name) {
log.Warn("Using default mainnet config")
cfg.NoCustomConfig = true
}
if ctx.GlobalBool(minimalConfigFlag.Name) {
log.Warn("Using minimal config")
cfg.MinimalConfig = true
}
// Use custom config values if the --no-custom-config flag is not set.
if !cfg.NoCustomConfig {
if cfg.MinimalConfig {
log.WithField(
"config", "minimal-spec",
).Info("Using custom chain parameters")
params.UseMinimalConfig()
} else {
log.WithField(
"config", "demo",
).Info("Using custom chain parameters")
params.UseDemoBeaconConfig()
}
}
return cfg
}

View File

@ -1,11 +1,14 @@
package featureconfig
import (
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/urfave/cli"
)
var (
noCustomConfigFlag = cli.BoolFlag{
Name: "no-custom-config",
Usage: "Run the beacon chain with the real parameters from phase 0.",
}
minimalConfigFlag = cli.BoolFlag{
Name: "minimal-config",
Usage: "Use minimal config with parameters as defined in the spec.",
@ -63,7 +66,6 @@ var (
Name: "custom-genesis-delay",
Usage: "Start the genesis event with the configured genesis delay in seconds. " +
"This flag should be used for local development and testing only.",
Value: params.BeaconConfig().MinGenesisDelay,
}
cacheFilteredBlockTreeFlag = cli.BoolFlag{
Name: "cache-filtered-block-tree",
@ -270,6 +272,7 @@ var E2EValidatorFlags = []string{
// BeaconChainFlags contains a list of all the feature flags that apply to the beacon-chain client.
var BeaconChainFlags = append(deprecatedFlags, []cli.Flag{
noCustomConfigFlag,
customGenesisDelayFlag,
minimalConfigFlag,
writeSSZStateTransitionsFlag,