Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(taiko-client): use EncodeAndCompressTxList() instead of EncodeT… #18972

Merged
merged 3 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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