diff --git a/packages/taiko-client/driver/chain_syncer/blob/syncer.go b/packages/taiko-client/driver/chain_syncer/blob/syncer.go index 9cfea3c5a63..f07d2e6cffc 100644 --- a/packages/taiko-client/driver/chain_syncer/blob/syncer.go +++ b/packages/taiko-client/driver/chain_syncer/blob/syncer.go @@ -16,6 +16,7 @@ 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" @@ -260,13 +261,20 @@ 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(event.BlockId, txListBytes, event.Meta.BlobUsed) + } else { + decompressedTxListBytes = s.txListDecompressor.TryDecompress(event.BlockId, txListBytes, event.Meta.BlobUsed) + } + // Decompress the transactions list and try to insert a new head block to L2 EE. payloadData, err := s.insertNewHead( ctx, event, parent, s.state.GetHeadBlockID(), - s.txListDecompressor.TryDecompress(event.BlockId, txListBytes, event.Meta.BlobUsed), + decompressedTxListBytes, &rawdb.L1Origin{ BlockID: event.BlockId, 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 80f6e553b2d..e288115fc8b 100644 --- a/packages/taiko-client/driver/txlist_decompressor/txlist_decompressor.go +++ b/packages/taiko-client/driver/txlist_decompressor/txlist_decompressor.go @@ -75,3 +75,44 @@ func (v *TxListDecompressor) TryDecompress( log.Info("Transaction list is valid", "blockID", blockID) return txListBytes } + +// 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( + blockID *big.Int, + txListBytes []byte, + blobUsed bool, +) []byte { + // If the transaction list is empty, it's valid. + if len(txListBytes) == 0 { + return []byte{} + } + + var ( + txs types.Transactions + err error + ) + + // Decompress the transaction list bytes. + if txListBytes, err = utils.Decompress(txListBytes); err != nil { + log.Info("Failed to decompress tx list bytes", "blockID", blockID, "error", err) + return []byte{} + } + + // If calldata is used, the compressed bytes of the transaction list must be + // less than or equal to maxBytesPerTxList. + if !blobUsed && (len(txListBytes) > int(v.maxBytesPerTxList)) { + log.Info("Compressed transactions list binary too large", "length", len(txListBytes), "blockID", blockID) + return []byte{} + } + + // Try to RLP decode the transaction list bytes. + if err = rlp.DecodeBytes(txListBytes, &txs); err != nil { + log.Info("Failed to decode transactions list bytes", "blockID", blockID, "error", err) + return []byte{} + } + + log.Info("Transaction list is valid", "blockID", blockID) + return txListBytes +}