Skip to content

Commit c5593ed

Browse files
jsvisalightclient
authored andcommitted
check fork
1 parent fac65f9 commit c5593ed

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

eth/catalyst/api.go

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,6 @@ func (api *ConsensusAPI) GetPayloadV1(payloadID engine.PayloadID) (*engine.Execu
413413
if err != nil {
414414
return nil, err
415415
}
416-
// Check if the payload timestamp is greater or equal to Shanghai activation timestamp
417-
if data.ExecutionPayload != nil && api.config().LatestFork(data.ExecutionPayload.Timestamp) >= forks.Shanghai {
418-
return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV1 is not available after Shanghai fork"))
419-
}
420416
return data.ExecutionPayload, nil
421417
}
422418

@@ -436,9 +432,9 @@ func (api *ConsensusAPI) GetPayloadV2(payloadID engine.PayloadID) (*engine.Execu
436432
if err != nil {
437433
return nil, err
438434
}
439-
// Check if the payload timestamp is greater or equal to Cancun activation timestamp
440-
if data.ExecutionPayload != nil && api.config().LatestFork(data.ExecutionPayload.Timestamp) >= forks.Cancun {
441-
return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV2 is not available after Cancun fork"))
435+
// Check if the payload timestamp falls within the Shanghai fork timeframe
436+
if data.ExecutionPayload != nil && !api.checkFork(data.ExecutionPayload.Timestamp, forks.Shanghai) {
437+
return nil, engine.UnsupportedFork
442438
}
443439
return data, nil
444440
}
@@ -453,9 +449,9 @@ func (api *ConsensusAPI) GetPayloadV3(payloadID engine.PayloadID) (*engine.Execu
453449
if err != nil {
454450
return nil, err
455451
}
456-
// Check if the payload timestamp is greater or equal to Prague activation timestamp
457-
if data.ExecutionPayload != nil && api.config().LatestFork(data.ExecutionPayload.Timestamp) >= forks.Prague {
458-
return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV3 is not available after Prague fork"))
452+
// Check if the payload timestamp falls within the Cancun fork timeframe
453+
if data.ExecutionPayload != nil && !api.checkFork(data.ExecutionPayload.Timestamp, forks.Cancun) {
454+
return nil, engine.UnsupportedFork
459455
}
460456
return data, nil
461457
}
@@ -470,9 +466,9 @@ func (api *ConsensusAPI) GetPayloadV4(payloadID engine.PayloadID) (*engine.Execu
470466
if err != nil {
471467
return nil, err
472468
}
473-
// Check if the payload timestamp is greater or equal to Osaka activation timestamp
474-
if data.ExecutionPayload != nil && api.config().LatestFork(data.ExecutionPayload.Timestamp) >= forks.Osaka {
475-
return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV4 is not available after Osaka fork"))
469+
// Check if the payload timestamp falls within the Prague fork timeframe
470+
if data.ExecutionPayload != nil && !api.checkFork(data.ExecutionPayload.Timestamp, forks.Prague) {
471+
return nil, engine.UnsupportedFork
476472
}
477473
return data, nil
478474
}
@@ -490,9 +486,9 @@ func (api *ConsensusAPI) GetPayloadV5(payloadID engine.PayloadID) (*engine.Execu
490486
if err != nil {
491487
return nil, err
492488
}
493-
// Check if the payload timestamp falls within the time frame of the Osaka fork
489+
// Check if the payload timestamp falls within the time frame of the Osaka fork or later
494490
if data.ExecutionPayload != nil && api.config().LatestFork(data.ExecutionPayload.Timestamp) < forks.Osaka {
495-
return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV5 is not available before Osaka fork"))
491+
return nil, engine.UnsupportedFork
496492
}
497493
return data, nil
498494
}

0 commit comments

Comments
 (0)