Skip to content

Commit

Permalink
fix return on node OOC. Fix logs (#3359)
Browse files Browse the repository at this point in the history
  • Loading branch information
agnusmor authored Feb 23, 2024
1 parent 19c6694 commit 6aacee4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const (
EventID_SequenceSenderHalt EventID = "SEQUENCESENDER HALT"
// EventID_NodeOOC is triggered when an OOC at node level is detected
EventID_NodeOOC EventID = "NODE OOC"
// EventID_UsedZKCountersOverflow is triggered when used ZK counters exceeds remaining batch ZK counters
EventID_UsedZKCountersOverflow EventID = "USED ZKCOUNTERS OVERFLOW"
// EventID_ReservedZKCountersOverflow is triggered when reserved ZK counters exceeds remaining batch ZK counters
EventID_ReservedZKCountersOverflow EventID = "RESERVED ZKCOUNTERS OVERFLOW"
// Source_Node is the source of the event
Expand Down
16 changes: 11 additions & 5 deletions sequencer/finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,20 +528,24 @@ func (f *finalizer) handleProcessTransactionResponse(ctx context.Context, tx *Tx
subOverflow := false
fits, overflowResource := f.wipBatch.imRemainingResources.Fits(state.BatchResources{ZKCounters: result.ReservedZkCounters, Bytes: uint64(len(tx.RawTx))})
if fits {
// Sustract the used resources from the batch
// Subtract the used resources from the batch
subOverflow, overflowResource = f.wipBatch.imRemainingResources.Sub(state.BatchResources{ZKCounters: result.UsedZkCounters, Bytes: uint64(len(tx.RawTx))})
if subOverflow { // Sanity check, this cannot happen as reservedZKCounters should be >= that usedZKCounters
log.Infof("current tx %s used resources exceeds the remaining batch resources, overflow resource: %s, updating metadata for tx in worker and continuing. Batch counters: %s, tx used counters: %s",
sLog := fmt.Sprintf("tx %s used resources exceeds the remaining batch resources, overflow resource: %s, updating metadata for tx in worker and continuing. Batch counters: %s, tx used counters: %s",
tx.HashStr, overflowResource, f.logZKCounters(f.wipBatch.imRemainingResources.ZKCounters), f.logZKCounters(result.UsedZkCounters))

log.Errorf(sLog)

f.LogEvent(ctx, event.Level_Error, event.EventID_UsedZKCountersOverflow, sLog, nil)
}
} else {
log.Infof("current tx %s reserved resources exceeds the remaining batch resources, overflow resource: %s, updating metadata for tx in worker and continuing. Batch counters: %s, tx reserved counters: %s",
tx.HashStr, overflowResource, f.logZKCounters(f.wipBatch.imRemainingResources.ZKCounters), f.logZKCounters(result.ReservedZkCounters))
if !f.batchConstraints.IsWithinConstraints(result.ReservedZkCounters) {
log.Warnf("current tx %s reserved resources exceeds the max limit for batch resources (node OOC), setting tx as invalid in the pool", tx.HashStr)
log.Infof("current tx %s reserved resources exceeds the max limit for batch resources (node OOC), setting tx as invalid in the pool", tx.HashStr)

f.LogEvent(ctx, event.Level_Error, event.EventID_NodeOOC,
fmt.Sprintf("tx: %s exceeds node max limit batch resources (node OOC), from: %s, IP: %s", tx.HashStr, tx.FromStr, tx.IP), nil)
f.LogEvent(ctx, event.Level_Info, event.EventID_NodeOOC,
fmt.Sprintf("tx %s exceeds node max limit batch resources (node OOC), from: %s, IP: %s", tx.HashStr, tx.FromStr, tx.IP), nil)

// Delete the transaction from the txSorted list
f.workerIntf.DeleteTx(tx.Hash, tx.From)
Expand All @@ -551,6 +555,8 @@ func (f *finalizer) handleProcessTransactionResponse(ctx context.Context, tx *Tx
if err != nil {
log.Errorf("failed to update status to invalid in the pool for tx %s, error: %v", tx.Hash.String(), err)
}

return nil, ErrBatchResourceOverFlow
}
}

Expand Down
4 changes: 1 addition & 3 deletions sequencer/l2block.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ func (f *finalizer) processPendingL2Blocks(ctx context.Context) {
}

err := f.processL2Block(ctx, l2Block)
f.dumpL2Block(l2Block)

if err != nil {
// Dump L2Block info
Expand Down Expand Up @@ -143,7 +142,6 @@ func (f *finalizer) storePendingL2Blocks(ctx context.Context) {
}

err := f.storeL2Block(ctx, l2Block)
f.dumpL2Block(l2Block)

if err != nil {
// Dump L2Block info
Expand Down Expand Up @@ -206,7 +204,7 @@ func (f *finalizer) processL2Block(ctx context.Context, l2Block *L2Block) error
if fits {
subOverflow, overflowResource := f.wipBatch.finalRemainingResources.Sub(state.BatchResources{ZKCounters: batchResponse.UsedZkCounters, Bytes: batchL2DataSize})
if subOverflow { // Sanity check, this cannot happen as reservedZKCounters should be >= that usedZKCounters
return fmt.Errorf("error sustracting L2 block %d [%d] used resources from the batch %d, overflow resource: %s, batch counters: %s, L2 block used counters: %s, batch bytes: %d, L2 block bytes: %d",
return fmt.Errorf("error subtracting L2 block %d [%d] used resources from the batch %d, overflow resource: %s, batch counters: %s, L2 block used counters: %s, batch bytes: %d, L2 block bytes: %d",
blockResponse.BlockNumber, l2Block.trackingNum, f.wipBatch.batchNumber, overflowResource, f.logZKCounters(f.wipBatch.finalRemainingResources.ZKCounters), f.logZKCounters(batchResponse.UsedZkCounters), f.wipBatch.finalRemainingResources.Bytes, batchL2DataSize)
}
} else {
Expand Down

0 comments on commit 6aacee4

Please sign in to comment.