Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cmd/receiver-proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ var flags = []cli.Flag{
Usage: "address to send local ordeflow to",
EnvVars: []string{"BUILDER_ENDPOINT"},
},
&cli.StringFlag{
Name: "builder-ready-endpoint",
Value: "http://127.0.0.1:6070",
Usage: "address to send /readyz to",
EnvVars: []string{"BUILDER_READY_ENDPOINT"},
},
&cli.StringFlag{
Name: "rpc-endpoint",
Value: "http://127.0.0.1:8545",
Expand Down Expand Up @@ -201,6 +207,7 @@ func runMain(cCtx *cli.Context) error {

builderEndpoint := cCtx.String("builder-endpoint")
rpcEndpoint := cCtx.String("rpc-endpoint")
builderReadyEndpoint := cCtx.String("builder-ready-endpoint")

builderConfigHubEndpoint := cCtx.String("builder-confighub-endpoint")
archiveEndpoint := cCtx.String("orderflow-archive-endpoint")
Expand All @@ -220,6 +227,7 @@ func runMain(cCtx *cli.Context) error {
BuilderConfigHubEndpoint: builderConfigHubEndpoint,
ArchiveEndpoint: archiveEndpoint,
ArchiveConnections: connectionsPerPeer,
BuilderReadyEndpoint: builderReadyEndpoint,
EthRPC: rpcEndpoint,
MaxRequestBodySizeBytes: maxRequestBodySizeBytes,
ConnectionsPerPeer: connectionsPerPeer,
Expand Down
11 changes: 8 additions & 3 deletions proxy/receiver_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,27 @@ func (prx *ReceiverProxy) UserJSONRPCHandler(maxRequestBodySizeBytes int64) (*rp

// readyHandler calls /readyz on rbuilder
func (prx *ReceiverProxy) readyHandler(w http.ResponseWriter, r *http.Request) error {
resp, err := http.Get(prx.LocalBuilderEndpoint + "/readyz")
if prx.builderReadyEndpoint == "" {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("ready"))
return nil
}

resp, err := http.Get(prx.builderReadyEndpoint + "/readyz")
if err != nil {
prx.Log.Warn("Failed to check builder readiness", slog.Any("error", err))
http.Error(w, "not ready", http.StatusServiceUnavailable)
return nil
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
http.Error(w, "not ready", http.StatusServiceUnavailable)
return nil
}

// If the builder is ready, return 200 OK
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("ready"))
_, _ = w.Write([]byte("OK"))
return nil
}

Expand Down
4 changes: 4 additions & 0 deletions proxy/receiver_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ type ReceiverProxy struct {
userAPIRateLimiter *rate.Limiter

localBuilderSender LocalBuilderSender

builderReadyEndpoint string
}

type ReceiverProxyConstantConfig struct {
Expand All @@ -76,6 +78,7 @@ type ReceiverProxyConfig struct {
BuilderConfigHubEndpoint string
ArchiveEndpoint string
ArchiveConnections int
BuilderReadyEndpoint string

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