fix engine_getPayloadV4 compliance error

Fix the issue on engine API: engine_getPayloadV4, to make it compliant with osaka engine API spec. 
According to issue listed in Fusaka contest: https://audits.sherlock.xyz/contests/1140/voting/157, the issue of API: engine_getPayloadV4 should also follow the spec restriction as the previous PR on getBlobsV1: https://github.com/ethereum/go-ethereum/pull/32731
This commit is contained in:
CertiK 2025-11-10 15:17:58 +08:00 committed by GitHub
parent ebc7dc9e37
commit 579374bec6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -442,6 +442,12 @@ func (api *ConsensusAPI) GetPayloadV3(payloadID engine.PayloadID) (*engine.Execu
// GetPayloadV4 returns a cached payload by id. This endpoint should only // GetPayloadV4 returns a cached payload by id. This endpoint should only
// be used for the Prague fork. // be used for the Prague fork.
func (api *ConsensusAPI) GetPayloadV4(payloadID engine.PayloadID) (*engine.ExecutionPayloadEnvelope, error) { func (api *ConsensusAPI) GetPayloadV4(payloadID engine.PayloadID) (*engine.ExecutionPayloadEnvelope, error) {
// Reject the request if Osaka has been activated.
// follow https://github.com/ethereum/execution-apis/blob/main/src/engine/osaka.md#prague-api
head := api.eth.BlockChain().CurrentHeader()
if !api.checkFork(head.Time, forks.Prague) {
return nil, unsupportedForkErr("engine_getPayloadV4 is only available at Prague fork")
}
if !payloadID.Is(engine.PayloadV3) { if !payloadID.Is(engine.PayloadV3) {
return nil, engine.UnsupportedFork return nil, engine.UnsupportedFork
} }
@ -454,6 +460,10 @@ func (api *ConsensusAPI) GetPayloadV4(payloadID engine.PayloadID) (*engine.Execu
// This method follows the same specification as engine_getPayloadV4 with // This method follows the same specification as engine_getPayloadV4 with
// changes of returning BlobsBundleV2 with BlobSidecar version 1. // changes of returning BlobsBundleV2 with BlobSidecar version 1.
func (api *ConsensusAPI) GetPayloadV5(payloadID engine.PayloadID) (*engine.ExecutionPayloadEnvelope, error) { func (api *ConsensusAPI) GetPayloadV5(payloadID engine.PayloadID) (*engine.ExecutionPayloadEnvelope, error) {
head := api.eth.BlockChain().CurrentHeader()
if api.config().LatestFork(head.Time) < forks.Osaka {
return nil, unsupportedForkErr("engine_getPayloadV5 is not available before Osaka fork")
}
if !payloadID.Is(engine.PayloadV3) { if !payloadID.Is(engine.PayloadV3) {
return nil, engine.UnsupportedFork return nil, engine.UnsupportedFork
} }