@@ -19,9 +19,11 @@ package apitypes
1919import (
2020 "crypto/sha256"
2121 "encoding/json"
22+ "math/big"
2223 "testing"
2324
2425 "github.com/ethereum/go-ethereum/common"
26+ "github.com/ethereum/go-ethereum/common/hexutil"
2527 "github.com/ethereum/go-ethereum/core/types"
2628 "github.com/ethereum/go-ethereum/crypto/kzg4844"
2729 "github.com/holiman/uint256"
@@ -139,6 +141,74 @@ func TestBlobTxs(t *testing.T) {
139141 t .Logf ("tx %v" , string (data ))
140142}
141143
144+ func TestBlobTxsWithCellProofs (t * testing.T ) {
145+ blob := kzg4844.Blob {0x1 }
146+ commitment , err := kzg4844 .BlobToCommitment (& blob )
147+ if err != nil {
148+ t .Fatal (err )
149+ }
150+
151+ // Generate cell proofs (128 proofs per blob) instead of a single blob proof
152+ cellProofs , err := kzg4844 .ComputeCellProofs (& blob )
153+ if err != nil {
154+ t .Fatal (err )
155+ }
156+
157+ // Verify we got the expected number of cell proofs
158+ if len (cellProofs ) != kzg4844 .CellProofsPerBlob {
159+ t .Fatalf ("expected %d cell proofs, got %d" , kzg4844 .CellProofsPerBlob , len (cellProofs ))
160+ }
161+
162+ // Test that SendTxArgs accepts cell proofs and converts to Version 1 sidecar
163+ hash := kzg4844 .CalcBlobHashV1 (sha256 .New (), & commitment )
164+ args := & SendTxArgs {
165+ From : common.MixedcaseAddress {},
166+ To : & common.MixedcaseAddress {},
167+ Gas : 21000 ,
168+ MaxFeePerGas : (* hexutil .Big )(big .NewInt (600 )),
169+ MaxPriorityFeePerGas : (* hexutil .Big )(big .NewInt (500 )),
170+ BlobFeeCap : (* hexutil .Big )(big .NewInt (700 )),
171+ Value : hexutil .Big (* big .NewInt (100 )),
172+ Nonce : 8 ,
173+ ChainID : (* hexutil .Big )(big .NewInt (6 )),
174+ BlobHashes : []common.Hash {hash },
175+ Blobs : []kzg4844.Blob {blob },
176+ Commitments : []kzg4844.Commitment {commitment },
177+ Proofs : cellProofs ,
178+ }
179+
180+ // This should succeed with the validation fix
181+ tx , err := args .ToTransaction ()
182+ if err != nil {
183+ t .Fatalf ("failed to convert args with cell proofs to transaction: %v" , err )
184+ }
185+
186+ // Verify the transaction type is BlobTx
187+ if tx .Type () != types .BlobTxType {
188+ t .Fatalf ("expected BlobTxType, got %d" , tx .Type ())
189+ }
190+
191+ // Verify the transaction has a Version 1 sidecar
192+ sidecar := tx .BlobTxSidecar ()
193+ if sidecar == nil {
194+ t .Fatal ("expected sidecar to be present" )
195+ }
196+ if sidecar .Version != types .BlobSidecarVersion1 {
197+ t .Fatalf ("expected sidecar version %d, got %d" , types .BlobSidecarVersion1 , sidecar .Version )
198+ }
199+
200+ // Verify the sidecar has the correct number of proofs
201+ if len (sidecar .Proofs ) != len (cellProofs ) {
202+ t .Fatalf ("expected %d proofs in sidecar, got %d" , len (cellProofs ), len (sidecar .Proofs ))
203+ }
204+
205+ data , err := json .Marshal (tx )
206+ if err != nil {
207+ t .Fatal (err )
208+ }
209+ t .Logf ("cell proof tx %v" , string (data ))
210+ }
211+
142212func TestType_IsArray (t * testing.T ) {
143213 t .Parallel ()
144214 // Expected positives
0 commit comments