Skip to content

Commit

Permalink
default path, replace deprecated docker command
Browse files Browse the repository at this point in the history
  • Loading branch information
InoMurko committed May 31, 2024
1 parent 47d002f commit fcf4e9b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build:
.PHONY: build

build-docker:
docker-compose build
docker compose build
.PHONY: build-docker

clean:
Expand All @@ -21,8 +21,8 @@ test:
.PHONY: test

integration:
docker-compose down
docker-compose up -d minio create-buckets
docker compose down
docker compose up -d minio create-buckets
RUN_INTEGRATION_TESTS=true go test -v ./...
.PHONY: integration

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ To run the project locally, you should first copy `.env.template` to `.env` and
to your beacon client and storage backend of choice. Then you can run the project with:

```sh
docker-compose up
docker compose up
```

You can see a full list of configuration options by running:
Expand Down
5 changes: 2 additions & 3 deletions archiver/flags/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package flags

import (
"fmt"
"time"
"strings"

"time"

common "github.com/base-org/blob-archiver/common/flags"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
Expand Down Expand Up @@ -48,7 +48,6 @@ func (c ArchiverConfig) Check() error {

func ReadConfig(cliCtx *cli.Context) ArchiverConfig {
pollInterval, _ := time.ParseDuration(cliCtx.String(ArchiverPollIntervalFlag.Name))

return ArchiverConfig{
LogConfig: oplog.ReadCLIConfig(cliCtx),
MetricsConfig: opmetrics.ReadCLIConfig(cliCtx),
Expand Down
1 change: 1 addition & 0 deletions common/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func CLIFlags(envPrefix string) []cli.Flag {
Usage: "The path to append to file",
Hidden: true,
EnvVars: opservice.PrefixEnvVar(envPrefix, "S3_PATH"),
Value: "",
},
// File Data Store Flags
&cli.StringFlag{
Expand Down
9 changes: 5 additions & 4 deletions common/storage/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"context"
"encoding/json"
"io"
"path"

"github.com/base-org/blob-archiver/common/flags"
"github.com/ethereum/go-ethereum/common"
Expand All @@ -17,7 +18,7 @@ import (
type S3Storage struct {
s3 *minio.Client
bucket string
path string
path string
log log.Logger
compress bool
}
Expand Down Expand Up @@ -49,7 +50,7 @@ func NewS3Storage(cfg flags.S3Config, l log.Logger) (*S3Storage, error) {
}

func (s *S3Storage) Exists(ctx context.Context, hash common.Hash) (bool, error) {
_, err := s.s3.StatObject(ctx, s.bucket, s.path+hash.String(), minio.StatObjectOptions{})
_, err := s.s3.StatObject(ctx, s.bucket, path.Join(s.path, hash.String()), minio.StatObjectOptions{})
if err != nil {
errResponse := minio.ToErrorResponse(err)
if errResponse.Code == "NoSuchKey" {
Expand All @@ -63,7 +64,7 @@ func (s *S3Storage) Exists(ctx context.Context, hash common.Hash) (bool, error)
}

func (s *S3Storage) Read(ctx context.Context, hash common.Hash) (BlobData, error) {
res, err := s.s3.GetObject(ctx, s.bucket, s.path+hash.String(), minio.GetObjectOptions{})
res, err := s.s3.GetObject(ctx, s.bucket, path.Join(s.path, hash.String()), minio.GetObjectOptions{})
if err != nil {
s.log.Info("unexpected error fetching blob", "hash", hash.String(), "err", err)
return BlobData{}, ErrStorage
Expand Down Expand Up @@ -124,7 +125,7 @@ func (s *S3Storage) Write(ctx context.Context, data BlobData) error {

reader := bytes.NewReader(b)

_, err = s.s3.PutObject(ctx, s.bucket, s.path+data.Header.BeaconBlockHash.String(), reader, int64(len(b)), options)
_, err = s.s3.PutObject(ctx, s.bucket, path.Join(s.path, data.Header.BeaconBlockHash.String()), reader, int64(len(b)), options)

if err != nil {
s.log.Warn("error writing blob", "err", err)
Expand Down
4 changes: 2 additions & 2 deletions common/storage/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (

// Prior to running these tests, a local Minio server must be running.
// You can accomplish this with:
// docker-compose down # shut down any running services
// docker-compose up minio create-buckets # start the minio service
// docker compose down # shut down any running services
// docker compose up minio create-buckets # start the minio service
func setupS3(t *testing.T) *S3Storage {
if os.Getenv("RUN_INTEGRATION_TESTS") == "" {
t.Skip("skipping integration tests: set RUN_INTEGRATION_TESTS environment variable")
Expand Down

0 comments on commit fcf4e9b

Please sign in to comment.