Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle no deneb fork schedule from beacon client #572

Merged
merged 2 commits into from
Jan 25, 2024
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
23 changes: 14 additions & 9 deletions services/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ type RelayAPI struct {

headSlot uberatomic.Uint64
genesisInfo *beaconclient.GetGenesisResponse
capellaEpoch uint64
denebEpoch uint64
capellaEpoch int64
denebEpoch int64

proposerDutiesLock sync.RWMutex
proposerDutiesResponse *[]byte // raw http response
Expand Down Expand Up @@ -411,23 +411,28 @@ func (api *RelayAPI) StartServer() (err error) {
if err != nil {
return err
}
var foundCapellaEpoch, foundDenebEpoch bool

api.denebEpoch = -1
api.capellaEpoch = -1
for _, fork := range forkSchedule.Data {
log.Infof("forkSchedule: version=%s / epoch=%d", fork.CurrentVersion, fork.Epoch)
switch fork.CurrentVersion {
case api.opts.EthNetDetails.CapellaForkVersionHex:
foundCapellaEpoch = true
api.capellaEpoch = fork.Epoch
api.capellaEpoch = int64(fork.Epoch)
case api.opts.EthNetDetails.DenebForkVersionHex:
foundDenebEpoch = true
api.denebEpoch = fork.Epoch
api.denebEpoch = int64(fork.Epoch)
}
}

if api.denebEpoch == -1 {
// log warning that deneb epoch was not found in CL fork schedule, suggest CL upgrade
log.Info("Deneb epoch not found in fork schedule")
}

// Print fork version information
if foundDenebEpoch && hasReachedFork(currentSlot, api.denebEpoch) {
if hasReachedFork(currentSlot, api.denebEpoch) {
log.Infof("deneb fork detected (currentEpoch: %d / denebEpoch: %d)", common.SlotToEpoch(currentSlot), api.denebEpoch)
} else if foundCapellaEpoch && hasReachedFork(currentSlot, api.capellaEpoch) {
} else if hasReachedFork(currentSlot, api.capellaEpoch) {
log.Infof("capella fork detected (currentEpoch: %d / capellaEpoch: %d)", common.SlotToEpoch(currentSlot), api.capellaEpoch)
}

Expand Down
7 changes: 5 additions & 2 deletions services/api/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,12 @@ func checkBLSPublicKeyHex(pkHex string) error {
return err
}

func hasReachedFork(slot, forkEpoch uint64) bool {
func hasReachedFork(slot uint64, forkEpoch int64) bool {
if forkEpoch < 0 {
return false
}
currentEpoch := slot / common.SlotsPerEpoch
return currentEpoch >= forkEpoch
return currentEpoch >= uint64(forkEpoch)
}

func verifyBlockSignature(block *common.VersionedSignedBlindedBeaconBlock, domain phase0.Domain, pubKey []byte) (bool, error) {
Expand Down
Loading