Skip to content

Commit

Permalink
fix getting stateroot from previous batch (GetWIPBatch)
Browse files Browse the repository at this point in the history
  • Loading branch information
agnusmor committed Jun 21, 2023
1 parent 0b33b87 commit 860f0e7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sequencer/dbmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,18 +257,18 @@ func (d *dbManager) GetWIPBatch(ctx context.Context) (*WipBatch, error) {
}
lastBatch.Transactions = lastBatchTxs

var prevLastBatchTxs []types.Transaction
/*var prevLastBatchTxs []types.Transaction
if previousLastBatch != nil {
prevLastBatchTxs, _, err = state.DecodeTxs(previousLastBatch.BatchL2Data)
if err != nil {
return nil, err
log.Errorf("failed to decode txs of previous last batch %d: %v", previousLastBatch.BatchNumber, err)
}
}
}*/

var lastStateRoot common.Hash
// If the last two batches have no txs, the stateRoot can not be retrieved from the l2block because there is no tx.
// If the last batch have no txs, the stateRoot can not be retrieved from the l2block because there is no tx.
// In this case, the stateRoot must be gotten from the previousLastBatch
if len(lastBatchTxs) == 0 && previousLastBatch != nil && len(prevLastBatchTxs) == 0 {
if len(lastBatchTxs) == 0 && previousLastBatch != nil {
lastStateRoot = previousLastBatch.StateRoot
} else {
lastStateRoot, err = d.state.GetLastStateRoot(ctx, dbTx)
Expand Down

0 comments on commit 860f0e7

Please sign in to comment.