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 8fcf29d2101..f2c6d41fbfd 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" @@ -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 { diff --git a/packages/taiko-client/proposer/transaction_builder/calldata.go b/packages/taiko-client/proposer/transaction_builder/calldata.go index 6d4f80935ac..d4b8ea3629f 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" @@ -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(