Skip to content

Commit 3826c51

Browse files
committed
Remove max(publish, commit) to support older publish
1 parent 507ef74 commit 3826c51

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

internal/orchestrator/committer.go

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,8 @@ func (c *Committer) Start(ctx context.Context) {
124124
Str("target_publish_block", targetPublishBlock.String()).
125125
Msg("No previous publish position, initializing publisher cursor")
126126
} else {
127-
// We have a previous position - use max(lastPublished, lastCommitted)
127+
// We have a previous position
128128
targetPublishBlock = lastPublished
129-
if latestCommittedBlockNumber != nil && latestCommittedBlockNumber.Sign() > 0 {
130-
if latestCommittedBlockNumber.Cmp(lastPublished) > 0 {
131-
gap := new(big.Int).Sub(latestCommittedBlockNumber, lastPublished)
132-
log.Warn().
133-
Str("last_published", lastPublished.String()).
134-
Str("latest_committed", latestCommittedBlockNumber.String()).
135-
Str("gap", gap.String()).
136-
Msg("Publisher is behind committed position, seeking forward to committed value")
137-
targetPublishBlock = latestCommittedBlockNumber
138-
}
139-
}
140129
}
141130

142131
// Only update storage if we're changing the position
@@ -150,7 +139,7 @@ func (c *Committer) Start(ctx context.Context) {
150139
}
151140
}
152141

153-
// Store in memory for quick access
142+
// Store in memory for quick acess
154143
c.lastPublishedBlock.Store(targetPublishBlock.Uint64())
155144

156145
log.Info().
@@ -326,26 +315,26 @@ func (c *Committer) getBlockNumbersToCommit(ctx context.Context) ([]*big.Int, er
326315

327316
func (c *Committer) getBlockNumbersToPublish(ctx context.Context) ([]*big.Int, error) {
328317
// Get the last published block from storage (which was already corrected in Start)
329-
lastestPublishedBlockNumber, err := c.storage.StagingStorage.GetLastPublishedBlockNumber(c.rpc.GetChainID())
318+
latestPublishedBlockNumber, err := c.storage.StagingStorage.GetLastPublishedBlockNumber(c.rpc.GetChainID())
330319
if err != nil {
331320
return nil, fmt.Errorf("failed to get last published block number: %v", err)
332321
}
333322

334323
// This should never happen after Start() has run, but handle it defensively
335-
if lastestPublishedBlockNumber == nil || lastestPublishedBlockNumber.Sign() == 0 {
324+
if latestPublishedBlockNumber == nil || latestPublishedBlockNumber.Sign() == 0 {
336325
// Fall back to in-memory value which was set during Start
337-
lastestPublishedBlockNumber = new(big.Int).SetUint64(c.lastPublishedBlock.Load())
326+
latestPublishedBlockNumber = new(big.Int).SetUint64(c.lastPublishedBlock.Load())
338327
log.Warn().
339-
Str("fallback_value", lastestPublishedBlockNumber.String()).
328+
Str("fallback_value", latestPublishedBlockNumber.String()).
340329
Msg("Storage returned nil/0 for last published block, using in-memory value")
341330
}
342331

343332
log.Debug().
344-
Str("last_published", lastestPublishedBlockNumber.String()).
333+
Str("last_published", latestPublishedBlockNumber.String()).
345334
Msg("Determining blocks to publish")
346335

347-
startBlock := new(big.Int).Add(lastestPublishedBlockNumber, big.NewInt(1))
348-
endBlock, err := c.getBlockToCommitUntil(ctx, lastestPublishedBlockNumber)
336+
startBlock := new(big.Int).Add(latestPublishedBlockNumber, big.NewInt(1))
337+
endBlock, err := c.getBlockToCommitUntil(ctx, latestPublishedBlockNumber)
349338
if err != nil {
350339
return nil, fmt.Errorf("error getting block to commit until: %v", err)
351340
}

0 commit comments

Comments
 (0)