From b9ba03b863f5eeaba93a36c0e89e83493d1c04ec Mon Sep 17 00:00:00 2001 From: Javed Khan Date: Sun, 20 Oct 2024 14:10:34 -0700 Subject: [PATCH] fix(daserver): rm unused flag; fmt --- Makefile | 6 ++++++ celestia_storage.go | 10 +++++----- cmd/daserver/entrypoint.go | 2 +- cmd/daserver/flags.go | 31 +++++++++++-------------------- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index 087bebc..fe8159a 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,12 @@ LDFLAGS := -ldflags "$(LDFLAGSSTRING)" da-server: env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -v $(LDFLAGS) -o ./bin/da-server ./cmd/daserver +lint: + golangci-lint run + +fmt: + golangci-lint run --fix + clean: rm bin/da-server diff --git a/celestia_storage.go b/celestia_storage.go index 290ab44..3327513 100644 --- a/celestia_storage.go +++ b/celestia_storage.go @@ -23,8 +23,8 @@ type CelestiaConfig struct { type CelestiaStore struct { Log log.Logger GetTimeout time.Duration - Namespace []byte - Client *client.Client + Namespace []byte + Client *client.Client } // NewCelestiaStore returns a celestia store. @@ -37,15 +37,15 @@ func NewCelestiaStore(cfg CelestiaConfig) *CelestiaStore { } return &CelestiaStore{ Log: Log, - Client: client, + Client: client, GetTimeout: time.Minute, - Namespace: cfg.Namespace, + Namespace: cfg.Namespace, } } func (d *CelestiaStore) Get(ctx context.Context, key []byte) ([]byte, error) { log.Info("celestia: blob request", "id", hex.EncodeToString(key)) - ctx, cancel := context.WithTimeout(context.Background(), d.GetTimeout) + ctx, cancel := context.WithTimeout(ctx, d.GetTimeout) blobs, err := d.Client.DA.Get(ctx, [][]byte{key[2:]}, d.Namespace) cancel() if err != nil || len(blobs) == 0 { diff --git a/cmd/daserver/entrypoint.go b/cmd/daserver/entrypoint.go index 6c2a1ef..416520a 100644 --- a/cmd/daserver/entrypoint.go +++ b/cmd/daserver/entrypoint.go @@ -5,9 +5,9 @@ import ( "github.com/urfave/cli/v2" + celestia "github.com/celestiaorg/op-plasma-celestia" oplog "github.com/ethereum-optimism/optimism/op-service/log" "github.com/ethereum-optimism/optimism/op-service/opio" - celestia "github.com/celestiaorg/op-plasma-celestia" ) type Server interface { diff --git a/cmd/daserver/flags.go b/cmd/daserver/flags.go index 7657a80..16bf7ff 100644 --- a/cmd/daserver/flags.go +++ b/cmd/daserver/flags.go @@ -7,18 +7,17 @@ import ( "github.com/urfave/cli/v2" + celestia "github.com/celestiaorg/op-plasma-celestia" opservice "github.com/ethereum-optimism/optimism/op-service" oplog "github.com/ethereum-optimism/optimism/op-service/log" - celestia "github.com/celestiaorg/op-plasma-celestia" ) const ( ListenAddrFlagName = "addr" PortFlagName = "port" - GenericCommFlagName = "generic-commitment" - CelestiaServerFlagName = "celestia.server" - CelestiaAuthTokenFlagName = "celestia.auth-token" - CelestiaNamespaceFlagName = "celestia.namespace" + CelestiaServerFlagName = "celestia.server" + CelestiaAuthTokenFlagName = "celestia.auth-token" + CelestiaNamespaceFlagName = "celestia.namespace" ) const EnvVarPrefix = "OP_PLASMA_DA_SERVER" @@ -40,16 +39,10 @@ var ( Value: 3100, EnvVars: prefixEnvVars("PORT"), } - GenericCommFlag = &cli.BoolFlag{ - Name: GenericCommFlagName, - Usage: "enable generic commitments for testing. Not for production use.", - EnvVars: prefixEnvVars("GENERIC_COMMITMENT"), - Value: true, - } CelestiaServerFlag = &cli.StringFlag{ Name: CelestiaServerFlagName, Usage: "celestia server endpoint", - Value: "http://localhost:26658", + Value: "http://localhost:26658", EnvVars: prefixEnvVars("CELESTIA_SERVER"), } CelestiaAuthTokenFlag = &cli.StringFlag{ @@ -72,7 +65,6 @@ var requiredFlags = []cli.Flag{ } var optionalFlags = []cli.Flag{ - GenericCommFlag, CelestiaServerFlag, CelestiaAuthTokenFlag, CelestiaNamespaceFlag, @@ -88,17 +80,16 @@ var Flags []cli.Flag type CLIConfig struct { UseGenericComm bool - CelestiaEndpoint string - CelestiaAuthToken string - CelestiaNamespace string + CelestiaEndpoint string + CelestiaAuthToken string + CelestiaNamespace string } func ReadCLIConfig(ctx *cli.Context) CLIConfig { return CLIConfig{ - UseGenericComm: ctx.Bool(GenericCommFlagName), - CelestiaEndpoint: ctx.String(CelestiaServerFlagName), - CelestiaAuthToken: ctx.String(CelestiaAuthTokenFlagName), - CelestiaNamespace: ctx.String(CelestiaNamespaceFlagName), + CelestiaEndpoint: ctx.String(CelestiaServerFlagName), + CelestiaAuthToken: ctx.String(CelestiaAuthTokenFlagName), + CelestiaNamespace: ctx.String(CelestiaNamespaceFlagName), } }