check for v1..3

This commit is contained in:
jsvisa 2025-09-26 12:27:36 +08:00 committed by lightclient
parent 9411be428f
commit fac65f9c6c
No known key found for this signature in database
GPG key ID: 657913021EF45A6A

View file

@ -413,6 +413,10 @@ func (api *ConsensusAPI) GetPayloadV1(payloadID engine.PayloadID) (*engine.Execu
if err != nil {
return nil, err
}
// Check if the payload timestamp is greater or equal to Shanghai activation timestamp
if data.ExecutionPayload != nil && api.config().LatestFork(data.ExecutionPayload.Timestamp) >= forks.Shanghai {
return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV1 is not available after Shanghai fork"))
}
return data.ExecutionPayload, nil
}
@ -428,7 +432,15 @@ func (api *ConsensusAPI) GetPayloadV2(payloadID engine.PayloadID) (*engine.Execu
if !payloadID.Is(engine.PayloadV1, engine.PayloadV2) {
return nil, engine.UnsupportedFork
}
return api.getPayload(payloadID, false)
data, err := api.getPayload(payloadID, false)
if err != nil {
return nil, err
}
// Check if the payload timestamp is greater or equal to Cancun activation timestamp
if data.ExecutionPayload != nil && api.config().LatestFork(data.ExecutionPayload.Timestamp) >= forks.Cancun {
return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV2 is not available after Cancun fork"))
}
return data, nil
}
// GetPayloadV3 returns a cached payload by id. This endpoint should only
@ -437,7 +449,15 @@ func (api *ConsensusAPI) GetPayloadV3(payloadID engine.PayloadID) (*engine.Execu
if !payloadID.Is(engine.PayloadV3) {
return nil, engine.UnsupportedFork
}
return api.getPayload(payloadID, false)
data, err := api.getPayload(payloadID, false)
if err != nil {
return nil, err
}
// Check if the payload timestamp is greater or equal to Prague activation timestamp
if data.ExecutionPayload != nil && api.config().LatestFork(data.ExecutionPayload.Timestamp) >= forks.Prague {
return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV3 is not available after Prague fork"))
}
return data, nil
}
// GetPayloadV4 returns a cached payload by id. This endpoint should only
@ -450,7 +470,6 @@ func (api *ConsensusAPI) GetPayloadV4(payloadID engine.PayloadID) (*engine.Execu
if err != nil {
return nil, err
}
// Check if the payload timestamp is greater or equal to Osaka activation timestamp
if data.ExecutionPayload != nil && api.config().LatestFork(data.ExecutionPayload.Timestamp) >= forks.Osaka {
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
if err != nil {
return nil, err
}
// Check if the payload timestamp falls within the time frame of the Osaka fork
if data.ExecutionPayload != nil && api.config().LatestFork(data.ExecutionPayload.Timestamp) < forks.Osaka {
return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV5 is not available after Osaka fork"))
return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV5 is not available before Osaka fork"))
}
return data, nil
}