Skip to content

Commit 4f2963a

Browse files
committed
pipeline replay mode
1 parent b1491c4 commit 4f2963a

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

rollup/pipeline/pipeline.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ var (
5353
)
5454

5555
type Pipeline struct {
56-
chain *core.BlockChain
57-
vmConfig vm.Config
58-
parent *types.Block
59-
start time.Time
60-
wg sync.WaitGroup
61-
ctx context.Context
62-
cancelCtx context.CancelFunc
56+
chain *core.BlockChain
57+
vmConfig vm.Config
58+
parent *types.Block
59+
start time.Time
60+
wg sync.WaitGroup
61+
ctx context.Context
62+
cancelCtx context.CancelFunc
63+
replayMode bool
6364

6465
// accumulators
6566
ccc *circuitcapacitychecker.CircuitCapacityChecker
@@ -114,6 +115,12 @@ func (p *Pipeline) WithBeforeTxHook(beforeTxHook func()) *Pipeline {
114115
return p
115116
}
116117

118+
// WithReplayMode enables the replay mode that allows L1 messages to be skipped
119+
func (p *Pipeline) WithReplayMode() *Pipeline {
120+
p.replayMode = true
121+
return p
122+
}
123+
117124
func (p *Pipeline) Start(deadline time.Time) error {
118125
p.start = time.Now()
119126
p.txnQueue = make(chan *types.Transaction)
@@ -266,7 +273,7 @@ func (p *Pipeline) traceAndApplyStage(txsIn <-chan *types.Transaction) (<-chan e
266273
return
267274
}
268275

269-
if tx.IsL1MessageTx() && tx.AsL1MessageTx().QueueIndex != p.nextL1MsgIndex {
276+
if !p.replayMode && tx.IsL1MessageTx() && tx.AsL1MessageTx().QueueIndex != p.nextL1MsgIndex {
270277
// Continue, we might still be able to include some L2 messages
271278
sendCancellable(resCh, ErrUnexpectedL1MessageIndex, p.ctx.Done())
272279
continue

rollup/state_processor/pipelined_state_processor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (p *Processor) Process(block *types.Block, statedb *state.StateDB, cfg vm.C
4343
}
4444
}
4545

46-
pl := pipeline.NewPipeline(p.chain, cfg, statedb, header, nextL1MsgIndex, p.ccc)
46+
pl := pipeline.NewPipeline(p.chain, cfg, statedb, header, nextL1MsgIndex, p.ccc).WithReplayMode()
4747
pl.Start(time.Now().Add(time.Minute))
4848
defer pl.Release()
4949

0 commit comments

Comments
 (0)