Skip to content

Commit 168d73b

Browse files
committed
fixes
1 parent 9a09230 commit 168d73b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

sequencers/based/sequencer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func NewBasedSequencer(
5454
logger: logger.With().Str("component", "based_sequencer").Logger(),
5555
checkpointStore: seqcommon.NewCheckpointStore(db, ds.NewKey("/based/checkpoint")),
5656
}
57-
bs.SetDAHeight(genesis.DAStartHeight) // based sequencers need community approval of da start height given no submission are done
57+
bs.SetDAHeight(genesis.DAStartHeight) // based sequencers need community consensus about the da start height given no submission are done
5858

5959
// Load checkpoint from DB, or initialize if none exists
6060
loadCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)

sequencers/single/sequencer.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ func NewSequencer(
7373
proposer: proposer,
7474
fiRetriever: fiRetriever,
7575
checkpointStore: seqcommon.NewCheckpointStore(db, ds.NewKey("/single/checkpoint")),
76-
daHeight: atomic.Uint64{}, // empty, set by executor or submitter
7776
}
77+
s.SetDAHeight(genesis.DAStartHeight) // default value, will be overriden by executor or submitter
7878

7979
loadCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
8080
defer cancel()
@@ -86,8 +86,16 @@ func NewSequencer(
8686

8787
// Load checkpoint from DB, or initialize if none exists
8888
checkpoint, err := s.checkpointStore.Load(loadCtx)
89-
if err != nil && !errors.Is(err, seqcommon.ErrCheckpointNotFound) {
90-
return nil, fmt.Errorf("failed to load checkpoint from DB: %w", err)
89+
if err != nil {
90+
if errors.Is(err, seqcommon.ErrCheckpointNotFound) {
91+
// No checkpoint exists, initialize with current DA height
92+
s.checkpoint = &seqcommon.Checkpoint{
93+
DAHeight: s.GetDAHeight(),
94+
TxIndex: 0,
95+
}
96+
} else {
97+
return nil, fmt.Errorf("failed to load checkpoint from DB: %w", err)
98+
}
9199
} else {
92100
s.checkpoint = checkpoint
93101
// If we had a non-zero tx index, we're resuming from a crash mid-block
@@ -142,7 +150,7 @@ func (c *Sequencer) GetNextBatch(ctx context.Context, req coresequencer.GetNextB
142150
daHeight := c.GetDAHeight()
143151

144152
// checkpoint init path, only hit when sequencer is bootstrapping
145-
if daHeight > 0 && c.checkpoint == nil {
153+
if c.checkpoint.DAHeight == 0 {
146154
c.checkpoint = &seqcommon.Checkpoint{
147155
DAHeight: daHeight,
148156
TxIndex: 0,

0 commit comments

Comments
 (0)