Skip to content

Commit

Permalink
fix: Add v2 messages
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Sep 4, 2023
1 parent 814d028 commit c0f52d8
Show file tree
Hide file tree
Showing 5 changed files with 424 additions and 252 deletions.
25 changes: 13 additions & 12 deletions pkg/cannon/event/beacon/eth/v2/proposer_slashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/google/uuid"
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/wrapperspb"
)

const (
Expand Down Expand Up @@ -67,30 +68,30 @@ func (b *BeaconBlockProposerSlashing) Process(ctx context.Context, metadata *Bea
return events, nil
}

func (b *BeaconBlockProposerSlashing) getProposerSlashings(ctx context.Context, block *spec.VersionedSignedBeaconBlock) ([]*xatuethv1.ProposerSlashing, error) {
slashings := []*xatuethv1.ProposerSlashing{}
func (b *BeaconBlockProposerSlashing) getProposerSlashings(ctx context.Context, block *spec.VersionedSignedBeaconBlock) ([]*xatuethv1.ProposerSlashingV2, error) {
slashings := []*xatuethv1.ProposerSlashingV2{}

blockSlashings, err := block.ProposerSlashings()
if err != nil {
return nil, err
}

for _, slashing := range blockSlashings {
slashings = append(slashings, &xatuethv1.ProposerSlashing{
SignedHeader_1: &xatuethv1.SignedBeaconBlockHeader{
Message: &xatuethv1.BeaconBlockHeader{
Slot: uint64(slashing.SignedHeader1.Message.Slot),
ProposerIndex: uint64(slashing.SignedHeader1.Message.ProposerIndex),
slashings = append(slashings, &xatuethv1.ProposerSlashingV2{
SignedHeader_1: &xatuethv1.SignedBeaconBlockHeaderV2{
Message: &xatuethv1.BeaconBlockHeaderV2{
Slot: wrapperspb.UInt64(uint64(slashing.SignedHeader1.Message.Slot)),
ProposerIndex: wrapperspb.UInt64(uint64(slashing.SignedHeader1.Message.ProposerIndex)),
ParentRoot: slashing.SignedHeader1.Message.ParentRoot.String(),
StateRoot: slashing.SignedHeader1.Message.StateRoot.String(),
BodyRoot: slashing.SignedHeader1.Message.BodyRoot.String(),
},
Signature: slashing.SignedHeader1.Signature.String(),
},
SignedHeader_2: &xatuethv1.SignedBeaconBlockHeader{
Message: &xatuethv1.BeaconBlockHeader{
Slot: uint64(slashing.SignedHeader2.Message.Slot),
ProposerIndex: uint64(slashing.SignedHeader2.Message.ProposerIndex),
SignedHeader_2: &xatuethv1.SignedBeaconBlockHeaderV2{
Message: &xatuethv1.BeaconBlockHeaderV2{
Slot: wrapperspb.UInt64(uint64(slashing.SignedHeader2.Message.Slot)),
ProposerIndex: wrapperspb.UInt64(uint64(slashing.SignedHeader2.Message.ProposerIndex)),
ParentRoot: slashing.SignedHeader2.Message.ParentRoot.String(),
StateRoot: slashing.SignedHeader2.Message.StateRoot.String(),
BodyRoot: slashing.SignedHeader2.Message.BodyRoot.String(),
Expand All @@ -103,7 +104,7 @@ func (b *BeaconBlockProposerSlashing) getProposerSlashings(ctx context.Context,
return slashings, nil
}

func (b *BeaconBlockProposerSlashing) createEvent(ctx context.Context, metadata *BeaconBlockMetadata, slashing *xatuethv1.ProposerSlashing) (*xatu.DecoratedEvent, error) {
func (b *BeaconBlockProposerSlashing) createEvent(ctx context.Context, metadata *BeaconBlockMetadata, slashing *xatuethv1.ProposerSlashingV2) (*xatu.DecoratedEvent, error) {
decoratedEvent := &xatu.DecoratedEvent{
Event: &xatu.Event{
Name: xatu.Event_BEACON_API_ETH_V2_BEACON_BLOCK_PROPOSER_SLASHING,
Expand Down
Loading

0 comments on commit c0f52d8

Please sign in to comment.