You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### TL;DR
Added context propagation throughout the codebase to improve cancellation handling and resource management.
### What changed?
This PR adds proper context propagation throughout the codebase by:
1. Adding context parameters to all RPC client interface methods:
- `GetFullBlocks`
- `GetBlocks`
- `GetTransactions`
- `GetLatestBlockNumber`
2. Updating all orchestrator components to pass context to RPC calls:
- ChainTracker
- Committer
- FailureRecoverer
- Poller
- ReorgHandler
3. Propagating context through the worker package to ensure proper cancellation handling
4. Updating all batch RPC operations to respect context cancellation
### How to test?
1. Run the application and verify that it functions normally
2. Test context cancellation by:
- Starting the application
- Triggering a graceful shutdown
- Verifying that in-progress operations are properly canceled
### Why make this change?
This change improves resource management and application behavior by:
1. Ensuring proper cancellation of in-progress operations when the application is shutting down
2. Preventing resource leaks by propagating context through all layers of the application
3. Following Go best practices for handling context propagation
4. Enabling better timeout and cancellation handling for RPC operations
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
- **New Features**
- Added support for cancellation and timeout controls to blockchain data fetching and processing operations, improving responsiveness and robustness of long-running tasks.
- Introduced context propagation to search functionality for better request handling and cancellation support.
- **Bug Fixes**
- Enhanced cancellation and timeout handling across multiple components to prevent unresponsive or hanging processes.
- **Tests**
- Updated tests to validate context-aware operations and ensure proper handling of cancellations and timeouts.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
log.Warn().Msgf("Committer didn't find the following range in staging: %v - %v", blocksToCommit[0].Int64(), blocksToCommit[len(blocksToCommit)-1].Int64())
log.Debug().Msgf("Polling %d blocks while handling gap: %v", len(missingBlockNumbers), missingBlockNumbers)
223
-
poller.Poll(missingBlockNumbers)
223
+
poller.Poll(ctx, missingBlockNumbers)
224
224
returnfmt.Errorf("first block number (%s) in commit batch does not match expected (%s)", actualFirstBlock.Number.String(), expectedStartBlockNumber.String())
log.Debug().Msgf("Polled %d blocks due to committer detecting them as missing. Range: %s - %s", len(blocksToPoll), blocksToPoll[0].String(), blocksToPoll[len(blocksToPoll)-1].String())
0 commit comments