Skip to content

Commit fac65f9

Browse files
jsvisalightclient
authored andcommitted
check for v1..3
1 parent 9411be4 commit fac65f9

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

eth/catalyst/api.go

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,10 @@ 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+
}
416420
return data.ExecutionPayload, nil
417421
}
418422

@@ -428,7 +432,15 @@ func (api *ConsensusAPI) GetPayloadV2(payloadID engine.PayloadID) (*engine.Execu
428432
if !payloadID.Is(engine.PayloadV1, engine.PayloadV2) {
429433
return nil, engine.UnsupportedFork
430434
}
431-
return api.getPayload(payloadID, false)
435+
data, err := api.getPayload(payloadID, false)
436+
if err != nil {
437+
return nil, err
438+
}
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"))
442+
}
443+
return data, nil
432444
}
433445

434446
// GetPayloadV3 returns a cached payload by id. This endpoint should only
@@ -437,7 +449,15 @@ func (api *ConsensusAPI) GetPayloadV3(payloadID engine.PayloadID) (*engine.Execu
437449
if !payloadID.Is(engine.PayloadV3) {
438450
return nil, engine.UnsupportedFork
439451
}
440-
return api.getPayload(payloadID, false)
452+
data, err := api.getPayload(payloadID, false)
453+
if err != nil {
454+
return nil, err
455+
}
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"))
459+
}
460+
return data, nil
441461
}
442462

443463
// GetPayloadV4 returns a cached payload by id. This endpoint should only
@@ -450,7 +470,6 @@ func (api *ConsensusAPI) GetPayloadV4(payloadID engine.PayloadID) (*engine.Execu
450470
if err != nil {
451471
return nil, err
452472
}
453-
454473
// Check if the payload timestamp is greater or equal to Osaka activation timestamp
455474
if data.ExecutionPayload != nil && api.config().LatestFork(data.ExecutionPayload.Timestamp) >= forks.Osaka {
456475
return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV4 is not available after Osaka fork"))
@@ -471,10 +490,9 @@ func (api *ConsensusAPI) GetPayloadV5(payloadID engine.PayloadID) (*engine.Execu
471490
if err != nil {
472491
return nil, err
473492
}
474-
475493
// Check if the payload timestamp falls within the time frame of the Osaka fork
476494
if data.ExecutionPayload != nil && api.config().LatestFork(data.ExecutionPayload.Timestamp) < forks.Osaka {
477-
return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV5 is not available after Osaka fork"))
495+
return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV5 is not available before Osaka fork"))
478496
}
479497
return data, nil
480498
}

0 commit comments

Comments
 (0)