arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
Reorg l2db before starting pipeline
Eduard S eduard@iden3.io
Thu, 25 Feb 2021 13:24:59 +0100
commit

3c68aa501449297f77b16b7fe13ac8a94f63db6b

parent

706e4c7a3d4d896bde998d725612ca73ad45092a

1 files changed, 12 insertions(+), 0 deletions(-)

jump to
M coordinator/coordinator.go → coordinator/coordinator.go

@@ -383,11 +383,23 @@ fromBatch.BatchNum = c.lastNonFailedBatchNum

fromBatch.ForgerAddr = c.cfg.ForgerAddress fromBatch.StateRoot = big.NewInt(0) } + // Before starting the pipeline make sure we reset any + // l2tx from the pool that was forged in a batch that + // didn't end up being mined. We are already doing + // this in handleStopPipeline, but we do it again as a + // failsafe in case the last synced batchnum is + // different than in the previous call to l2DB.Reorg, + // or in case the node was restarted when there was a + // started batch that included l2txs but was not mined. + if err := c.l2DB.Reorg(fromBatch.BatchNum); err != nil { + return tracerr.Wrap(err) + } var err error if c.pipeline, err = c.newPipeline(ctx); err != nil { return tracerr.Wrap(err) } c.pipelineFromBatch = fromBatch + // Start the pipeline if err := c.pipeline.Start(fromBatch.BatchNum, stats, &c.vars); err != nil { c.pipeline = nil return tracerr.Wrap(err)