Deneb: blob sidecar events (#12928)

* adding in deneb blob event triggers

* fixing linting

* kasey's feedback

---------

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
james-prysm
2023-09-22 16:54:10 -05:00
committed by GitHub
parent 6454081577
commit 723f73795f
9 changed files with 263 additions and 41 deletions

View File

@@ -405,8 +405,13 @@ func kzgCommitmentsToVersionedHashes(body interfaces.ReadOnlyBeaconBlockBody) ([
versionedHashes := make([]common.Hash, len(commitments))
for i, commitment := range commitments {
versionedHashes[i] = sha256.Sum256(commitment)
versionedHashes[i][0] = blobCommitmentVersionKZG
versionedHashes[i] = ConvertKzgCommitmentToVersionedHash(commitment)
}
return versionedHashes, nil
}
func ConvertKzgCommitmentToVersionedHash(commitment []byte) common.Hash {
versionedHash := sha256.Sum256(commitment)
versionedHash[0] = blobCommitmentVersionKZG
return versionedHash
}

View File

@@ -22,6 +22,9 @@ const (
// BLSToExecutionChangeReceived is sent after a BLS to execution change object has been received from gossip or rpc.
BLSToExecutionChangeReceived
// BlobSidecarReceived is sent after a blob sidecar is received from gossip or rpc.
BlobSidecarReceived = 6
)
// UnAggregatedAttReceivedData is the data sent with UnaggregatedAttReceived events.
@@ -52,3 +55,8 @@ type SyncCommitteeContributionReceivedData struct {
type BLSToExecutionChangeReceivedData struct {
Change *ethpb.SignedBLSToExecutionChange
}
// BlobSidecarReceivedData is the data sent with BlobSidecarReceived events.
type BlobSidecarReceivedData struct {
Blob *ethpb.SignedBlobSidecar
}

View File

@@ -16,6 +16,7 @@ go_library(
"//beacon-chain/core/helpers:go_default_library",
"//beacon-chain/core/time:go_default_library",
"//beacon-chain/core/transition:go_default_library",
"//encoding/bytesutil:go_default_library",
"//proto/engine/v1:go_default_library",
"//proto/eth/service:go_default_library",
"//proto/eth/v1:go_default_library",
@@ -38,6 +39,7 @@ go_test(
embed = [":go_default_library"],
deps = [
"//async/event:go_default_library",
"//beacon-chain/blockchain:go_default_library",
"//beacon-chain/blockchain/testing:go_default_library",
"//beacon-chain/core/blocks:go_default_library",
"//beacon-chain/core/feed:go_default_library",
@@ -47,6 +49,7 @@ go_test(
"//beacon-chain/core/time:go_default_library",
"//config/fieldparams:go_default_library",
"//consensus-types/blocks:go_default_library",
"//encoding/bytesutil:go_default_library",
"//proto/engine/v1:go_default_library",
"//proto/eth/v1:go_default_library",
"//proto/migration:go_default_library",

View File

@@ -5,12 +5,14 @@ import (
gwpb "github.com/grpc-ecosystem/grpc-gateway/v2/proto/gateway"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/feed"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/feed/operation"
statefeed "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/feed/state"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/time"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/transition"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
ethpbservice "github.com/prysmaticlabs/prysm/v4/proto/eth/service"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/eth/v1"
@@ -43,6 +45,8 @@ const (
BLSToExecutionChangeTopic = "bls_to_execution_change"
// PayloadAttributesTopic represents a new payload attributes for execution payload building event topic.
PayloadAttributesTopic = "payload_attributes"
// BlobSidecarTopic represents a new blob sidecar event topic
BlobSidecarTopic = "blob_sidecar"
)
var casesHandled = map[string]bool{
@@ -55,6 +59,7 @@ var casesHandled = map[string]bool{
SyncCommitteeContributionTopic: true,
BLSToExecutionChangeTopic: true,
PayloadAttributesTopic: true,
BlobSidecarTopic: true,
}
// StreamEvents allows requesting all events from a set of topics defined in the Ethereum consensus API standard.
@@ -161,7 +166,26 @@ func handleBlockOperationEvents(
}
v2Change := migration.V1Alpha1SignedBLSToExecChangeToV2(changeData.Change)
return streamData(stream, BLSToExecutionChangeTopic, v2Change)
case operation.BlobSidecarReceived:
if _, ok := requestedTopics[BlobSidecarTopic]; !ok {
return nil
}
blobData, ok := event.Data.(*operation.BlobSidecarReceivedData)
if !ok {
return nil
}
if blobData == nil || blobData.Blob == nil {
return nil
}
versionedHash := blockchain.ConvertKzgCommitmentToVersionedHash(blobData.Blob.Message.KzgCommitment)
blobEvent := &ethpb.EventBlobSidecar{
BlockRoot: bytesutil.SafeCopyBytes(blobData.Blob.Message.BlockRoot),
Index: blobData.Blob.Message.Index,
Slot: blobData.Blob.Message.Slot,
VersionedHash: bytesutil.SafeCopyBytes(versionedHash.Bytes()),
KzgCommitment: bytesutil.SafeCopyBytes(blobData.Blob.Message.KzgCommitment),
}
return streamData(stream, BlobSidecarTopic, blobEvent)
default:
return nil
}

View File

@@ -10,6 +10,7 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/v2/proto/gateway"
"github.com/prysmaticlabs/go-bitfield"
"github.com/prysmaticlabs/prysm/v4/async/event"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain"
mockChain "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain/testing"
b "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/blocks"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/feed"
@@ -19,6 +20,7 @@ import (
prysmtime "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/time"
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
"github.com/prysmaticlabs/prysm/v4/consensus-types/blocks"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/eth/v1"
"github.com/prysmaticlabs/prysm/v4/proto/migration"
@@ -233,6 +235,52 @@ func TestStreamEvents_OperationsEvents(t *testing.T) {
feed: srv.OperationNotifier.OperationFeed(),
})
})
t.Run(BlobSidecarTopic, func(t *testing.T) {
ctx := context.Background()
srv, ctrl, mockStream := setupServer(ctx, t)
defer ctrl.Finish()
commitment, err := hexutil.Decode("0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8000")
require.NoError(t, err)
wantedBlobV1alpha1 := &eth.SignedBlobSidecar{
Message: &eth.BlobSidecar{
BlockRoot: make([]byte, fieldparams.RootLength),
Index: 1,
Slot: 3,
KzgCommitment: commitment,
},
Signature: make([]byte, 96),
}
versionedHash := blockchain.ConvertKzgCommitmentToVersionedHash(commitment)
blobEvent := &ethpb.EventBlobSidecar{
BlockRoot: bytesutil.SafeCopyBytes(wantedBlobV1alpha1.Message.BlockRoot),
Index: wantedBlobV1alpha1.Message.Index,
Slot: wantedBlobV1alpha1.Message.Slot,
VersionedHash: bytesutil.SafeCopyBytes(versionedHash.Bytes()),
KzgCommitment: bytesutil.SafeCopyBytes(wantedBlobV1alpha1.Message.KzgCommitment),
}
genericResponse, err := anypb.New(blobEvent)
require.NoError(t, err)
wantedMessage := &gateway.EventSource{
Event: BlobSidecarTopic,
Data: genericResponse,
}
assertFeedSendAndReceive(ctx, &assertFeedArgs{
t: t,
srv: srv,
topics: []string{BlobSidecarTopic},
stream: mockStream,
shouldReceive: wantedMessage,
itemToSend: &feed.Event{
Type: operation.BlobSidecarReceived,
Data: &operation.BlobSidecarReceivedData{
Blob: wantedBlobV1alpha1,
},
},
feed: srv.OperationNotifier.OperationFeed(),
})
})
}
func TestStreamEvents_StateEvents(t *testing.T) {

View File

@@ -4,6 +4,8 @@ import (
"context"
"fmt"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/feed"
opfeed "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/feed/operation"
eth "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"google.golang.org/protobuf/proto"
)
@@ -22,5 +24,11 @@ func (s *Service) blobSubscriber(ctx context.Context, msg proto.Message) error {
s.cfg.chain.SendNewBlobEvent([32]byte(b.Message.BlockRoot), b.Message.Index)
s.cfg.operationNotifier.OperationFeed().Send(&feed.Event{
Type: opfeed.BlobSidecarReceived,
Data: &opfeed.BlobSidecarReceivedData{
Blob: b,
},
})
return nil
}

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.30.0
// protoc v3.15.8
// protoc v4.23.3
// source: proto/eth/v1/events.proto
package v1
@@ -514,6 +514,85 @@ func (x *EventPayloadAttributeV2) GetData() *EventPayloadAttributeV2_BasePayload
return nil
}
type EventBlobSidecar struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
BlockRoot []byte `protobuf:"bytes,1,opt,name=block_root,json=blockRoot,proto3" json:"block_root,omitempty" ssz-size:"32"`
Index uint64 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"`
Slot github_com_prysmaticlabs_prysm_v4_consensus_types_primitives.Slot `protobuf:"varint,3,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives.Slot"`
VersionedHash []byte `protobuf:"bytes,4,opt,name=versioned_hash,json=versionedHash,proto3" json:"versioned_hash,omitempty" ssz-size:"32"`
KzgCommitment []byte `protobuf:"bytes,5,opt,name=kzg_commitment,json=kzgCommitment,proto3" json:"kzg_commitment,omitempty" ssz-size:"48"`
}
func (x *EventBlobSidecar) Reset() {
*x = EventBlobSidecar{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_eth_v1_events_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EventBlobSidecar) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EventBlobSidecar) ProtoMessage() {}
func (x *EventBlobSidecar) ProtoReflect() protoreflect.Message {
mi := &file_proto_eth_v1_events_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use EventBlobSidecar.ProtoReflect.Descriptor instead.
func (*EventBlobSidecar) Descriptor() ([]byte, []int) {
return file_proto_eth_v1_events_proto_rawDescGZIP(), []int{7}
}
func (x *EventBlobSidecar) GetBlockRoot() []byte {
if x != nil {
return x.BlockRoot
}
return nil
}
func (x *EventBlobSidecar) GetIndex() uint64 {
if x != nil {
return x.Index
}
return 0
}
func (x *EventBlobSidecar) GetSlot() github_com_prysmaticlabs_prysm_v4_consensus_types_primitives.Slot {
if x != nil {
return x.Slot
}
return github_com_prysmaticlabs_prysm_v4_consensus_types_primitives.Slot(0)
}
func (x *EventBlobSidecar) GetVersionedHash() []byte {
if x != nil {
return x.VersionedHash
}
return nil
}
func (x *EventBlobSidecar) GetKzgCommitment() []byte {
if x != nil {
return x.KzgCommitment
}
return nil
}
type EventPayloadAttributeV1_BasePayloadAttribute struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -530,7 +609,7 @@ type EventPayloadAttributeV1_BasePayloadAttribute struct {
func (x *EventPayloadAttributeV1_BasePayloadAttribute) Reset() {
*x = EventPayloadAttributeV1_BasePayloadAttribute{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_eth_v1_events_proto_msgTypes[7]
mi := &file_proto_eth_v1_events_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -543,7 +622,7 @@ func (x *EventPayloadAttributeV1_BasePayloadAttribute) String() string {
func (*EventPayloadAttributeV1_BasePayloadAttribute) ProtoMessage() {}
func (x *EventPayloadAttributeV1_BasePayloadAttribute) ProtoReflect() protoreflect.Message {
mi := &file_proto_eth_v1_events_proto_msgTypes[7]
mi := &file_proto_eth_v1_events_proto_msgTypes[8]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -617,7 +696,7 @@ type EventPayloadAttributeV2_BasePayloadAttribute struct {
func (x *EventPayloadAttributeV2_BasePayloadAttribute) Reset() {
*x = EventPayloadAttributeV2_BasePayloadAttribute{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_eth_v1_events_proto_msgTypes[8]
mi := &file_proto_eth_v1_events_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -630,7 +709,7 @@ func (x *EventPayloadAttributeV2_BasePayloadAttribute) String() string {
func (*EventPayloadAttributeV2_BasePayloadAttribute) ProtoMessage() {}
func (x *EventPayloadAttributeV2_BasePayloadAttribute) ProtoReflect() protoreflect.Message {
mi := &file_proto_eth_v1_events_proto_msgTypes[8]
mi := &file_proto_eth_v1_events_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -862,15 +941,32 @@ var file_proto_eth_v1_events_proto_rawDesc = []byte{
0x6d, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x79, 0x6c,
0x6f, 0x61, 0x64, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x56, 0x32, 0x52,
0x11, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74,
0x65, 0x73, 0x42, 0x7e, 0x0a, 0x13, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65,
0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x42, 0x11, 0x42, 0x65, 0x61, 0x63, 0x6f,
0x6e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e,
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d,
0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76,
0x34, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0xaa, 0x02,
0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e, 0x56, 0x31,
0xca, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c,
0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x65, 0x73, 0x22, 0x88, 0x02, 0x0a, 0x10, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x42, 0x6c, 0x6f, 0x62,
0x53, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x12, 0x25, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b,
0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18,
0x02, 0x33, 0x32, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x14,
0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x69,
0x6e, 0x64, 0x65, 0x78, 0x12, 0x59, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01,
0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73,
0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x34, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e,
0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74,
0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x12,
0x2d, 0x0a, 0x0e, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x64, 0x5f, 0x68, 0x61, 0x73,
0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52,
0x0d, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x64, 0x48, 0x61, 0x73, 0x68, 0x12, 0x2d,
0x0a, 0x0e, 0x6b, 0x7a, 0x67, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74,
0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x34, 0x38, 0x52, 0x0d,
0x6b, 0x7a, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x7e, 0x0a,
0x13, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74,
0x68, 0x2e, 0x76, 0x31, 0x42, 0x11, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x45, 0x76, 0x65, 0x6e,
0x74, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75,
0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c,
0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x34, 0x2f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0xaa, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65,
0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0f, 0x45, 0x74,
0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x76, 0x31, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -885,7 +981,7 @@ func file_proto_eth_v1_events_proto_rawDescGZIP() []byte {
return file_proto_eth_v1_events_proto_rawDescData
}
var file_proto_eth_v1_events_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_proto_eth_v1_events_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_proto_eth_v1_events_proto_goTypes = []interface{}{
(*StreamEventsRequest)(nil), // 0: ethereum.eth.v1.StreamEventsRequest
(*EventHead)(nil), // 1: ethereum.eth.v1.EventHead
@@ -894,16 +990,17 @@ var file_proto_eth_v1_events_proto_goTypes = []interface{}{
(*EventFinalizedCheckpoint)(nil), // 4: ethereum.eth.v1.EventFinalizedCheckpoint
(*EventPayloadAttributeV1)(nil), // 5: ethereum.eth.v1.EventPayloadAttributeV1
(*EventPayloadAttributeV2)(nil), // 6: ethereum.eth.v1.EventPayloadAttributeV2
(*EventPayloadAttributeV1_BasePayloadAttribute)(nil), // 7: ethereum.eth.v1.EventPayloadAttributeV1.BasePayloadAttribute
(*EventPayloadAttributeV2_BasePayloadAttribute)(nil), // 8: ethereum.eth.v1.EventPayloadAttributeV2.BasePayloadAttribute
(*v1.PayloadAttributes)(nil), // 9: ethereum.engine.v1.PayloadAttributes
(*v1.PayloadAttributesV2)(nil), // 10: ethereum.engine.v1.PayloadAttributesV2
(*EventBlobSidecar)(nil), // 7: ethereum.eth.v1.EventBlobSidecar
(*EventPayloadAttributeV1_BasePayloadAttribute)(nil), // 8: ethereum.eth.v1.EventPayloadAttributeV1.BasePayloadAttribute
(*EventPayloadAttributeV2_BasePayloadAttribute)(nil), // 9: ethereum.eth.v1.EventPayloadAttributeV2.BasePayloadAttribute
(*v1.PayloadAttributes)(nil), // 10: ethereum.engine.v1.PayloadAttributes
(*v1.PayloadAttributesV2)(nil), // 11: ethereum.engine.v1.PayloadAttributesV2
}
var file_proto_eth_v1_events_proto_depIdxs = []int32{
7, // 0: ethereum.eth.v1.EventPayloadAttributeV1.data:type_name -> ethereum.eth.v1.EventPayloadAttributeV1.BasePayloadAttribute
8, // 1: ethereum.eth.v1.EventPayloadAttributeV2.data:type_name -> ethereum.eth.v1.EventPayloadAttributeV2.BasePayloadAttribute
9, // 2: ethereum.eth.v1.EventPayloadAttributeV1.BasePayloadAttribute.payload_attributes:type_name -> ethereum.engine.v1.PayloadAttributes
10, // 3: ethereum.eth.v1.EventPayloadAttributeV2.BasePayloadAttribute.payload_attributes:type_name -> ethereum.engine.v1.PayloadAttributesV2
8, // 0: ethereum.eth.v1.EventPayloadAttributeV1.data:type_name -> ethereum.eth.v1.EventPayloadAttributeV1.BasePayloadAttribute
9, // 1: ethereum.eth.v1.EventPayloadAttributeV2.data:type_name -> ethereum.eth.v1.EventPayloadAttributeV2.BasePayloadAttribute
10, // 2: ethereum.eth.v1.EventPayloadAttributeV1.BasePayloadAttribute.payload_attributes:type_name -> ethereum.engine.v1.PayloadAttributes
11, // 3: ethereum.eth.v1.EventPayloadAttributeV2.BasePayloadAttribute.payload_attributes:type_name -> ethereum.engine.v1.PayloadAttributesV2
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
@@ -1002,7 +1099,7 @@ func file_proto_eth_v1_events_proto_init() {
}
}
file_proto_eth_v1_events_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EventPayloadAttributeV1_BasePayloadAttribute); i {
switch v := v.(*EventBlobSidecar); i {
case 0:
return &v.state
case 1:
@@ -1014,6 +1111,18 @@ func file_proto_eth_v1_events_proto_init() {
}
}
file_proto_eth_v1_events_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EventPayloadAttributeV1_BasePayloadAttribute); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_eth_v1_events_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EventPayloadAttributeV2_BasePayloadAttribute); i {
case 0:
return &v.state
@@ -1032,7 +1141,7 @@ func file_proto_eth_v1_events_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_proto_eth_v1_events_proto_rawDesc,
NumEnums: 0,
NumMessages: 9,
NumMessages: 10,
NumExtensions: 0,
NumServices: 0,
},

View File

@@ -161,4 +161,13 @@ message EventPayloadAttributeV2 {
// 1) snake_case identifiers must be used rather than camelCase; 2) integers must be encoded as quoted decimals rather than big-endian hex.
engine.v1.PayloadAttributesV2 payload_attributes = 8;
}
}
message EventBlobSidecar {
bytes block_root = 1 [(ethereum.eth.ext.ssz_size) = "32"];
uint64 index = 2;
uint64 slot = 3 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives.Slot"];
// calculated from the kzg commitment
bytes versioned_hash = 4 [(ethereum.eth.ext.ssz_size) = "32"];
bytes kzg_commitment = 5 [(ethereum.eth.ext.ssz_size) = "48"];
}

View File

@@ -154,23 +154,31 @@ func V1Alpha1SignedBlindedBlobSidecarsToV2(sidecars []*ethpbalpha.SignedBlindedB
func V1Alpha1SignedBlobsToV2(sidecars []*ethpbalpha.SignedBlobSidecar) []*ethpbv2.SignedBlobSidecar {
result := make([]*ethpbv2.SignedBlobSidecar, len(sidecars))
for i, sc := range sidecars {
result[i] = &ethpbv2.SignedBlobSidecar{
Message: &ethpbv2.BlobSidecar{
BlockRoot: bytesutil.SafeCopyBytes(sc.Message.BlockRoot),
Index: sc.Message.Index,
Slot: sc.Message.Slot,
BlockParentRoot: bytesutil.SafeCopyBytes(sc.Message.BlockParentRoot),
ProposerIndex: sc.Message.ProposerIndex,
Blob: bytesutil.SafeCopyBytes(sc.Message.Blob),
KzgCommitment: bytesutil.SafeCopyBytes(sc.Message.KzgCommitment),
KzgProof: bytesutil.SafeCopyBytes(sc.Message.KzgProof),
},
Signature: bytesutil.SafeCopyBytes(sc.Signature),
}
result[i] = V1Alpha1SignedBlobToV2(sc)
}
return result
}
// V1Alpha1SignedBlobToV2 converts a v1alpha1 object to its v2 SignedBlobSidecar equivalent.
func V1Alpha1SignedBlobToV2(sidecar *ethpbalpha.SignedBlobSidecar) *ethpbv2.SignedBlobSidecar {
if sidecar == nil || sidecar.Message == nil {
return &ethpbv2.SignedBlobSidecar{}
}
return &ethpbv2.SignedBlobSidecar{
Message: &ethpbv2.BlobSidecar{
BlockRoot: bytesutil.SafeCopyBytes(sidecar.Message.BlockRoot),
Index: sidecar.Message.Index,
Slot: sidecar.Message.Slot,
BlockParentRoot: bytesutil.SafeCopyBytes(sidecar.Message.BlockParentRoot),
ProposerIndex: sidecar.Message.ProposerIndex,
Blob: bytesutil.SafeCopyBytes(sidecar.Message.Blob),
KzgCommitment: bytesutil.SafeCopyBytes(sidecar.Message.KzgCommitment),
KzgProof: bytesutil.SafeCopyBytes(sidecar.Message.KzgProof),
},
Signature: bytesutil.SafeCopyBytes(sidecar.Signature),
}
}
// V1Alpha1BeaconBlockDenebAndBlobsToV2 converts a v1alpha1 Deneb beacon block and blobs to a v2
// Deneb block.
func V1Alpha1BeaconBlockDenebAndBlobsToV2(v1alpha1Block *ethpbalpha.BeaconBlockAndBlobsDeneb) (*ethpbv2.BeaconBlockContentsDeneb, error) {