Skip to content

Commit fa3ab8d

Browse files
committed
updates
1 parent e808357 commit fa3ab8d

File tree

4 files changed

+23
-26
lines changed

4 files changed

+23
-26
lines changed

block/internal/da/forced_inclusion_retriever.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ func (r *ForcedInclusionRetriever) RetrieveForcedIncludedTxs(ctx context.Context
6262
return nil, ErrForceInclusionNotConfigured
6363
}
6464

65+
if daHeight < r.daStartHeight {
66+
return nil, ErrForceInclusionNotConfigured
67+
}
68+
6569
epochStart, epochEnd, currentEpochNumber := types.CalculateEpochBoundaries(daHeight, r.daStartHeight, r.daEpochSize)
6670

6771
if daHeight != epochEnd {

block/internal/executing/executor.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,21 +197,13 @@ func (e *Executor) initializeState() error {
197197
LastBlockHeight: e.genesis.InitialHeight - 1,
198198
LastBlockTime: e.genesis.StartTime,
199199
AppHash: stateRoot,
200-
// DA start height is usually 0 at InitChain unless it is a re-genesis.
201-
// The sequencer does not know at which DA block its first block will be included.
200+
// DA start height is usually 0 at InitChain unless it is a re-genesis or a based sequencer.
202201
DAHeight: e.genesis.DAStartHeight,
203202
}
204203
}
205204

206205
e.setLastState(state)
207-
// Defer setting sequencer DA height at genesis. At chain genesis there are no
208-
// included DA blocks yet, so the sequencer shouldn't be updated with the
209-
// state's DA height until we've produced/observed at least the first included
210-
// block. Only set the sequencer DA height when the chain has progressed past
211-
// the initial genesis height.
212-
if state.LastBlockHeight >= e.genesis.InitialHeight {
213-
e.sequencer.SetDAHeight(state.DAHeight)
214-
}
206+
e.sequencer.SetDAHeight(state.DAHeight)
215207

216208
// Initialize store height using batch for atomicity
217209
batch, err := e.store.NewBatch(e.ctx)

sequencers/based/sequencer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ func NewBasedSequencer(
5353
fiRetriever: fiRetriever,
5454
logger: logger.With().Str("component", "based_sequencer").Logger(),
5555
checkpointStore: seqcommon.NewCheckpointStore(db, ds.NewKey("/based/checkpoint")),
56-
daHeight: atomic.Uint64{}, // empty, set by executor or submitter
5756
}
57+
bs.SetDAHeight(genesis.DAStartHeight) // based sequencers need community approval of 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)
@@ -96,11 +96,11 @@ func (s *BasedSequencer) SubmitBatchTxs(ctx context.Context, req coresequencer.S
9696
// GetNextBatch retrieves the next batch of transactions from the DA layer using the checkpoint
9797
// It treats DA as a queue and only persists where it is in processing
9898
func (s *BasedSequencer) GetNextBatch(ctx context.Context, req coresequencer.GetNextBatchRequest) (*coresequencer.GetNextBatchResponse, error) {
99-
// If we have no cached transactions or we've consumed all from the current DA block,
100-
// fetch the next DA epoch
10199
daHeight := s.GetDAHeight()
102100

103-
if len(s.currentBatchTxs) == 0 || s.checkpoint.TxIndex >= uint64(len(s.currentBatchTxs)) {
101+
// If we have no cached transactions or we've consumed all from the current DA block,
102+
// fetch the next DA epoch
103+
if daHeight > 0 && (len(s.currentBatchTxs) == 0 || s.checkpoint.TxIndex >= uint64(len(s.currentBatchTxs))) {
104104
daEndTime, daEndHeight, err := s.fetchNextDAEpoch(ctx, req.MaxBytes)
105105
if err != nil {
106106
return nil, err

sequencers/single/sequencer.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,8 @@ func NewSequencer(
8686

8787
// Load checkpoint from DB, or initialize if none exists
8888
checkpoint, err := s.checkpointStore.Load(loadCtx)
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-
}
89+
if err != nil && errors.Is(err, seqcommon.ErrCheckpointNotFound) {
90+
return nil, fmt.Errorf("failed to load checkpoint from DB: %w", err)
9991
} else {
10092
s.checkpoint = checkpoint
10193
// If we had a non-zero tx index, we're resuming from a crash mid-block
@@ -147,10 +139,19 @@ func (c *Sequencer) GetNextBatch(ctx context.Context, req coresequencer.GetNextB
147139
return nil, ErrInvalidId
148140
}
149141

142+
daHeight := c.GetDAHeight()
143+
144+
// checkpoint init path, only hit when sequencer is bootstrapping
145+
if daHeight > 0 && c.checkpoint == nil {
146+
c.checkpoint = &seqcommon.Checkpoint{
147+
DAHeight: daHeight,
148+
TxIndex: 0,
149+
}
150+
}
151+
150152
// If we have no cached transactions or we've consumed all from the current cache,
151153
// fetch the next DA epoch
152-
daHeight := c.GetDAHeight()
153-
if len(c.cachedForcedInclusionTxs) == 0 || c.checkpoint.TxIndex >= uint64(len(c.cachedForcedInclusionTxs)) {
154+
if daHeight > 0 && (len(c.cachedForcedInclusionTxs) == 0 || c.checkpoint.TxIndex >= uint64(len(c.cachedForcedInclusionTxs))) {
154155
daEndHeight, err := c.fetchNextDAEpoch(ctx, req.MaxBytes)
155156
if err != nil {
156157
return nil, err

0 commit comments

Comments
 (0)