From fc08d7365689615f9308633d5934df6c91af6404 Mon Sep 17 00:00:00 2001 From: Vitaly Drogan Date: Wed, 30 Oct 2024 16:35:10 +0100 Subject: [PATCH] sender-proxy env vars config --- sender.dockerfile => Dockerfile | 0 Makefile | 4 +- README.md | 42 +++++--------------- cmd/sender-proxy/main.go | 70 +++++++++++++++++++-------------- 4 files changed, 52 insertions(+), 64 deletions(-) rename sender.dockerfile => Dockerfile (100%) diff --git a/sender.dockerfile b/Dockerfile similarity index 100% rename from sender.dockerfile rename to Dockerfile diff --git a/Makefile b/Makefile index 55b3473..82502db 100644 --- a/Makefile +++ b/Makefile @@ -72,11 +72,11 @@ cover-html: ## Run tests with coverage and open the HTML report unlink /tmp/go-sim-lb.cover.tmp .PHONY: docker -docker: ## Build the HTTP server Docker image +docker: DOCKER_BUILDKIT=1 docker build \ --platform linux/amd64 \ --build-arg VERSION=${VERSION} \ - --file sender.dockerfile \ + --file Dockerfile \ --tag tdx-orderflow-proxy-sender-proxy \ . diff --git a/README.md b/README.md index 74e1e2c..b248913 100644 --- a/README.md +++ b/README.md @@ -83,37 +83,15 @@ COMMANDS: help, h Shows a list of commands or help for one command GLOBAL OPTIONS: - --listen-address value address to listen on for requests (default: "127.0.0.1:8080") - --builder-confighub-endpoint value address of the builder config hub enpoint (directly or throught the cvm-proxy) (default: "http://127.0.0.1:14892") - --orderflow-signer-key value ordreflow will be signed with this address (default: "0xfb5ad18432422a84514f71d63b45edf51165d33bef9c2bd60957a48d4c4cb68e") - --max-request-body-size-bytes value Maximum size of the request body, if 0 default will be used (default: 0) - --metrics-addr value address to listen on for Prometheus metrics (metrics are served on $metrics-addr/metrics) (default: "127.0.0.1:8090") - --log-json log in JSON format (default: false) - --log-debug log debug messages (default: false) - --log-uid generate a uuid and add to all log messages (default: false) - --log-service value add 'service' tag to logs (default: "tdx-orderflow-proxy-sender") - --pprof enable pprof debug endpoint (pprof is served on $metrics-addr/debug/pprof/*) (default: false) - --help, -h show help -dvush@ripper> ./build/sender-proxy -h ~/flashbots/orderflow-proxy -NAME: - sender-proxy - Serve API, and metrics - -USAGE: - sender-proxy [global options] command [command options] - -COMMANDS: - help, h Shows a list of commands or help for one command - -GLOBAL OPTIONS: - --listen-address value address to listen on for requests (default: "127.0.0.1:8080") - --builder-confighub-endpoint value address of the builder config hub enpoint (directly or throught the cvm-proxy) (default: "http://127.0.0.1:14892") - --orderflow-signer-key value ordreflow will be signed with this address (default: "0xfb5ad18432422a84514f71d63b45edf51165d33bef9c2bd60957a48d4c4cb68e") - --max-request-body-size-bytes value Maximum size of the request body, if 0 default will be used (default: 0) - --metrics-addr value address to listen on for Prometheus metrics (metrics are served on $metrics-addr/metrics) (default: "127.0.0.1:8090") - --log-json log in JSON format (default: false) - --log-debug log debug messages (default: false) - --log-uid generate a uuid and add to all log messages (default: false) - --log-service value add 'service' tag to logs (default: "tdx-orderflow-proxy-sender") - --pprof enable pprof debug endpoint (pprof is served on $metrics-addr/debug/pprof/*) (default: false) + --listen-address value address to listen on for requests (default: "127.0.0.1:8080") [$LISTEN_ADDRESS] + --builder-confighub-endpoint value address of the builder config hub enpoint (directly or throught the cvm-proxy) (default: "http://127.0.0.1:14892") [$BUILDER_CONFIGHUB_ENDPOINT] + --orderflow-signer-key value ordreflow will be signed with this address (default: "0xfb5ad18432422a84514f71d63b45edf51165d33bef9c2bd60957a48d4c4cb68e") [$ORDERFLOW_SIGNER_KEY] + --max-request-body-size-bytes value Maximum size of the request body, if 0 default will be used (default: 0) [$MAX_REQUEST_BODY_SIZE_BYTES] + --metrics-addr value address to listen on for Prometheus metrics (metrics are served on $metrics-addr/metrics) (default: "127.0.0.1:8090") [$METRICS_ADDR] + --log-json log in JSON format (default: false) [$LOG_JSON] + --log-debug log debug messages (default: false) [$LOG_DEBUG] + --log-uid generate a uuid and add to all log messages (default: false) [$LOG_UID] + --log-service value add 'service' tag to logs (default: "tdx-orderflow-proxy-sender") [$LOG_SERVICE] + --pprof enable pprof debug endpoint (pprof is served on $metrics-addr/debug/pprof/*) (default: false) [$PPROF] --help, -h show help ``` diff --git a/cmd/sender-proxy/main.go b/cmd/sender-proxy/main.go index a4a1bf7..5c03fc8 100644 --- a/cmd/sender-proxy/main.go +++ b/cmd/sender-proxy/main.go @@ -20,56 +20,66 @@ import ( var flags []cli.Flag = []cli.Flag{ // input and output &cli.StringFlag{ - Name: "listen-address", - Value: "127.0.0.1:8080", - Usage: "address to listen on for requests", + Name: "listen-address", + Value: "127.0.0.1:8080", + Usage: "address to listen on for requests", + EnvVars: []string{"LISTEN_ADDRESS"}, }, &cli.StringFlag{ - Name: "builder-confighub-endpoint", - Value: "http://127.0.0.1:14892", - Usage: "address of the builder config hub enpoint (directly or throught the cvm-proxy)", + Name: "builder-confighub-endpoint", + Value: "http://127.0.0.1:14892", + Usage: "address of the builder config hub enpoint (directly or throught the cvm-proxy)", + EnvVars: []string{"BUILDER_CONFIGHUB_ENDPOINT"}, }, &cli.StringFlag{ - Name: "orderflow-signer-key", - Value: "0xfb5ad18432422a84514f71d63b45edf51165d33bef9c2bd60957a48d4c4cb68e", - Usage: "ordreflow will be signed with this address", + Name: "orderflow-signer-key", + Value: "0xfb5ad18432422a84514f71d63b45edf51165d33bef9c2bd60957a48d4c4cb68e", + Usage: "ordreflow will be signed with this address", + EnvVars: []string{"ORDERFLOW_SIGNER_KEY"}, }, &cli.Int64Flag{ - Name: "max-request-body-size-bytes", - Value: 0, - Usage: "Maximum size of the request body, if 0 default will be used", + Name: "max-request-body-size-bytes", + Value: 0, + Usage: "Maximum size of the request body, if 0 default will be used", + EnvVars: []string{"MAX_REQUEST_BODY_SIZE_BYTES"}, }, // logging, metrics and debug &cli.StringFlag{ - Name: "metrics-addr", - Value: "127.0.0.1:8090", - Usage: "address to listen on for Prometheus metrics (metrics are served on $metrics-addr/metrics)", + Name: "metrics-addr", + Value: "127.0.0.1:8090", + Usage: "address to listen on for Prometheus metrics (metrics are served on $metrics-addr/metrics)", + EnvVars: []string{"METRICS_ADDR"}, }, &cli.BoolFlag{ - Name: "log-json", - Value: false, - Usage: "log in JSON format", + Name: "log-json", + Value: false, + Usage: "log in JSON format", + EnvVars: []string{"LOG_JSON"}, }, &cli.BoolFlag{ - Name: "log-debug", - Value: false, - Usage: "log debug messages", + Name: "log-debug", + Value: false, + Usage: "log debug messages", + EnvVars: []string{"LOG_DEBUG"}, }, &cli.BoolFlag{ - Name: "log-uid", - Value: false, - Usage: "generate a uuid and add to all log messages", + Name: "log-uid", + Value: false, + Usage: "generate a uuid and add to all log messages", + EnvVars: []string{"LOG_UID"}, }, &cli.StringFlag{ - Name: "log-service", - Value: "tdx-orderflow-proxy-sender", - Usage: "add 'service' tag to logs", + Name: "log-service", + Value: "tdx-orderflow-proxy-sender", + Usage: "add 'service' tag to logs", + EnvVars: []string{"LOG_SERVICE"}, }, &cli.BoolFlag{ - Name: "pprof", - Value: false, - Usage: "enable pprof debug endpoint (pprof is served on $metrics-addr/debug/pprof/*)", + Name: "pprof", + Value: false, + Usage: "enable pprof debug endpoint (pprof is served on $metrics-addr/debug/pprof/*)", + EnvVars: []string{"PPROF"}, }, }