Skip to content

Commit

Permalink
Fix pre state of target block does not exist error (prysmaticlabs#4740
Browse files Browse the repository at this point in the history
)

* Save state even w/ initial sync cache state flag

* Tested

Co-authored-by: Nishant Das <nish1993@hotmail.com>
  • Loading branch information
2 people authored and cryptomental committed Feb 28, 2020
1 parent 9e2af68 commit 9843e98
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions beacon-chain/blockchain/process_block.go
Expand Up @@ -241,6 +241,14 @@ func (s *Service) onBlockInitialSyncStateTransition(ctx context.Context, signed
if err := helpers.UpdateProposerIndicesInCache(postState, helpers.CurrentEpoch(postState)); err != nil {
return nil, err
}

if featureconfig.Get().InitSyncCacheState {
if helpers.IsEpochStart(postState.Slot()) {
if err := s.beaconDB.SaveState(ctx, postState, root); err != nil {
return nil, errors.Wrap(err, "could not save state")
}
}
}
}

return postState, nil
Expand Down
8 changes: 4 additions & 4 deletions beacon-chain/blockchain/receive_attestation.go
Expand Up @@ -112,10 +112,10 @@ func (s *Service) processAttestation() {

if err := s.ReceiveAttestationNoPubsub(ctx, a); err != nil {
log.WithFields(logrus.Fields{
"slot": a.Data.Slot,
"committeeIndex": a.Data.CommitteeIndex,
"beaconBlockRoot": fmt.Sprintf("%#x", bytesutil.Trunc(a.Data.BeaconBlockRoot)),
"targetRoot": fmt.Sprintf("%#x", bytesutil.Trunc(a.Data.Target.Root)),
"slot": a.Data.Slot,
"committeeIndex": a.Data.CommitteeIndex,
"beaconBlockRoot": fmt.Sprintf("%#x", bytesutil.Trunc(a.Data.BeaconBlockRoot)),
"targetRoot": fmt.Sprintf("%#x", bytesutil.Trunc(a.Data.Target.Root)),
"aggregationCount": a.AggregationBits.Count(),
}).WithError(err).Error("Could not receive attestation in chain service")
}
Expand Down

0 comments on commit 9843e98

Please sign in to comment.