Skip to content

Commit f9b65af

Browse files
committed
Update comment and acquire lock in called function
1 parent ab074fc commit f9b65af

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

node/pkg/accountant/accountant.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,14 @@ func (acct *Accountant) submitToChannel(ctx context.Context, pe *pendingEntry, s
486486
acct.logger.Warn(fmt.Sprintf("timeout submitting observation to %s channel, will retry next audit", tag),
487487
zap.String("msgId", pe.msgId),
488488
zap.Duration("timeout", timeout))
489+
pe.stateLock.Lock()
489490
pe.state.submitPending = false
491+
pe.stateLock.Unlock()
490492
case <-ctx.Done():
491493
acct.logger.Debug(fmt.Sprintf("context cancelled while submitting to %s channel", tag), zap.String("msgId", pe.msgId))
494+
pe.stateLock.Lock()
492495
pe.state.submitPending = false
496+
pe.stateLock.Unlock()
493497
}
494498
} else {
495499
// Non-blocking write (existing behavior for processor)
@@ -498,7 +502,9 @@ func (acct *Accountant) submitToChannel(ctx context.Context, pe *pendingEntry, s
498502
acct.logger.Debug(fmt.Sprintf("submitted observation to channel for %s", tag), zap.String("msgId", pe.msgId))
499503
default:
500504
acct.logger.Error(fmt.Sprintf("unable to submit observation to %s because the channel is full, will try next interval", tag), zap.String("msgId", pe.msgId))
505+
pe.stateLock.Lock()
501506
pe.state.submitPending = false
507+
pe.stateLock.Unlock()
502508
}
503509
}
504510
}

node/pkg/accountant/audit.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,7 @@ func (acct *Accountant) performAudit(ctx context.Context, knownPendingTransferMa
251251
zap.Int("totalPending", len(pendingTransfers)),
252252
zap.String("contract", contract))
253253

254-
// SECURITY: knownPendingTransferMap contains only transfers that this guardian has personally
255-
// observed and verified through the normal message processing pipeline. Transfers returned by
254+
// SECURITY: knownPendingTransferMap contains only transfers that are verified through the normal message processing pipeline. Transfers returned by
256255
// the contract's all_pending_transfers query are untrusted external data. We must ONLY resubmit
257256
// observations for transfers present in knownPendingTransferMap. For transfers the contract
258257
// reports that we do NOT have locally, we request a reobservation from the watcher, which

0 commit comments

Comments
 (0)