diff --git a/packages/taiko-client/driver/chain_syncer/blob/syncer.go b/packages/taiko-client/driver/chain_syncer/blob/syncer.go index 8320eb60c08..2abb04395d0 100644 --- a/packages/taiko-client/driver/chain_syncer/blob/syncer.go +++ b/packages/taiko-client/driver/chain_syncer/blob/syncer.go @@ -18,7 +18,6 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" "github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/metadata" @@ -261,23 +260,17 @@ func (s *Syncer) onBlockProposed( return fmt.Errorf("failed to fetch tx list: %w", err) } - var decompressedTxListBytes []byte - if s.rpc.L2.ChainID.Cmp(params.HeklaNetworkID) == 0 { - decompressedTxListBytes = s.txListDecompressor.TryDecompressHekla( - meta.GetBlockID(), - txListBytes, - meta.GetBlobUsed(), - ) - } else { - decompressedTxListBytes = s.txListDecompressor.TryDecompress(meta.GetBlockID(), txListBytes, meta.GetBlobUsed()) - } - // Decompress the transactions list and try to insert a new head block to L2 EE. payloadData, err := s.insertNewHead( ctx, meta, parent, - decompressedTxListBytes, + s.txListDecompressor.TryDecompress( + s.rpc.L2.ChainID, + meta.GetBlockID(), + txListBytes, + meta.GetBlobUsed(), + ), &rawdb.L1Origin{ BlockID: meta.GetBlockID(), L2BlockHash: common.Hash{}, // Will be set by taiko-geth. diff --git a/packages/taiko-client/driver/txlist_decompressor/txlist_decompressor.go b/packages/taiko-client/driver/txlist_decompressor/txlist_decompressor.go index e288115fc8b..1edd4158557 100644 --- a/packages/taiko-client/driver/txlist_decompressor/txlist_decompressor.go +++ b/packages/taiko-client/driver/txlist_decompressor/txlist_decompressor.go @@ -5,6 +5,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" "github.com/taikoxyz/taiko-mono/packages/taiko-client/internal/utils" @@ -39,6 +40,20 @@ func NewTxListDecompressor( // less than or equal to maxBytesPerTxList. // 2. The transaction list bytes must be able to be RLP decoded into a list of transactions. func (v *TxListDecompressor) TryDecompress( + chainID *big.Int, + blockID *big.Int, + txListBytes []byte, + blobUsed bool, +) []byte { + if chainID.Cmp(params.HeklaNetworkID) == 0 { + return v.tryDecompressHekla(blockID, txListBytes, blobUsed) + } + + return v.tryDecompress(blockID, txListBytes, blobUsed) +} + +// tryDecompress is the inner implementation of TryDecompress. +func (v *TxListDecompressor) tryDecompress( blockID *big.Int, txListBytes []byte, blobUsed bool, @@ -76,10 +91,10 @@ func (v *TxListDecompressor) TryDecompress( return txListBytes } -// TryDecompressHekla is the same as TryDecompress, but it's used for Hekla network with +// TryDecompressHekla is the same as tryDecompress, but it's used for Hekla network with // an incorrect legacy bytes size check. // ref: https://github.com/taikoxyz/taiko-client/pull/783 -func (v *TxListDecompressor) TryDecompressHekla( +func (v *TxListDecompressor) tryDecompressHekla( blockID *big.Int, txListBytes []byte, blobUsed bool, diff --git a/packages/taiko-client/driver/txlist_decompressor/txlist_decompressor_test.go b/packages/taiko-client/driver/txlist_decompressor/txlist_decompressor_test.go index 980e866bb24..071ea04a0ec 100644 --- a/packages/taiko-client/driver/txlist_decompressor/txlist_decompressor_test.go +++ b/packages/taiko-client/driver/txlist_decompressor/txlist_decompressor_test.go @@ -39,12 +39,12 @@ func (s *TxListDecompressorTestSuite) SetupTest() { } func (s *TxListDecompressorTestSuite) TestZeroBytes() { - s.Empty(s.d.TryDecompress(chainID, []byte{}, false)) + s.Empty(s.d.TryDecompress(chainID, common.Big1, []byte{}, false)) } func (s *TxListDecompressorTestSuite) TestCalldataSize() { - s.Empty(s.d.TryDecompress(chainID, randBytes(rpc.BlockMaxTxListBytes+1), false)) - s.Empty(s.d.TryDecompress(chainID, randBytes(rpc.BlockMaxTxListBytes-1), false)) + s.Empty(s.d.TryDecompress(chainID, common.Big1, randBytes(rpc.BlockMaxTxListBytes+1), false)) + s.Empty(s.d.TryDecompress(chainID, common.Big1, randBytes(rpc.BlockMaxTxListBytes-1), false)) } func (s *TxListDecompressorTestSuite) TestValidTxList() { @@ -53,21 +53,21 @@ func (s *TxListDecompressorTestSuite) TestValidTxList() { decompressed, err := utils.Decompress(compressed) s.Nil(err) - s.Equal(s.d.TryDecompress(chainID, compressed, true), decompressed) - s.Equal(s.d.TryDecompress(chainID, compressed, false), decompressed) + s.Equal(s.d.TryDecompress(chainID, common.Big1, compressed, true), decompressed) + s.Equal(s.d.TryDecompress(chainID, common.Big1, compressed, false), decompressed) } func (s *TxListDecompressorTestSuite) TestInvalidTxList() { compressed, err := utils.Compress(randBytes(1024)) s.Nil(err) - s.Zero(len(s.d.TryDecompress(chainID, compressed, true))) - s.Zero(len(s.d.TryDecompress(chainID, compressed, false))) + s.Zero(len(s.d.TryDecompress(chainID, common.Big1, compressed, true))) + s.Zero(len(s.d.TryDecompress(chainID, common.Big1, compressed, false))) } func (s *TxListDecompressorTestSuite) TestInvalidZlibBytes() { - s.Zero(len(s.d.TryDecompress(chainID, randBytes(1024), true))) - s.Zero(len(s.d.TryDecompress(chainID, randBytes(1024), false))) + s.Zero(len(s.d.TryDecompress(chainID, common.Big1, randBytes(1024), true))) + s.Zero(len(s.d.TryDecompress(chainID, common.Big1, randBytes(1024), false))) } func TestDriverTestSuite(t *testing.T) {