From 150e8aa14dfe22d4cc3174e02224c17ffa39cba1 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Thu, 6 Apr 2023 15:56:55 -0500 Subject: [PATCH] Remove unused beacon-chain/server binary (#12241) Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> --- beacon-chain/server/BUILD.bazel | 28 ---------- beacon-chain/server/log.go | 5 -- beacon-chain/server/main.go | 96 --------------------------------- 3 files changed, 129 deletions(-) delete mode 100644 beacon-chain/server/BUILD.bazel delete mode 100644 beacon-chain/server/log.go delete mode 100644 beacon-chain/server/main.go diff --git a/beacon-chain/server/BUILD.bazel b/beacon-chain/server/BUILD.bazel deleted file mode 100644 index 70fe1117c..000000000 --- a/beacon-chain/server/BUILD.bazel +++ /dev/null @@ -1,28 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary") -load("@prysm//tools/go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "log.go", - "main.go", - ], - importpath = "github.com/prysmaticlabs/prysm/v4/beacon-chain/server", - visibility = ["//visibility:private"], - deps = [ - "//api/gateway:go_default_library", - "//beacon-chain/gateway:go_default_library", - "//beacon-chain/rpc/apimiddleware:go_default_library", - "//cmd/beacon-chain/flags:go_default_library", - "//runtime/maxprocs:go_default_library", - "@com_github_gorilla_mux//:go_default_library", - "@com_github_joonix_log//:go_default_library", - "@com_github_sirupsen_logrus//:go_default_library", - ], -) - -go_binary( - name = "server", - embed = [":go_default_library"], - visibility = ["//visibility:private"], -) diff --git a/beacon-chain/server/log.go b/beacon-chain/server/log.go deleted file mode 100644 index 4f254e16d..000000000 --- a/beacon-chain/server/log.go +++ /dev/null @@ -1,5 +0,0 @@ -package main - -import "github.com/sirupsen/logrus" - -var log = logrus.New() diff --git a/beacon-chain/server/main.go b/beacon-chain/server/main.go deleted file mode 100644 index cf2b5fec8..000000000 --- a/beacon-chain/server/main.go +++ /dev/null @@ -1,96 +0,0 @@ -// Package main allows for creation of an HTTP-JSON to gRPC -// gateway as a binary go process. -package main - -import ( - "context" - "flag" - "fmt" - "math" - "net/http" - "strings" - - "github.com/gorilla/mux" - joonix "github.com/joonix/log" - "github.com/prysmaticlabs/prysm/v4/api/gateway" - beaconGateway "github.com/prysmaticlabs/prysm/v4/beacon-chain/gateway" - "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/apimiddleware" - "github.com/prysmaticlabs/prysm/v4/cmd/beacon-chain/flags" - _ "github.com/prysmaticlabs/prysm/v4/runtime/maxprocs" - "github.com/sirupsen/logrus" -) - -var ( - beaconRPC = flag.String("beacon-rpc", "localhost:4000", "Beacon chain gRPC endpoint") - port = flag.Int("port", 8000, "Port to serve on") - host = flag.String("host", "127.0.0.1", "Host to serve on") - debug = flag.Bool("debug", false, "Enable debug logging") - allowedOrigins = flag.String("corsdomain", "localhost:4242", "A comma separated list of CORS domains to allow") - enableDebugRPCEndpoints = flag.Bool("enable-debug-rpc-endpoints", false, "Enable debug rpc endpoints such as /eth/v1alpha1/beacon/state") - grpcMaxMsgSize = flag.Int("grpc-max-msg-size", math.MaxInt32, "Integer to define max recieve message call size") - httpModules = flag.String( - "http-modules", - strings.Join([]string{flags.PrysmAPIModule, flags.EthAPIModule}, ","), - "Comma-separated list of API module names. Possible values: `"+flags.PrysmAPIModule+`,`+flags.EthAPIModule+"`.", - ) -) - -func init() { - logrus.SetFormatter(joonix.NewFormatter()) -} - -func main() { - flag.Parse() - if *debug { - log.SetLevel(logrus.DebugLevel) - } - - r := mux.NewRouter() - gatewayConfig := beaconGateway.DefaultConfig(*enableDebugRPCEndpoints, *httpModules) - muxs := make([]*gateway.PbMux, 0) - if gatewayConfig.V1AlphaPbMux != nil { - muxs = append(muxs, gatewayConfig.V1AlphaPbMux) - } - if gatewayConfig.EthPbMux != nil { - muxs = append(muxs, gatewayConfig.EthPbMux) - } - opts := []gateway.Option{ - gateway.WithRouter(r), - gateway.WithPbHandlers(muxs), - gateway.WithMuxHandler(gatewayConfig.Handler), - gateway.WithRemoteAddr(*beaconRPC), - gateway.WithGatewayAddr(fmt.Sprintf("%s:%d", *host, *port)), - gateway.WithAllowedOrigins(strings.Split(*allowedOrigins, ",")), - gateway.WithMaxCallRecvMsgSize(uint64(*grpcMaxMsgSize)), - } - - if flags.EnableHTTPEthAPI(*httpModules) { - opts = append(opts, gateway.WithApiMiddleware(&apimiddleware.BeaconEndpointFactory{})) - } - - gw, err := gateway.New(context.Background(), opts...) - if err != nil { - log.Fatal(err) - } - - r.HandleFunc("/swagger/", gateway.SwaggerServer()) - r.HandleFunc("/healthz", healthzServer(gw)) - - gw.Start() - - select {} -} - -// healthzServer returns a simple health handler which returns ok. -func healthzServer(gw *gateway.Gateway) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "text/plain") - if err := gw.Status(); err != nil { - http.Error(w, err.Error(), http.StatusBadGateway) - return - } - if _, err := fmt.Fprintln(w, "ok"); err != nil { - log.WithError(err).Error("failed to respond to healthz") - } - } -}