diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index e4401fd9c6..e22dc5b179 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -492,12 +492,12 @@ func (api *ConsensusAPI) getPayload(payloadID engine.PayloadID, full bool) (*eng // Client software MAY return an array of all null entries if syncing or otherwise // unable to serve blob pool data. func (api *ConsensusAPI) GetBlobsV1(hashes []common.Hash) ([]*engine.BlobAndProofV1, error) { - // Check if Osaka fork is active + // Reject the request if Osaka has been activated. // follow https://github.com/ethereum/execution-apis/blob/main/src/engine/osaka.md#cancun-api - if header := api.eth.BlockChain().CurrentHeader(); api.config().IsOsaka(header.Number, header.Time) { + header := api.eth.BlockChain().CurrentHeader() + if api.config().IsOsaka(header.Number, header.Time) { return nil, unsupportedForkErr("engine_getBlobsV1 is not supported after Osaka fork") } - if len(hashes) > 128 { return nil, engine.TooLargeRequest.With(fmt.Errorf("requested blob count too large: %v", len(hashes))) } diff --git a/eth/catalyst/api_test.go b/eth/catalyst/api_test.go index 58378580c9..a29fee1a06 100644 --- a/eth/catalyst/api_test.go +++ b/eth/catalyst/api_test.go @@ -1991,53 +1991,28 @@ func TestGetBlobsV1(t *testing.T) { } } -func TestGetBlobsV1OsakaFork(t *testing.T) { - config := *params.AllEthashProtocolChanges - time := new(uint64) - config.ShanghaiTime = time - config.CancunTime = time - config.PragueTime = time - config.OsakaTime = time - - // Add blob schedule configuration - config.BlobScheduleConfig = ¶ms.BlobScheduleConfig{ - Cancun: params.DefaultCancunBlobConfig, - Prague: params.DefaultPragueBlobConfig, - Osaka: params.DefaultOsakaBlobConfig, - } - +func TestGetBlobsV1AfterOsakaFork(t *testing.T) { genesis := &core.Genesis{ - Config: &config, + Config: params.MergedTestChainConfig, Alloc: types.GenesisAlloc{testAddr: {Balance: testBalance}}, Difficulty: common.Big0, Timestamp: 1, // Timestamp > 0 to ensure Osaka fork is active } - n, ethServ := startEthService(t, genesis, nil) defer n.Close() + var engineErr *engine.EngineAPIError api := newConsensusAPIWithoutHeartbeat(ethServ) - - vhashes := []common.Hash{testrand.Hash(), testrand.Hash()} - result, err := api.GetBlobsV1(vhashes) - - if err == nil { - t.Fatal("Expected UnsupportedFork error when Osaka fork is active") - } - - if engineErr, ok := err.(*engine.EngineAPIError); ok { + _, err := api.GetBlobsV1([]common.Hash{testrand.Hash()}) + if !errors.As(err, &engineErr) { + t.Fatalf("Unexpected error: %T", err) + } else { if engineErr.ErrorCode() != -38005 { t.Fatalf("Expected error code -38005, got %d", engineErr.ErrorCode()) } if engineErr.Error() != "Unsupported fork" { t.Fatalf("Expected error message 'Unsupported fork', got '%s'", engineErr.Error()) } - } else { - t.Fatalf("Expected EngineAPIError, got %T", err) - } - - if result != nil { - t.Fatal("Expected nil result when Osaka fork is active") } }