Skip to content
Merged
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
2 changes: 1 addition & 1 deletion relayer/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func Build() {
}

func BuildMain() error {
err := sh.Run("sszgen", "--path", "relays/beacon/state", "--objs", "BlockRootsContainerMainnet,TransactionsRootContainer,WithdrawalsRootContainerMainnet,BeaconStateDenebMainnet,BeaconBlockDenebMainnet,SignedBeaconBlockDeneb,SignedBeaconBlockElectra,BeaconStateElectra,BeaconBlockElectra")
err := sh.Run("sszgen", "--path", "relays/beacon/state", "--objs", "BlockRootsContainerMainnet,TransactionsRootContainer,WithdrawalsRootContainerMainnet,BeaconStateDenebMainnet,BeaconBlockDenebMainnet,SignedBeaconBlockDeneb,SignedBeaconBlockElectra,BeaconStateElectra,BeaconBlockElectra,BeaconStateFulu")
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions relayer/relays/beacon/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type SpecSettings struct {
type ForkVersions struct {
Deneb uint64 `mapstructure:"deneb"`
Electra uint64 `mapstructure:"electra"`
Fulu uint64 `mapstructure:"fulu"`
}

type SourceConfig struct {
Expand Down
33 changes: 13 additions & 20 deletions relayer/relays/beacon/header/header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ func TestSyncInterimFinalizedUpdate_WithDataFromAPI(t *testing.T) {
settings := config.SpecSettings{
SlotsInEpoch: 32,
EpochsPerSyncCommitteePeriod: 256,
ForkVersions: config.ForkVersions{
Deneb: 0,
Electra: 800000,
},
ForkVersions: getForkVersions(),
}
p := protocol.New(settings, MaxRedundancy)
client := mock.API{}
Expand Down Expand Up @@ -84,10 +81,7 @@ func TestSyncInterimFinalizedUpdate_WithDataFromStore(t *testing.T) {
settings := config.SpecSettings{
SlotsInEpoch: 32,
EpochsPerSyncCommitteePeriod: 256,
ForkVersions: config.ForkVersions{
Deneb: 0,
Electra: 800000,
},
ForkVersions: getForkVersions(),
}
p := protocol.New(settings, MaxRedundancy)
client := mock.API{}
Expand Down Expand Up @@ -153,10 +147,7 @@ func TestSyncInterimFinalizedUpdate_WithDataFromStoreWithDifferentBlocks(t *test
settings := config.SpecSettings{
SlotsInEpoch: 32,
EpochsPerSyncCommitteePeriod: 256,
ForkVersions: config.ForkVersions{
Deneb: 0,
Electra: 800000,
},
ForkVersions: getForkVersions(),
}
p := protocol.New(settings, MaxRedundancy)
client := mock.API{}
Expand Down Expand Up @@ -222,10 +213,7 @@ func TestSyncInterimFinalizedUpdate_BeaconStateNotAvailableInAPIAndStore(t *test
settings := config.SpecSettings{
SlotsInEpoch: 32,
EpochsPerSyncCommitteePeriod: 256,
ForkVersions: config.ForkVersions{
Deneb: 0,
Electra: 800000,
},
ForkVersions: getForkVersions(),
}
p := protocol.New(settings, MaxRedundancy)
client := mock.API{}
Expand Down Expand Up @@ -269,10 +257,7 @@ func TestSyncInterimFinalizedUpdate_NoValidBlocksFound(t *testing.T) {
settings := config.SpecSettings{
SlotsInEpoch: 32,
EpochsPerSyncCommitteePeriod: 256,
ForkVersions: config.ForkVersions{
Deneb: 0,
Electra: 800000,
},
ForkVersions: getForkVersions(),
}
p := protocol.New(settings, MaxRedundancy)
client := mock.API{}
Expand Down Expand Up @@ -440,3 +425,11 @@ func TestFindLatestCheckPoint(t *testing.T) {
assert.Equal(t, headerIndex4, header.BeaconBlockRoot)
assert.Equal(t, uint64(46), header.BeaconSlot)
}

func getForkVersions() config.ForkVersions {
return config.ForkVersions{
Deneb: 0,
Electra: 800000,
Fulu: 1000000,
}
}
10 changes: 7 additions & 3 deletions relayer/relays/beacon/header/syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,9 @@ func (s *Syncer) GetBlockRoots(slot uint64) (scale.BlockRootProof, error) {
forkVersion := s.protocol.ForkVersion(slot)

blockRootsContainer = &state.BlockRootsContainerMainnet{}
if forkVersion == protocol.Electra {
if forkVersion == protocol.Fulu {
beaconState = &state.BeaconStateFulu{}
} else if forkVersion == protocol.Electra {
beaconState = &state.BeaconStateElectra{}
} else {
beaconState = &state.BeaconStateDenebMainnet{}
Expand Down Expand Up @@ -557,7 +559,7 @@ func (s *Syncer) GetHeaderUpdate(blockRoot common.Hash, checkpoint *cache.Proof)

var signedBlock state.SignedBeaconBlock
forkVersion := s.protocol.ForkVersion(slot)
if forkVersion == protocol.Electra {
if forkVersion == protocol.Fulu || forkVersion == protocol.Electra {
signedBlock = &state.SignedBeaconBlockElectra{}
} else {
signedBlock = &state.SignedBeaconBlockDeneb{}
Expand Down Expand Up @@ -635,7 +637,9 @@ func (s *Syncer) getBeaconStateAtSlot(slot uint64) (state.BeaconState, error) {
func (s *Syncer) UnmarshalBeaconState(slot uint64, data []byte) (state.BeaconState, error) {
var beaconState state.BeaconState
forkVersion := s.protocol.ForkVersion(slot)
if forkVersion == protocol.Electra {
if forkVersion == protocol.Fulu {
beaconState = &state.BeaconStateFulu{}
} else if forkVersion == protocol.Electra {
beaconState = &state.BeaconStateElectra{}
} else {
beaconState = &state.BeaconStateDenebMainnet{}
Expand Down
25 changes: 18 additions & 7 deletions relayer/relays/beacon/protocol/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,46 +81,57 @@ type ForkVersion string
const (
Deneb ForkVersion = "Deneb"
Electra ForkVersion = "Electra"
Fulu ForkVersion = "Fulu"
)

func (p *Protocol) ForkVersion(slot uint64) ForkVersion {
epoch := p.ComputeEpochAtSlot(slot)
fv := Deneb
if epoch >= p.Settings.ForkVersions.Electra {
return Electra
fv = Electra
}
return Deneb
if epoch >= p.Settings.ForkVersions.Fulu {
fv = Fulu
}
log.WithField("fork_version", fv).Info("Found fork version")
return fv
}

func (p *Protocol) BlockRootGeneralizedIndex(slot uint64) int {
if p.ForkVersion(slot) == Electra {
forkVersion := p.ForkVersion(slot)
if forkVersion == Fulu || forkVersion == Electra {
return ElectraBlockRootGeneralizedIndex
}
return AltairBlockRootGeneralizedIndex
}

func (p *Protocol) FinalizedCheckpointGeneralizedIndex(slot uint64) int {
if p.ForkVersion(slot) == Electra {
forkVersion := p.ForkVersion(slot)
if forkVersion == Fulu || forkVersion == Electra {
return ElectraFinalizedCheckpointGeneralizedIndex
}
return AltairFinalizedCheckpointGeneralizedIndex
}

func (p *Protocol) CurrentSyncCommitteeGeneralizedIndex(slot uint64) int {
if p.ForkVersion(slot) == Electra {
forkVersion := p.ForkVersion(slot)
if forkVersion == Fulu || forkVersion == Electra {
return ElectraCurrentSyncCommitteeGeneralizedIndex
}
return AltairCurrentSyncCommitteeGeneralizedIndex
}

func (p *Protocol) NextSyncCommitteeGeneralizedIndex(slot uint64) int {
if p.ForkVersion(slot) == Electra {
forkVersion := p.ForkVersion(slot)
if forkVersion == Fulu || forkVersion == Electra {
return ElectraNextSyncCommitteeGeneralizedIndex
}
return AltairNextSyncCommitteeGeneralizedIndex
}

func (p *Protocol) ExecutionPayloadGeneralizedIndex(slot uint64) int {
if p.ForkVersion(slot) == Electra {
forkVersion := p.ForkVersion(slot)
if forkVersion == Fulu || forkVersion == Electra {
return ElectraExecutionPayloadGeneralizedIndex
}
return AltairExecutionPayloadGeneralizedIndex
Expand Down
23 changes: 16 additions & 7 deletions relayer/relays/beacon/state/beacon_deneb_encoding.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading