prysm-pulse/beacon-chain/sync/subscriber_beacon_blocks.go
Raul Jordan d9c0e65cef
Improve Beacon Node Logging UX (#3600)
* info logs beacon node improvements

* prom test fixes

* info logging changes

* wrapped up node info logging

* changed to debug level

* warn logs taken care of

* Terence suggestion

* warn spacing

* better logging in initial sync

* debug level standardized

* complete debug standardization

* participation at epoch end

* fix archive tests

* even more test fixes

* prom test

* ops test

* powtest

* rpc sync test

* rem part

* log formatting
2019-10-01 15:05:17 -05:00

46 lines
1.3 KiB
Go

package sync
import (
"context"
"github.com/gogo/protobuf/proto"
"github.com/prysmaticlabs/go-ssz"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/beacon-chain/core/state/interop"
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
)
func (r *RegularSync) beaconBlockSubscriber(ctx context.Context, msg proto.Message) error {
block := msg.(*ethpb.BeaconBlock)
headState := r.chain.HeadState()
// Ignore block older than last finalized checkpoint.
if block.Slot < helpers.StartSlot(headState.FinalizedCheckpoint.Epoch) {
log.Debugf("Received a block older than finalized checkpoint, %d < %d",
block.Slot, helpers.StartSlot(headState.FinalizedCheckpoint.Epoch))
return nil
}
blockRoot, err := ssz.SigningRoot(block)
if err != nil {
log.Errorf("Could not sign root block: %v", err)
return nil
}
// Handle block when the parent is unknown
if !r.db.HasBlock(ctx, bytesutil.ToBytes32(block.ParentRoot)) {
r.pendingQueueLock.Lock()
r.slotToPendingBlocks[block.Slot] = block
r.seenPendingBlocks[blockRoot] = true
r.pendingQueueLock.Unlock()
return nil
}
err = r.chain.ReceiveBlockNoPubsub(ctx, block)
if err != nil {
interop.WriteBlockToDisk(block, true /*failed*/)
}
return err
}