diff --git a/beacon-chain/rpc/eth/validator/validator.go b/beacon-chain/rpc/eth/validator/validator.go index 25069c26e089..af5f5a042ffb 100644 --- a/beacon-chain/rpc/eth/validator/validator.go +++ b/beacon-chain/rpc/eth/validator/validator.go @@ -482,6 +482,9 @@ func (vs *Server) ProduceBlindedBlock(ctx context.Context, req *ethpbv1.ProduceB ctx, span := trace.StartSpan(ctx, "validator.ProduceBlindedBlock") defer span.End() + if !vs.V1Alpha1Server.BlockBuilder.Configured() { + return nil, status.Error(codes.Internal, "Block builder not configured") + } if err := rpchelpers.ValidateSync(ctx, vs.SyncChecker, vs.HeadFetcher, vs.TimeFetcher, vs.OptimisticModeFetcher); err != nil { // We simply return the error because it's already a gRPC error. return nil, err @@ -533,6 +536,10 @@ func (vs *Server) ProduceBlindedBlock(ctx context.Context, req *ethpbv1.ProduceB if optimistic { return nil, status.Errorf(codes.Unavailable, "The node is currently optimistic and cannot serve validators") } + _, ok := v1alpha1resp.Block.(*ethpbalpha.GenericBeaconBlock_Bellatrix) + if ok { + return nil, status.Error(codes.Internal, "Prepared beacon block is not blinded") + } bellatrixBlock, ok := v1alpha1resp.Block.(*ethpbalpha.GenericBeaconBlock_BlindedBellatrix) if ok { blk, err := migration.V1Alpha1BeaconBlockBlindedBellatrixToV2Blinded(bellatrixBlock.BlindedBellatrix) @@ -546,6 +553,10 @@ func (vs *Server) ProduceBlindedBlock(ctx context.Context, req *ethpbv1.ProduceB }, }, nil } + _, ok = v1alpha1resp.Block.(*ethpbalpha.GenericBeaconBlock_Capella) + if ok { + return nil, status.Error(codes.Internal, "Prepared beacon block is not blinded") + } capellaBlock, ok := v1alpha1resp.Block.(*ethpbalpha.GenericBeaconBlock_BlindedCapella) if ok { blk, err := migration.V1Alpha1BeaconBlockBlindedCapellaToV2Blinded(capellaBlock.BlindedCapella) diff --git a/beacon-chain/rpc/eth/validator/validator_test.go b/beacon-chain/rpc/eth/validator/validator_test.go index eeb4c7d34cff..fa53d3c7eb02 100644 --- a/beacon-chain/rpc/eth/validator/validator_test.go +++ b/beacon-chain/rpc/eth/validator/validator_test.go @@ -2271,6 +2271,7 @@ func TestProduceBlindedBlock(t *testing.T) { SlashingsPool: slashings.NewPool(), ExitPool: voluntaryexits.NewPool(), StateGen: stategen.New(db, doublylinkedtree.New()), + BlockBuilder: &builderTest.MockBuilderService{HasConfigured: true}, } proposerSlashings := make([]*ethpbalpha.ProposerSlashing, params.BeaconConfig().MaxProposerSlashings) @@ -2379,6 +2380,7 @@ func TestProduceBlindedBlock(t *testing.T) { ExitPool: voluntaryexits.NewPool(), StateGen: stategen.New(db, doublylinkedtree.New()), SyncCommitteePool: synccommittee.NewStore(), + BlockBuilder: &builderTest.MockBuilderService{HasConfigured: true}, } proposerSlashings := make([]*ethpbalpha.ProposerSlashing, params.BeaconConfig().MaxProposerSlashings) @@ -2918,7 +2920,7 @@ func TestProduceBlindedBlock(t *testing.T) { assert.DeepEqual(t, expectedBits, blk.Body.SyncAggregate.SyncCommitteeBits) assert.DeepEqual(t, aggregatedSig, blk.Body.SyncAggregate.SyncCommitteeSignature) }) - t.Run("Unsupported Block Type", func(t *testing.T) { + t.Run("full block", func(t *testing.T) { db := dbutil.SetupDB(t) ctx := context.Background() @@ -3054,7 +3056,7 @@ func TestProduceBlindedBlock(t *testing.T) { SyncCommitteePool: synccommittee.NewStore(), ProposerSlotIndexCache: cache.NewProposerPayloadIDsCache(), BlockBuilder: &builderTest.MockBuilderService{ - HasConfigured: false, + HasConfigured: true, }, } @@ -3072,7 +3074,14 @@ func TestProduceBlindedBlock(t *testing.T) { Graffiti: graffiti[:], } _, err = v1Server.ProduceBlindedBlock(ctx, req) - require.ErrorContains(t, " block was not a supported blinded block type", err) + require.ErrorContains(t, "Prepared beacon block is not blinded", err) + }) + t.Run("builder not configured", func(t *testing.T) { + v1Server := &Server{ + V1Alpha1Server: &v1alpha1validator.Server{BlockBuilder: &builderTest.MockBuilderService{HasConfigured: false}}, + } + _, err := v1Server.ProduceBlindedBlock(context.Background(), nil) + require.ErrorContains(t, "Block builder not configured", err) }) } @@ -3902,6 +3911,7 @@ func TestProduceBlindedBlock_SyncNotReady(t *testing.T) { HeadFetcher: chainService, TimeFetcher: chainService, OptimisticModeFetcher: chainService, + V1Alpha1Server: &v1alpha1validator.Server{BlockBuilder: &builderTest.MockBuilderService{HasConfigured: true}}, } _, err = vs.ProduceBlindedBlock(context.Background(), ðpbv1.ProduceBlockRequest{}) assert.ErrorContains(t, "Syncing to latest head, not ready to respond", err)