From 8737aca3687292e5ec2fdab1d2979d3739200973 Mon Sep 17 00:00:00 2001 From: shana Date: Sat, 20 Jan 2024 08:43:30 +1100 Subject: [PATCH 1/2] backwards compatibility if no deneb schedule --- services/api/service.go | 23 ++++++++++++++--------- services/api/utils.go | 7 +++++-- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/services/api/service.go b/services/api/service.go index 4a2538b6..eaf8e5a4 100644 --- a/services/api/service.go +++ b/services/api/service.go @@ -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 @@ -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.Warn("deneb epoch not found in fork schedule, you may need to upgrade the beacon client") + } + // 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) } diff --git a/services/api/utils.go b/services/api/utils.go index 83c3eccc..e0fde907 100644 --- a/services/api/utils.go +++ b/services/api/utils.go @@ -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) { From 17c7fe084f8b44137b387924fddf1096ac183afa Mon Sep 17 00:00:00 2001 From: shana Date: Fri, 26 Jan 2024 05:32:33 +1100 Subject: [PATCH 2/2] Update services/api/service.go Co-authored-by: Chris Hager --- services/api/service.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/api/service.go b/services/api/service.go index eaf8e5a4..4d2262e6 100644 --- a/services/api/service.go +++ b/services/api/service.go @@ -426,7 +426,7 @@ func (api *RelayAPI) StartServer() (err error) { if api.denebEpoch == -1 { // log warning that deneb epoch was not found in CL fork schedule, suggest CL upgrade - log.Warn("deneb epoch not found in fork schedule, you may need to upgrade the beacon client") + log.Info("Deneb epoch not found in fork schedule") } // Print fork version information