diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel b/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel index f279bbb37407..12c85ee66768 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel @@ -4,10 +4,10 @@ go_library( name = "go_default_library", srcs = [ "aggregator.go", - "duties.go", "attester.go", "blocks.go", "construct_generic_block.go", + "duties.go", "exit.go", "log.go", "proposer.go", @@ -179,10 +179,10 @@ go_test( timeout = "moderate", srcs = [ "aggregator_test.go", - "duties_test.go", "attester_test.go", "blocks_test.go", "construct_generic_block_test.go", + "duties_test.go", "exit_test.go", "proposer_altair_test.go", "proposer_attestations_test.go", @@ -201,6 +201,7 @@ go_test( "status_mainnet_test.go", "status_test.go", "sync_committee_test.go", + "unblinder_test.go", "validator_test.go", ], embed = [":go_default_library"], diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/unblinder.go b/beacon-chain/rpc/prysm/v1alpha1/validator/unblinder.go index 86e9669bd048..ccb781cd59e2 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/unblinder.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/unblinder.go @@ -13,15 +13,22 @@ import ( ) func unblindBlobsSidecars(block interfaces.SignedBeaconBlock, bundle *enginev1.BlobsBundle) ([]*ethpb.BlobSidecar, error) { - if block.Version() < version.Deneb || bundle == nil { + if block.Version() < version.Deneb { return nil, nil } - header, err := block.Header() + body := block.Block().Body() + blockCommitments, err := body.BlobKzgCommitments() if err != nil { return nil, err } - body := block.Block().Body() - blockCommitments, err := body.BlobKzgCommitments() + if len(blockCommitments) == 0 { + return nil, nil + } + // Do not allow builders to provide no blob bundles for blocks which carry commitments. + if bundle == nil { + return nil, errors.New("no valid bundle provided") + } + header, err := block.Header() if err != nil { return nil, err } diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/unblinder_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/unblinder_test.go new file mode 100644 index 000000000000..8b06a0528edb --- /dev/null +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/unblinder_test.go @@ -0,0 +1,34 @@ +package validator + +import ( + "testing" + + consensusblocks "github.com/prysmaticlabs/prysm/v5/consensus-types/blocks" + ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" + "github.com/prysmaticlabs/prysm/v5/testing/assert" +) + +func TestUnblinder_UnblindBlobSidecars_InvalidBundle(t *testing.T) { + wBlock, err := consensusblocks.NewSignedBeaconBlock(ðpb.SignedBeaconBlockDeneb{ + Block: ðpb.BeaconBlockDeneb{ + Body: ðpb.BeaconBlockBodyDeneb{}, + }, + Signature: nil, + }) + assert.NoError(t, err) + _, err = unblindBlobsSidecars(wBlock, nil) + assert.NoError(t, err) + + wBlock, err = consensusblocks.NewSignedBeaconBlock(ðpb.SignedBeaconBlockDeneb{ + Block: ðpb.BeaconBlockDeneb{ + Body: ðpb.BeaconBlockBodyDeneb{ + BlobKzgCommitments: [][]byte{[]byte("a"), []byte("b")}, + }, + }, + Signature: nil, + }) + assert.NoError(t, err) + _, err = unblindBlobsSidecars(wBlock, nil) + assert.ErrorContains(t, "no valid bundle provided", err) + +}