From 19d72d5c8aada3713824e0223e9c202887cf79f6 Mon Sep 17 00:00:00 2001 From: dike Date: Mon, 19 Aug 2024 18:04:35 +0800 Subject: [PATCH] ethclient: fix BlobSidecars api --- core/types/tx_blob.go | 9 +++++++++ ethclient/ethclient.go | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/types/tx_blob.go b/core/types/tx_blob.go index 158d76e6f1..302cce47c4 100644 --- a/core/types/tx_blob.go +++ b/core/types/tx_blob.go @@ -19,6 +19,7 @@ package types import ( "bytes" "crypto/sha256" + "github.com/ethereum/go-ethereum/common/hexutil" "math/big" "github.com/ethereum/go-ethereum/common" @@ -85,6 +86,14 @@ func (sc *BlobTxSidecar) encodedSize() uint64 { return rlp.ListSize(blobs) + rlp.ListSize(commitments) + rlp.ListSize(proofs) } +type BlobTxSidecarResp struct { + BlobSidecar BlobTxSidecar `json:"blobSidecar"` + BlockNumber *hexutil.Big `json:"blockNumber"` + BlockHash common.Hash `json:"blockHash"` + TxIndex *hexutil.Big `json:"txIndex"` + TxHash common.Hash `json:"txHash"` +} + // blobTxWithBlobs is used for encoding of transactions when blobs are present. type blobTxWithBlobs struct { BlobTx *BlobTx diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index bf26c79aa8..164f333779 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -131,8 +131,8 @@ 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) ([]*types.BlobTxSidecar, error) { - var r []*types.BlobTxSidecar +func (ec *Client) BlobSidecars(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]*types.BlobTxSidecarResp, error) { + var r []*types.BlobTxSidecarResp err := ec.c.CallContext(ctx, &r, "eth_getBlobSidecars", blockNrOrHash.String()) if err == nil && r == nil { return nil, ethereum.NotFound @@ -141,8 +141,8 @@ 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) (*types.BlobTxSidecar, error) { - var r *types.BlobTxSidecar +func (ec *Client) BlobSidecarByTxHash(ctx context.Context, hash common.Hash) (*types.BlobTxSidecarResp, error) { + var r *types.BlobTxSidecarResp err := ec.c.CallContext(ctx, &r, "eth_getBlobSidecarByTxHash", hash) if err == nil && r == nil { return nil, ethereum.NotFound