Skip to content

Commit

Permalink
feat: Add function to create epoch defaults from fork epochs
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Dec 3, 2024
1 parent 590acb7 commit 8e5ccae
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions pkg/cannon/iterator/epoch_defaults.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package iterator

import (
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/ethpandaops/beacon/pkg/beacon/state"
"github.com/ethpandaops/xatu/pkg/proto/xatu"
)

func NewEpochDefaultsFromForkEpochs(forkEpochs state.ForkEpochs) map[xatu.CannonType]phase0.Epoch {
var (
bellatrixEpoch,
capellaEpoch,
denebEpoch phase0.Epoch
)

bellatrix, err := forkEpochs.GetByName(spec.DataVersionBellatrix.String())
if err == nil {
bellatrixEpoch = bellatrix.Epoch
}

capella, err := forkEpochs.GetByName(spec.DataVersionCapella.String())
if err == nil {
capellaEpoch = capella.Epoch
}

deneb, err := forkEpochs.GetByName(spec.DataVersionDeneb.String())
if err == nil {
denebEpoch = deneb.Epoch
}

return map[xatu.CannonType]phase0.Epoch{
xatu.CannonType_BEACON_API_ETH_V2_BEACON_BLOCK_BLS_TO_EXECUTION_CHANGE: capellaEpoch,
xatu.CannonType_BEACON_API_ETH_V2_BEACON_BLOCK_WITHDRAWAL: capellaEpoch,
xatu.CannonType_BEACON_API_ETH_V2_BEACON_BLOCK_EXECUTION_TRANSACTION: bellatrixEpoch,
xatu.CannonType_BEACON_API_ETH_V1_BEACON_BLOB_SIDECAR: denebEpoch,
}
}

0 comments on commit 8e5ccae

Please sign in to comment.