Skip to content

Commit

Permalink
Add additional trigger module logging (#1742)
Browse files Browse the repository at this point in the history
* Add additional logging.

* Update logging to show success.

* Update changelog.
  • Loading branch information
Taztingo authored Nov 10, 2023
1 parent 27d2f0c commit 5128186
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Wrote unit tests on the keeper methods [#1699](https://github.com/provenance-io/provenance/issues/1699).
* During `FillBids`, the seller settlement fee is now calculated on the total price instead of each order individually [#1699](https://github.com/provenance-io/provenance/issues/1699).
* In the `OrderFeeCalc` query, ensure the market exists [#1699](https://github.com/provenance-io/provenance/issues/1699).
* Add additional logging to trigger module [#1718](https://github.com/provenance-io/provenance/issues/1718).

### Bug Fixes

Expand Down
2 changes: 2 additions & 0 deletions x/trigger/keeper/event_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func (k Keeper) DetectBlockEvents(ctx sdk.Context) {
triggers = append(triggers, k.detectTimeEvents(ctx)...)

for _, trigger := range triggers {
k.Logger(ctx).Debug(fmt.Sprintf("Trigger %d added to queue", trigger.Id))
k.UnregisterTrigger(ctx, trigger)
k.QueueTrigger(ctx, trigger)
}
Expand Down Expand Up @@ -77,6 +78,7 @@ func (k Keeper) getMatchingTriggersUntil(ctx sdk.Context, prefix string, match f
err := k.IterateEventListeners(ctx, prefix, func(trigger types.Trigger) (stop bool, err error) {
event, _ := trigger.GetTriggerEventI()
if match(trigger, event) {
k.Logger(ctx).Debug(fmt.Sprintf("Event detected for trigger %d", trigger.Id))
triggers = append(triggers, trigger)
}
return terminator(trigger, event), nil
Expand Down
4 changes: 4 additions & 0 deletions x/trigger/keeper/trigger_dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ func (k Keeper) ProcessTriggers(ctx sdk.Context) {
item := k.QueuePeek(ctx)
triggerID := item.GetTrigger().Id
gasLimit := k.GetGasLimit(ctx, triggerID)
k.Logger(ctx).Debug(fmt.Sprintf("Processing trigger %d with gas limit %d", triggerID, gasLimit))

if gasLimit+gasConsumed > MaximumQueueGas {
k.Logger(ctx).Debug(fmt.Sprintf("Exceeded MaximumQueueGas %d/%d skipping...", gasLimit+gasConsumed, MaximumQueueGas))
return
}
actionsProcessed++
Expand Down Expand Up @@ -79,6 +81,7 @@ func (k Keeper) handleMsgs(ctx sdk.Context, msgs []sdk.Msg) ([]sdk.Result, error
if handler == nil {
return nil, fmt.Errorf("no message handler found for message %s at position %d", sdk.MsgTypeURL(msg), i)
}
k.Logger(ctx).Debug(fmt.Sprintf("Executing %s at position %d", sdk.MsgTypeURL(msg), i))
r, err := k.safeHandle(ctx, msg, handler)
if err != nil {
return nil, fmt.Errorf("error processing message %s at position %d: %w", sdk.MsgTypeURL(msg), i, err)
Expand All @@ -87,6 +90,7 @@ func (k Keeper) handleMsgs(ctx sdk.Context, msgs []sdk.Msg) ([]sdk.Result, error
if r == nil {
return nil, fmt.Errorf("got nil sdk.Result for message %s at position %d", sdk.MsgTypeURL(msg), i)
}
k.Logger(ctx).Debug(fmt.Sprintf("Successfully executed %s at position %d", sdk.MsgTypeURL(msg), i))

results[i] = *r
}
Expand Down

0 comments on commit 5128186

Please sign in to comment.