Skip to content

Fixed operator eventTrigger not capturing all ERC20 transfer problem #329

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

Merged
merged 3 commits into from
Jun 16, 2025

Conversation

chrisli30
Copy link
Member

This pull request introduces several enhancements and fixes to the task engine, focusing on improved execution state handling, deduplication of events, and more robust event processing. The key changes include adding execution state tracking, ensuring event deduplication, and refining event-trigger processing logic.

Execution State Enhancements:

  • Introduced AggregateChecksResultWithState to return detailed execution state, including task activity status, remaining executions, and error messages. Updated NotifyTriggers to leverage this new method. (aggregator/rpc_server.go, core/taskengine/engine.go) [1] [2] [3] [4]

Event Deduplication:

  • Added a deduplication mechanism to track processed events using a unique key (blockNumber-txHash-logIndex) and avoid duplicate processing across multiple subscriptions. (core/taskengine/trigger/event.go) [1] [2]

Event Processing Improvements:

  • Enhanced buildExecutionStepOutputData to handle nil trigger outputs gracefully by creating empty structures based on trigger type. (core/taskengine/engine.go) [1] [2]
  • Updated buildTriggerDataMapFromProtobuf to align field names with the runTrigger format for consistency. (core/taskengine/engine.go)

Event Trigger Logic Refinements:

  • Modified event trigger subscriptions to initialize even when no queries are available initially, allowing dynamic task additions. Introduced periodic cleanup of old processed events and event counts to prevent memory leaks. (core/taskengine/trigger/event.go) [1] [2]

Event Search Optimization:

  • Adjusted event search logic to comprehensively scan recent blocks instead of stopping early, ensuring the most recent events are captured. (core/taskengine/run_node_immediately.go) [1] [2] [3]

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances event processing and execution state management for the task engine, addressing duplicate event handling, improved logging, and more robust trigger output processing. Key changes include:

  • Updates to protobuf messages and generated code to include execution state fields.
  • Modifications in operator and trigger processing logic to leverage new execution state and enhanced deduplication.
  • Improvements in event query optimization and cleanup routines.

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
protobuf/node.proto & protobuf/node.pb.go Added execution state fields in NotifyTriggersResp to support detailed task status.
operator/worker_loop.go Updated logging and task removal logic based on new execution state fields.
core/taskengine/vm*.go Injected enhanced trigger configuration data to support downstream processing.
core/taskengine/trigger/event.go Improved event deduplication, optimized filter query grouping, and added cleanup for processed events.
core/taskengine/run_node_immediately.go Adjusted event search logic to perform comprehensive query searches.
core/taskengine/engine.go & aggregator/rpc_server.go Modified aggregator logic to leverage AggregateChecksResultWithState for robust trigger handling.
core/taskengine/vm_trigger_config_test.go Expanded tests to verify proper exposure of trigger configuration data.

eventKey := fmt.Sprintf("%s-%d", log.TxHash.Hex(), log.Index)

t.processedEventsMutex.Lock()
if t.processedEvents[eventKey] {
Copy link
Preview

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The duplicate deduplication checks in the main event loop and in processLog create redundancy. Consider centralizing the deduplication logic to a single function to reduce code duplication and potential inconsistency.

Copilot uses AI. Check for mistakes.

@@ -727,3 +934,32 @@ func (t *EventTrigger) cleanupOldEventCounts(blocksToKeep uint64) {
}
}
}

// Add cleanup for processed events to prevent memory leaks
func (t *EventTrigger) cleanupOldProcessedEvents(maxEvents uint64) {
Copy link
Preview

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The current cleanup method removes arbitrary entries since the keys lack timestamps. To improve accuracy and avoid processing duplicates that may reappear soon, consider augmenting the deduplication keys with timestamps or another expiry mechanism.

Copilot uses AI. Check for mistakes.

@chrisli30 chrisli30 merged commit 62f490a into staging Jun 16, 2025
16 checks passed
@chrisli30 chrisli30 deleted the chris-add_node_config branch June 16, 2025 07:11
chrisli30 added a commit that referenced this pull request Jun 16, 2025
…329)

* Improved operator event trigger monitoring

* Fixed operator eventTrigger not capturing all ERC20 transfer problem

* Updated tests that failed in CI/CD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant