mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
Merge pull request #537 from hermeznetwork/fix/l2dbreorg
Fix l2db reorg of forging l2txs
This commit is contained in:
@@ -348,13 +348,13 @@ func (c *Coordinator) handleReorg(ctx context.Context, msg *MsgSyncReorg) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Coordinator) handleStopPipeline(ctx context.Context, reason string) error {
|
func (c *Coordinator) handleStopPipeline(ctx context.Context, reason string) error {
|
||||||
if err := c.l2DB.Reorg(common.BatchNum(c.stats.Sync.LastBatch)); err != nil {
|
|
||||||
return tracerr.Wrap(err)
|
|
||||||
}
|
|
||||||
if c.pipeline != nil {
|
if c.pipeline != nil {
|
||||||
c.pipeline.Stop(c.ctx)
|
c.pipeline.Stop(c.ctx)
|
||||||
c.pipeline = nil
|
c.pipeline = nil
|
||||||
}
|
}
|
||||||
|
if err := c.l2DB.Reorg(common.BatchNum(c.stats.Sync.LastBatch)); err != nil {
|
||||||
|
return tracerr.Wrap(err)
|
||||||
|
}
|
||||||
if strings.Contains(reason, common.AuctionErrMsgCannotForge) { //nolint:staticcheck
|
if strings.Contains(reason, common.AuctionErrMsgCannotForge) { //nolint:staticcheck
|
||||||
// TODO: Check that we are in a slot in which we can't forge
|
// TODO: Check that we are in a slot in which we can't forge
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -346,9 +346,10 @@ func (l2db *L2DB) InvalidateOldNonces(updatedAccounts []common.IdxNonce, batchNu
|
|||||||
// The state of the affected txs can change form Forged -> Pending or from Invalid -> Pending
|
// The state of the affected txs can change form Forged -> Pending or from Invalid -> Pending
|
||||||
func (l2db *L2DB) Reorg(lastValidBatch common.BatchNum) error {
|
func (l2db *L2DB) Reorg(lastValidBatch common.BatchNum) error {
|
||||||
_, err := l2db.db.Exec(
|
_, err := l2db.db.Exec(
|
||||||
`UPDATE tx_pool SET batch_num = NULL, state = $1
|
`UPDATE tx_pool SET batch_num = NULL, state = $1
|
||||||
WHERE (state = $2 OR state = $3) AND batch_num > $4`,
|
WHERE (state = $2 OR state = $3 OR state = $4) AND batch_num > $5`,
|
||||||
common.PoolL2TxStatePending,
|
common.PoolL2TxStatePending,
|
||||||
|
common.PoolL2TxStateForging,
|
||||||
common.PoolL2TxStateForged,
|
common.PoolL2TxStateForged,
|
||||||
common.PoolL2TxStateInvalid,
|
common.PoolL2TxStateInvalid,
|
||||||
lastValidBatch,
|
lastValidBatch,
|
||||||
|
|||||||
Reference in New Issue
Block a user