Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
NazariiDenha committed Aug 20, 2024
1 parent 76f6081 commit c41a465
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions encoding/codecv1/codecv1.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (c *DAChunk) Encode() []byte {
}

// DecodeDAChunksRawTx takes a byte slice and decodes it into a []*DAChunkRawTx.
// From codecv1 tx data posted to blobs, not to chunk bytes in calldata
// Beginning from codecv1 tx data posted to blobs, not to chunk bytes in calldata
func DecodeDAChunksRawTx(bytes [][]byte) ([]*DAChunkRawTx, error) {
var chunks []*DAChunkRawTx
for _, chunk := range bytes {
Expand Down Expand Up @@ -357,12 +357,12 @@ func MakeBlobCanonical(blobBytes []byte) (*kzg4844.Blob, error) {
}

// DecodeTxsFromBytes decodes txs from blob bytes and writes to chunks
func DecodeTxsFromBytes(blobBytes []byte, chunks []*DAChunkRawTx) error {
func DecodeTxsFromBytes(blobBytes []byte, chunks []*DAChunkRawTx, maxNumChunks int) error {
numChunks := int(binary.BigEndian.Uint16(blobBytes[0:2]))
if numChunks != len(chunks) {
return fmt.Errorf("blob chunk number is not same as calldata, blob num chunks: %d, calldata num chunks: %d", numChunks, len(chunks))
}
index := 2 + MaxNumChunks*4
index := 2 + maxNumChunks*4
for chunkID, chunk := range chunks {
var transactions []types.Transactions
chunkSize := int(binary.BigEndian.Uint32(blobBytes[2+4*chunkID : 2+4*chunkID+4]))
Expand Down Expand Up @@ -391,7 +391,7 @@ func DecodeTxsFromBytes(blobBytes []byte, chunks []*DAChunkRawTx) error {
// DecodeTxsFromBlob decodes txs from blob bytes and writes to chunks
func DecodeTxsFromBlob(blob *kzg4844.Blob, chunks []*DAChunkRawTx) error {
blobBytes := BytesFromBlobCanonical(blob)
return DecodeTxsFromBytes(blobBytes[:], chunks)
return DecodeTxsFromBytes(blobBytes[:], chunks, MaxNumChunks)
}

var errSmallLength error = fmt.Errorf("length of blob bytes is too small")
Expand Down
2 changes: 1 addition & 1 deletion encoding/codecv2/codecv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func DecodeTxsFromBlob(blob *kzg4844.Blob, chunks []*DAChunkRawTx) error {
if err != nil {
return err
}
return codecv1.DecodeTxsFromBytes(blobBytes, chunks)
return codecv1.DecodeTxsFromBytes(blobBytes, chunks, MaxNumChunks)
}

// MakeBlobCanonical converts the raw blob data into the canonical blob representation of 4096 BLSFieldElements.
Expand Down

0 comments on commit c41a465

Please sign in to comment.