Skip to content

Commit

Permalink
chore: Update logging to use layr-labs/eigensdk-go (#264)
Browse files Browse the repository at this point in the history
* chore: Update logging to use eigengo-sdk

* chore: Update logging to use eigengo-sdk - fmt

* chore: Update logging to use eigengo-sdk - incorporate latest eigenda changes, deprecate flags, and update docs / code comments

* chore: Update logging to use eigengo-sdk - fix test

* chore: Update logging to use eigengo-sdk - svc_binding -> edsm_binding

* chore: Update logging to use eigengo-sdk - move logging to own packag e and copy entire dependency package vs hyrbid

* chore: Update logging to use eigengo-sdk - rm todo in metrics && fix lint errs

* chore: Update logging to use eigengo-sdk - refactor flag construction patterns across subpackages to adhere to uniform abstraction

* chore: Update logging to use eigengo-sdk - refactor flag construction patterns across subpackages to adhere to uniform abstraction

* chore: Update logging to use eigengo-sdk - update metric

* chore: Update logging to use eigengo-sdk - go gfmt

* chore: Update logging to use eigengo-sdk - apppease white space linting

* chore: Update logging to use eigengo-sdk - white space lint

* chore: Update logging to use eigengo-sdk - white space lint
  • Loading branch information
ethenotethan authored Feb 2, 2025
1 parent cbf53e1 commit 1477835
Show file tree
Hide file tree
Showing 24 changed files with 411 additions and 154 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,9 @@ To quickly set up monitoring dashboard, add eigenda-proxy metrics endpoint to a
| `--eigenda.signer-private-key-hex` | | `$EIGENDA_PROXY_EIGENDA_SIGNER_PRIVATE_KEY_HEX` | Hex-encoded signer private key. This key should not be associated with an Ethereum address holding any funds. |
| `--eigenda.status-query-retry-interval` | `5s` | `$EIGENDA_PROXY_EIGENDA_STATUS_QUERY_INTERVAL` | Interval between retries when awaiting network blob finalization. Default is 5 seconds. |
| `--eigenda.status-query-timeout` | `30m0s` | `$EIGENDA_PROXY_EIGENDA_STATUS_QUERY_TIMEOUT` | Duration to wait for a blob to finalize after being sent for dispersal. Default is 30 minutes. |
| `--log.color` | `false` | `$EIGENDA_PROXY_LOG_COLOR` | Color the log output if in terminal mode. |
| `--log.format` | `text` | `$EIGENDA_PROXY_LOG_FORMAT` | Format the log output. Supported formats: 'text', 'terminal', 'logfmt', 'json', 'json-pretty'. |
| `--log.level` | `INFO` | `$EIGENDA_PROXY_LOG_LEVEL` | The lowest log level that will be output. |
| `--log.pid` | `false` | `$EIGENDA_PROXY_LOG_PID` | Show pid in the log. |
| `--log.format` | `text` | `$EIGENDA_PROXY_LOG_FORMAT` | The format of the log file. Accepted options are 'json' and 'text' (default: "json") |
| `--log.level` | `INFO` | `$EIGENDA_PROXY_LOG_LEVEL` | The lowest log level that will be output. The lowest log level that will be output. Accepted options are "debug", "info", "warn" "error" |
| `log.path` | `""` | `$EIGENDA_PROXY_LOG_PATH` | Path to file where logs will be written |
| `--memstore.enabled` | `false` | `$EIGENDA_PROXY_MEMSTORE_ENABLED` | Whether to use mem-store for DA logic. |
| `--memstore.expiration` | `25m0s` | `$EIGENDA_PROXY_MEMSTORE_EXPIRATION` | Duration that a mem-store blob/commitment pair are allowed to live. |
| `--memstore.put-latency` | `0` | `$EIGENDA_PROXY_MEMSTORE_PUT_LATENCY` | Artificial latency added for memstore backend to mimic EigenDA's dispersal latency. |
Expand Down
21 changes: 15 additions & 6 deletions cmd/server/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,35 @@ import (
"encoding/json"
"fmt"

proxy_logging "github.com/Layr-Labs/eigenda-proxy/logging"
"github.com/Layr-Labs/eigensdk-go/logging"

"github.com/Layr-Labs/eigenda-proxy/flags"
"github.com/Layr-Labs/eigenda-proxy/metrics"
"github.com/Layr-Labs/eigenda-proxy/server"
"github.com/ethereum/go-ethereum/log"
"github.com/urfave/cli/v2"

"github.com/ethereum-optimism/optimism/op-service/ctxinterrupt"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
)

func StartProxySvr(cliCtx *cli.Context) error {
log := oplog.NewLogger(oplog.AppOut(cliCtx), oplog.ReadCLIConfig(cliCtx)).New("role", "eigenda_proxy")
oplog.SetGlobalLogHandler(log.Handler())
logCfg, err := proxy_logging.ReadLoggerCLIConfig(cliCtx)
if err != nil {
return err
}

log, err := proxy_logging.NewLogger(*logCfg)
if err != nil {
return err
}

log.Info("Starting EigenDA Proxy Server", "version", Version, "date", Date, "commit", Commit)

cfg := server.ReadCLIConfig(cliCtx)
if err := cfg.Check(); err != nil {
return err
}
err := prettyPrintConfig(cliCtx, log)
err = prettyPrintConfig(cliCtx, log)
if err != nil {
return fmt.Errorf("failed to pretty print config: %w", err)
}
Expand Down Expand Up @@ -73,7 +82,7 @@ func StartProxySvr(cliCtx *cli.Context) error {
}

// TODO: we should probably just change EdaClientConfig struct definition in eigenda-client
func prettyPrintConfig(cliCtx *cli.Context, log log.Logger) error {
func prettyPrintConfig(cliCtx *cli.Context, log logging.Logger) error {
// we read a new config which we modify to hide private info in order to log the rest
cfg := server.ReadCLIConfig(cliCtx)
if cfg.EigenDAConfig.EdaClientConfig.SignerPrivateKeyHex != "" {
Expand Down
6 changes: 6 additions & 0 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import (
"strings"
)

const GlobalPrefix = "EIGENDA_PROXY"

func PrefixEnvVar(prefix, suffix string) []string {
return []string{prefix + "_" + suffix}
}

// Helper utility functions //

func ContainsDuplicates[P comparable](s []P) bool {
Expand Down
14 changes: 4 additions & 10 deletions e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ import (
"github.com/Layr-Labs/eigenda-proxy/verify"
"github.com/Layr-Labs/eigenda/api/clients"
"github.com/Layr-Labs/eigenda/encoding/kzg"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/ethereum/go-ethereum/log"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
"golang.org/x/exp/rand"

oplog "github.com/ethereum-optimism/optimism/op-service/log"
opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"

miniotc "github.com/testcontainers/testcontainers-go/modules/minio"
redistc "github.com/testcontainers/testcontainers-go/modules/redis"
)
Expand Down Expand Up @@ -243,7 +241,7 @@ func TestSuiteConfig(testCfg *Cfg) server.CLIConfig {
default:
cfg = server.CLIConfig{
EigenDAConfig: eigendaCfg,
MetricsCfg: opmetrics.CLIConfig{},
MetricsCfg: metrics.CLIConfig{},
}
}

Expand All @@ -252,17 +250,13 @@ func TestSuiteConfig(testCfg *Cfg) server.CLIConfig {

type TestSuite struct {
Ctx context.Context
Log log.Logger
Log logging.Logger
Server *server.Server
Metrics *metrics.EmulatedMetricer
}

func CreateTestSuite(testSuiteCfg server.CLIConfig) (TestSuite, func()) {
log := oplog.NewLogger(os.Stdout, oplog.CLIConfig{
Level: log.LevelDebug,
Format: oplog.FormatLogFmt,
Color: true,
}).New("role", svcName)
log := logging.NewTextSLogger(os.Stdout, &logging.SLoggerOptions{})

m := metrics.NewEmulatedMetricer()
ctx := context.Background()
Expand Down
41 changes: 19 additions & 22 deletions flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@ package flags

import (
"github.com/Layr-Labs/eigenda-proxy/flags/eigendaflags"
"github.com/Layr-Labs/eigenda-proxy/logging"
"github.com/Layr-Labs/eigenda-proxy/metrics"
"github.com/Layr-Labs/eigenda-proxy/store"
"github.com/Layr-Labs/eigenda-proxy/store/generated_key/memstore"
"github.com/Layr-Labs/eigenda-proxy/store/precomputed_key/redis"
"github.com/Layr-Labs/eigenda-proxy/store/precomputed_key/s3"
"github.com/Layr-Labs/eigenda-proxy/verify"

"github.com/urfave/cli/v2"

opservice "github.com/ethereum-optimism/optimism/op-service"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
"github.com/Layr-Labs/eigenda-proxy/common"
)

const (
EigenDAClientCategory = "EigenDA Client"
LoggingFlagsCategory = "Logging"
MetricsFlagCategory = "Metrics"
EigenDADeprecatedCategory = "DEPRECATED EIGENDA CLIENT FLAGS -- THESE WILL BE REMOVED IN V2.0.0"
MemstoreFlagsCategory = "Memstore (for testing purposes - replaces EigenDA backend)"
StorageFlagsCategory = "Storage"
Expand All @@ -31,26 +34,20 @@ const (
PortFlagName = "port"
)

const EnvVarPrefix = "EIGENDA_PROXY"

func prefixEnvVars(name string) []string {
return opservice.PrefixEnvVar(EnvVarPrefix, name)
}

func CLIFlags() []cli.Flag {
// TODO: Decompose all flags into constituent parts based on their respective category / usage
flags := []cli.Flag{
&cli.StringFlag{
Name: ListenAddrFlagName,
Usage: "Server listening address",
Value: "0.0.0.0",
EnvVars: prefixEnvVars("ADDR"),
EnvVars: common.PrefixEnvVar(common.GlobalPrefix, "ADDR"),
},
&cli.IntFlag{
Name: PortFlagName,
Usage: "Server listening port",
Value: 3100,
EnvVars: prefixEnvVars("PORT"),
EnvVars: common.PrefixEnvVar(common.GlobalPrefix, "PORT"),
},
}

Expand All @@ -62,15 +59,15 @@ var Flags = []cli.Flag{}

func init() {
Flags = CLIFlags()
Flags = append(Flags, oplog.CLIFlags(EnvVarPrefix)...)
Flags = append(Flags, opmetrics.CLIFlags(EnvVarPrefix)...)
Flags = append(Flags, eigendaflags.CLIFlags(EnvVarPrefix, EigenDAClientCategory)...)
Flags = append(Flags, eigendaflags.DeprecatedCLIFlags(EnvVarPrefix, EigenDADeprecatedCategory)...)
Flags = append(Flags, store.CLIFlags(EnvVarPrefix, StorageFlagsCategory)...)
Flags = append(Flags, store.DeprecatedCLIFlags(EnvVarPrefix, StorageDeprecatedCategory)...)
Flags = append(Flags, redis.CLIFlags(EnvVarPrefix, RedisCategory)...)
Flags = append(Flags, s3.CLIFlags(EnvVarPrefix, S3Category)...)
Flags = append(Flags, memstore.CLIFlags(EnvVarPrefix, MemstoreFlagsCategory)...)
Flags = append(Flags, verify.CLIFlags(EnvVarPrefix, VerifierCategory)...)
Flags = append(Flags, verify.DeprecatedCLIFlags(EnvVarPrefix, VerifierDeprecatedCategory)...)
Flags = append(Flags, logging.CLIFlags(common.GlobalPrefix, LoggingFlagsCategory)...)
Flags = append(Flags, metrics.CLIFlags(common.GlobalPrefix, MetricsFlagCategory)...)
Flags = append(Flags, eigendaflags.CLIFlags(common.GlobalPrefix, EigenDAClientCategory)...)
Flags = append(Flags, eigendaflags.DeprecatedCLIFlags(common.GlobalPrefix, EigenDADeprecatedCategory)...)
Flags = append(Flags, store.CLIFlags(common.GlobalPrefix, StorageFlagsCategory)...)
Flags = append(Flags, store.DeprecatedCLIFlags(common.GlobalPrefix, StorageDeprecatedCategory)...)
Flags = append(Flags, redis.CLIFlags(common.GlobalPrefix, RedisCategory)...)
Flags = append(Flags, s3.CLIFlags(common.GlobalPrefix, S3Category)...)
Flags = append(Flags, memstore.CLIFlags(common.GlobalPrefix, MemstoreFlagsCategory)...)
Flags = append(Flags, verify.CLIFlags(common.GlobalPrefix, VerifierCategory)...)
Flags = append(Flags, verify.DeprecatedCLIFlags(common.GlobalPrefix, VerifierDeprecatedCategory)...)
}
20 changes: 12 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ go 1.22.0
toolchain go1.22.7

require (
github.com/Layr-Labs/eigenda v0.8.5-rc.0.0.20241101212705-fa8776ae648c
github.com/Layr-Labs/eigenda v0.8.6-rc.0.0.20250130173836-0d293cc03198
github.com/Layr-Labs/eigenda-proxy/client v0.0.0-00010101000000-000000000000
github.com/Layr-Labs/eigensdk-go v0.2.0-beta.1.0.20250118004418-2a25f31b3b28
github.com/avast/retry-go/v4 v4.6.0
github.com/consensys/gnark-crypto v0.12.1
github.com/ethereum-optimism/optimism v1.9.5
Expand All @@ -21,6 +22,7 @@ require (
github.com/testcontainers/testcontainers-go/modules/minio v0.33.0
github.com/testcontainers/testcontainers-go/modules/redis v0.33.0
github.com/urfave/cli/v2 v2.27.5
github.com/wealdtech/go-merkletree/v2 v2.6.0
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c
google.golang.org/grpc v1.64.1
)
Expand All @@ -33,7 +35,8 @@ require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/DataDog/zstd v1.5.6-0.20230824185856-869dae002e5e // indirect
github.com/Layr-Labs/eigensdk-go v0.1.7-0.20240507215523-7e4891d5099a // indirect
github.com/Layr-Labs/cerberus-api v0.0.2-0.20250117193600-e69c5e8b08fd // indirect
github.com/Layr-Labs/eigensdk-go/signer v0.0.0-20250118004418-2a25f31b3b28 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/VictoriaMetrics/fastcache v1.12.2 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
Expand Down Expand Up @@ -63,7 +66,7 @@ require (
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
Expand Down Expand Up @@ -129,6 +132,7 @@ require (
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/graph-gophers/graphql-go v1.3.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-bexpr v0.1.11 // indirect
github.com/hashicorp/go-hclog v1.6.2 // indirect
Expand All @@ -148,6 +152,7 @@ require (
github.com/influxdata/influxdb-client-go/v2 v2.4.0 // indirect
github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c // indirect
github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 // indirect
github.com/ingonyama-zk/icicle/v3 v3.4.0 // indirect
github.com/ipfs/go-cid v0.4.1 // indirect
github.com/ipfs/go-datastore v0.6.0 // indirect
github.com/ipfs/go-log/v2 v2.5.1 // indirect
Expand Down Expand Up @@ -213,7 +218,6 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 // indirect
github.com/pingcap/errors v0.11.4 // indirect
github.com/pion/datachannel v1.5.8 // indirect
github.com/pion/dtls/v2 v2.2.12 // indirect
github.com/pion/ice/v2 v2.3.34 // indirect
Expand Down Expand Up @@ -242,14 +246,13 @@ require (
github.com/quic-go/webtransport-go v0.8.0 // indirect
github.com/raulk/go-watchdog v1.3.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/cors v1.11.0 // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/status-im/keycard-go v0.2.0 // indirect
Expand All @@ -261,7 +264,6 @@ require (
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/urfave/cli v1.22.14 // indirect
github.com/wealdtech/go-merkletree/v2 v2.6.0 // indirect
github.com/wlynxg/anet v0.0.4 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
Expand All @@ -271,6 +273,7 @@ require (
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.uber.org/automaxprocs v1.5.2 // indirect
go.uber.org/dig v1.18.0 // indirect
go.uber.org/fx v1.22.2 // indirect
go.uber.org/mock v0.4.0 // indirect
Expand All @@ -285,7 +288,8 @@ require (
golang.org/x/text v0.19.0 // indirect
golang.org/x/time v0.7.0 // indirect
golang.org/x/tools v0.26.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading

0 comments on commit 1477835

Please sign in to comment.