From dc0f2140b3193bafea0fdf181c10b2b3b3650ebf Mon Sep 17 00:00:00 2001 From: terence tsao Date: Thu, 6 Aug 2020 10:13:09 -0700 Subject: [PATCH] Rpc service: log error if slasher is not up (#6907) Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> --- beacon-chain/rpc/BUILD.bazel | 1 + beacon-chain/rpc/service.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/beacon-chain/rpc/BUILD.bazel b/beacon-chain/rpc/BUILD.bazel index 826a98179..864995b32 100644 --- a/beacon-chain/rpc/BUILD.bazel +++ b/beacon-chain/rpc/BUILD.bazel @@ -39,6 +39,7 @@ go_library( "@com_github_sirupsen_logrus//:go_default_library", "@io_opencensus_go//plugin/ocgrpc:go_default_library", "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//connectivity:go_default_library", "@org_golang_google_grpc//credentials:go_default_library", "@org_golang_google_grpc//peer:go_default_library", "@org_golang_google_grpc//reflection:go_default_library", diff --git a/beacon-chain/rpc/service.go b/beacon-chain/rpc/service.go index b6cebbc69..e578fbe76 100644 --- a/beacon-chain/rpc/service.go +++ b/beacon-chain/rpc/service.go @@ -40,6 +40,7 @@ import ( "github.com/sirupsen/logrus" "go.opencensus.io/plugin/ocgrpc" "google.golang.org/grpc" + "google.golang.org/grpc/connectivity" "google.golang.org/grpc/credentials" "google.golang.org/grpc/peer" "google.golang.org/grpc/reflection" @@ -341,6 +342,11 @@ func (s *Service) startSlasherClient() { log.Errorf("Could not dial endpoint: %s, %v", s.slasherProvider, err) return } + if conn.GetState() != connectivity.Ready { + log.Errorf("Slasher status is %s, please verify slasher is up", conn.GetState()) + return + } + log.Info("Successfully started hash slinging slasher©️ gRPC connection") s.slasherConn = conn s.slasherClient = slashpb.NewSlasherClient(s.slasherConn)