Skip to content
Open
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
6 changes: 6 additions & 0 deletions api/server/structs/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,12 @@ type PayloadAttestation struct {
Signature string `json:"signature"`
}

type PayloadAttestationMessage struct {
ValidatorIndex string `json:"validator_index"`
Data *PayloadAttestationData `json:"data"`
Signature string `json:"signature"`
}

type BeaconBlockBodyGloas struct {
RandaoReveal string `json:"randao_reveal"`
Eth1Data *Eth1Data `json:"eth1_data"`
Expand Down
8 changes: 8 additions & 0 deletions api/server/structs/conversions_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -2971,6 +2971,14 @@ func PayloadAttestationDataFromConsensus(d *eth.PayloadAttestationData) *Payload
}
}

func PayloadAttestationMessageFromConsensus(m *eth.PayloadAttestationMessage) *PayloadAttestationMessage {
return &PayloadAttestationMessage{
ValidatorIndex: fmt.Sprintf("%d", m.ValidatorIndex),
Data: PayloadAttestationDataFromConsensus(m.Data),
Signature: hexutil.Encode(m.Signature),
}
}

func (b *SignedBeaconBlockGloas) ToConsensus() (*eth.SignedBeaconBlockGloas, error) {
if b == nil {
return nil, errNilValue
Expand Down
5 changes: 5 additions & 0 deletions api/server/structs/endpoints_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,8 @@ type LightClientOptimisticUpdateEvent struct {
Version string `json:"version"`
Data *LightClientOptimisticUpdate `json:"data"`
}

type ExecutionPayloadAvailableEvent struct {
Slot string `json:"slot"`
BlockRoot string `json:"block_root"`
}
18 changes: 18 additions & 0 deletions beacon-chain/core/feed/operation/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ const (

// DataColumnReceived is sent after a data column has been seen after gossip validation rules.
DataColumnReceived = 12

// ExecutionPayloadBidReceived is sent after a signed execution payload bid is received from gossip or API
// that passes gossip validation on the execution_payload_bid topic.
ExecutionPayloadBidReceived = 13

// PayloadAttestationMessageReceived is sent after a payload attestation message is received
// that passes validation rules of the payload_attestation_message topic.
PayloadAttestationMessageReceived = 14
)

// UnAggregatedAttReceivedData is the data sent with UnaggregatedAttReceived events.
Expand Down Expand Up @@ -114,3 +122,13 @@ type DataColumnReceivedData struct {
BlockRoot [32]byte
KzgCommitments [][]byte
}

// ExecutionPayloadBidReceivedData is the data sent with ExecutionPayloadBidReceived events.
type ExecutionPayloadBidReceivedData struct {
SignedBid *ethpb.SignedExecutionPayloadBid
}

// PayloadAttestationMessageReceivedData is the data sent with PayloadAttestationMessageReceived events.
type PayloadAttestationMessageReceivedData struct {
PayloadAttestationMessage *ethpb.PayloadAttestationMessage
}
11 changes: 11 additions & 0 deletions beacon-chain/core/feed/state/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const (
LightClientOptimisticUpdate
// PayloadAttributes events are fired upon a missed slot or new head.
PayloadAttributes
// ExecutionPayloadAvailable is sent when the node has verified that the execution payload
// and blobs for a block are available and ready for payload attestation.
ExecutionPayloadAvailable
)

// BlockProcessedData is the data sent with BlockProcessed events.
Expand Down Expand Up @@ -72,3 +75,11 @@ type InitializedData struct {
// GenesisValidatorsRoot represents state.validators.HashTreeRoot().
GenesisValidatorsRoot []byte
}

// ExecutionPayloadAvailableData is the data sent with ExecutionPayloadAvailable events.
type ExecutionPayloadAvailableData struct {
// Slot is the slot of the block whose execution payload became available.
Slot primitives.Slot
// BlockRoot is the root of the block whose execution payload became available.
BlockRoot [32]byte
}
30 changes: 30 additions & 0 deletions beacon-chain/rpc/eth/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ const (
LightClientOptimisticUpdateTopic = "light_client_optimistic_update"
// DataColumnTopic represents a data column sidecar event topic
DataColumnTopic = "data_column_sidecar"
// ExecutionPayloadAvailableTopic represents an event indicating execution payload and blobs are available.
ExecutionPayloadAvailableTopic = "execution_payload_available"
// ExecutionPayloadBidTopic represents an event for a signed execution payload bid passing gossip validation.
ExecutionPayloadBidTopic = "execution_payload_bid"
// PayloadAttestationMessageTopic represents an event for a payload attestation message passing validation.
PayloadAttestationMessageTopic = "payload_attestation_message"
)

var (
Expand Down Expand Up @@ -108,6 +114,8 @@ var opsFeedEventTopics = map[feed.EventType]string{
operation.ProposerSlashingReceived: ProposerSlashingTopic,
operation.BlockGossipReceived: BlockGossipTopic,
operation.DataColumnReceived: DataColumnTopic,
operation.ExecutionPayloadBidReceived: ExecutionPayloadBidTopic,
operation.PayloadAttestationMessageReceived: PayloadAttestationMessageTopic,
}

var stateFeedEventTopics = map[feed.EventType]string{
Expand All @@ -118,6 +126,7 @@ var stateFeedEventTopics = map[feed.EventType]string{
statefeed.Reorg: ChainReorgTopic,
statefeed.BlockProcessed: BlockTopic,
statefeed.PayloadAttributes: PayloadAttributesTopic,
statefeed.ExecutionPayloadAvailable: ExecutionPayloadAvailableTopic,
}

var topicsForStateFeed = topicsForFeed(stateFeedEventTopics)
Expand Down Expand Up @@ -466,6 +475,12 @@ func topicForEvent(event *feed.Event) string {
return PayloadAttributesTopic
case *operation.DataColumnReceivedData:
return DataColumnTopic
case *operation.ExecutionPayloadBidReceivedData:
return ExecutionPayloadBidTopic
case *operation.PayloadAttestationMessageReceivedData:
return PayloadAttestationMessageTopic
case *statefeed.ExecutionPayloadAvailableData:
return ExecutionPayloadAvailableTopic
default:
return InvalidTopic
}
Expand Down Expand Up @@ -638,6 +653,21 @@ func (s *Server) lazyReaderForEvent(ctx context.Context, event *feed.Event, topi
}
return jsonMarshalReader(eventName, blk)
}, nil
case *statefeed.ExecutionPayloadAvailableData:
return func() io.Reader {
return jsonMarshalReader(eventName, &structs.ExecutionPayloadAvailableEvent{
Slot: fmt.Sprintf("%d", v.Slot),
BlockRoot: hexutil.Encode(v.BlockRoot[:]),
})
}, nil
case *operation.ExecutionPayloadBidReceivedData:
return func() io.Reader {
return jsonMarshalReader(eventName, structs.SignedExecutionPayloadBidFromConsensus(v.SignedBid))
}, nil
case *operation.PayloadAttestationMessageReceivedData:
return func() io.Reader {
return jsonMarshalReader(eventName, structs.PayloadAttestationMessageFromConsensus(v.PayloadAttestationMessage))
}, nil
default:
return nil, errors.Wrapf(errUnhandledEventData, "event data type %T unsupported", v)
}
Expand Down
48 changes: 47 additions & 1 deletion beacon-chain/rpc/eth/events/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ func operationEventsFixtures(t *testing.T) (*topicRequest, []*feed.Event) {
ProposerSlashingTopic,
BlockGossipTopic,
DataColumnTopic,
ExecutionPayloadBidTopic,
PayloadAttestationMessageTopic,
})
require.NoError(t, err)
ro, err := blocks.NewROBlob(util.HydrateBlobSidecar(&eth.BlobSidecar{}))
Expand Down Expand Up @@ -312,6 +314,42 @@ func operationEventsFixtures(t *testing.T) (*topicRequest, []*feed.Event) {
KzgCommitments: [][]byte{{'a'}, {'b'}, {'c'}},
},
},
{
Type: operation.ExecutionPayloadBidReceived,
Data: &operation.ExecutionPayloadBidReceivedData{
SignedBid: &eth.SignedExecutionPayloadBid{
Message: &eth.ExecutionPayloadBid{
ParentBlockHash: make([]byte, 32),
ParentBlockRoot: make([]byte, 32),
BlockHash: make([]byte, 32),
PrevRandao: make([]byte, 32),
FeeRecipient: make([]byte, 20),
GasLimit: 30000000,
BuilderIndex: 42,
Slot: 10,
Value: 1000000000,
ExecutionPayment: 0,
BlobKzgCommitmentsRoot: make([]byte, 32),
},
Signature: make([]byte, 96),
},
},
},
{
Type: operation.PayloadAttestationMessageReceived,
Data: &operation.PayloadAttestationMessageReceivedData{
PayloadAttestationMessage: &eth.PayloadAttestationMessage{
ValidatorIndex: 123,
Data: &eth.PayloadAttestationData{
BeaconBlockRoot: make([]byte, 32),
Slot: 10,
PayloadPresent: true,
BlobDataAvailable: true,
},
Signature: make([]byte, 96),
},
},
},
}
}

Expand Down Expand Up @@ -393,6 +431,7 @@ func TestStreamEvents_OperationsEvents(t *testing.T) {
FinalizedCheckpointTopic,
ChainReorgTopic,
BlockTopic,
ExecutionPayloadAvailableTopic,
})
require.NoError(t, err)
request := topics.testHttpRequest(testSync.ctx, t)
Expand Down Expand Up @@ -445,6 +484,13 @@ func TestStreamEvents_OperationsEvents(t *testing.T) {
ExecutionOptimistic: false,
},
},
{
Type: statefeed.ExecutionPayloadAvailable,
Data: &statefeed.ExecutionPayloadAvailableData{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the api pr says slot and blockroot is all that is needed, should we suggest any other fields?

Slot: 10,
BlockRoot: [32]byte{0x9a},
},
},
}

go func() {
Expand Down Expand Up @@ -721,7 +767,7 @@ func TestStuckReaderScenarios(t *testing.T) {

func wedgedWriterTestCase(t *testing.T, queueDepth func([]*feed.Event) int) {
topics, events := operationEventsFixtures(t)
require.Equal(t, 12, len(events))
require.Equal(t, 14, len(events))

// set eventFeedDepth to a number lower than the events we intend to send to force the server to drop the reader.
stn := mockChain.NewEventFeedWrapper()
Expand Down
3 changes: 3 additions & 0 deletions changelog/james-prysm_gloas-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Added

- the following events available at gloas `execution_payload_available`, `execution_payload_bid`,and `payload_attestation_message`
Loading