Skip to content

Commit

Permalink
chore(taiko-client): use EncodeAndCompressTxList() instead of `Enco…
Browse files Browse the repository at this point in the history
…deToBytes()` then `Compress()` (#18972)
  • Loading branch information
estensen authored Feb 19, 2025
1 parent 16bbe5f commit 05e43ab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
9 changes: 7 additions & 2 deletions packages/taiko-client/pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,15 @@ func Min[T constraints.Integer](a, b T) T {
func EncodeAndCompressTxList(txs types.Transactions) ([]byte, error) {
b, err := rlp.EncodeToBytes(txs)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to RLP encode transactions: %w", err)
}

compressed, err := Compress(b)
if err != nil {
return nil, fmt.Errorf("failed to compress RLP encoded transactions: %w", err)
}

return Compress(b)
return compressed, nil
}

// Compress compresses the given txList bytes using zlib.
Expand Down
9 changes: 2 additions & 7 deletions packages/taiko-client/proposer/transaction_builder/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rlp"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/encoding"
pacayaBindings "github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/pacaya"
Expand Down Expand Up @@ -193,13 +192,9 @@ func (b *BlobTransactionBuilder) BuildPacaya(
})
}

rlpEncoded, err := rlp.EncodeToBytes(allTxs)
txListsBytes, err := utils.EncodeAndCompressTxList(allTxs)
if err != nil {
return nil, fmt.Errorf("failed to encode transactions: %w", err)
}
txListsBytes, err := utils.Compress(rlpEncoded)
if err != nil {
return nil, fmt.Errorf("failed to compress transactions: %w", err)
return nil, err
}

if blobs, err = b.splitToBlobs(txListsBytes); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rlp"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/encoding"
pacayaBindings "github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/pacaya"
Expand Down Expand Up @@ -177,13 +176,9 @@ func (b *CalldataTransactionBuilder) BuildPacaya(
})
}

rlpEncoded, err := rlp.EncodeToBytes(allTxs)
txListsBytes, err := utils.EncodeAndCompressTxList(allTxs)
if err != nil {
return nil, fmt.Errorf("failed to encode transactions: %w", err)
}
txListsBytes, err := utils.Compress(rlpEncoded)
if err != nil {
return nil, fmt.Errorf("failed to compress transactions: %w", err)
return nil, err
}

if encodedParams, err = encoding.EncodeBatchParamsWithForcedInclusion(
Expand Down

0 comments on commit 05e43ab

Please sign in to comment.