Skip to content

Commit

Permalink
Avoid setting minInclusionBlock to math.MaxUint64 (will cause channel…
Browse files Browse the repository at this point in the history
… timeouts if ChannelTimeout == 1 because 0-math.MaxUint64 == 1)
  • Loading branch information
mdehoog committed Oct 11, 2024
1 parent a1940c3 commit 2621ef8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions op-batcher/batcher/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package batcher

import (
"fmt"
"math"

"github.com/ethereum-optimism/optimism/op-batcher/metrics"
"github.com/ethereum-optimism/optimism/op-node/rollup"
Expand Down Expand Up @@ -45,7 +44,6 @@ func newChannel(log log.Logger, metr metrics.Metricer, cfg ChannelConfig, rollup
channelBuilder: cb,
pendingTransactions: make(map[string]txData),
confirmedTransactions: make(map[string]eth.BlockID),
minInclusionBlock: uint64(math.MaxUint64),
}, nil
}

Expand Down Expand Up @@ -84,7 +82,11 @@ func (s *channel) TxConfirmed(id string, inclusionBlock eth.BlockID) (bool, []*t
s.channelBuilder.FramePublished(inclusionBlock.Number)

// Update min/max inclusion blocks for timeout check
s.minInclusionBlock = min(s.minInclusionBlock, inclusionBlock.Number)
if s.minInclusionBlock == 0 {
s.minInclusionBlock = inclusionBlock.Number
} else {
s.minInclusionBlock = min(s.minInclusionBlock, inclusionBlock.Number)
}
s.maxInclusionBlock = max(s.maxInclusionBlock, inclusionBlock.Number)

// If this channel timed out, put the pending blocks back into the local saved blocks
Expand Down

0 comments on commit 2621ef8

Please sign in to comment.