@@ -22,7 +22,6 @@ import (
2222 "errors"
2323 "fmt"
2424 "math/big"
25-
2625 "slices"
2726
2827 "github.com/ethereum/go-ethereum/common"
@@ -75,17 +74,19 @@ func (sc *BlobTxSidecar) BlobHashes() []common.Hash {
7574}
7675
7776// CellProofsAt returns the cell proofs for blob with index idx.
78- func (sc * BlobTxSidecar ) CellProofsAt (idx int ) []kzg4844.Proof {
79- var cellProofs []kzg4844.Proof
80- for i := range kzg4844 .CellProofsPerBlob {
81- index := idx * kzg4844 .CellProofsPerBlob + i
82- if index > len (sc .Proofs ) {
83- return nil
84- }
85- proof := sc .Proofs [index ]
86- cellProofs = append (cellProofs , proof )
77+ // This method is only valid for sidecars with version 1.
78+ func (sc * BlobTxSidecar ) CellProofsAt (idx int ) ([]kzg4844.Proof , error ) {
79+ if sc .Version != 1 {
80+ return nil , fmt .Errorf ("cell proof unsupported, version: %d" , sc .Version )
81+ }
82+ if idx < 0 || idx >= len (sc .Blobs ) {
83+ return nil , fmt .Errorf ("cell proof out of bounds, index: %d, blobs: %d" , idx , len (sc .Blobs ))
8784 }
88- return cellProofs
85+ index := idx * kzg4844 .CellProofsPerBlob
86+ if len (sc .Proofs ) < index + kzg4844 .CellProofsPerBlob {
87+ return nil , fmt .Errorf ("cell proof is corrupted, index: %d, proofs: %d" , idx , len (sc .Proofs ))
88+ }
89+ return sc .Proofs [index : index + kzg4844 .CellProofsPerBlob ], nil
8990}
9091
9192// encodedSize computes the RLP size of the sidecar elements. This does NOT return the
@@ -217,6 +218,7 @@ func (tx *BlobTx) copy() TxData {
217218 }
218219 if tx .Sidecar != nil {
219220 cpy .Sidecar = & BlobTxSidecar {
221+ Version : tx .Sidecar .Version ,
220222 Blobs : slices .Clone (tx .Sidecar .Blobs ),
221223 Commitments : slices .Clone (tx .Sidecar .Commitments ),
222224 Proofs : slices .Clone (tx .Sidecar .Proofs ),
0 commit comments