@@ -22,7 +22,6 @@ import (
22
22
"errors"
23
23
"fmt"
24
24
"math/big"
25
-
26
25
"slices"
27
26
28
27
"github.com/ethereum/go-ethereum/common"
@@ -75,17 +74,19 @@ func (sc *BlobTxSidecar) BlobHashes() []common.Hash {
75
74
}
76
75
77
76
// 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 ))
87
84
}
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
89
90
}
90
91
91
92
// encodedSize computes the RLP size of the sidecar elements. This does NOT return the
@@ -217,6 +218,7 @@ func (tx *BlobTx) copy() TxData {
217
218
}
218
219
if tx .Sidecar != nil {
219
220
cpy .Sidecar = & BlobTxSidecar {
221
+ Version : tx .Sidecar .Version ,
220
222
Blobs : slices .Clone (tx .Sidecar .Blobs ),
221
223
Commitments : slices .Clone (tx .Sidecar .Commitments ),
222
224
Proofs : slices .Clone (tx .Sidecar .Proofs ),
0 commit comments