mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 20:07:17 +00:00
Disable some block checks without state mgmt (#5498)
* Revert "Add WaitForSynced to beacon node for validator startup (#5366)"
This reverts commit 1224e75ba1
.
* Disable various checks in block validator sync without new state mgmt
* Revert "Revert "Add WaitForSynced to beacon node for validator startup (#5366)""
This reverts commit 927d8d9e06ab700e10c5848eb46def6b40f1ecfa.
* Invert
This commit is contained in:
parent
1224e75ba1
commit
0078f42554
@ -10,6 +10,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
||||
"github.com/prysmaticlabs/prysm/shared/traceutil"
|
||||
"go.opencensus.io/trace"
|
||||
)
|
||||
@ -89,36 +90,38 @@ func (r *Service) validateBeaconBlockPubSub(ctx context.Context, pid peer.ID, ms
|
||||
return false
|
||||
}
|
||||
|
||||
hasStateSummaryDB := r.db.HasStateSummary(ctx, bytesutil.ToBytes32(blk.Block.ParentRoot))
|
||||
hasStateSummaryCache := r.stateSummaryCache.Has(bytesutil.ToBytes32(blk.Block.ParentRoot))
|
||||
if !hasStateSummaryDB && !hasStateSummaryCache {
|
||||
log.WithError(err).WithField("blockSlot", blk.Block.Slot).Warn("No access to parent state")
|
||||
return false
|
||||
}
|
||||
parentState, err := r.stateGen.StateByRoot(ctx, bytesutil.ToBytes32(blk.Block.ParentRoot))
|
||||
if err != nil {
|
||||
log.WithError(err).WithField("blockSlot", blk.Block.Slot).Warn("Could not get parent state")
|
||||
return false
|
||||
}
|
||||
if !featureconfig.Get().DisableNewStateMgmt {
|
||||
hasStateSummaryDB := r.db.HasStateSummary(ctx, bytesutil.ToBytes32(blk.Block.ParentRoot))
|
||||
hasStateSummaryCache := r.stateSummaryCache.Has(bytesutil.ToBytes32(blk.Block.ParentRoot))
|
||||
if !hasStateSummaryDB && !hasStateSummaryCache {
|
||||
log.WithError(err).WithField("blockSlot", blk.Block.Slot).Warn("No access to parent state")
|
||||
return false
|
||||
}
|
||||
parentState, err := r.stateGen.StateByRoot(ctx, bytesutil.ToBytes32(blk.Block.ParentRoot))
|
||||
if err != nil {
|
||||
log.WithError(err).WithField("blockSlot", blk.Block.Slot).Warn("Could not get parent state")
|
||||
return false
|
||||
}
|
||||
|
||||
if err := blocks.VerifyBlockHeaderSignature(parentState, blk); err != nil {
|
||||
log.WithError(err).WithField("blockSlot", blk.Block.Slot).Warn("Could not verify block signature")
|
||||
return false
|
||||
}
|
||||
if err := blocks.VerifyBlockHeaderSignature(parentState, blk); err != nil {
|
||||
log.WithError(err).WithField("blockSlot", blk.Block.Slot).Warn("Could not verify block signature")
|
||||
return false
|
||||
}
|
||||
|
||||
err = parentState.SetSlot(blk.Block.Slot)
|
||||
if err != nil {
|
||||
log.WithError(err).WithField("blockSlot", blk.Block.Slot).Warn("Could not set parent state slot")
|
||||
return false
|
||||
}
|
||||
idx, err := helpers.BeaconProposerIndex(parentState)
|
||||
if err != nil {
|
||||
log.WithError(err).WithField("blockSlot", blk.Block.Slot).Warn("Could not get proposer index using parent state")
|
||||
return false
|
||||
}
|
||||
if blk.Block.ProposerIndex != idx {
|
||||
log.WithError(err).WithField("blockSlot", blk.Block.Slot).Warn("Incorrect proposer index")
|
||||
return false
|
||||
err = parentState.SetSlot(blk.Block.Slot)
|
||||
if err != nil {
|
||||
log.WithError(err).WithField("blockSlot", blk.Block.Slot).Warn("Could not set parent state slot")
|
||||
return false
|
||||
}
|
||||
idx, err := helpers.BeaconProposerIndex(parentState)
|
||||
if err != nil {
|
||||
log.WithError(err).WithField("blockSlot", blk.Block.Slot).Warn("Could not get proposer index using parent state")
|
||||
return false
|
||||
}
|
||||
if blk.Block.ProposerIndex != idx {
|
||||
log.WithError(err).WithField("blockSlot", blk.Block.Slot).Warn("Incorrect proposer index")
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
msg.ValidatorData = blk // Used in downstream subscriber
|
||||
|
Loading…
Reference in New Issue
Block a user