forked from erigontech/erigon
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sequencer): add-checked-regarding-ds-execution (#1249)
- Loading branch information
Showing
3 changed files
with
91 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package stages | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/ledgerwatch/log/v3" | ||
|
||
"github.com/ledgerwatch/erigon/eth/stagedsync" | ||
) | ||
|
||
func resequence( | ||
s *stagedsync.StageState, | ||
u stagedsync.Unwinder, | ||
ctx context.Context, | ||
cfg SequenceBlockCfg, | ||
historyCfg stagedsync.HistoryCfg, | ||
lastBatch, highestBatchInDs uint64, | ||
) (err error) { | ||
if !cfg.zk.SequencerResequence { | ||
panic(fmt.Sprintf("[%s] The node need re-sequencing but this option is disabled.", s.LogPrefix())) | ||
} | ||
|
||
log.Info(fmt.Sprintf("[%s] Last batch %d is lower than highest batch in datastream %d, resequencing...", s.LogPrefix(), lastBatch, highestBatchInDs)) | ||
|
||
batches, err := cfg.datastreamServer.ReadBatches(lastBatch+1, highestBatchInDs) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err = cfg.datastreamServer.UnwindToBatchStart(lastBatch + 1); err != nil { | ||
return err | ||
} | ||
|
||
log.Info(fmt.Sprintf("[%s] Resequence from batch %d to %d in data stream", s.LogPrefix(), lastBatch+1, highestBatchInDs)) | ||
for _, batch := range batches { | ||
batchJob := NewResequenceBatchJob(batch) | ||
subBatchCount := 0 | ||
for batchJob.HasMoreBlockToProcess() { | ||
if err = sequencingBatchStep(s, u, ctx, cfg, historyCfg, batchJob); err != nil { | ||
return err | ||
} | ||
|
||
subBatchCount += 1 | ||
} | ||
|
||
log.Info(fmt.Sprintf("[%s] Resequenced original batch %d with %d batches", s.LogPrefix(), batchJob.batchToProcess[0].BatchNumber, subBatchCount)) | ||
if cfg.zk.SequencerResequenceStrict && subBatchCount != 1 { | ||
return fmt.Errorf("strict mode enabled, but resequenced batch %d has %d sub-batches", batchJob.batchToProcess[0].BatchNumber, subBatchCount) | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters