Skip to content

Commit

Permalink
comment code (#1684)
Browse files Browse the repository at this point in the history
  • Loading branch information
ARR552 committed Feb 22, 2023
1 parent 1d908b5 commit b788401
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions sequencer/dbmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,41 +162,41 @@ func (d *dbManager) storeProcessedTxAndDeleteFromPool() {
log.Errorf("StoreProcessedTxAndDeleteFromPool: %v", err)
}

// Check if the Tx is still valid in the state to detect reorgs
lastStateRoot, err := d.state.GetLastStateRoot(d.ctx, dbTx)
if err != nil {
err = dbTx.Rollback(d.ctx)
if err != nil {
log.Errorf("StoreProcessedTxAndDeleteFromPool: %v", err)
}
d.txsStore.Wg.Done()
continue
}

if txToStore.previousL2BlockStateRoot != state.ZeroHash && lastStateRoot != txToStore.previousL2BlockStateRoot {
// We may have closed the batch because of a new GER without transactions
// If there are no transactions in the batch when closing it, we can not base our check in l2 blocks
// so we will check against the latest closed batch

lastBatch, err := d.state.GetLastClosedBatch(d.ctx, dbTx)
if err != nil {
err = dbTx.Rollback(d.ctx)
if err != nil {
log.Errorf("StoreProcessedTxAndDeleteFromPool: %v", err)
}
d.txsStore.Wg.Done()
continue
}

lastStateRoot = lastBatch.StateRoot

if lastStateRoot != txToStore.previousL2BlockStateRoot {
log.Warnf("L2 reorg detected. Expected OldStateRoot: %v actual OldStateRoot: %v", lastStateRoot, txToStore.previousL2BlockStateRoot)
d.l2ReorgCh <- L2ReorgEvent{}
d.txsStore.Wg.Done()
continue
}
}
// // Check if the Tx is still valid in the state to detect reorgs
// lastStateRoot, err := d.state.GetLastStateRoot(d.ctx, dbTx)
// if err != nil {
// err = dbTx.Rollback(d.ctx)
// if err != nil {
// log.Errorf("StoreProcessedTxAndDeleteFromPool: %v", err)
// }
// d.txsStore.Wg.Done()
// continue
// }

// if txToStore.previousL2BlockStateRoot != state.ZeroHash && lastStateRoot != txToStore.previousL2BlockStateRoot {
// // We may have closed the batch because of a new GER without transactions
// // If there are no transactions in the batch when closing it, we can not base our check in l2 blocks
// // so we will check against the latest closed batch

// lastBatch, err := d.state.GetLastClosedBatch(d.ctx, dbTx)
// if err != nil {
// err = dbTx.Rollback(d.ctx)
// if err != nil {
// log.Errorf("StoreProcessedTxAndDeleteFromPool: %v", err)
// }
// d.txsStore.Wg.Done()
// continue
// }

// lastStateRoot = lastBatch.StateRoot

// if lastStateRoot != txToStore.previousL2BlockStateRoot {
// log.Warnf("L2 reorg detected. Expected OldStateRoot: %v actual OldStateRoot: %v", lastStateRoot, txToStore.previousL2BlockStateRoot)
// d.l2ReorgCh <- L2ReorgEvent{}
// d.txsStore.Wg.Done()
// continue
// }
// }

err = d.StoreProcessedTransaction(d.ctx, txToStore.batchNumber, txToStore.txResponse, txToStore.coinbase, txToStore.timestamp, dbTx)
if err != nil {
Expand Down

0 comments on commit b788401

Please sign in to comment.