prysm-pulse/beacon-chain/flags/config.go

71 lines
1.9 KiB
Go
Raw Normal View History

package flags
import (
"github.com/prysmaticlabs/prysm/shared/cmd"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
// GlobalFlags specifies all the global flags for the
// beacon node.
type GlobalFlags struct {
EnableArchive bool
EnableArchivedValidatorSetChanges bool
EnableArchivedBlocks bool
EnableArchivedAttestations bool
MinimumSyncPeers int
MaxPageSize int
Fix Stuck Beacon Node (#4454) * Revert "Revert #4392 (#4449)" This reverts commit 67c380b197536a3cf2309c200897ba5d2d8b1ddd. * bound start req * Merge refs/heads/master into revert-4449-revert-4392 * fix test * Merge branch 'revert-4449-revert-4392' of https://github.com/prysmaticlabs/geth-sharding into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * add flag for deployment block * Merge branch 'revert-4449-revert-4392' of https://github.com/prysmaticlabs/geth-sharding into revert-4449-revert-4392 * use constant and comments * lint * skip test for now * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Update shared/params/config.go Co-Authored-By: terence tsao <terence@prysmaticlabs.com> * Update beacon-chain/powchain/testing/mock.go Co-Authored-By: terence tsao <terence@prysmaticlabs.com> * preston's review * Merge branch 'revert-4449-revert-4392' of https://github.com/prysmaticlabs/geth-sharding into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * add flag * Merge branch 'revert-4449-revert-4392' of https://github.com/prysmaticlabs/geth-sharding into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * use stateutils * Merge branch 'revert-4449-revert-4392' of https://github.com/prysmaticlabs/geth-sharding into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392
2020-01-16 01:46:15 +00:00
DeploymentBlock int
UnsafeSync bool
}
var globalConfig *GlobalFlags
// Get retrieves the global config.
func Get() *GlobalFlags {
if globalConfig == nil {
return &GlobalFlags{}
}
return globalConfig
}
// Init sets the global config equal to the config that is passed in.
func Init(c *GlobalFlags) {
globalConfig = c
}
// ConfigureGlobalFlags initializes the global config.
// based on the provided cli context.
func ConfigureGlobalFlags(ctx *cli.Context) {
cfg := &GlobalFlags{}
if ctx.GlobalBool(ArchiveEnableFlag.Name) {
cfg.EnableArchive = true
}
if ctx.GlobalBool(ArchiveValidatorSetChangesFlag.Name) {
cfg.EnableArchivedValidatorSetChanges = true
}
if ctx.GlobalBool(ArchiveBlocksFlag.Name) {
cfg.EnableArchivedBlocks = true
}
if ctx.GlobalBool(ArchiveAttestationsFlag.Name) {
cfg.EnableArchivedAttestations = true
}
if ctx.GlobalBool(UnsafeSync.Name) {
cfg.UnsafeSync = true
}
cfg.MaxPageSize = ctx.GlobalInt(RPCMaxPageSize.Name)
Fix Stuck Beacon Node (#4454) * Revert "Revert #4392 (#4449)" This reverts commit 67c380b197536a3cf2309c200897ba5d2d8b1ddd. * bound start req * Merge refs/heads/master into revert-4449-revert-4392 * fix test * Merge branch 'revert-4449-revert-4392' of https://github.com/prysmaticlabs/geth-sharding into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * add flag for deployment block * Merge branch 'revert-4449-revert-4392' of https://github.com/prysmaticlabs/geth-sharding into revert-4449-revert-4392 * use constant and comments * lint * skip test for now * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Update shared/params/config.go Co-Authored-By: terence tsao <terence@prysmaticlabs.com> * Update beacon-chain/powchain/testing/mock.go Co-Authored-By: terence tsao <terence@prysmaticlabs.com> * preston's review * Merge branch 'revert-4449-revert-4392' of https://github.com/prysmaticlabs/geth-sharding into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * add flag * Merge branch 'revert-4449-revert-4392' of https://github.com/prysmaticlabs/geth-sharding into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * use stateutils * Merge branch 'revert-4449-revert-4392' of https://github.com/prysmaticlabs/geth-sharding into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392 * Merge refs/heads/master into revert-4449-revert-4392
2020-01-16 01:46:15 +00:00
cfg.DeploymentBlock = ctx.GlobalInt(ContractDeploymentBlock.Name)
configureMinimumPeers(ctx, cfg)
Init(cfg)
}
func configureMinimumPeers(ctx *cli.Context, cfg *GlobalFlags) {
cfg.MinimumSyncPeers = ctx.GlobalInt(MinSyncPeers.Name)
maxPeers := int(ctx.GlobalInt64(cmd.P2PMaxPeers.Name))
if cfg.MinimumSyncPeers > maxPeers {
log.Warnf("Changing Minimum Sync Peers to %d", maxPeers)
cfg.MinimumSyncPeers = maxPeers
}
}