Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions beacon-chain/rpc/eth/beacon/blinded_blocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ func TestServer_GetBlindedBlock(t *testing.T) {
require.NoError(t, err)
resp, err := bs.GetBlindedBlock(ctx, &ethpbv1.BlockRequest{})
require.NoError(t, err)
capellaBlock, ok := resp.Data.Message.(*ethpbv2.SignedBlindedBeaconBlockContainer_DenebBlock)
denebBlock, ok := resp.Data.Message.(*ethpbv2.SignedBlindedBeaconBlockContainer_DenebBlock)
require.Equal(t, true, ok)
assert.DeepEqual(t, expected, capellaBlock.DenebBlock)
assert.DeepEqual(t, expected, denebBlock.DenebBlock)
assert.Equal(t, ethpbv2.Version_DENEB, resp.Version)
})
t.Run("execution optimistic", func(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions beacon-chain/rpc/eth/validator/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ go_test(
"//encoding/bytesutil:go_default_library",
"//proto/eth/v1:go_default_library",
"//proto/eth/v2:go_default_library",
"//proto/migration:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//testing/assert:go_default_library",
"//testing/mock:go_default_library",
Expand Down
82 changes: 82 additions & 0 deletions beacon-chain/rpc/eth/validator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,27 @@ func (vs *Server) ProduceBlockV2(ctx context.Context, req *ethpbv1.ProduceBlockR
},
}, nil
}
_, ok = v1alpha1resp.Block.(*ethpbalpha.GenericBeaconBlock_BlindedDeneb)
if ok {
return nil, status.Error(codes.Internal, "Prepared Deneb beacon block contents are blinded")
}
denebBlock, ok := v1alpha1resp.Block.(*ethpbalpha.GenericBeaconBlock_Deneb)
if ok {
blockAndBlobs, err := migration.V1Alpha1BeaconBlockDenebAndBlobsToV2(denebBlock.Deneb)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not prepare beacon block contents: %v", err)
}
return &ethpbv2.ProduceBlockResponseV2{
Version: ethpbv2.Version_DENEB,
Data: &ethpbv2.BeaconBlockContainerV2{
Block: &ethpbv2.BeaconBlockContainerV2_DenebContents{
DenebContents: &ethpbv2.BeaconBlockContentsDeneb{
Block: blockAndBlobs.Block,
BlobSidecars: blockAndBlobs.BlobSidecars,
}},
},
}, nil
}
return nil, status.Error(codes.InvalidArgument, "Unsupported block type")
}

Expand Down Expand Up @@ -497,6 +518,27 @@ func (vs *Server) ProduceBlockV2SSZ(ctx context.Context, req *ethpbv1.ProduceBlo
Data: sszBlock,
}, nil
}

_, ok = v1alpha1resp.Block.(*ethpbalpha.GenericBeaconBlock_BlindedDeneb)
if ok {
return nil, status.Error(codes.Internal, "Prepared Deneb beacon blockcontent is blinded")
}
denebBlockcontent, ok := v1alpha1resp.Block.(*ethpbalpha.GenericBeaconBlock_Deneb)
if ok {
blockContent, err := migration.V1Alpha1BeaconBlockDenebAndBlobsToV2(denebBlockcontent.Deneb)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not prepare beacon block: %v", err)
}
sszBlock, err := blockContent.MarshalSSZ()
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not marshal block into SSZ format: %v", err)
}
return &ethpbv2.SSZContainer{
Version: ethpbv2.Version_DENEB,
Data: sszBlock,
}, nil
}

return nil, status.Error(codes.InvalidArgument, "Unsupported block type")
}

Expand Down Expand Up @@ -598,6 +640,27 @@ func (vs *Server) ProduceBlindedBlock(ctx context.Context, req *ethpbv1.ProduceB
},
}, nil
}
_, ok = v1alpha1resp.Block.(*ethpbalpha.GenericBeaconBlock_Deneb)
if ok {
return nil, status.Error(codes.Internal, "Prepared Deneb beacon block contents are not blinded")
}
denebBlock, ok := v1alpha1resp.Block.(*ethpbalpha.GenericBeaconBlock_BlindedDeneb)
if ok {
blockAndBlobs, err := migration.V1Alpha1BlindedBlockAndBlobsDenebToV2Blinded(denebBlock.BlindedDeneb)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not prepare beacon block contents: %v", err)
}
return &ethpbv2.ProduceBlindedBlockResponse{
Version: ethpbv2.Version_DENEB,
Data: &ethpbv2.BlindedBeaconBlockContainer{
Block: &ethpbv2.BlindedBeaconBlockContainer_DenebContents{
DenebContents: &ethpbv2.BlindedBeaconBlockContentsDeneb{
BlindedBlock: blockAndBlobs.BlindedBlock,
BlindedBlobSidecars: blockAndBlobs.BlindedBlobSidecars,
}},
},
}, nil
}
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("block was not a supported blinded block type, validator may not be registered if using a relay. received: %T", v1alpha1resp.Block))
}

Expand Down Expand Up @@ -705,6 +768,25 @@ func (vs *Server) ProduceBlindedBlockSSZ(ctx context.Context, req *ethpbv1.Produ
Data: sszBlock,
}, nil
}
_, ok = v1alpha1resp.Block.(*ethpbalpha.GenericBeaconBlock_Deneb)
if ok {
return nil, status.Error(codes.Internal, "Prepared Deneb beacon block content is not blinded")
}
denebBlockcontent, ok := v1alpha1resp.Block.(*ethpbalpha.GenericBeaconBlock_BlindedDeneb)
if ok {
blockContent, err := migration.V1Alpha1BlindedBlockAndBlobsDenebToV2Blinded(denebBlockcontent.BlindedDeneb)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not prepare beacon block: %v", err)
}
sszBlock, err := blockContent.MarshalSSZ()
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not marshal block into SSZ format: %v", err)
}
return &ethpbv2.SSZContainer{
Version: ethpbv2.Version_DENEB,
Data: sszBlock,
}, nil
}
return nil, status.Error(codes.InvalidArgument, "Unsupported block type")
}

Expand Down
Loading