Skip to content

Commit

Permalink
added a few logs on tx process in sequencer and repeating code abstra…
Browse files Browse the repository at this point in the history
…ction (#1140)
  • Loading branch information
V-Staykov authored Sep 9, 2024
1 parent 9d3c09a commit b0003ac
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
4 changes: 4 additions & 0 deletions zk/stages/stage_sequence_execute_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func attemptAddTransaction(
}
anyOverflow := overflow || batchDataOverflow
if anyOverflow && !l1Recovery {
log.Debug("Transaction preexecute overflow detected", "txHash", transaction.Hash(), "coutners", batchCounters.CombineCollectorsNoChanges().UsedAsString())
return nil, nil, true, nil
}

Expand Down Expand Up @@ -177,10 +178,13 @@ func attemptAddTransaction(
return nil, nil, false, err
}

counters := batchCounters.CombineCollectorsNoChanges().UsedAsString()
if overflow {
log.Debug("Transaction overflow detected", "txHash", transaction.Hash(), "coutners", counters)
ibs.RevertToSnapshot(snapshot)
return nil, nil, true, nil
}
log.Debug("Transaction added", "txHash", transaction.Hash(), "coutners", counters)

// add the gas only if not reverted. This should not be moved above the overflow check
header.GasUsed = gasUsed
Expand Down
18 changes: 2 additions & 16 deletions zk/txpool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1052,14 +1052,7 @@ func (p *TxPool) addTxs(blockNum uint64, cacheView kvcache.CacheView, senders *s
sendersWithChangedState[mt.Tx.SenderID] = struct{}{}
}

for _, mt := range p.overflowZkCounters {
pending.Remove(mt)
discard(mt, OverflowZkCounters)
sendersWithChangedState[mt.Tx.SenderID] = struct{}{}
// do not hold on to the discard reason for an OOC issue
p.discardReasonsLRU.Remove(string(mt.Tx.IDHash[:]))
}
p.overflowZkCounters = p.overflowZkCounters[:0]
p.discardOverflowZkCountersFromPending(pending, discard, sendersWithChangedState)

for senderID := range sendersWithChangedState {
nonce, balance, err := senders.info(cacheView, senderID)
Expand Down Expand Up @@ -1149,14 +1142,7 @@ func (p *TxPool) addTxsOnNewBlock(
}
}

for _, mt := range p.overflowZkCounters {
pending.Remove(mt)
discard(mt, OverflowZkCounters)
sendersWithChangedState[mt.Tx.SenderID] = struct{}{}
// do not hold on to the discard reason for an OOC issue
p.discardReasonsLRU.Remove(string(mt.Tx.IDHash[:]))
}
p.overflowZkCounters = p.overflowZkCounters[:0]
p.discardOverflowZkCountersFromPending(pending, discard, sendersWithChangedState)

for senderID := range sendersWithChangedState {
nonce, balance, err := senders.info(cacheView, senderID)
Expand Down
16 changes: 16 additions & 0 deletions zk/txpool/pool_zk.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,22 @@ func (p *TxPool) MarkForDiscardFromPendingBest(txHash common.Hash) {
}
}

// discards the transactions that are in overflowZkCoutners from pending
// executes the discard function on them
// deletes the tx from the sendersWithChangedState map
// deletes the discarded txs from the overflowZkCounters
func (p *TxPool) discardOverflowZkCountersFromPending(pending *PendingPool, discard func(*metaTx, DiscardReason), sendersWithChangedState map[uint64]struct{}) {
for _, mt := range p.overflowZkCounters {
log.Info("[tx_pool] Removing TX from pending due to counter overflow", "tx", mt.Tx.IDHash)
pending.Remove(mt)
discard(mt, OverflowZkCounters)
sendersWithChangedState[mt.Tx.SenderID] = struct{}{}
// do not hold on to the discard reason for an OOC issue
p.discardReasonsLRU.Remove(string(mt.Tx.IDHash[:]))
}
p.overflowZkCounters = p.overflowZkCounters[:0]
}

func (p *TxPool) StartIfNotStarted(ctx context.Context, txPoolDb kv.RoDB, coreTx kv.Tx) error {
p.lock.Lock()
defer p.lock.Unlock()
Expand Down

0 comments on commit b0003ac

Please sign in to comment.