Skip to content

Commit

Permalink
Fix crash when block info has no blobs.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdee committed Oct 1, 2024
1 parent fd0a89c commit 0276a72
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 82 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
1.36.1:
- more JSON data for epoch summary
- fix crash when block ifno had no blobs

1.36.0:
- support keystore wallets
Expand Down
40 changes: 29 additions & 11 deletions cmd/block/info/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,20 @@ func process(ctx context.Context, data *dataIn) (*dataOut, error) {
return nil, errors.Wrap(err, "failed to output block")
}
case spec.DataVersionDeneb:
blobSidecarsResponse, err := results.eth2Client.(eth2client.BlobSidecarsProvider).BlobSidecars(ctx, &api.BlobSidecarsOpts{
Block: data.blockID,
})
var blobSidecars []*deneb.BlobSidecar
kzgCommitments, err := block.BlobKZGCommitments()
if err != nil {
return nil, errors.Wrap(err, "failed to obtain blob sidecars")
return nil, err
}
if len(kzgCommitments) > 0 {
blobSidecarsResponse, err := results.eth2Client.(eth2client.BlobSidecarsProvider).BlobSidecars(ctx, &api.BlobSidecarsOpts{
Block: data.blockID,
})
if err != nil {
return nil, errors.Wrap(err, "failed to obtain blob sidecars")
}
blobSidecars = blobSidecarsResponse.Data
}
blobSidecars := blobSidecarsResponse.Data
if err := outputDenebBlock(ctx, data.jsonOutput, data.sszOutput, block.Deneb, blobSidecars); err != nil {
return nil, errors.Wrap(err, "failed to output block")
}
Expand Down Expand Up @@ -180,13 +187,24 @@ func headEventHandler(event *apiv1.Event) {
case spec.DataVersionCapella:
err = outputCapellaBlock(ctx, jsonOutput, sszOutput, block.Capella)
case spec.DataVersionDeneb:
var blobSidecarsResponse *api.Response[[]*deneb.BlobSidecar]
blobSidecarsResponse, err = results.eth2Client.(eth2client.BlobSidecarsProvider).BlobSidecars(ctx, &api.BlobSidecarsOpts{
Block: blockID,
})
if err == nil {
err = outputDenebBlock(context.Background(), jsonOutput, sszOutput, block.Deneb, blobSidecarsResponse.Data)
var blobSidecars []*deneb.BlobSidecar
kzgCommitments, err := block.BlobKZGCommitments()
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to obtain KZG commitments: %v\n", err)
return
}
if len(kzgCommitments) > 0 {
var blobSidecarsResponse *api.Response[[]*deneb.BlobSidecar]
blobSidecarsResponse, err = results.eth2Client.(eth2client.BlobSidecarsProvider).BlobSidecars(ctx, &api.BlobSidecarsOpts{
Block: blockID,
})
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to obtain blob sidecars: %v\n", err)
return
}
blobSidecars = blobSidecarsResponse.Data
}
err = outputDenebBlock(context.Background(), jsonOutput, sszOutput, block.Deneb, blobSidecars)

Check failure on line 207 in cmd/block/info/process.go

View workflow job for this annotation

GitHub Actions / lint

ineffectual assignment to err (ineffassign)
default:
err = errors.New("unknown block version")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

// ReleaseVersion is the release version of the codebase.
// Usually overridden by tag names when building binaries.
var ReleaseVersion = "local build (latest release 1.36.0)"
var ReleaseVersion = "local build (latest release 1.36.1)"

// versionCmd represents the version command.
var versionCmd = &cobra.Command{
Expand Down
43 changes: 21 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/wealdtech/ethdo

go 1.21.0
go 1.22.0

toolchain go1.22.2

Expand All @@ -10,7 +10,7 @@ require (
github.com/gofrs/uuid v4.4.0+incompatible
github.com/google/uuid v1.6.0
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b
github.com/herumi/bls-eth-go-binary v1.35.0
github.com/herumi/bls-eth-go-binary v1.36.1
github.com/mitchellh/go-homedir v1.1.0
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354
github.com/pkg/errors v0.9.1
Expand All @@ -28,7 +28,7 @@ require (
github.com/wealdtech/go-eth2-types/v2 v2.8.2
github.com/wealdtech/go-eth2-util v1.8.2
github.com/wealdtech/go-eth2-wallet v1.17.0
github.com/wealdtech/go-eth2-wallet-dirk v1.4.9
github.com/wealdtech/go-eth2-wallet-dirk v1.5.0
github.com/wealdtech/go-eth2-wallet-distributed v1.2.1
github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4 v1.4.1
github.com/wealdtech/go-eth2-wallet-hd/v2 v2.7.0
Expand All @@ -37,30 +37,29 @@ require (
github.com/wealdtech/go-eth2-wallet-store-filesystem v1.18.1
github.com/wealdtech/go-eth2-wallet-store-s3 v1.12.0
github.com/wealdtech/go-eth2-wallet-store-scratch v1.7.2
github.com/wealdtech/go-eth2-wallet-types/v2 v2.11.0
github.com/wealdtech/go-eth2-wallet-types/v2 v2.12.0
github.com/wealdtech/go-string2eth v1.2.1
golang.org/x/text v0.17.0
golang.org/x/text v0.18.0
)

require (
github.com/aws/aws-sdk-go v1.55.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dgraph-io/ristretto v0.2.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/emicklei/dot v1.6.2 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/goccy/go-yaml v1.9.2 // indirect
github.com/golang/glog v1.2.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/holiman/uint256 v1.3.1 // indirect
github.com/huandu/go-clone v1.7.2 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/magiconair/properties v1.8.7 // indirect
Expand All @@ -73,9 +72,9 @@ require (
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pk910/dynamic-ssz v0.0.5 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.20.2 // indirect
github.com/prometheus/client_golang v1.20.4 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.57.0 // indirect
github.com/prometheus/common v0.59.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/protolambda/zssz v0.1.5 // indirect
github.com/r3labs/sse/v2 v2.10.0 // indirect
Expand All @@ -88,20 +87,20 @@ require (
github.com/subosito/gotenv v1.6.0 // indirect
github.com/wealdtech/eth2-signer-api v1.7.2 // indirect
github.com/wealdtech/go-indexer v1.1.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.55.0 // indirect
go.opentelemetry.io/otel v1.30.0 // indirect
go.opentelemetry.io/otel/metric v1.30.0 // indirect
go.opentelemetry.io/otel/trace v1.30.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240827150818-7e3bb234dfed // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed // indirect
google.golang.org/grpc v1.66.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240930140551-af27646dc61f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/Knetic/govaluate.v3 v3.0.0 // indirect
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
Expand Down
Loading

0 comments on commit 0276a72

Please sign in to comment.