Skip to content

Commit 67c648b

Browse files
nisdasnalepae
authored andcommitted
Add Data Column Gossip Handlers (#13894)
* Add Data Column Subscriber * Add Data Column Vaidator * Wire all Handlers In * Fix Build * Fix Test * Fix IP in Test * Fix IP in Test
1 parent 76cf2c3 commit 67c648b

File tree

15 files changed

+348
-11
lines changed

15 files changed

+348
-11
lines changed

beacon-chain/blockchain/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ go_library(
2626
"receive_attestation.go",
2727
"receive_blob.go",
2828
"receive_block.go",
29+
"receive_sidecar.go",
2930
"service.go",
3031
"tracked_proposer.go",
3132
"weak_subjectivity_checks.go",

beacon-chain/blockchain/receive_block.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ type BlobReceiver interface {
5050
ReceiveBlob(context.Context, blocks.VerifiedROBlob) error
5151
}
5252

53+
// DataColumnReceiver interface defines the methods of chain service for receiving new
54+
// data columns
55+
type DataColumnReceiver interface {
56+
ReceiveDataColumn(context.Context, *ethpb.DataColumnSidecar) error
57+
}
58+
5359
// SlashingReceiver interface defines the methods of chain service for receiving validated slashing over the wire.
5460
type SlashingReceiver interface {
5561
ReceiveAttesterSlashing(ctx context.Context, slashing ethpb.AttSlashing)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package blockchain
2+
3+
import (
4+
"context"
5+
6+
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
7+
)
8+
9+
func (s *Service) ReceiveDataColumn(ctx context.Context, ds *ethpb.DataColumnSidecar) error {
10+
// TODO
11+
return nil
12+
}

beacon-chain/blockchain/testing/mock.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,11 @@ func (c *ChainService) ReceiveBlob(_ context.Context, b blocks.VerifiedROBlob) e
628628
return nil
629629
}
630630

631+
// ReceiveDataColumn implements the same method in chain service
632+
func (c *ChainService) ReceiveDataColumn(_ context.Context, _ *ethpb.DataColumnSidecar) error {
633+
return nil
634+
}
635+
631636
// TargetRootForEpoch mocks the same method in the chain service
632637
func (c *ChainService) TargetRootForEpoch(_ [32]byte, _ primitives.Epoch) ([32]byte, error) {
633638
return c.TargetRoot, nil

beacon-chain/core/blocks/signature.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,24 @@ func VerifyBlockHeaderSignature(beaconState state.BeaconState, header *ethpb.Sig
9696
return signing.VerifyBlockHeaderSigningRoot(header.Header, proposerPubKey, header.Signature, domain)
9797
}
9898

99+
func VerifyBlockHeaderSignatureUsingCurrentFork(beaconState state.BeaconState, header *ethpb.SignedBeaconBlockHeader) error {
100+
currentEpoch := slots.ToEpoch(header.Header.Slot)
101+
fork, err := forks.Fork(currentEpoch)
102+
if err != nil {
103+
return err
104+
}
105+
domain, err := signing.Domain(fork, currentEpoch, params.BeaconConfig().DomainBeaconProposer, beaconState.GenesisValidatorsRoot())
106+
if err != nil {
107+
return err
108+
}
109+
proposer, err := beaconState.ValidatorAtIndex(header.Header.ProposerIndex)
110+
if err != nil {
111+
return err
112+
}
113+
proposerPubKey := proposer.PublicKey
114+
return signing.VerifyBlockHeaderSigningRoot(header.Header, proposerPubKey, header.Signature, domain)
115+
}
116+
99117
// VerifyBlockSignatureUsingCurrentFork verifies the proposer signature of a beacon block. This differs
100118
// from the above method by not using fork data from the state and instead retrieving it
101119
// via the respective epoch.

beacon-chain/core/feed/operation/events.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ const (
3232

3333
// AttesterSlashingReceived is sent after an attester slashing is received from gossip or rpc
3434
AttesterSlashingReceived = 8
35+
36+
// DataColumnSidecarReceived is sent after a data column sidecar is received from gossip or rpc.
37+
DataColumnSidecarReceived = 9
3538
)
3639

3740
// UnAggregatedAttReceivedData is the data sent with UnaggregatedAttReceived events.
@@ -77,3 +80,7 @@ type ProposerSlashingReceivedData struct {
7780
type AttesterSlashingReceivedData struct {
7881
AttesterSlashing ethpb.AttSlashing
7982
}
83+
84+
type DataColumnSidecarReceivedData struct {
85+
DataColumn *ethpb.DataColumnSidecar
86+
}

beacon-chain/p2p/gossip_topic_mappings.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var gossipTopicMappings = map[string]proto.Message{
2222
SyncCommitteeSubnetTopicFormat: &ethpb.SyncCommitteeMessage{},
2323
BlsToExecutionChangeSubnetTopicFormat: &ethpb.SignedBLSToExecutionChange{},
2424
BlobSubnetTopicFormat: &ethpb.BlobSidecar{},
25+
DataColumnSubnetTopicFormat: &ethpb.DataColumnSidecar{},
2526
}
2627

2728
// GossipTopicMappings is a function to return the assigned data type

beacon-chain/p2p/pubsub_filter_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func TestService_CanSubscribe(t *testing.T) {
9090
formatting := []interface{}{digest}
9191

9292
// Special case for attestation subnets which have a second formatting placeholder.
93-
if topic == AttestationSubnetTopicFormat || topic == SyncCommitteeSubnetTopicFormat || topic == BlobSubnetTopicFormat {
93+
if topic == AttestationSubnetTopicFormat || topic == SyncCommitteeSubnetTopicFormat || topic == BlobSubnetTopicFormat || topic == DataColumnSubnetTopicFormat {
9494
formatting = append(formatting, 0 /* some subnet ID */)
9595
}
9696

beacon-chain/p2p/topics.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ const (
3030
GossipBlsToExecutionChangeMessage = "bls_to_execution_change"
3131
// GossipBlobSidecarMessage is the name for the blob sidecar message type.
3232
GossipBlobSidecarMessage = "blob_sidecar"
33+
// GossipDataColumnSidecarMessage is the name for the data column sidecar message type.
34+
GossipDataColumnSidecarMessage = "data_column_sidecar"
35+
3336
// Topic Formats
3437
//
3538
// AttestationSubnetTopicFormat is the topic format for the attestation subnet.
@@ -52,4 +55,6 @@ const (
5255
BlsToExecutionChangeSubnetTopicFormat = GossipProtocolAndDigest + GossipBlsToExecutionChangeMessage
5356
// BlobSubnetTopicFormat is the topic format for the blob subnet.
5457
BlobSubnetTopicFormat = GossipProtocolAndDigest + GossipBlobSidecarMessage + "_%d"
58+
// DataColumnSubnetTopicFormat is the topic format for the data column subnet.
59+
DataColumnSubnetTopicFormat = GossipProtocolAndDigest + GossipDataColumnSidecarMessage + "_%d"
5560
)

beacon-chain/sync/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ go_library(
3737
"subscriber_beacon_blocks.go",
3838
"subscriber_blob_sidecar.go",
3939
"subscriber_bls_to_execution_change.go",
40+
"subscriber_data_column_sidecar.go",
4041
"subscriber_handlers.go",
4142
"subscriber_sync_committee_message.go",
4243
"subscriber_sync_contribution_proof.go",
@@ -47,6 +48,7 @@ go_library(
4748
"validate_beacon_blocks.go",
4849
"validate_blob.go",
4950
"validate_bls_to_execution_change.go",
51+
"validate_data_column_sidecar.go",
5052
"validate_proposer_slashing.go",
5153
"validate_sync_committee_message.go",
5254
"validate_sync_contribution_proof.go",

0 commit comments

Comments
 (0)