From b1522ace51daf7dd4e18339553994c153edd1641 Mon Sep 17 00:00:00 2001 From: felipe <130432649+felipe-op@users.noreply.github.com> Date: Mon, 18 Dec 2023 10:58:18 -0800 Subject: [PATCH] feat(proxyd): impl proxyd_healthz method (#8658) --- proxyd/proxyd/backend.go | 5 +++-- proxyd/proxyd/server.go | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/proxyd/proxyd/backend.go b/proxyd/proxyd/backend.go index b558ff8..f00e951 100644 --- a/proxyd/proxyd/backend.go +++ b/proxyd/proxyd/backend.go @@ -17,6 +17,7 @@ import ( "sync" "time" + sw "github.com/ethereum-optimism/optimism/proxyd/pkg/avg-sliding-window" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" @@ -24,8 +25,6 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/xaionaro-go/weightedshuffle" "golang.org/x/sync/semaphore" - - sw "github.com/ethereum-optimism/optimism/proxyd/pkg/avg-sliding-window" ) const ( @@ -285,6 +284,8 @@ type indexedReqRes struct { res *RPCRes } +const proxydHealthzMethod = "proxyd_healthz" + const ConsensusGetReceiptsMethod = "consensus_getReceipts" const ReceiptsTargetDebugGetRawReceipts = "debug_getRawReceipts" diff --git a/proxyd/proxyd/server.go b/proxyd/proxyd/server.go index a53abf2..4c27785 100644 --- a/proxyd/proxyd/server.go +++ b/proxyd/proxyd/server.go @@ -435,6 +435,16 @@ func (s *Server) handleBatchRPC(ctx context.Context, reqs []json.RawMessage, isL continue } + // Simple health check + if len(reqs) == 1 && parsedReq.Method == proxydHealthzMethod { + res := &RPCRes{ + ID: parsedReq.ID, + JSONRPC: JSONRPCVersion, + Result: "OK", + } + return []*RPCRes{res}, false, "", nil + } + if err := ValidateRPCReq(parsedReq); err != nil { RecordRPCError(ctx, BackendProxyd, MethodUnknown, err) responses[i] = NewRPCErrorRes(nil, err)