eth/catalyst: add fork constraint for GetBlobs APIs

This commit is contained in:
Gary Rong 2025-09-24 22:47:33 +08:00
parent e58a3ae086
commit f9a408b957

View file

@ -494,9 +494,9 @@ func (api *ConsensusAPI) getPayload(payloadID engine.PayloadID, full bool) (*eng
func (api *ConsensusAPI) GetBlobsV1(hashes []common.Hash) ([]*engine.BlobAndProofV1, error) { func (api *ConsensusAPI) GetBlobsV1(hashes []common.Hash) ([]*engine.BlobAndProofV1, error) {
// Reject the request if Osaka has been activated. // Reject the request if Osaka has been activated.
// follow https://github.com/ethereum/execution-apis/blob/main/src/engine/osaka.md#cancun-api // follow https://github.com/ethereum/execution-apis/blob/main/src/engine/osaka.md#cancun-api
header := api.eth.BlockChain().CurrentHeader() head := api.eth.BlockChain().CurrentHeader()
if api.config().IsOsaka(header.Number, header.Time) { if !api.checkFork(head.Time, forks.Cancun, forks.Prague) {
return nil, unsupportedForkErr("engine_getBlobsV1 is not supported after Osaka fork") return nil, unsupportedForkErr("engine_getBlobsV1 is only available at Cancun/Prague fork")
} }
if len(hashes) > 128 { if len(hashes) > 128 {
return nil, engine.TooLargeRequest.With(fmt.Errorf("requested blob count too large: %v", len(hashes))) return nil, engine.TooLargeRequest.With(fmt.Errorf("requested blob count too large: %v", len(hashes)))
@ -538,9 +538,6 @@ func (api *ConsensusAPI) GetBlobsV1(hashes []common.Hash) ([]*engine.BlobAndProo
// - if the request is [A_versioned_hash_for_blob_with_blob_proof], the response // - if the request is [A_versioned_hash_for_blob_with_blob_proof], the response
// MUST be null as well. // MUST be null as well.
// //
// Note, geth internally make the conversion from old version to new one, so the
// data will be returned normally.
//
// Client software MUST support request sizes of at least 128 blob versioned // Client software MUST support request sizes of at least 128 blob versioned
// hashes. The client MUST return -38004: Too large request error if the number // hashes. The client MUST return -38004: Too large request error if the number
// of requested blobs is too large. // of requested blobs is too large.
@ -548,6 +545,10 @@ func (api *ConsensusAPI) GetBlobsV1(hashes []common.Hash) ([]*engine.BlobAndProo
// Client software MUST return null if syncing or otherwise unable to serve // Client software MUST return null if syncing or otherwise unable to serve
// blob pool data. // blob pool data.
func (api *ConsensusAPI) GetBlobsV2(hashes []common.Hash) ([]*engine.BlobAndProofV2, error) { func (api *ConsensusAPI) GetBlobsV2(hashes []common.Hash) ([]*engine.BlobAndProofV2, error) {
head := api.eth.BlockChain().CurrentHeader()
if !api.checkFork(head.Time, forks.Osaka) {
return nil, unsupportedForkErr("engine_getBlobsV2 is only available at Osaka fork")
}
if len(hashes) > 128 { if len(hashes) > 128 {
return nil, engine.TooLargeRequest.With(fmt.Errorf("requested blob count too large: %v", len(hashes))) return nil, engine.TooLargeRequest.With(fmt.Errorf("requested blob count too large: %v", len(hashes)))
} }