From e9e1cc24e42f5144ead381e8ee0d181f675db952 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 26 Apr 2024 13:47:27 +0800 Subject: [PATCH] feat(proposer): fix an issue in `ProposeTxLists` --- proposer/proposer.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/proposer/proposer.go b/proposer/proposer.go index f2aa606e1..cbbcbf6fd 100644 --- a/proposer/proposer.go +++ b/proposer/proposer.go @@ -340,12 +340,12 @@ func (p *Proposer) ProposeOp(ctx context.Context) error { // ProposeTxLists proposes the given transaction lists to TaikoL1 contract. func (p *Proposer) ProposeTxLists(ctx context.Context, txListsBytes [][]byte) []error { - txCandidates := make([]txmgr.TxCandidate, len(txListsBytes)) + txCandidates := make([]txmgr.TxCandidate, 0) for i, txListBytes := range txListsBytes { compressedTxListBytes, err := utils.Compress(txListBytes) if err != nil { - log.Warn("Failed to compress transactions list", "index", i, "error", err) + log.Error("Failed to compress transactions list", "index", i, "error", err) break } @@ -356,11 +356,15 @@ func (p *Proposer) ProposeTxLists(ctx context.Context, txListsBytes [][]byte) [] compressedTxListBytes, ) if err != nil { - log.Warn("Failed to build TaikoL1.proposeBlock transaction", "error", err) + log.Error("Failed to build TaikoL1.proposeBlock transaction", "error", err) break } - txCandidates[i] = *candidate + txCandidates = append(txCandidates, *candidate) + } + + if len(txCandidates) == 0 { + return []error{} } // Send the transactions to the TaikoL1 contract, and if any of them fails, try