Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional trigger module logging #1742

Merged
merged 5 commits into from
Nov 10, 2023
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
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
Loading