Skip to content

Commit

Permalink
[Batcher] Fix memory leak, reverse prepended blocks (#12874)
Browse files Browse the repository at this point in the history
* Don't prepend blocks in reverse order

* Fix memory leak
  • Loading branch information
mdehoog authored Nov 8, 2024
1 parent 6ea4e40 commit f7cef71
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions op-batcher/batcher/channel_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,11 @@ func (s *channelManager) TxConfirmed(_id txID, inclusionBlock eth.BlockID) {
delete(s.txChannels, id)
done, blocksToRequeue := channel.TxConfirmed(id, inclusionBlock)
if done {
s.removePendingChannel(channel)
if len(blocksToRequeue) > 0 {
s.blocks.Prepend(blocksToRequeue...)
}
for _, b := range blocksToRequeue {
s.blocks.Prepend(b)
s.metr.RecordL2BlockInPendingQueue(b)
}
}
Expand Down Expand Up @@ -505,8 +508,8 @@ func (s *channelManager) Requeue(newCfg ChannelConfig) {
}

// We put the blocks back at the front of the queue:
s.blocks.Prepend(blocksToRequeue...)
for _, b := range blocksToRequeue {
s.blocks.Prepend(b)
s.metr.RecordL2BlockInPendingQueue(b)
}

Expand Down

0 comments on commit f7cef71

Please sign in to comment.