Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve Miscellaneous Bugs in Beacon Node #4743

Merged
merged 3 commits into from Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 0 additions & 20 deletions beacon-chain/blockchain/metrics.go
Expand Up @@ -18,10 +18,6 @@ var (
Name: "beacon_head_slot",
Help: "Slot of the head block of the beacon chain",
})
competingAtts = promauto.NewCounter(prometheus.CounterOpts{
Name: "competing_attestations",
Help: "The # of attestations received and processed from a competing chain",
})
competingBlks = promauto.NewCounter(prometheus.CounterOpts{
Name: "competing_blocks",
Help: "The # of blocks received and processed from a competing chain",
Expand All @@ -42,10 +38,6 @@ var (
Name: "processed_no_pubsub_attestation_counter",
Help: "The # of processed attestation without pubsub, this usually means the attestations from sync",
})
processedAtt = promauto.NewCounter(prometheus.CounterOpts{
Name: "processed_attestation_counter",
Help: "The # of processed attestation with pubsub and fork choice, this ususally means attestations from rpc",
})
headFinalizedEpoch = promauto.NewGauge(prometheus.GaugeOpts{
Name: "chain_service_head_finalized_epoch",
Help: "Last finalized epoch of the head state",
Expand All @@ -62,14 +54,6 @@ var (
Name: "chain_service_beacon_finalized_root",
Help: "Last finalized root of the processed state",
})
cacheFinalizedEpoch = promauto.NewGauge(prometheus.GaugeOpts{
Name: "chain_service_cache_finalized_epoch",
Help: "Last cached finalized epoch",
})
cacheFinalizedRoot = promauto.NewGauge(prometheus.GaugeOpts{
Name: "chain_service_cache_finalized_root",
Help: "Last cached finalized root",
})
beaconCurrentJustifiedEpoch = promauto.NewGauge(prometheus.GaugeOpts{
Name: "chain_service_beacon_current_justified_epoch",
Help: "Current justified epoch of the processed state",
Expand All @@ -86,10 +70,6 @@ var (
Name: "chain_service_beacon_previous_justified_root",
Help: "Previous justified root of the processed state",
})
sigFailsToVerify = promauto.NewCounter(prometheus.CounterOpts{
Name: "chain_service_att_signature_failed_to_verify_with_cache",
Help: "Number of attestation signatures that failed to verify with cache on, but succeeded without cache",
})
validatorsCount = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "chain_service_validator_count",
Help: "The total number of validators",
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/blockchain/receive_attestation.go
Expand Up @@ -117,7 +117,7 @@ func (s *Service) processAttestation() {
"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")
}).WithError(err).Warn("Could not receive attestation in chain service")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/powchain/service.go
Expand Up @@ -591,7 +591,7 @@ func (s *Service) run(done <-chan struct{}) {
log.Debug("Context closed, exiting goroutine")
return
case s.runError = <-headSub.Err():
log.WithError(s.runError).Error("Subscription to new head notifier failed")
log.WithError(s.runError).Warn("Subscription to new head notifier failed")
s.connectedETH1 = false
s.waitForConnection()
headSub, err = s.reader.SubscribeNewHead(s.ctx, s.headerChan)
Expand Down
3 changes: 3 additions & 0 deletions beacon-chain/rpc/beacon/blocks.go
Expand Up @@ -206,6 +206,9 @@ func (bs *Server) StreamChainHead(_ *ptypes.Empty, stream ethpb.BeaconChain_Stre
// Retrieve chain head information from the DB and the current beacon state.
func (bs *Server) chainHeadRetrieval(ctx context.Context) (*ethpb.ChainHead, error) {
headBlock := bs.HeadFetcher.HeadBlock()
if headBlock == nil {
return nil, status.Error(codes.Internal, "Head block of chain was nil")
}
headBlockRoot, err := ssz.HashTreeRoot(headBlock.Block)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get head block root: %v", err)
Expand Down
14 changes: 14 additions & 0 deletions beacon-chain/rpc/beacon/blocks_test.go
Expand Up @@ -346,6 +346,20 @@ func TestServer_GetChainHead_NoFinalizedBlock(t *testing.T) {
}
}

func TestServer_GetChainHead_NoHeadBlock(t *testing.T) {
bs := &Server{
HeadFetcher: &mock.ChainService{Block: nil},
}
if _, err := bs.GetChainHead(context.Background(), nil); err != nil && !strings.Contains(
err.Error(),
"Head block of chain was nil",
) {
t.Fatal("Did not get wanted error")
} else if err == nil {
t.Error("Expected error, received nil")
}
}

func TestServer_GetChainHead(t *testing.T) {
db := dbTest.SetupDB(t)
defer dbTest.TeardownDB(t, db)
Expand Down
8 changes: 4 additions & 4 deletions beacon-chain/sync/rpc.go
Expand Up @@ -81,28 +81,28 @@ func (r *Service) registerRPC(topic string, base interface{}, handle rpcHandler)
if t.Kind() == reflect.Ptr {
msg := reflect.New(t.Elem())
if err := r.p2p.Encoding().DecodeWithLength(stream, msg.Interface()); err != nil {
log.WithError(err).Error("Failed to decode stream message")
log.WithError(err).Warn("Failed to decode stream message")
traceutil.AnnotateError(span, err)
return
}
if err := handle(ctx, msg.Interface(), stream); err != nil {
messageFailedProcessingCounter.WithLabelValues(topic).Inc()
if err != errWrongForkVersion {
log.WithError(err).Error("Failed to handle p2p RPC")
log.WithError(err).Warn("Failed to handle p2p RPC")
}
traceutil.AnnotateError(span, err)
}
} else {
msg := reflect.New(t)
if err := r.p2p.Encoding().DecodeWithLength(stream, msg.Interface()); err != nil {
log.WithError(err).Error("Failed to decode stream message")
log.WithError(err).Warn("Failed to decode stream message")
traceutil.AnnotateError(span, err)
return
}
if err := handle(ctx, msg.Elem().Interface(), stream); err != nil {
messageFailedProcessingCounter.WithLabelValues(topic).Inc()
if err != errWrongForkVersion {
log.WithError(err).Error("Failed to handle p2p RPC")
log.WithError(err).Warn("Failed to handle p2p RPC")
}
traceutil.AnnotateError(span, err)
}
Expand Down
1 change: 0 additions & 1 deletion tools/bootnode/bootnode.go
Expand Up @@ -132,7 +132,6 @@ func startKademliaDHT(privKey crypto.PrivKey) {
}

fmt.Printf("Running Kademlia DHT bootnode: /ip4/%s/tcp/%d/p2p/%s\n", *externalIP, *kademliaPort, host.ID().Pretty())

}

func createListener(ipAddr string, port int, cfg discover.Config) *discover.UDPv5 {
Expand Down