Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(daserver): rm unused flag; fmt #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions celestia_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cmd/daserver/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
31 changes: 11 additions & 20 deletions cmd/daserver/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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{
Expand All @@ -72,7 +65,6 @@ var requiredFlags = []cli.Flag{
}

var optionalFlags = []cli.Flag{
GenericCommFlag,
CelestiaServerFlag,
CelestiaAuthTokenFlag,
CelestiaNamespaceFlag,
Expand All @@ -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),
}
}

Expand Down