Skip to content

Commit

Permalink
Feature flag to disable head update on attestation basis (prysmaticla…
Browse files Browse the repository at this point in the history
  • Loading branch information
terencechain authored and cryptomental committed Feb 28, 2020
1 parent 57c8bc6 commit 6dd2f7d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
9 changes: 6 additions & 3 deletions beacon-chain/blockchain/process_attestation.go
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/beacon-chain/flags"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/featureconfig"
"go.opencensus.io/trace"
)

Expand Down Expand Up @@ -128,9 +129,11 @@ func (s *Service) onAttestation(ctx context.Context, a *ethpb.Attestation) ([]ui
// Update forkchoice store with the new attestation for updating weight.
s.forkChoiceStore.ProcessAttestation(ctx, indexedAtt.AttestingIndices, bytesutil.ToBytes32(a.Data.BeaconBlockRoot), a.Data.Target.Epoch)

// Update fork choice head after updating weight.
if err := s.updateHead(ctx, baseState.Balances()); err != nil {
return nil, err
if !featureconfig.Get().DisableUpdateHeadPerAttestation {
// Update fork choice head after updating weight.
if err := s.updateHead(ctx, baseState.Balances()); err != nil {
return nil, err
}
}

return indexedAtt.AttestingIndices, nil
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/sync/rpc_goodbye.go
Expand Up @@ -27,7 +27,7 @@ func (r *Service) goodbyeRPCHandler(ctx context.Context, msg interface{}, stream
defer cancel()
setRPCStreamDeadlines(stream)

m, ok:= msg.(uint64)
m, ok := msg.(uint64)
if !ok {
return fmt.Errorf("wrong message type for goodbye, got %T, wanted uint64", msg)
}
Expand Down
5 changes: 5 additions & 0 deletions shared/featureconfig/config.go
Expand Up @@ -42,6 +42,7 @@ type Flags struct {
ProtectAttester bool // ProtectAttester prevents the validator client from signing any attestations that would be considered a slashable offense.
ForkchoiceAggregateAttestations bool // ForkchoiceAggregateAttestations attempts to aggregate attestations before processing in fork choice.
DisableStrictAttestationPubsubVerification bool // DisableStrictAttestationPubsubVerification will disabling strict signature verification in pubsub.
DisableUpdateHeadPerAttestation bool // DisableUpdateHeadPerAttestation will disabling update head on per attestation basis.

// DisableForkChoice disables using LMD-GHOST fork choice to update
// the head of the chain based on attestations and instead accepts any valid received block
Expand Down Expand Up @@ -148,6 +149,10 @@ func ConfigureBeaconChain(ctx *cli.Context) {
log.Warn("Disabled strict attestation signature verification in pubsub")
cfg.DisableStrictAttestationPubsubVerification = true
}
if ctx.GlobalBool(disableUpdateHeadPerAttestation.Name) {
log.Warn("Disabled update head on per attestation basis")
cfg.DisableUpdateHeadPerAttestation = true
}

Init(cfg)
}
Expand Down
5 changes: 5 additions & 0 deletions shared/featureconfig/flags.go
Expand Up @@ -98,6 +98,10 @@ var (
Name: "disable-strict-attestation-pubsub-verification",
Usage: "Disable strict signature verification of attestations in pubsub. See PR 4782 for details.",
}
disableUpdateHeadPerAttestation = cli.BoolFlag{
Name: "disable-update-head-attestation",
Usage: "Disable update fork choice head on per attestation. See PR 4802 for details.",
}
)

// Deprecated flags list.
Expand Down Expand Up @@ -249,6 +253,7 @@ var BeaconChainFlags = append(deprecatedFlags, []cli.Flag{
cacheFilteredBlockTreeFlag,
forkchoiceAggregateAttestations,
disableStrictAttestationPubsubVerificationFlag,
disableUpdateHeadPerAttestation,
}...)

// E2EBeaconChainFlags contains a list of the beacon chain feature flags to be tested in E2E.
Expand Down

0 comments on commit 6dd2f7d

Please sign in to comment.