Skip to content

Commit

Permalink
feat: Support for new deneb blob sidecare structure (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm authored Nov 30, 2023
1 parent c5b7238 commit 4aa4a93
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ server.yaml
discovery.yaml
mimicry.yaml
cannon.yaml
seer.yaml
dist
GeoLite2-ASN.mmdb
GeoLite2-City.mmdb
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ go 1.19

require (
github.com/IBM/sarama v1.41.2
github.com/attestantio/go-eth2-client v0.18.4-0.20231012194602-0eff364fec01
github.com/attestantio/go-eth2-client v0.19.5
github.com/avast/retry-go/v4 v4.3.4
github.com/beevik/ntp v1.0.0
github.com/cenkalti/backoff/v4 v4.2.1
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9
github.com/creasty/defaults v1.7.0
github.com/ethereum/go-ethereum v1.12.0
github.com/ethpandaops/beacon v0.31.0
github.com/ethpandaops/beacon v0.32.0
github.com/ethpandaops/ethcore v0.0.0-20230804013106-6453c36c8c30
github.com/ethpandaops/ethwallclock v0.3.0
github.com/go-co-op/gocron v1.27.1
Expand Down Expand Up @@ -77,6 +77,7 @@ require (
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.2.3 // indirect
github.com/huandu/go-clone v1.6.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/huin/goupnp v1.2.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand Down
9 changes: 5 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bw
github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/attestantio/go-eth2-client v0.18.4-0.20231012194602-0eff364fec01 h1:KSfIKKL501RgHJrQIoS+0OpJuG3pFi2o5wKPrHkcs5M=
github.com/attestantio/go-eth2-client v0.18.4-0.20231012194602-0eff364fec01/go.mod h1:KSVlZSW1A3jUg5H8O89DLtqxgJprRfTtI7k89fLdhu0=
github.com/attestantio/go-eth2-client v0.19.5 h1:4V+vhXsCYji5jWrlONbr03GV7qoLRdzq96dLgXaqmek=
github.com/attestantio/go-eth2-client v0.19.5/go.mod h1:mZve1kV9Ctj0I1HH9gdg+MnI8lZ+Cb2EktEtOYrBlsM=
github.com/avast/retry-go/v4 v4.3.4 h1:pHLkL7jvCvP317I8Ge+Km2Yhntv3SdkJm7uekkqbKhM=
github.com/avast/retry-go/v4 v4.3.4/go.mod h1:rv+Nla6Vk3/ilU0H51VHddWHiwimzX66yZ0JT6T+UvE=
github.com/beevik/ntp v1.0.0 h1:d0Lgy1xbNNqVyGfvg2Z96ItKcfyn3lzgus/oRoj9vnk=
Expand Down Expand Up @@ -59,8 +59,8 @@ github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
github.com/ethereum/go-ethereum v1.12.0 h1:bdnhLPtqETd4m3mS8BGMNvBTf36bO5bx/hxE2zljOa0=
github.com/ethereum/go-ethereum v1.12.0/go.mod h1:/oo2X/dZLJjf2mJ6YT9wcWxa4nNJDBKDBU6sFIpx1Gs=
github.com/ethpandaops/beacon v0.31.0 h1:jD5zSeQNv35nfPuT6Qxx/5XwNhlHAWzO1m4Ux8FuRzI=
github.com/ethpandaops/beacon v0.31.0/go.mod h1:8guusdkbrF/TrO8IzjXvl6YRtoW2zgYga9ZWBrrYMqE=
github.com/ethpandaops/beacon v0.32.0 h1:D6XwiMrBwsfQxc1Zygo54m9XMlJKbVtZI6ybscI6CfU=
github.com/ethpandaops/beacon v0.32.0/go.mod h1:LK9PmXlmBMMv5BIsIIPSWaHQ2ZunRK4xyEjrUZxLKvc=
github.com/ethpandaops/ethcore v0.0.0-20230804013106-6453c36c8c30 h1:xziHHIPT9iHoocM91UXwxICQoF121cdfontVAFwtapM=
github.com/ethpandaops/ethcore v0.0.0-20230804013106-6453c36c8c30/go.mod h1:5UfUQ+9IBe1iZsk3KBoF/jtnRv7WVnMjebik4EW6ULE=
github.com/ethpandaops/ethwallclock v0.3.0 h1:xF5fwtBf+bHFHZKBnwiPFEuelW3sMM7SD3ZNFq1lJY4=
Expand Down Expand Up @@ -147,6 +147,7 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c=
github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U=
github.com/huandu/go-clone v1.6.0 h1:HMo5uvg4wgfiy5FoGOqlFLQED/VGRm2D9Pi8g1FXPGc=
github.com/huandu/go-clone v1.6.0/go.mod h1:ReGivhG6op3GYr+UY3lS6mxjKp7MIGTknuU5TbTVaXE=
github.com/huandu/go-clone/generic v1.6.0 h1:Wgmt/fUZ28r16F2Y3APotFD59sHk1p78K0XLdbUYN5U=
github.com/huandu/go-sqlbuilder v1.21.0 h1:+NLH8PQg5/WGMXJLIpAXTdoH1pv9Q3BU6w4P7OabBmc=
github.com/huandu/go-sqlbuilder v1.21.0/go.mod h1:nUVmMitjOmn/zacMLXT0d3Yd3RHoO2K+vy906JzqxMI=
Expand Down
31 changes: 21 additions & 10 deletions pkg/cannon/deriver/beacon/eth/v1/beacon_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"time"

"github.com/attestantio/go-eth2-client/api"
"github.com/attestantio/go-eth2-client/spec/deneb"
"github.com/attestantio/go-eth2-client/spec/phase0"
backoff "github.com/cenkalti/backoff/v4"
Expand Down Expand Up @@ -193,6 +194,16 @@ func (b *BeaconBlobDeriver) processSlot(ctx context.Context, slot phase0.Slot) (
// Get the block
blobs, err := b.beacon.Node().FetchBeaconBlockBlobs(ctx, xatuethv1.SlotAsString(slot))
if err != nil {
var apiErr *api.Error
if errors.As(err, &apiErr) {
switch apiErr.StatusCode {
case 404:
return []*xatu.DecoratedEvent{}, nil
case 503:
return nil, errors.New("beacon node is syncing")
}
}

return nil, errors.Wrapf(err, "failed to get beacon block for slot %d", slot)
}

Expand Down Expand Up @@ -232,14 +243,14 @@ func (b *BeaconBlobDeriver) createEventFromBlob(ctx context.Context, blob *deneb
},
Data: &xatu.DecoratedEvent_EthV1BeaconBlockBlobSidecar{
EthV1BeaconBlockBlobSidecar: &xatuethv1.BlobSidecar{
Slot: &wrapperspb.UInt64Value{Value: uint64(blob.Slot)},
Slot: &wrapperspb.UInt64Value{Value: uint64(blob.SignedBlockHeader.Message.Slot)},
Blob: fmt.Sprintf("0x%s", hex.EncodeToString(blob.Blob[:])),
Index: &wrapperspb.UInt64Value{Value: uint64(blob.Index)},
BlockRoot: blob.BlockRoot.String(),
BlockParentRoot: blob.BlockParentRoot.String(),
ProposerIndex: &wrapperspb.UInt64Value{Value: uint64(blob.ProposerIndex)},
KzgCommitment: blob.KzgCommitment.String(),
KzgProof: blob.KzgProof.String(),
BlockRoot: blob.SignedBlockHeader.Message.BodyRoot.String(),
BlockParentRoot: blob.SignedBlockHeader.Message.ParentRoot.String(),
ProposerIndex: &wrapperspb.UInt64Value{Value: uint64(blob.SignedBlockHeader.Message.ProposerIndex)},
KzgCommitment: blob.KZGCommitment.String(),
KzgProof: blob.KZGProof.String(),
},
},
}
Expand All @@ -261,15 +272,15 @@ func (b *BeaconBlobDeriver) createEventFromBlob(ctx context.Context, blob *deneb
func (b *BeaconBlobDeriver) getAdditionalData(_ context.Context, blob *deneb.BlobSidecar) (*xatu.ClientMeta_AdditionalEthV1BeaconBlobSidecarData, error) {
extra := &xatu.ClientMeta_AdditionalEthV1BeaconBlobSidecarData{
DataSize: &wrapperspb.UInt64Value{Value: uint64(len(blob.Blob))},
VersionedHash: ethereum.ConvertKzgCommitmentToVersionedHash(blob.KzgCommitment[:]).String(),
VersionedHash: ethereum.ConvertKzgCommitmentToVersionedHash(blob.KZGCommitment[:]).String(),
}

slot := b.beacon.Metadata().Wallclock().Slots().FromNumber(uint64(blob.Slot))
epoch := b.beacon.Metadata().Wallclock().Epochs().FromSlot(uint64(blob.Slot))
slot := b.beacon.Metadata().Wallclock().Slots().FromNumber(uint64(blob.SignedBlockHeader.Message.Slot))
epoch := b.beacon.Metadata().Wallclock().Epochs().FromSlot(uint64(blob.SignedBlockHeader.Message.Slot))

extra.Slot = &xatu.SlotV2{
StartDateTime: timestamppb.New(slot.TimeWindow().Start()),
Number: &wrapperspb.UInt64Value{Value: uint64(blob.Slot)},
Number: &wrapperspb.UInt64Value{Value: uint64(blob.SignedBlockHeader.Message.Slot)},
}

extra.Epoch = &xatu.EpochV2{
Expand Down
2 changes: 1 addition & 1 deletion pkg/proto/eth/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func NewEventBlockFromCapella(block *spec.VersionedSignedBeaconBlock) *v2.EventB
func NewEventBlockFromDeneb(block *spec.VersionedSignedBeaconBlock) *v2.EventBlockV2 {
kzgCommitments := []string{}

for _, commitment := range block.Deneb.Message.Body.BlobKzgCommitments {
for _, commitment := range block.Deneb.Message.Body.BlobKZGCommitments {
kzgCommitments = append(kzgCommitments, commitment.String())
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/proto/eth/v1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func BLSSignatureToString(s *phase0.BLSSignature) string {
return fmt.Sprintf("%#x", s)
}

func KzgCommitmentToString(c deneb.KzgCommitment) string {
func KzgCommitmentToString(c deneb.KZGCommitment) string {
return fmt.Sprintf("%#x", c)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/sentry/event/beacon/eth/v1/events_blob_sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (e *EventsBlobSidecar) Decorate(ctx context.Context) (*xatu.DecoratedEvent,
BlockRoot: xatuethv1.RootAsString(e.event.BlockRoot),
Slot: &wrapperspb.UInt64Value{Value: uint64(e.event.Slot)},
Index: &wrapperspb.UInt64Value{Value: uint64(e.event.Index)},
KzgCommitment: xatuethv1.KzgCommitmentToString(e.event.KzgCommitment),
KzgCommitment: xatuethv1.KzgCommitmentToString(e.event.KZGCommitment),
VersionedHash: xatuethv1.VersionedHashToString(e.event.VersionedHash),
},
},
Expand Down

0 comments on commit 4aa4a93

Please sign in to comment.