Skip to content

Commit 8552ab4

Browse files
committed
feat: check index before slicing allTxs
1 parent 998c79a commit 8552ab4

File tree

1 file changed

+7
-1
lines changed
  • packages/taiko-client/driver/chain_syncer/blob/blocks_inserter

1 file changed

+7
-1
lines changed

Diff for: packages/taiko-client/driver/chain_syncer/blob/blocks_inserter/pacaya.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ func (i *BlocksInserterPacaya) InsertBlocks(
188188
return fmt.Errorf("failed to create TaikoAnchor.anchorV3 transaction: %w", err)
189189
}
190190

191+
// Get transactions in the block.
192+
txs := types.Transactions{}
193+
if txListCursor+int(blockInfo.NumTransactions) > len(allTxs) {
194+
txs = allTxs[txListCursor : txListCursor+int(blockInfo.NumTransactions)]
195+
}
196+
191197
// Decompress the transactions list and try to insert a new head block to L2 EE.
192198
if lastPayloadData, err = createPayloadAndSetHead(
193199
ctx,
@@ -207,7 +213,7 @@ func (i *BlocksInserterPacaya) InsertBlocks(
207213
L1BlockHeight: meta.GetRawBlockHeight(),
208214
L1BlockHash: meta.GetRawBlockHash(),
209215
},
210-
Txs: allTxs[txListCursor : txListCursor+int(blockInfo.NumTransactions)],
216+
Txs: txs,
211217
Withdrawals: make([]*types.Withdrawal, 0),
212218
BaseFee: baseFee,
213219
},

0 commit comments

Comments
 (0)