Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions chain_capabilities/evm/trigger/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,10 @@ func (lts *LogTriggerService) deliverLogReliably(
// checkLimitsOnLog checks the rate limit and payload size limit for a single log event, it should not error as we
// want to continue processing other logs even if one fails the limits
func (lts *LogTriggerService) checkLimitsOnLog(ctx context.Context, telemetryContext monitoring.TelemetryContext, protoLog *evmcappb.Log, triggerID string, eventID string, log *evmtypes.Log) bool {
if err := lts.eventRateLimit.AllowErr(ctx); err != nil {
summary := fmt.Sprintf("Rate limited, dropping event (triggerID: %s, eventID: %s)", triggerID, eventID)
lts.lggr.Errorw(summary, "triggerID", triggerID, "eventID", eventID, "err", err)
protoLogSize := commoncfg.Size(proto.Size(protoLog))
if err := lts.eventPayloadSizeLimiter.Check(ctx, protoLogSize); err != nil {
summary := fmt.Sprintf("Size limited, log size is too big (current size %d), dropping event (triggerID: %s, eventID: %s)", protoLogSize, triggerID, eventID)
lts.lggr.Errorw(summary, "triggerID", triggerID, "eventID", eventID, "protoLogSize", protoLogSize, "err", err)
Comment thread
amit-momin marked this conversation as resolved.
monitoring.LogAndEmitError(
ctx,
lts.lggr,
Expand All @@ -626,10 +627,10 @@ func (lts *LogTriggerService) checkLimitsOnLog(ctx context.Context, telemetryCon
return false
}

protoLogSize := commoncfg.Size(proto.Size(protoLog))
if err := lts.eventPayloadSizeLimiter.Check(ctx, protoLogSize); err != nil {
summary := fmt.Sprintf("Size limited, log size is too big (current size %d), dropping event (triggerID: %s, eventID: %s)", protoLogSize, triggerID, eventID)
lts.lggr.Errorw(summary, "triggerID", triggerID, "eventID", eventID, "protoLogSize", protoLogSize, "err", err)
// Prefer increased delivery time to event dropping
if err := lts.eventRateLimit.Wait(ctx); err != nil {
summary := fmt.Sprintf("Rate limited, dropping event (triggerID: %s, eventID: %s)", triggerID, eventID)
lts.lggr.Errorw(summary, "triggerID", triggerID, "eventID", eventID, "err", err)
monitoring.LogAndEmitError(
ctx,
lts.lggr,
Expand Down
15 changes: 8 additions & 7 deletions chain_capabilities/solana/trigger/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,10 @@ func (lts *SolanaLogTriggerService) generateFilterID(triggerID string) string {
// checkLimitsOnLog checks the rate limit and payload size limit for a single log event, it should not error as we
// want to continue processing other logs even if one fails the limits
func (lts *SolanaLogTriggerService) checkLimitsOnLog(ctx context.Context, telemetryContext monitoring.TelemetryContext, protoLog *solanacappb.Log, triggerID string, eventID string, log *solana.Log) bool {
if err := lts.eventRateLimit.AllowErr(ctx); err != nil {
summary := fmt.Sprintf("Rate limited, dropping event (triggerID: %s, eventID: %s)", triggerID, eventID)
lts.lggr.Errorw(summary, "triggerID", triggerID, "eventID", eventID, "err", err)
protoLogSize := commoncfg.Size(proto.Size(protoLog))
if err := lts.eventPayloadSizeLimiter.Check(ctx, protoLogSize); err != nil {
summary := fmt.Sprintf("Size limited, log size is too big (current size %d), dropping event (triggerID: %s, eventID: %s)", protoLogSize, triggerID, eventID)
lts.lggr.Errorw(summary, "triggerID", triggerID, "eventID", eventID, "protoLogSize", protoLogSize, "err", err)
monitoring.LogAndEmitError(
ctx,
lts.lggr,
Expand All @@ -504,10 +505,10 @@ func (lts *SolanaLogTriggerService) checkLimitsOnLog(ctx context.Context, teleme
return false
}

protoLogSize := commoncfg.Size(proto.Size(protoLog))
if err := lts.eventPayloadSizeLimiter.Check(ctx, protoLogSize); err != nil {
summary := fmt.Sprintf("Size limited, log size is too big (current size %d), dropping event (triggerID: %s, eventID: %s)", protoLogSize, triggerID, eventID)
lts.lggr.Errorw(summary, "triggerID", triggerID, "eventID", eventID, "protoLogSize", protoLogSize, "err", err)
// Prefer increased delivery time to event dropping
if err := lts.eventRateLimit.Wait(ctx); err != nil {
summary := fmt.Sprintf("Rate limited, dropping event (triggerID: %s, eventID: %s)", triggerID, eventID)
lts.lggr.Errorw(summary, "triggerID", triggerID, "eventID", eventID, "err", err)
monitoring.LogAndEmitError(
ctx,
lts.lggr,
Expand Down
Loading