Skip to content

Commit e179462

Browse files
authored
new receiver flag: builder-ready-endpoint (#54)
1 parent 5e83b7e commit e179462

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

cmd/receiver-proxy/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ var flags = []cli.Flag{
4646
Usage: "address to send local ordeflow to",
4747
EnvVars: []string{"BUILDER_ENDPOINT"},
4848
},
49+
&cli.StringFlag{
50+
Name: "builder-ready-endpoint",
51+
Value: "http://127.0.0.1:6070",
52+
Usage: "address to send /readyz to",
53+
EnvVars: []string{"BUILDER_READY_ENDPOINT"},
54+
},
4955
&cli.StringFlag{
5056
Name: "rpc-endpoint",
5157
Value: "http://127.0.0.1:8545",
@@ -201,6 +207,7 @@ func runMain(cCtx *cli.Context) error {
201207

202208
builderEndpoint := cCtx.String("builder-endpoint")
203209
rpcEndpoint := cCtx.String("rpc-endpoint")
210+
builderReadyEndpoint := cCtx.String("builder-ready-endpoint")
204211

205212
builderConfigHubEndpoint := cCtx.String("builder-confighub-endpoint")
206213
archiveEndpoint := cCtx.String("orderflow-archive-endpoint")
@@ -220,6 +227,7 @@ func runMain(cCtx *cli.Context) error {
220227
BuilderConfigHubEndpoint: builderConfigHubEndpoint,
221228
ArchiveEndpoint: archiveEndpoint,
222229
ArchiveConnections: connectionsPerPeer,
230+
BuilderReadyEndpoint: builderReadyEndpoint,
223231
EthRPC: rpcEndpoint,
224232
MaxRequestBodySizeBytes: maxRequestBodySizeBytes,
225233
ConnectionsPerPeer: connectionsPerPeer,

proxy/receiver_api.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,27 @@ func (prx *ReceiverProxy) UserJSONRPCHandler(maxRequestBodySizeBytes int64) (*rp
8080

8181
// readyHandler calls /readyz on rbuilder
8282
func (prx *ReceiverProxy) readyHandler(w http.ResponseWriter, r *http.Request) error {
83-
resp, err := http.Get(prx.LocalBuilderEndpoint + "/readyz")
83+
if prx.builderReadyEndpoint == "" {
84+
w.WriteHeader(http.StatusOK)
85+
_, _ = w.Write([]byte("ready"))
86+
return nil
87+
}
88+
89+
resp, err := http.Get(prx.builderReadyEndpoint + "/readyz")
8490
if err != nil {
8591
prx.Log.Warn("Failed to check builder readiness", slog.Any("error", err))
8692
http.Error(w, "not ready", http.StatusServiceUnavailable)
8793
return nil
8894
}
8995
defer resp.Body.Close()
90-
9196
if resp.StatusCode != http.StatusOK {
9297
http.Error(w, "not ready", http.StatusServiceUnavailable)
9398
return nil
9499
}
95100

96101
// If the builder is ready, return 200 OK
97102
w.WriteHeader(http.StatusOK)
98-
_, _ = w.Write([]byte("ready"))
103+
_, _ = w.Write([]byte("OK"))
99104
return nil
100105
}
101106

proxy/receiver_proxy.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ type ReceiverProxy struct {
6060
userAPIRateLimiter *rate.Limiter
6161

6262
localBuilderSender LocalBuilderSender
63+
64+
builderReadyEndpoint string
6365
}
6466

6567
type ReceiverProxyConstantConfig struct {
@@ -76,6 +78,7 @@ type ReceiverProxyConfig struct {
7678
BuilderConfigHubEndpoint string
7779
ArchiveEndpoint string
7880
ArchiveConnections int
81+
BuilderReadyEndpoint string
7982

8083
// EthRPC should support eth_blockNumber API
8184
EthRPC string
@@ -110,6 +113,7 @@ func NewReceiverProxy(config ReceiverProxyConfig) (*ReceiverProxy, error) {
110113
replacementNonceRLU: expirable.NewLRU[replacementNonceKey, int](replacementNonceSize, nil, replacementNonceTTL),
111114
userAPIRateLimiter: userAPIRateLimiter,
112115
localBuilderSender: localBuilderSender,
116+
builderReadyEndpoint: config.BuilderReadyEndpoint,
113117
}
114118
maxRequestBodySizeBytes := DefaultMaxRequestBodySizeBytes
115119
if config.MaxRequestBodySizeBytes != 0 {

0 commit comments

Comments
 (0)