Skip to content

Commit 9ee9954

Browse files
committed
Merge branch 'julien/persist-base' into julien/based-block-time
2 parents 7ed1ee3 + feb309b commit 9ee9954

File tree

5 files changed

+264
-250
lines changed

5 files changed

+264
-250
lines changed

docs/guides/migrating-to-ev-abci.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ import (
4141
)
4242
```
4343

44-
1. Add the migration manager keeper to your app struct
45-
2. Register the module in your module manager
46-
3. Configure the migration manager in your app initialization
44+
2. Add the migration manager keeper to your app struct
45+
3. Register the module in your module manager
46+
4. Configure the migration manager in your app initialization
4747

4848
### Step 2: Replace Staking Module with Wrapper
4949

sequencers/based/sequencer.go

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,14 @@ func NewBasedSequencer(
7171
}
7272
} else {
7373
bs.checkpoint = checkpoint
74-
bs.logger.Info().
75-
Uint64("da_height", checkpoint.DAHeight).
76-
Uint64("tx_index", checkpoint.TxIndex).
77-
Msg("loaded based sequencer checkpoint from DB")
74+
// If we had a non-zero tx index, we're resuming from a crash mid-block
75+
// The transactions starting from that index are what we need
76+
if checkpoint.TxIndex > 0 {
77+
bs.logger.Debug().
78+
Uint64("tx_index", checkpoint.TxIndex).
79+
Uint64("da_height", checkpoint.DAHeight).
80+
Msg("resuming from checkpoint within DA epoch")
81+
}
7882
}
7983

8084
return bs, nil
@@ -109,9 +113,8 @@ func (s *BasedSequencer) GetNextBatch(ctx context.Context, req coresequencer.Get
109113
batch := s.createBatchFromCheckpoint(req.MaxBytes)
110114

111115
// Update checkpoint with how many transactions we consumed
112-
txCount := uint64(len(batch.Transactions))
113-
if txCount > 0 {
114-
s.checkpoint.TxIndex += txCount
116+
if daHeight > 0 || len(batch.Transactions) > 0 {
117+
s.checkpoint.TxIndex += uint64(len(batch.Transactions))
115118

116119
// If we've consumed all transactions from this DA epoch, move to next
117120
if s.checkpoint.TxIndex >= uint64(len(s.currentBatchTxs)) {
@@ -125,7 +128,6 @@ func (s *BasedSequencer) GetNextBatch(ctx context.Context, req coresequencer.Get
125128

126129
// Persist checkpoint
127130
if err := s.checkpointStore.Save(ctx, s.checkpoint); err != nil {
128-
s.logger.Error().Err(err).Msg("failed to save checkpoint")
129131
return nil, fmt.Errorf("failed to save checkpoint: %w", err)
130132
}
131133
}
@@ -150,17 +152,16 @@ func (s *BasedSequencer) fetchNextDAEpoch(ctx context.Context, maxBytes uint64)
150152
if err != nil {
151153
// Check if forced inclusion is not configured
152154
if errors.Is(err, block.ErrForceInclusionNotConfigured) {
153-
return time.Time{}, currentDAHeight, block.ErrForceInclusionNotConfigured
155+
return time.Time{}, 0, block.ErrForceInclusionNotConfigured
154156
} else if errors.Is(err, coreda.ErrHeightFromFuture) {
155157
// If we get a height from future error, stay at current position
156158
// We'll retry the same height on the next call until DA produces that block
157159
s.logger.Debug().
158160
Uint64("da_height", currentDAHeight).
159161
Msg("DA height from future, waiting for DA to produce block")
160-
return time.Time{}, currentDAHeight, nil
162+
return time.Time{}, 0, nil
161163
}
162-
s.logger.Error().Err(err).Uint64("da_height", currentDAHeight).Msg("failed to retrieve forced inclusion transactions")
163-
return time.Time{}, currentDAHeight, err
164+
return time.Time{}, 0, fmt.Errorf("failed to retrieve forced inclusion transactions: %w", err)
164165
}
165166

166167
// Validate and filter transactions
@@ -190,14 +191,6 @@ func (s *BasedSequencer) fetchNextDAEpoch(ctx context.Context, maxBytes uint64)
190191
// Cache the transactions for this DA epoch
191192
s.currentBatchTxs = validTxs
192193

193-
// If we had a non-zero tx index, we're resuming from a crash mid-block
194-
// The transactions starting from that index are what we need
195-
if s.checkpoint.TxIndex > 0 {
196-
s.logger.Info().
197-
Uint64("tx_index", s.checkpoint.TxIndex).
198-
Msg("resuming from checkpoint within DA epoch")
199-
}
200-
201194
return forcedTxsEvent.Timestamp.UTC(), forcedTxsEvent.EndDaHeight, nil
202195
}
203196

0 commit comments

Comments
 (0)