Skip to content

Commit

Permalink
fix node OOC (#3263)
Browse files Browse the repository at this point in the history
  • Loading branch information
agnusmor authored Feb 13, 2024
1 parent 0e47e24 commit 9828977
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
2 changes: 2 additions & 0 deletions event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const (
EventID_SynchronizerHalt EventID = "SYNCHRONIZER HALT"
// EventID_SequenceSenderHalt is triggered when the SequenceSender halts
EventID_SequenceSenderHalt EventID = "SEQUENCESENDER HALT"
// EventID_NodeOOC is triggered when an OOC at node level is detected
EventID_NodeOOC EventID = "NODE OOC"
// Source_Node is the source of the event
Source_Node Source = "node"

Expand Down
38 changes: 34 additions & 4 deletions sequencer/finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,13 +527,43 @@ func (f *finalizer) handleProcessTransactionResponse(ctx context.Context, tx *Tx
}

// Check remaining resources

overflow, overflowResource := f.wipBatch.imRemainingResources.Sub(state.BatchResources{ZKCounters: result.UsedZkCounters, Bytes: uint64(len(tx.RawTx))})
if overflow {
log.Infof("current tx %s exceeds the remaining batch resources, overflow resource: %s, updating metadata for tx in worker and continuing", tx.HashStr, overflowResource)
start := time.Now()
f.workerIntf.UpdateTxZKCounters(result.BlockResponses[0].TransactionResponses[0].TxHash, tx.From, result.UsedZkCounters)
metrics.WorkerProcessingTime(time.Since(start))
return nil, ErrBatchResourceUnderFlow
if !f.batchConstraints.IsWithinConstraints(result.UsedZkCounters) {
log.Warnf("current tx %s exceeds the max limit for batch resources (node OOC), setting tx as invalid in the pool", tx.HashStr)

event := &event.Event{
ReceivedAt: time.Now(),
Source: event.Source_Node,
Component: event.Component_Sequencer,
Level: event.Level_Error,
EventID: event.EventID_NodeOOC,
Description: fmt.Sprintf("tx: %s exceeds node max limit batch resources (node OOC), from: %s, IP: %s", tx.HashStr, tx.FromStr, tx.IP),
}

eventErr := f.eventLog.LogEvent(ctx, event)
if eventErr != nil {
log.Errorf("error storing finalizer halt event, error: %v", eventErr)
}

// Delete the transaction from the txSorted list
f.workerIntf.DeleteTx(tx.Hash, tx.From)

errMsg := "node OOC"
err = f.poolIntf.UpdateTxStatus(ctx, tx.Hash, pool.TxStatusInvalid, false, &errMsg)
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, ErrBatchResourceUnderFlow
} else {
start := time.Now()
f.workerIntf.UpdateTxZKCounters(result.BlockResponses[0].TransactionResponses[0].TxHash, tx.From, result.UsedZkCounters)
metrics.WorkerProcessingTime(time.Since(start))
return nil, ErrBatchResourceUnderFlow
}
}

// Save Enabled, GasPriceOC, BalanceOC and final effective gas price for later logging
Expand Down

0 comments on commit 9828977

Please sign in to comment.