From b9fff0dbdee2a988c49e97fdf1331ddc0ef054aa Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Tue, 25 Feb 2025 12:54:58 +0000 Subject: [PATCH] Handle blocks without blobs. --- CHANGELOG.md | 4 ++++ cmd/block/info/output.go | 22 +++++++++++++--------- cmd/block/info/process.go | 16 ++++++++++++---- cmd/version.go | 2 +- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f629ec1..a713ca1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +1.37.1: + - handle missing blobs for block info + - fix `--epoch` flag for epoch summary + 1.37.0: - support Electra - add `--compounding` flag when creating validator deposit data diff --git a/cmd/block/info/output.go b/cmd/block/info/output.go index 34fa5c3..5b9120c 100644 --- a/cmd/block/info/output.go +++ b/cmd/block/info/output.go @@ -607,7 +607,7 @@ func outputDenebBlockText(ctx context.Context, } res.WriteString(tmp) - tmp, err = outputBlobInfo(ctx, data.verbose, blobs) + tmp, err = outputBlobInfo(ctx, data.verbose, signedBlock.Message.Body.BlobKZGCommitments, blobs) if err != nil { return "", err } @@ -717,7 +717,7 @@ func outputElectraBlockText(ctx context.Context, } res.WriteString(tmp) - tmp, err = outputBlobInfo(ctx, data.verbose, blobs) + tmp, err = outputBlobInfo(ctx, data.verbose, signedBlock.Message.Body.BlobKZGCommitments, blobs) if err != nil { return "", err } @@ -1160,6 +1160,7 @@ func outputElectraBlockExecutionRequests(_ context.Context, func outputBlobInfo(_ context.Context, verbose bool, + commitments []deneb.KZGCommitment, blobs []*deneb.BlobSidecar, ) ( string, @@ -1167,13 +1168,16 @@ func outputBlobInfo(_ context.Context, ) { res := strings.Builder{} - res.WriteString(fmt.Sprintf("Blobs: %d\n", len(blobs))) - - if verbose { - for i, blob := range blobs { - res.WriteString(fmt.Sprintf("%3d:\n", i)) - res.WriteString(fmt.Sprintf(" KZG proof: %s\n", blob.KZGProof.String())) - res.WriteString(fmt.Sprintf(" KZG commitment: %s\n", blob.KZGCommitment.String())) + if len(blobs) == 0 && len(commitments) > 0 { + res.WriteString(fmt.Sprintf("Blobs: %d (but no blobs obtained from the beacon node)\n", len(commitments))) + } else { + res.WriteString(fmt.Sprintf("Blobs: %d\n", len(blobs))) + if verbose { + for i, blob := range blobs { + res.WriteString(fmt.Sprintf("%3d:\n", i)) + res.WriteString(fmt.Sprintf(" KZG proof: %s\n", blob.KZGProof.String())) + res.WriteString(fmt.Sprintf(" KZG commitment: %s\n", blob.KZGCommitment.String())) + } } } diff --git a/cmd/block/info/process.go b/cmd/block/info/process.go index effb97e..a692849 100644 --- a/cmd/block/info/process.go +++ b/cmd/block/info/process.go @@ -168,9 +168,13 @@ func processDenebBlock(ctx context.Context, Block: data.blockID, }) if err != nil { - return errors.Wrap(err, "failed to obtain blob sidecars") + var apiErr *api.Error + if errors.As(err, &apiErr) && apiErr.StatusCode != http.StatusNotFound { + return errors.Wrap(err, "failed to obtain blob sidecars") + } + } else { + blobSidecars = blobSidecarsResponse.Data } - blobSidecars = blobSidecarsResponse.Data } if err := outputDenebBlock(ctx, data.jsonOutput, data.sszOutput, block.Deneb, blobSidecars); err != nil { return errors.Wrap(err, "failed to output block") @@ -193,9 +197,13 @@ func processElectraBlock(ctx context.Context, Block: data.blockID, }) if err != nil { - return errors.Wrap(err, "failed to obtain blob sidecars") + var apiErr *api.Error + if errors.As(err, &apiErr) && apiErr.StatusCode != http.StatusNotFound { + return errors.Wrap(err, "failed to obtain blob sidecars") + } + } else { + blobSidecars = blobSidecarsResponse.Data } - blobSidecars = blobSidecarsResponse.Data } if err := outputElectraBlock(ctx, data.jsonOutput, data.sszOutput, block.Electra, blobSidecars); err != nil { return errors.Wrap(err, "failed to output block") diff --git a/cmd/version.go b/cmd/version.go index b79cf35..65831ab 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -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.37.0)" +var ReleaseVersion = "local build (latest release 1.37.1)" // versionCmd represents the version command. var versionCmd = &cobra.Command{