From 6aacee4cdc0e0cfa2cc8db18dd7f268a32662f62 Mon Sep 17 00:00:00 2001 From: agnusmor <100322135+agnusmor@users.noreply.github.com> Date: Fri, 23 Feb 2024 12:39:07 +0100 Subject: [PATCH] fix return on node OOC. Fix logs (#3359) --- event/event.go | 2 ++ sequencer/finalizer.go | 16 +++++++++++----- sequencer/l2block.go | 4 +--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/event/event.go b/event/event.go index 7c325cc242..f43502df67 100644 --- a/event/event.go +++ b/event/event.go @@ -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 diff --git a/sequencer/finalizer.go b/sequencer/finalizer.go index 4a96c421c9..e2ea879ab0 100644 --- a/sequencer/finalizer.go +++ b/sequencer/finalizer.go @@ -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) @@ -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 } } diff --git a/sequencer/l2block.go b/sequencer/l2block.go index 8c81932fd2..498d48b193 100644 --- a/sequencer/l2block.go +++ b/sequencer/l2block.go @@ -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 @@ -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 @@ -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 {