Skip to content

Commit

Permalink
feat: Add support for Electra block in beacon block processing
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Sep 26, 2024
1 parent 8b75f71 commit af2b04e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
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/spec"
v2 "github.com/ethpandaops/xatu/pkg/proto/eth/v2"
"github.com/ethpandaops/xatu/pkg/proto/xatu"
"github.com/ethpandaops/xatu/pkg/server/store"
Expand Down Expand Up @@ -69,21 +70,24 @@ func (b *BeaconBlock) Filter(ctx context.Context) bool {
var hash string

switch version {
case "phase0":
case spec.DataVersionPhase0.String():
//nolint:staticcheck // Handled by v2
hash = data.EthV2BeaconBlock.Message.(*v2.EventBlock_Phase0Block).Phase0Block.StateRoot
case "altair":
case spec.DataVersionAltair.String():
//nolint:staticcheck // Handled by v2
hash = data.EthV2BeaconBlock.Message.(*v2.EventBlock_AltairBlock).AltairBlock.StateRoot
case "bellatrix":
case spec.DataVersionBellatrix.String():
//nolint:staticcheck // Handled by v2
hash = data.EthV2BeaconBlock.Message.(*v2.EventBlock_BellatrixBlock).BellatrixBlock.StateRoot
case "capella":
case spec.DataVersionCapella.String():
//nolint:staticcheck // Handled by v2
hash = data.EthV2BeaconBlock.Message.(*v2.EventBlock_CapellaBlock).CapellaBlock.StateRoot
case "deneb":
case spec.DataVersionDeneb.String():
//nolint:staticcheck // Handled by v2
hash = data.EthV2BeaconBlock.Message.(*v2.EventBlock_DenebBlock).DenebBlock.StateRoot
case spec.DataVersionElectra.String():
//nolint:staticcheck // Handled by v2
hash = data.EthV2BeaconBlock.Message.(*v2.EventBlock_ElectraBlock).ElectraBlock.StateRoot
default:
b.log.Error(fmt.Errorf("unknown version: %s", version))

Expand Down
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/spec"
v2 "github.com/ethpandaops/xatu/pkg/proto/eth/v2"
"github.com/ethpandaops/xatu/pkg/proto/xatu"
"github.com/ethpandaops/xatu/pkg/server/store"
Expand Down Expand Up @@ -72,16 +73,18 @@ func (b *BeaconBlockV2) Filter(ctx context.Context) bool {
var hash string

switch version {
case "phase0":
case spec.DataVersionPhase0.String():
hash = data.EthV2BeaconBlockV2.Message.(*v2.EventBlockV2_Phase0Block).Phase0Block.StateRoot
case "altair":
case spec.DataVersionAltair.String():
hash = data.EthV2BeaconBlockV2.Message.(*v2.EventBlockV2_AltairBlock).AltairBlock.StateRoot
case "bellatrix":
case spec.DataVersionBellatrix.String():
hash = data.EthV2BeaconBlockV2.Message.(*v2.EventBlockV2_BellatrixBlock).BellatrixBlock.StateRoot
case "capella":
case spec.DataVersionCapella.String():
hash = data.EthV2BeaconBlockV2.Message.(*v2.EventBlockV2_CapellaBlock).CapellaBlock.StateRoot
case "deneb":
case spec.DataVersionDeneb.String():
hash = data.EthV2BeaconBlockV2.Message.(*v2.EventBlockV2_DenebBlock).DenebBlock.StateRoot
case spec.DataVersionElectra.String():
hash = data.EthV2BeaconBlockV2.Message.(*v2.EventBlockV2_ElectraBlock).ElectraBlock.StateRoot
default:
b.log.Error(fmt.Errorf("unknown version: %s", version))

Expand Down

0 comments on commit af2b04e

Please sign in to comment.