diff --git a/op-ufm/op-ufm/example.config.toml b/op-ufm/op-ufm/example.config.toml index 9a88341..418910d 100644 --- a/op-ufm/op-ufm/example.config.toml +++ b/op-ufm/op-ufm/example.config.toml @@ -16,7 +16,7 @@ enabled = true # Host for the healthz endpoint to listen on host = "0.0.0.0" # Port for the above. -port = 8080 +port = "8080" [metrics] # Whether or not to enable Prometheus metrics @@ -24,7 +24,7 @@ enabled = true # Host for the Prometheus metrics endpoint to listen on. host = "0.0.0.0" # Port for the above. -port = 9761 +port = "9761" [wallets.default] # OP Stack Chain ID diff --git a/op-ufm/op-ufm/pkg/config/config.go b/op-ufm/op-ufm/pkg/config/config.go index 3b8bb86..39c96ce 100644 --- a/op-ufm/op-ufm/pkg/config/config.go +++ b/op-ufm/op-ufm/pkg/config/config.go @@ -29,13 +29,13 @@ type MetricsConfig struct { Enabled bool `toml:"enabled"` Debug bool `toml:"debug"` Host string `toml:"host"` - Port int `toml:"port"` + Port string `toml:"port"` } type HealthzConfig struct { Enabled bool `toml:"enabled"` Host string `toml:"host"` - Port int `toml:"port"` + Port string `toml:"port"` } type WalletConfig struct { @@ -80,12 +80,12 @@ func New(file string) (*Config, error) { func (c *Config) Validate() error { if c.Metrics.Enabled { - if c.Metrics.Host == "" || c.Metrics.Port == 0 { + if c.Metrics.Host == "" || c.Metrics.Port == "" { return errors.New("metrics is enabled but host or port are missing") } } if c.Healthz.Enabled { - if c.Healthz.Host == "" || c.Healthz.Port == 0 { + if c.Healthz.Host == "" || c.Healthz.Port == "" { return errors.New("healthz is enabled but host or port are missing") } } diff --git a/op-ufm/op-ufm/pkg/metrics/clients/eth.go b/op-ufm/op-ufm/pkg/metrics/clients/eth.go index 791b2d9..8b2f89e 100644 --- a/op-ufm/op-ufm/pkg/metrics/clients/eth.go +++ b/op-ufm/op-ufm/pkg/metrics/clients/eth.go @@ -5,6 +5,7 @@ import ( "time" "github.com/ethereum-optimism/optimism/op-ufm/pkg/metrics" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" @@ -32,7 +33,9 @@ func Dial(providerName string, url string) (*InstrumentedEthClient, error) { func (i *InstrumentedEthClient) TransactionByHash(ctx context.Context, hash common.Hash) (*types.Transaction, bool, error) { start := time.Now() + log.Debug(">> TransactionByHash", "hash", hash, "provider", i.providerName) tx, isPending, err := i.c.TransactionByHash(ctx, hash) + log.Debug("<< TransactionByHash", "tx", tx, "isPending", isPending, "err", err, "hash", hash, "provider", i.providerName) if err != nil { if !i.ignorableErrors(err) { metrics.RecordError(i.providerName, "ethclient.TransactionByHash") diff --git a/op-ufm/op-ufm/pkg/service/healthz_server.go b/op-ufm/op-ufm/pkg/service/healthz_server.go index 9bfd2ed..aed2425 100644 --- a/op-ufm/op-ufm/pkg/service/healthz_server.go +++ b/op-ufm/op-ufm/pkg/service/healthz_server.go @@ -2,7 +2,6 @@ package service import ( "context" - "fmt" "net/http" "github.com/gorilla/mux" @@ -14,10 +13,9 @@ type HealthzServer struct { server *http.Server } -func (h *HealthzServer) Start(ctx context.Context, host string, port int) error { +func (h *HealthzServer) Start(ctx context.Context, addr string) error { hdlr := mux.NewRouter() hdlr.HandleFunc("/healthz", h.Handle).Methods("GET") - addr := fmt.Sprintf("%s:%d", host, port) c := cors.New(cors.Options{ AllowedOrigins: []string{"*"}, }) diff --git a/op-ufm/op-ufm/pkg/service/service.go b/op-ufm/op-ufm/pkg/service/service.go index aa746f7..04b4f6d 100644 --- a/op-ufm/op-ufm/pkg/service/service.go +++ b/op-ufm/op-ufm/pkg/service/service.go @@ -2,7 +2,7 @@ package service import ( "context" - "fmt" + "net" "github.com/ethereum-optimism/optimism/op-ufm/pkg/config" "github.com/ethereum-optimism/optimism/op-ufm/pkg/metrics" @@ -31,10 +31,10 @@ func New(cfg *config.Config) *Service { func (s *Service) Start(ctx context.Context) { log.Info("service starting") if s.Config.Healthz.Enabled { - addr := fmt.Sprintf("%s:%d", s.Config.Healthz.Host, s.Config.Healthz.Port) + addr := net.JoinHostPort(s.Config.Healthz.Host, s.Config.Healthz.Port) log.Info("starting healthz server", "addr", addr) go func() { - if err := s.Healthz.Start(ctx, s.Config.Healthz.Host, s.Config.Healthz.Port); err != nil { + if err := s.Healthz.Start(ctx, addr); err != nil { log.Error("error starting healthz server", "err", err) } }() @@ -42,7 +42,7 @@ func (s *Service) Start(ctx context.Context) { metrics.Debug = s.Config.Metrics.Debug if s.Config.Metrics.Enabled { - addr := fmt.Sprintf("%s:%d", s.Config.Metrics.Host, s.Config.Metrics.Port) + addr := net.JoinHostPort(s.Config.Metrics.Host, s.Config.Metrics.Port) log.Info("starting metrics server", "addr", addr) go func() { if err := s.Metrics.Start(ctx, addr); err != nil {