Skip to content

Commit 2143b8a

Browse files
authored
Merge pull request #21 from base-org/fix-ssz
fix: allow beacon api req/res to use JSON
2 parents d86a851 + 760a128 commit 2143b8a

File tree

8 files changed

+101
-89
lines changed

8 files changed

+101
-89
lines changed

api/cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func Main() cliapp.LifecycleAction {
5050
}
5151

5252
l := oplog.NewLogger(oplog.AppOut(cliCtx), cfg.LogConfig)
53-
oplog.SetGlobalLogHandler(l.GetHandler())
53+
oplog.SetGlobalLogHandler(l.Handler())
5454
opservice.ValidateEnvVars(flags.EnvVarPrefix, flags.Flags, l)
5555

5656
m := metrics.NewMetrics()

archiver/cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func Main() cliapp.LifecycleAction {
5151
}
5252

5353
l := oplog.NewLogger(oplog.AppOut(cliCtx), cfg.LogConfig)
54-
oplog.SetGlobalLogHandler(l.GetHandler())
54+
oplog.SetGlobalLogHandler(l.Handler())
5555
opservice.ValidateEnvVars(flags.EnvVarPrefix, flags.Flags, l)
5656

5757
m := metrics.NewMetrics()

common/beacon/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
client "github.com/attestantio/go-eth2-client"
77
"github.com/attestantio/go-eth2-client/http"
88
"github.com/base-org/blob-archiver/common/flags"
9+
"github.com/rs/zerolog"
910
)
1011

1112
// Client is an interface that wraps the go-eth-2 interfaces that the blob archiver and api require.
@@ -19,7 +20,7 @@ func NewBeaconClient(ctx context.Context, cfg flags.BeaconConfig) (Client, error
1920
cctx, cancel := context.WithCancel(ctx)
2021
defer cancel()
2122

22-
c, err := http.New(cctx, http.WithAddress(cfg.BeaconURL), http.WithTimeout(cfg.BeaconClientTimeout))
23+
c, err := http.New(cctx, http.WithAddress(cfg.BeaconURL), http.WithTimeout(cfg.BeaconClientTimeout), http.WithEnforceJSON(cfg.EnforceJSON), http.WithLogLevel(zerolog.ErrorLevel))
2324
if err != nil {
2425
return nil, err
2526
}

common/flags/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func (c S3Config) check() error {
6060
type BeaconConfig struct {
6161
BeaconURL string
6262
BeaconClientTimeout time.Duration
63+
EnforceJSON bool
6364
}
6465

6566
type StorageConfig struct {
@@ -74,6 +75,7 @@ func NewBeaconConfig(cliCtx *cli.Context) BeaconConfig {
7475
return BeaconConfig{
7576
BeaconURL: cliCtx.String(BeaconHttpFlagName),
7677
BeaconClientTimeout: timeout,
78+
EnforceJSON: cliCtx.Bool(BeaconHttpEnforceJson),
7779
}
7880
}
7981

common/flags/flags.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
const (
99
BeaconHttpFlagName = "l1-beacon-http"
1010
BeaconHttpClientTimeoutFlagName = "l1-beacon-client-timeout"
11+
BeaconHttpEnforceJson = "l1-beacon-enforce-json"
1112
DataStoreFlagName = "data-store"
1213
S3CredentialTypeFlagName = "s3-credential-type"
1314
S3EndpointFlagName = "s3-endpoint"
@@ -89,5 +90,11 @@ func CLIFlags(envPrefix string) []cli.Flag {
8990
Value: "10s",
9091
EnvVars: opservice.PrefixEnvVar(envPrefix, "L1_BEACON_CLIENT_TIMEOUT"),
9192
},
93+
&cli.BoolFlag{
94+
Name: BeaconHttpEnforceJson,
95+
Usage: "When true uses json for all requests/responses to the beacon node",
96+
Value: false,
97+
EnvVars: opservice.PrefixEnvVar(envPrefix, "L1_BEACON_CLIENT_ENFORCE_JSON"),
98+
},
9299
}
93100
}

go.mod

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ module github.com/base-org/blob-archiver
33
go 1.21.6
44

55
require (
6-
github.com/attestantio/go-eth2-client v0.19.10
7-
github.com/ethereum-optimism/optimism v1.4.0-rc.3
8-
github.com/ethereum/go-ethereum v1.13.5
9-
github.com/go-chi/chi/v5 v5.0.10
6+
github.com/attestantio/go-eth2-client v0.21.1
7+
github.com/ethereum-optimism/optimism v1.7.2
8+
github.com/ethereum/go-ethereum v1.13.8
9+
github.com/go-chi/chi/v5 v5.0.12
1010
github.com/minio/minio-go/v7 v7.0.66
11-
github.com/prometheus/client_golang v1.17.0
12-
github.com/stretchr/testify v1.8.4
13-
github.com/urfave/cli/v2 v2.25.7
11+
github.com/prometheus/client_golang v1.19.0
12+
github.com/stretchr/testify v1.9.0
13+
github.com/urfave/cli/v2 v2.27.1
1414
)
1515

1616
require (
1717
github.com/DataDog/zstd v1.5.2 // indirect
1818
github.com/Microsoft/go-winio v0.6.1 // indirect
1919
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
2020
github.com/beorn7/perks v1.0.1 // indirect
21-
github.com/bits-and-blooms/bitset v1.7.0 // indirect
21+
github.com/bits-and-blooms/bitset v1.10.0 // indirect
2222
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
2323
github.com/cespare/xxhash/v2 v2.2.0 // indirect
2424
github.com/cockroachdb/errors v1.11.1 // indirect
@@ -29,37 +29,37 @@ require (
2929
github.com/consensys/bavard v0.1.13 // indirect
3030
github.com/consensys/gnark-crypto v0.12.1 // indirect
3131
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
32+
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect
3233
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
3334
github.com/davecgh/go-spew v1.1.1 // indirect
3435
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
3536
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
3637
github.com/dustin/go-humanize v1.0.1 // indirect
38+
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240318114348-52d3dbd1605d // indirect
3739
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
3840
github.com/fatih/color v1.16.0 // indirect
3941
github.com/ferranbt/fastssz v0.1.3 // indirect
42+
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
4043
github.com/getsentry/sentry-go v0.18.0 // indirect
4144
github.com/go-logr/logr v1.2.4 // indirect
4245
github.com/go-logr/stdr v1.2.2 // indirect
43-
github.com/go-ole/go-ole v1.2.6 // indirect
44-
github.com/go-stack/stack v1.8.1 // indirect
46+
github.com/go-ole/go-ole v1.3.0 // indirect
4547
github.com/goccy/go-yaml v1.9.2 // indirect
4648
github.com/gofrs/flock v0.8.1 // indirect
4749
github.com/gogo/protobuf v1.3.2 // indirect
48-
github.com/golang/protobuf v1.5.3 // indirect
4950
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
50-
github.com/google/uuid v1.5.0 // indirect
51+
github.com/google/uuid v1.6.0 // indirect
5152
github.com/gorilla/websocket v1.5.0 // indirect
5253
github.com/holiman/uint256 v1.2.4 // indirect
5354
github.com/huandu/go-clone v1.6.0 // indirect
5455
github.com/json-iterator/go v1.1.12 // indirect
5556
github.com/klauspost/compress v1.17.4 // indirect
56-
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
57+
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
5758
github.com/kr/pretty v0.3.1 // indirect
5859
github.com/kr/text v0.2.0 // indirect
5960
github.com/mattn/go-colorable v0.1.13 // indirect
6061
github.com/mattn/go-isatty v0.0.20 // indirect
6162
github.com/mattn/go-runewidth v0.0.14 // indirect
62-
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
6363
github.com/minio/md5-simd v1.1.2 // indirect
6464
github.com/minio/sha256-simd v1.0.1 // indirect
6565
github.com/mitchellh/mapstructure v1.5.0 // indirect
@@ -69,15 +69,15 @@ require (
6969
github.com/olekukonko/tablewriter v0.0.5 // indirect
7070
github.com/pkg/errors v0.9.1 // indirect
7171
github.com/pmezard/go-difflib v1.0.0 // indirect
72-
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
73-
github.com/prometheus/common v0.44.0 // indirect
74-
github.com/prometheus/procfs v0.11.1 // indirect
72+
github.com/prometheus/client_model v0.5.0 // indirect
73+
github.com/prometheus/common v0.48.0 // indirect
74+
github.com/prometheus/procfs v0.12.0 // indirect
7575
github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7 // indirect
7676
github.com/r3labs/sse/v2 v2.10.0 // indirect
7777
github.com/rivo/uniseg v0.4.3 // indirect
7878
github.com/rogpeppe/go-internal v1.11.0 // indirect
7979
github.com/rs/xid v1.5.0 // indirect
80-
github.com/rs/zerolog v1.29.1 // indirect
80+
github.com/rs/zerolog v1.32.0 // indirect
8181
github.com/russross/blackfriday/v2 v2.1.0 // indirect
8282
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
8383
github.com/sirupsen/logrus v1.9.3 // indirect
@@ -90,20 +90,22 @@ require (
9090
go.opentelemetry.io/otel v1.16.0 // indirect
9191
go.opentelemetry.io/otel/metric v1.16.0 // indirect
9292
go.opentelemetry.io/otel/trace v1.16.0 // indirect
93-
golang.org/x/crypto v0.18.0 // indirect
93+
golang.org/x/crypto v0.21.0 // indirect
9494
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
9595
golang.org/x/mod v0.14.0 // indirect
96-
golang.org/x/net v0.19.0 // indirect
97-
golang.org/x/sync v0.5.0 // indirect
98-
golang.org/x/sys v0.16.0 // indirect
99-
golang.org/x/term v0.16.0 // indirect
96+
golang.org/x/net v0.21.0 // indirect
97+
golang.org/x/sync v0.6.0 // indirect
98+
golang.org/x/sys v0.18.0 // indirect
99+
golang.org/x/term v0.18.0 // indirect
100100
golang.org/x/text v0.14.0 // indirect
101-
golang.org/x/tools v0.15.0 // indirect
101+
golang.org/x/tools v0.16.1 // indirect
102102
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
103-
google.golang.org/protobuf v1.31.0 // indirect
103+
google.golang.org/protobuf v1.32.0 // indirect
104104
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
105105
gopkg.in/ini.v1 v1.67.0 // indirect
106106
gopkg.in/yaml.v2 v2.4.0 // indirect
107107
gopkg.in/yaml.v3 v3.0.1 // indirect
108108
rsc.io/tmplfunc v0.0.3 // indirect
109109
)
110+
111+
replace github.com/ethereum/go-ethereum v1.13.8 => github.com/ethereum-optimism/op-geth v1.101308.3-rc.1

0 commit comments

Comments
 (0)