beacon-chain: Reorganize flags in help text (#14959)

* Beacon flags: Comment on deprecated section

* Beacon flags: Organize flags relevant to logging, comment on logging section

* Beacon flags: Organize flags relevant to p2p, comment on p2p section

* Beacon flags: Introduce db flag section, organize flags relevant to db, comment on db section

* Beacon flags: Introduce builder flag section, organize flags relevant to builder, comment on builder section

* Beacon flags: Introduce sync flag section, organize flags relevant to sync, comment on sync section

* Beacon flags: Introduce execution layer flag section, organize flags relevant to execution layer, comment on execution layer section

* Beacon flags: Introduce monitoring flag section, organize flags relevant to monitoring, comment on monitoring section

* Beacon flags: Organizing remaining flags in cmd and beacon-chain sections

* Beacon flags: Introduce slasher flag section, organize flags relevant to slasher, comment on slasher section

* Move slasher flag from features to the slasher section

* Changelog fragment

* Beacon flags: Reorganize sections

* Move MaxGoroutines to debug section
This commit is contained in:
Preston Van Loon
2025-03-04 10:17:29 -06:00
committed by GitHub
parent d7efccf6a5
commit 0a8f947169
15 changed files with 198 additions and 148 deletions

View File

@@ -213,3 +213,10 @@ func WithSyncChecker(checker Checker) Option {
return nil
}
}
func WithSlasherEnabled(enabled bool) Option {
return func(s *Service) error {
s.slasherEnabled = enabled
return nil
}
}

View File

@@ -16,7 +16,6 @@ import (
"github.com/prysmaticlabs/prysm/v5/beacon-chain/das"
"github.com/prysmaticlabs/prysm/v5/beacon-chain/slasher/types"
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
"github.com/prysmaticlabs/prysm/v5/config/features"
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
@@ -121,7 +120,7 @@ func (s *Service) ReceiveBlock(ctx context.Context, block interfaces.ReadOnlySig
return err
}
// If slasher is configured, forward the attestations in the block via an event feed for processing.
if features.Get().EnableSlasher {
if s.slasherEnabled {
go s.sendBlockAttestationsToSlasher(blockCopy, preState)
}

View File

@@ -62,6 +62,7 @@ type Service struct {
blobNotifiers *blobNotifierMap
blockBeingSynced *currentlySyncingBlock
blobStorage *filesystem.BlobStorage
slasherEnabled bool
}
// config options for the service.

View File

@@ -122,6 +122,7 @@ type BeaconNode struct {
BlobStorageOptions []filesystem.BlobStorageOption
verifyInitWaiter *verification.InitializerWaiter
syncChecker *initialsync.SyncChecker
slasherEnabled bool
}
// New creates a new node instance, sets up configuration options, and registers
@@ -159,6 +160,7 @@ func New(cliCtx *cli.Context, cancel context.CancelFunc, opts ...Option) (*Beaco
serviceFlagOpts: &serviceFlagOpts{},
initialSyncComplete: make(chan struct{}),
syncChecker: &initialsync.SyncChecker{},
slasherEnabled: cliCtx.Bool(flags.SlasherFlag.Name),
}
for _, opt := range opts {
@@ -342,7 +344,7 @@ func registerServices(cliCtx *cli.Context, beacon *BeaconNode, synchronizer *sta
return errors.Wrap(err, "could not register slashing pool service")
}
log.Debugln("Registering Slasher Service")
log.WithField("enabled", beacon.slasherEnabled).Debugln("Registering Slasher Service")
if err := beacon.registerSlasherService(); err != nil {
return errors.Wrap(err, "could not register slasher service")
}
@@ -587,7 +589,7 @@ func (b *BeaconNode) startDB(cliCtx *cli.Context, depositAddress string) error {
}
func (b *BeaconNode) startSlasherDB(cliCtx *cli.Context) error {
if !features.Get().EnableSlasher {
if !b.slasherEnabled {
return nil
}
baseDir := cliCtx.String(cmd.DataDirFlag.Name)
@@ -775,6 +777,7 @@ func (b *BeaconNode) registerBlockchainService(fc forkchoice.ForkChoicer, gs *st
blockchain.WithTrackedValidatorsCache(b.trackedValidatorsCache),
blockchain.WithPayloadIDCache(b.payloadIDCache),
blockchain.WithSyncChecker(b.syncChecker),
blockchain.WithSlasherEnabled(b.slasherEnabled),
)
blockchainService, err := blockchain.NewService(b.ctx, opts...)
@@ -859,6 +862,7 @@ func (b *BeaconNode) registerSyncService(initialSyncComplete chan struct{}, bFil
regularsync.WithBlobStorage(b.BlobStorage),
regularsync.WithVerifierWaiter(b.verifyInitWaiter),
regularsync.WithAvailableBlocker(bFillStore),
regularsync.WithSlasherEnabled(b.slasherEnabled),
)
return b.services.RegisterService(rs)
}
@@ -887,7 +891,7 @@ func (b *BeaconNode) registerInitialSyncService(complete chan struct{}) error {
}
func (b *BeaconNode) registerSlasherService() error {
if !features.Get().EnableSlasher {
if !b.slasherEnabled {
return nil
}
var chainService *blockchain.Service
@@ -934,7 +938,7 @@ func (b *BeaconNode) registerRPCService(router *http.ServeMux) error {
}
var slasherService *slasher.Service
if features.Get().EnableSlasher {
if b.slasherEnabled {
if err := b.services.FetchService(&slasherService); err != nil {
return err
}

View File

@@ -188,3 +188,11 @@ func WithAvailableBlocker(avb coverage.AvailableBlocker) Option {
return nil
}
}
// WithSlasherEnabled configures the sync package to support slashing detection.
func WithSlasherEnabled(enabled bool) Option {
return func(s *Service) error {
s.slasherEnabled = enabled
return nil
}
}

View File

@@ -164,6 +164,7 @@ type Service struct {
newBlobVerifier verification.NewBlobVerifier
availableBlocker coverage.AvailableBlocker
ctxMap ContextByteVersions
slasherEnabled bool
}
// NewService initializes new regular sync service.

View File

@@ -17,7 +17,6 @@ import (
"github.com/prysmaticlabs/prysm/v5/beacon-chain/p2p"
"github.com/prysmaticlabs/prysm/v5/beacon-chain/slasher/types"
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
"github.com/prysmaticlabs/prysm/v5/config/features"
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
"github.com/prysmaticlabs/prysm/v5/monitoring/tracing"
@@ -88,7 +87,7 @@ func (s *Service) validateCommitteeIndexBeaconAttestation(
committeeIndex := att.GetCommitteeIndex()
if !features.Get().EnableSlasher {
if !s.slasherEnabled {
// Verify this the first attestation received for the participating validator for the slot.
if s.hasSeenCommitteeIndicesSlot(data.Slot, committeeIndex, att.GetAggregationBits()) {
return pubsub.ValidationIgnore, nil
@@ -174,7 +173,7 @@ func (s *Service) validateCommitteeIndexBeaconAttestation(
return validationRes, err
}
if features.Get().EnableSlasher {
if s.slasherEnabled {
// Feed the indexed attestation to slasher if enabled. This action
// is done in the background to avoid adding more load to this critical code path.
go func() {

View File

@@ -15,7 +15,6 @@ import (
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/transition"
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
"github.com/prysmaticlabs/prysm/v5/config/features"
"github.com/prysmaticlabs/prysm/v5/config/params"
consensusblocks "github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
@@ -80,7 +79,7 @@ func (s *Service) validateBeaconBlockPubSub(ctx context.Context, pid peer.ID, ms
},
})
if features.Get().EnableSlasher {
if s.slasherEnabled {
// Feed the block header to slasher if enabled. This action
// is done in the background to avoid adding more load to this critical code path.
go func() {

View File

@@ -0,0 +1,2 @@
### Changed
- Reorganized beacon chain flags in `--help` text into logical sections.

View File

@@ -296,6 +296,11 @@ var (
Usage: "Directory for the slasher database",
Value: cmd.DefaultDataDir(),
}
// SlasherFlag defines a flag to enable the beacon chain slasher.
SlasherFlag = &cli.BoolFlag{
Name: "slasher",
Usage: "Enables a slasher in the beacon node for detecting slashable offenses.",
}
// BeaconDBPruning enables the pruning of beacon db.
BeaconDBPruning = &cli.BoolFlag{
Name: "beacon-db-pruning",

View File

@@ -142,6 +142,7 @@ var appFlags = []cli.Flag{
genesis.StatePath,
genesis.BeaconAPIURL,
flags.SlasherDirFlag,
flags.SlasherFlag,
flags.JwtId,
storage.BlobStoragePathFlag,
storage.BlobRetentionEpochFlag,

View File

@@ -45,154 +45,188 @@ type flagGroup struct {
}
var appHelpFlagGroups = []flagGroup{
{
{ // Flags relevant to running the process.
Name: "cmd",
Flags: []cli.Flag{
cmd.MinimalConfigFlag,
cmd.E2EConfigFlag,
cmd.RPCMaxPageSizeFlag,
cmd.NoDiscovery,
cmd.BootstrapNode,
cmd.RelayNode,
cmd.P2PUDPPort,
cmd.P2PQUICPort,
cmd.P2PTCPPort,
cmd.DataDirFlag,
cmd.VerbosityFlag,
cmd.EnableTracingFlag,
cmd.TracingProcessNameFlag,
cmd.TracingEndpointFlag,
cmd.TraceSampleFractionFlag,
cmd.MonitoringHostFlag,
flags.MonitoringPortFlag,
cmd.DisableMonitoringFlag,
cmd.MaxGoroutines,
cmd.ForceClearDB,
cmd.ClearDB,
cmd.ConfigFileFlag,
cmd.ChainConfigFileFlag,
cmd.GrpcMaxCallRecvMsgSizeFlag,
cmd.AcceptTosFlag,
cmd.RestoreSourceFileFlag,
cmd.RestoreTargetDirFlag,
cmd.ValidatorMonitorIndicesFlag,
cmd.ApiTimeoutFlag,
cmd.ConfigFileFlag,
},
},
{
Name: "debug",
Flags: []cli.Flag{
debug.PProfFlag,
debug.PProfAddrFlag,
debug.PProfPortFlag,
debug.MemProfileRateFlag,
debug.CPUProfileFlag,
debug.TraceFlag,
debug.BlockProfileRateFlag,
debug.MutexProfileFractionFlag,
},
},
{
{ // Flags relevant to configuring the beacon chain and APIs.
Name: "beacon-chain",
Flags: []cli.Flag{
flags.InteropMockEth1DataVotesFlag,
flags.DepositContractFlag,
flags.ContractDeploymentBlock,
flags.RPCHost,
flags.RPCPort,
cmd.ApiTimeoutFlag,
cmd.ChainConfigFileFlag,
cmd.E2EConfigFlag,
cmd.GrpcMaxCallRecvMsgSizeFlag,
cmd.MinimalConfigFlag,
cmd.RPCMaxPageSizeFlag,
flags.CertFlag,
flags.KeyFlag,
flags.ChainID,
flags.DisableDebugRPCEndpoints,
flags.HTTPModules,
flags.HTTPServerCorsDomain,
flags.HTTPServerHost,
flags.HTTPServerPort,
flags.HTTPServerCorsDomain,
flags.KeyFlag,
flags.NetworkID,
flags.RPCHost,
flags.RPCPort,
},
},
{
// p2p flags configure the p2p side of beacon-chain.
Name: "p2p",
Flags: []cli.Flag{
cmd.BootstrapNode,
cmd.EnableUPnPFlag,
cmd.NoDiscovery,
cmd.P2PAllowList,
cmd.P2PDenyList,
cmd.P2PHost,
cmd.P2PHostDNS,
cmd.P2PIP,
cmd.P2PMaxPeers,
cmd.P2PMetadata,
cmd.P2PPrivKey,
cmd.P2PQUICPort,
cmd.P2PStaticID,
cmd.P2PTCPPort,
cmd.P2PUDPPort,
cmd.PubsubQueueSize,
cmd.RelayNode,
cmd.StaticPeers,
flags.BlobBatchLimit,
flags.BlobBatchLimitBurstFactor,
flags.BlockBatchLimit,
flags.BlockBatchLimitBurstFactor,
flags.MaxConcurrentDials,
flags.MinPeersPerSubnet,
flags.MinSyncPeers,
flags.SubscribeToAllSubnets,
},
},
{ // Flags relevant to storing data on disk and configuring the beacon chain database.
Name: "db",
Flags: []cli.Flag{
backfill.BackfillBatchSize,
backfill.BackfillOldestSlot,
backfill.BackfillWorkerCount,
backfill.EnableExperimentalBackfill,
cmd.ClearDB,
cmd.DataDirFlag,
cmd.ForceClearDB,
cmd.RestoreSourceFileFlag,
cmd.RestoreTargetDirFlag,
flags.BeaconDBPruning,
flags.PrunerRetentionEpochs,
flags.SlotsPerArchivedPoint,
storage.BlobRetentionEpochFlag,
storage.BlobStorageLayout,
storage.BlobStoragePathFlag,
},
},
{ // Flags relevant to configuring local block production or external builders such as mev-boost.
Name: "builder",
Flags: []cli.Flag{
flags.LocalBlockValueBoost,
flags.MaxBuilderConsecutiveMissedSlots,
flags.MaxBuilderEpochMissedSlots,
flags.MevRelayEndpoint,
flags.MinBuilderBid,
flags.MinBuilderDiff,
flags.SuggestedFeeRecipient,
},
},
{ // Flags relevant to syncing the beacon chain.
Name: "sync",
Flags: []cli.Flag{
checkpoint.BlockPath,
checkpoint.RemoteURL,
checkpoint.StatePath,
flags.WeakSubjectivityCheckpoint,
genesis.BeaconAPIURL,
genesis.StatePath,
},
},
{ // Flags relevant to interacting with the execution layer.
Name: "execution layer",
Flags: []cli.Flag{
flags.ContractDeploymentBlock,
flags.DepositContractFlag,
flags.EngineEndpointTimeoutSeconds,
flags.Eth1HeaderReqLimit,
flags.ExecutionEngineEndpoint,
flags.ExecutionEngineHeaders,
flags.ExecutionJWTSecretFlag,
flags.SetGCPercent,
flags.SlotsPerArchivedPoint,
flags.BlockBatchLimit,
flags.BlockBatchLimitBurstFactor,
flags.BlobBatchLimit,
flags.BlobBatchLimitBurstFactor,
flags.DisableDebugRPCEndpoints,
flags.SubscribeToAllSubnets,
flags.HistoricalSlasherNode,
flags.ChainID,
flags.NetworkID,
flags.WeakSubjectivityCheckpoint,
flags.Eth1HeaderReqLimit,
flags.MinPeersPerSubnet,
flags.MaxConcurrentDials,
flags.MevRelayEndpoint,
flags.MaxBuilderEpochMissedSlots,
flags.MaxBuilderConsecutiveMissedSlots,
flags.EngineEndpointTimeoutSeconds,
flags.SlasherDirFlag,
flags.LocalBlockValueBoost,
flags.MinBuilderBid,
flags.MinBuilderDiff,
flags.JwtId,
flags.BeaconDBPruning,
flags.PrunerRetentionEpochs,
checkpoint.BlockPath,
checkpoint.StatePath,
checkpoint.RemoteURL,
genesis.StatePath,
genesis.BeaconAPIURL,
storage.BlobStoragePathFlag,
storage.BlobRetentionEpochFlag,
storage.BlobStorageLayout,
backfill.EnableExperimentalBackfill,
backfill.BackfillWorkerCount,
backfill.BackfillBatchSize,
backfill.BackfillOldestSlot,
flags.InteropMockEth1DataVotesFlag,
},
},
{ // Flags relevant to configuring beacon chain monitoring.
Name: "monitoring",
Flags: []cli.Flag{
cmd.DisableMonitoringFlag,
cmd.EnableTracingFlag,
cmd.MonitoringHostFlag,
cmd.TraceSampleFractionFlag,
cmd.TracingEndpointFlag,
cmd.TracingProcessNameFlag,
cmd.ValidatorMonitorIndicesFlag,
flags.MonitoringPortFlag,
},
},
{ // Flags relevant to slasher operation.
Name: "slasher",
Flags: []cli.Flag{
flags.HistoricalSlasherNode,
flags.SlasherDirFlag,
flags.SlasherFlag,
},
},
{
// Flags in the "log" section control how Prysm handles logging.
Name: "log",
Flags: []cli.Flag{
cmd.LogFormat,
cmd.LogFileName,
cmd.VerbosityFlag,
},
},
{ // Feature flags.
Name: "features",
Flags: features.ActiveFlags(features.BeaconChainFlags),
},
{ // Flags required to configure the merge.
Name: "merge",
Flags: []cli.Flag{
flags.SuggestedFeeRecipient,
flags.TerminalTotalDifficultyOverride,
flags.TerminalBlockHashOverride,
flags.TerminalBlockHashActivationEpochOverride,
},
},
{
Name: "p2p",
Flags: []cli.Flag{
cmd.P2PIP,
cmd.P2PHost,
cmd.P2PHostDNS,
cmd.P2PMaxPeers,
cmd.P2PPrivKey,
cmd.P2PStaticID,
cmd.P2PMetadata,
cmd.P2PAllowList,
cmd.P2PDenyList,
cmd.PubsubQueueSize,
cmd.StaticPeers,
cmd.EnableUPnPFlag,
flags.MinSyncPeers,
},
},
{
Name: "log",
Flags: []cli.Flag{
cmd.LogFormat,
cmd.LogFileName,
},
},
{
Name: "features",
Flags: features.ActiveFlags(features.BeaconChainFlags),
},
{
{ // The deprecated section represents beacon flags that still have use, but should not be used
// as they are expected to be deleted in a feature release.
Name: "deprecated",
Flags: []cli.Flag{
cmd.BackupWebhookOutputDir,
},
},
{ // Flags used in debugging Prysm. These are flags not usually run by end users.
Name: "debug",
Flags: []cli.Flag{
cmd.MaxGoroutines,
debug.BlockProfileRateFlag,
debug.CPUProfileFlag,
debug.MemProfileRateFlag,
debug.MutexProfileFractionFlag,
debug.PProfAddrFlag,
debug.PProfFlag,
debug.PProfPortFlag,
debug.TraceFlag,
flags.SetGCPercent,
},
},
}
func init() {

View File

@@ -60,7 +60,6 @@ type Flags struct {
// Bug fixes related flags.
AttestTimely bool // AttestTimely fixes #8185. It is gated behind a flag to ensure beacon node's fix can safely roll out first. We'll invert this in v1.1.0.
EnableSlasher bool // Enable slasher in the beacon node runtime.
EnableSlashingProtectionPruning bool // Enable slashing protection pruning for the validator client.
EnableMinimalSlashingProtection bool // Enable minimal slashing protection database for the validator client.
@@ -211,10 +210,6 @@ func ConfigureBeaconChain(ctx *cli.Context) error {
logDisabled(disableBroadcastSlashingFlag)
cfg.DisableBroadcastSlashings = true
}
if ctx.Bool(enableSlasherFlag.Name) {
log.WithField(enableSlasherFlag.Name, enableSlasherFlag.Usage).Warn(enabledFeatureFlag)
cfg.EnableSlasher = true
}
if ctx.Bool(enableHistoricalSpaceRepresentation.Name) {
log.WithField(enableHistoricalSpaceRepresentation.Name, enableHistoricalSpaceRepresentation.Usage).Warn(enabledFeatureFlag)
cfg.EnableHistoricalSpaceRepresentation = true

View File

@@ -12,39 +12,39 @@ import (
func TestInitFeatureConfig(t *testing.T) {
defer Init(&Flags{})
cfg := &Flags{
EnableSlasher: true,
EnableDoppelGanger: true,
}
Init(cfg)
c := Get()
assert.Equal(t, true, c.EnableSlasher)
assert.Equal(t, true, c.EnableDoppelGanger)
}
func TestInitWithReset(t *testing.T) {
defer Init(&Flags{})
Init(&Flags{
EnableSlasher: true,
EnableDoppelGanger: true,
})
assert.Equal(t, true, Get().EnableSlasher)
assert.Equal(t, true, Get().EnableDoppelGanger)
// Overwrite previously set value (value that didn't come by default).
resetCfg := InitWithReset(&Flags{
EnableSlasher: false,
EnableDoppelGanger: false,
})
assert.Equal(t, false, Get().EnableSlasher)
assert.Equal(t, false, Get().EnableDoppelGanger)
// Reset must get to previously set configuration (not to default config values).
resetCfg()
assert.Equal(t, true, Get().EnableSlasher)
assert.Equal(t, true, Get().EnableDoppelGanger)
}
func TestConfigureBeaconConfig(t *testing.T) {
app := cli.App{}
set := flag.NewFlagSet("test", 0)
set.Bool(enableSlasherFlag.Name, true, "test")
set.Bool(saveInvalidBlockTempFlag.Name, true, "test")
context := cli.NewContext(&app, set, nil)
require.NoError(t, ConfigureBeaconChain(context))
c := Get()
assert.Equal(t, true, c.EnableSlasher)
assert.Equal(t, true, c.SaveInvalidBlock)
}
func TestValidateNetworkFlags(t *testing.T) {

View File

@@ -89,10 +89,6 @@ var (
Name: "attest-timely",
Usage: "Fixes validator can attest timely after current block processes. See #8185 for more details.",
}
enableSlasherFlag = &cli.BoolFlag{
Name: "slasher",
Usage: "Enables a slasher in the beacon node for detecting slashable offenses.",
}
enableSlashingProtectionPruning = &cli.BoolFlag{
Name: "enable-slashing-protection-history-pruning",
Usage: "Enables the pruning of the validator client's slashing protection database.",
@@ -217,7 +213,6 @@ var BeaconChainFlags = combinedFlags([]cli.Flag{
Mainnet,
disablePeerScorer,
disableBroadcastSlashingFlag,
enableSlasherFlag,
disableStakinContractCheck,
SaveFullExecutionPayloads,
enableStartupOptimistic,