Skip to content

Commit cec4116

Browse files
authored
Allow fork epochs to be 0 (#520)
1 parent 4e78ec8 commit cec4116

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

services/api/service.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,23 +408,28 @@ func (api *RelayAPI) StartServer() (err error) {
408408
if err != nil {
409409
return err
410410
}
411+
var foundCapellaEpoch, foundDenebEpoch bool
411412
for _, fork := range forkSchedule.Data {
412413
log.Infof("forkSchedule: version=%s / epoch=%d", fork.CurrentVersion, fork.Epoch)
413414
switch fork.CurrentVersion {
414415
case api.opts.EthNetDetails.CapellaForkVersionHex:
416+
foundCapellaEpoch = true
415417
api.capellaEpoch = fork.Epoch
416418
case api.opts.EthNetDetails.DenebForkVersionHex:
419+
foundDenebEpoch = true
417420
api.denebEpoch = fork.Epoch
418421
}
419422
}
420423

424+
if !foundCapellaEpoch || !foundDenebEpoch {
425+
return ErrMissingForkVersions
426+
}
427+
421428
// Print fork version information
422-
if hasReachedFork(currentSlot, api.capellaEpoch) {
423-
log.Infof("capella fork detected (currentEpoch: %d / capellaEpoch: %d)", common.SlotToEpoch(currentSlot), api.capellaEpoch)
424-
} else if hasReachedFork(currentSlot, api.denebEpoch) {
429+
if hasReachedFork(currentSlot, api.denebEpoch) {
425430
log.Infof("deneb fork detected (currentEpoch: %d / denebEpoch: %d)", common.SlotToEpoch(currentSlot), api.denebEpoch)
426-
} else {
427-
return ErrMismatchedForkVersions
431+
} else if hasReachedFork(currentSlot, api.capellaEpoch) {
432+
log.Infof("capella fork detected (currentEpoch: %d / capellaEpoch: %d)", common.SlotToEpoch(currentSlot), api.capellaEpoch)
428433
}
429434

430435
// start proposer API specific things

services/api/service_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,8 @@ func TestBuilderSubmitBlock(t *testing.T) {
429429

430430
// Setup the test relay backend
431431
backend.relay.headSlot.Store(headSlot)
432-
backend.relay.capellaEpoch = 1
432+
backend.relay.capellaEpoch = 0
433+
backend.relay.denebEpoch = 1
433434
backend.relay.proposerDutiesMap = make(map[uint64]*common.BuilderGetValidatorsResponseEntry)
434435
backend.relay.proposerDutiesMap[headSlot+1] = &common.BuilderGetValidatorsResponseEntry{
435436
Slot: headSlot,
@@ -719,7 +720,6 @@ func TestCheckSubmissionPayloadAttrs(t *testing.T) {
719720
backend.relay.payloadAttributesLock.RLock()
720721
backend.relay.payloadAttributes[testParentHash] = tc.attrs
721722
backend.relay.payloadAttributesLock.RUnlock()
722-
backend.relay.capellaEpoch = 1
723723

724724
w := httptest.NewRecorder()
725725
logger := logrus.New()

services/api/utils.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,6 @@ func checkBLSPublicKeyHex(pkHex string) error {
104104
}
105105

106106
func hasReachedFork(slot, forkEpoch uint64) bool {
107-
if forkEpoch == 0 {
108-
return false
109-
}
110107
currentEpoch := slot / common.SlotsPerEpoch
111108
return currentEpoch >= forkEpoch
112109
}

0 commit comments

Comments
 (0)