hoprnet / ct-research

Cover Traffic (CT) Research at HOPR
2 stars 11 forks source link

Do every API call async #574

Closed jeandemeusy closed 1 week ago

jeandemeusy commented 1 month ago

Summary by CodeRabbit

Results

This PR improves message sending rate from ~10 messages/s/node to ~100 messages/s/node.

image

coderabbitai[bot] commented 1 month ago

[!CAUTION]

Review failed

The pull request is closed.

📝 Walkthrough ## Walkthrough The changes in this pull request involve updates to configuration files, core components, and test suites. Key modifications include adjustments to channel management parameters in `core_prod_config.yaml` and `core_staging_config.yaml`, enhancements to API interaction methods in `hoprd_api.py`, and the introduction of new data structures in `api_types.py`. Additionally, various test files were updated to reflect these structural changes. The overall focus is on refining the handling of channels, addresses, and balances, as well as improving logging and error management across the application. ## Changes | File Path | Change Summary | |---------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `ct-app/.configs/core_prod_config.yaml` | Increased `openChannels`, `fundChannels`, and `closeOldChannels` parameters; updated `count` and `timeout` in `storage` section. | | `ct-app/.configs/core_staging_config.yaml` | Modified timing flags and storage parameters, including reductions in `topology` and `retrieveChannels` timings, and adjustments to `count` and `timeout` in `storage`. | | `ct-app/core/__main__.py` | Added import for `MessageQueue` and a call to `MessageQueue.clear()` before closing the database connection. | | `ct-app/core/components/api_types.py` | Introduced classes and a utility function for managing API data structures, including `ApiObject`, `Channel`, and `Channels`. | | `ct-app/core/components/hoprd_api.py` | Refactored `HoprdAPI` class methods to remove SDK dependencies, added `Method` enum for HTTP methods, and updated several public methods for API calls. | | `ct-app/core/components/messages.py` | Added `clear` method to `MessageQueue` class and updated `parse` method parameter type to `str`. | | `ct-app/core/components/utils.py` | Simplified condition in `balanceInChannels` method for checking channel status. | | `ct-app/core/core.py` | Enhanced error handling, improved variable naming, and restructured logic in `topology` and `apply_economic_model` methods. | | `ct-app/core/model/budget.py` | Minor formatting change with no functional impact. | | `ct-app/core/model/subgraph/providers.py` | Updated `GraphQLProvider` class to enhance query handling and error management, added new parameters for query initialization. | | `ct-app/core/node.py` | Modified methods for address and balance retrieval, and streamlined peer handling. | | `ct-app/requirements.txt` | Removed dependency for HOPRd SDK. | | `ct-app/test/components/test_utils.py` | Updated `channel_topology` fixture to use new `Channel` class structure. | | `ct-app/test/conftest.py` | Adjusted test fixture imports and updated data structures to reflect new API types. | | `ct-app/test/test_node.py` | Updated test functions to use `Channels` instead of `NodeChannelsResponse`. | | `helm/values-prod.yaml` | Updated `tag` from `v3.4.6` to `v3.5.0` in the Helm configuration. | | `ct-app/core/components/decorators.py` | Modified logging messages in the `formalin` decorator for clarity. | | `ct-app/tests_endurance/test_fund_channels.py` | Updated address and channel handling to reflect new API structure. | | `ct-app/tests_endurance/test_get_channels.py` | Changed recipient address retrieval to align with new API response structure. | | `ct-app/tests_endurance/test_send_messages.py` | Adjusted recipient address handling and logging to reflect changes in the API. | | `ct-app/run.sh` | Enhanced logging by redirecting standard error output to a log file. | ## Possibly related PRs - #569: The changes in `core_prod_config.yaml` regarding the `flags` section, particularly the adjustments to channel management parameters, are related to the modifications in the same file in the main PR, which also involves increasing limits for channel operations. - #574: This PR also updates the `core_prod_config.yaml` file, increasing the same parameters (`openChannels`, `fundChannels`, and `closeOldChannels`) as in the main PR, indicating a direct relation in terms of configuration changes for channel management. ## Suggested labels `status:in-testing` ## Suggested reviewers - Teebor-Choka

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
🪧 Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit , please review it.` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (Invoked using PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.