From 293e3845f5f9365fa4f00561bdded4e5c4449540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Anda=20Estensen?= Date: Wed, 19 Feb 2025 09:07:57 +0100 Subject: [PATCH] chore(taiko-client): use EncodeAndCompressTxList() instead of EncodeToBytes() then Compress() --- packages/taiko-client/pkg/utils/utils.go | 9 +++++++-- .../taiko-client/proposer/transaction_builder/blob.go | 9 ++------- .../proposer/transaction_builder/calldata.go | 9 ++------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/packages/taiko-client/pkg/utils/utils.go b/packages/taiko-client/pkg/utils/utils.go index 401f09c343e..4e33399590c 100644 --- a/packages/taiko-client/pkg/utils/utils.go +++ b/packages/taiko-client/pkg/utils/utils.go @@ -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. diff --git a/packages/taiko-client/proposer/transaction_builder/blob.go b/packages/taiko-client/proposer/transaction_builder/blob.go index 2522f460bfd..888be74a483 100644 --- a/packages/taiko-client/proposer/transaction_builder/blob.go +++ b/packages/taiko-client/proposer/transaction_builder/blob.go @@ -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" @@ -178,13 +177,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 { diff --git a/packages/taiko-client/proposer/transaction_builder/calldata.go b/packages/taiko-client/proposer/transaction_builder/calldata.go index abd75342ed7..a9ad77f7ecc 100644 --- a/packages/taiko-client/proposer/transaction_builder/calldata.go +++ b/packages/taiko-client/proposer/transaction_builder/calldata.go @@ -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" @@ -161,13 +160,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(