Skip to content

Troubleshoot operator on Base Sepolia and redo TaskRegistry for three triggrers #338

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 10 commits into from
Jun 20, 2025

Conversation

chrisli30
Copy link
Member

This pull request introduces significant updates to the taskengine package, focusing on transitioning from legacy data structures to a unified TaskRegistry for improved task management and backward compatibility. The changes streamline code, enhance logging, and ensure smooth migration from older formats. Key updates include modifications to BlockTrigger and EventTrigger implementations, adjustments to task notification handling, and updates to test cases for compatibility.

Transition to Unified TaskRegistry:

  • BlockTrigger Updates (core/taskengine/trigger/block.go):

    • Introduced TaskRegistry to replace the legacy schedule map, enabling unified task management. Added methods for automatic migration from the old format, including detectLegacyData and convertFromScheduleMap. [1] [2]
    • Refactored task addition, removal, and processing logic to use TaskRegistry, simplifying operations and improving logging. [1] [2] [3]
  • EventTrigger Updates (core/taskengine/trigger/event.go):

    • Replaced the legacy sync.Map with TaskRegistry for managing event-based tasks. Added migration methods similar to BlockTrigger. [1] [2]
    • Updated task addition, removal, and event processing logic to utilize the new registry, ensuring backward compatibility and cleaner code. [1] [2] [3]

Task Notification Handling:

  • Engine Notification Changes (core/taskengine/engine.go):
    • Removed batched notifications for MonitorTaskTrigger operations, as these now rely on StreamCheckToOperator for sending complete task metadata. Added warnings to ensure correct usage. [1] [2]

Test Case Updates:

  • BlockTrigger Tests (core/taskengine/trigger/block_test.go):
    • Updated tests to verify task addition and management using TaskRegistry instead of the legacy schedule map.

These changes improve maintainability, ensure compatibility during migration, and enhance task management efficiency across the codebase.

The codebase has two distinct notification systems that were incorrectly overlapping:
StreamCheckToOperator (Lines ~980-1050) - The "Primary Channel"
Purpose: Send MonitorTaskTrigger messages with complete task metadata
Triggers: When operators connect/reconnect via the streaming connection
Data: Full TaskMetadata with TaskId, Remain, ExpiredAt, and complete Trigger object
Delivery: Real-time via active gRPC streams
Batched Notifications (sendBatchedNotifications) - The "Cleanup Channel"
Purpose: Send CancelTask/DeleteTask messages with minimal data
Triggers: Periodic batching (every 3 seconds) for efficiency
Data: Just task ID and operation type (TaskMetadata = nil intentionally)
Delivery: Batched for performance
- Remove BadgerDB runtime files (*.vlog, DISCARD, KEYREGISTRY, MANIFEST) from git tracking
- Add BadgerDB patterns to .gitignore to prevent future commits of runtime data
- Fix nil pointer dereference in integration tests by properly initializing User.SmartAccountAddress
- Resolves panic: runtime error: invalid memory address or nil pointer dereference in ValidWalletOwner
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 pull request refactors the task engine by migrating legacy data handling (using schedule maps and sync.Map) to a unified TaskRegistry, improving logging, error handling, and backward compatibility. Key changes include updating BlockTrigger, EventTrigger, and TimeTrigger implementations, modifying task notification handling in the Engine, and enhancing test cases to reflect these structural upgrades.

Reviewed Changes

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

Show a summary per file
File Description
operator/worker_loop.go Updated streaming message processing with additional debug logging and panic recovery strategies.
integration_test/operator_reconnection_test.go Refactored user initialization to prevent nil pointer dereferences.
core/taskengine/trigger/time_test.go Added tests for new time trigger functionality including legacy migration.
core/taskengine/trigger/time.go Migrated legacy job management to the unified TaskRegistry with improved legacy conversion methods.
core/taskengine/trigger/registry_test.go Added tests covering TaskRegistry conversion, basic operations, and thread safety.
core/taskengine/trigger/registry.go Introduced a unified TaskRegistry to manage tasks across trigger types.
core/taskengine/trigger/event_test.go Updated tests for event triggers to utilize the new TaskRegistry.
core/taskengine/trigger/event_conditional_test.go Modified conditional filtering tests to align with the new event data API.
core/taskengine/trigger/event.go Refactored event trigger logic to integrate TaskRegistry and legacy conversion from sync.Map.
core/taskengine/trigger/block_test.go Adjusted tests to validate block trigger updates using TaskRegistry and legacy data conversion.
core/taskengine/trigger/block.go Migrated block trigger scheduling from a legacy schedule map to the new TaskRegistry.
core/taskengine/engine.go Updated task notification logic to warn against using batched notifications for MonitorTaskTrigger.
cmd/data/badger/KEYREGISTRY Removed legacy key registry data.
Comments suppressed due to low confidence (1)

core/taskengine/engine.go:1067

  • [nitpick] Clarify in inline comments or documentation why MonitorTaskTrigger events are excluded from batched notifications and must be handled by StreamCheckToOperator to ensure complete task metadata.
	if operation == avsproto.MessageOp_MonitorTaskTrigger {

- Remove all SEGFAULT_FIX debug logs and troubleshooting messages
- Simplify MonitorTaskTrigger processing by removing verbose debug logging
- Reduce file size by 190 lines (19% reduction) while maintaining functionality
- Keep essential error handling and panic recovery for production safety
- Improve performance by eliminating unnecessary debug log overhead
- Clean up code for production readiness
- Add ensureLegacyConversion() helper function to EventTrigger, BlockTrigger, and TimeTrigger
- Eliminate code duplication by replacing repeated detectLegacyData() + ensureNewFormat() calls
- Improve maintainability and reduce redundancy in trigger implementations
- All tests pass, maintaining backward compatibility
@chrisli30 chrisli30 merged commit 8787e8c into staging Jun 20, 2025
16 checks passed
@chrisli30 chrisli30 deleted the chris-troubleshoot_base_sepolia branch June 20, 2025 07:44
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