diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index f62363c84..521add7e9 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -131,9 +131,9 @@ func (ec *Client) BlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumb } // BlobSidecars return the Sidecars of a given block number or hash. -func (ec *Client) BlobSidecars(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, fullBlob bool) ([]*types.BlobTxSidecar, error) { +func (ec *Client) BlobSidecars(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]*types.BlobTxSidecar, error) { var r []*types.BlobTxSidecar - err := ec.c.CallContext(ctx, &r, "eth_getBlobSidecars", blockNrOrHash.String(), fullBlob) + err := ec.c.CallContext(ctx, &r, "eth_getBlobSidecars", blockNrOrHash.String(), true) if err == nil && r == nil { return nil, ethereum.NotFound } @@ -141,9 +141,9 @@ func (ec *Client) BlobSidecars(ctx context.Context, blockNrOrHash rpc.BlockNumbe } // BlobSidecarByTxHash return a sidecar of a given blob transaction -func (ec *Client) BlobSidecarByTxHash(ctx context.Context, hash common.Hash, fullBlob bool) (*types.BlobTxSidecar, error) { +func (ec *Client) BlobSidecarByTxHash(ctx context.Context, hash common.Hash) (*types.BlobTxSidecar, error) { var r *types.BlobTxSidecar - err := ec.c.CallContext(ctx, &r, "eth_getBlockSidecarByTxHash", hash, fullBlob) + err := ec.c.CallContext(ctx, &r, "eth_getBlockSidecarByTxHash", hash, true) if err == nil && r == nil { return nil, ethereum.NotFound } diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 5bee8ec58..e31cee15e 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1010,7 +1010,11 @@ func (s *BlockChainAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rpc. return result, nil } -func (s *BlockChainAPI) GetBlobSidecars(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, fullBlob bool) ([]map[string]interface{}, error) { +func (s *BlockChainAPI) GetBlobSidecars(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, fullBlob *bool) ([]map[string]interface{}, error) { + showBlob := true + if fullBlob != nil { + showBlob = *fullBlob + } header, err := s.b.HeaderByNumberOrHash(ctx, blockNrOrHash) if header == nil || err != nil { // When the block doesn't exist, the RPC method should return JSON null @@ -1023,12 +1027,16 @@ func (s *BlockChainAPI) GetBlobSidecars(ctx context.Context, blockNrOrHash rpc.B } result := make([]map[string]interface{}, len(blobSidecars)) for i, sidecar := range blobSidecars { - result[i] = marshalBlobSidecar(sidecar, fullBlob) + result[i] = marshalBlobSidecar(sidecar, showBlob) } return result, nil } -func (s *BlockChainAPI) GetBlobSidecarByTxHash(ctx context.Context, hash common.Hash, fullBlob bool) (map[string]interface{}, error) { +func (s *BlockChainAPI) GetBlobSidecarByTxHash(ctx context.Context, hash common.Hash, fullBlob *bool) (map[string]interface{}, error) { + showBlob := true + if fullBlob != nil { + showBlob = *fullBlob + } txTarget, blockHash, _, Index := rawdb.ReadTransaction(s.b.ChainDb(), hash) if txTarget == nil { return nil, nil @@ -1045,7 +1053,7 @@ func (s *BlockChainAPI) GetBlobSidecarByTxHash(ctx context.Context, hash common. } for _, sidecar := range blobSidecars { if sidecar.TxIndex == Index { - return marshalBlobSidecar(sidecar, fullBlob), nil + return marshalBlobSidecar(sidecar, showBlob), nil } } diff --git a/internal/ethapi/api_test.go b/internal/ethapi/api_test.go index bb77e36d0..d1c05797f 100644 --- a/internal/ethapi/api_test.go +++ b/internal/ethapi/api_test.go @@ -2204,7 +2204,7 @@ func TestRPCGetBlobSidecars(t *testing.T) { result interface{} err error ) - result, err = api.GetBlobSidecars(context.Background(), tt.test, tt.fullBlob) + result, err = api.GetBlobSidecars(context.Background(), tt.test, &tt.fullBlob) if err != nil { t.Errorf("test %d: want no error, have %v", i, err) continue @@ -2254,7 +2254,7 @@ func TestGetBlobSidecarByTxHash(t *testing.T) { fullBlob: true, file: "block-with-blobSidecars", }, - // 4. block show part blobs + // 5. block show part blobs { test: txHashs[6], fullBlob: false, @@ -2267,7 +2267,7 @@ func TestGetBlobSidecarByTxHash(t *testing.T) { result interface{} err error ) - result, err = api.GetBlobSidecarByTxHash(context.Background(), tt.test, tt.fullBlob) + result, err = api.GetBlobSidecarByTxHash(context.Background(), tt.test, &tt.fullBlob) if err != nil { t.Errorf("test %d: want no error, have %v", i, err) continue