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

feat: add new AsyncAnonymizedClient using arti-hyper #67

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

oleonardolima
Copy link
Collaborator

@oleonardolima oleonardolima commented Dec 8, 2023

  • add new async client, AsyncAnonymizedClient, that uses arti-hyper, and arti-client to connect and do requests over the Tor network.

fixes #61

Summary by CodeRabbit

  • New Features
    • Added support for asynchronous operations in AsyncClient with multiple HTTP clients.
    • Introduced AsyncAnonymizedClient for anonymized requests using Tor.
    • Expanded esplora_client library for anonymized asynchronous communication over Tor.
  • Chores
    • Updated dependencies including Tor-related and async utilities.
    • Adjusted test configurations for Rust projects and modified cache key generation in CI workflow.

@notmandatory notmandatory added the enhancement New feature or request label Dec 8, 2023
@oleonardolima oleonardolima force-pushed the feat/add-tor-with-async-arti-hyper-feature branch 2 times, most recently from 86103c8 to 9eef99f Compare December 21, 2023 19:20
@notmandatory
Copy link
Member

Please rebase to pick up changes in #69 that fix CI.

@oleonardolima oleonardolima force-pushed the feat/add-tor-with-async-arti-hyper-feature branch 18 times, most recently from d6e6b42 to 53c089b Compare January 15, 2024 15:00
@oleonardolima oleonardolima changed the title wip(feat): add new AsyncAnonymizedClient using arti-hyper feat: add new AsyncAnonymizedClient using arti-hyper Jan 15, 2024
@oleonardolima oleonardolima marked this pull request as ready for review January 15, 2024 15:07
@oleonardolima
Copy link
Collaborator Author

Most of the implementation is done, and it currently works on rust 1.70, also good to review and get inputs from it's being done.

But it does not work with our current MSRV, how do you usually go forward? just pin some of the dependencies?

cc @notmandatory @vladimirfomene

@oleonardolima oleonardolima force-pushed the feat/add-tor-with-async-arti-hyper-feature branch 4 times, most recently from 73db1cd to fd945b0 Compare January 16, 2024 16:24
@oleonardolima oleonardolima force-pushed the feat/add-tor-with-async-arti-hyper-feature branch 3 times, most recently from 85532de to f2707e4 Compare January 29, 2024 12:35
@oleonardolima oleonardolima force-pushed the feat/add-tor-with-async-arti-hyper-feature branch 3 times, most recently from 48799f5 to 0b196d1 Compare February 5, 2024 16:01
@notmandatory
Copy link
Member

@oleonardolima can your rebase and rework this now that #75 is merged? hopefully not too big a change.

@oleonardolima oleonardolima force-pushed the feat/add-tor-with-async-arti-hyper-feature branch from 0b196d1 to 0659252 Compare March 6, 2024 14:40
Copy link

coderabbitai bot commented Mar 6, 2024

Walkthrough

This update introduces Tor support to the rust-esplora-client and rust-electrum-client by integrating arti-hyper, enhancing privacy and anonymity features. It includes adjustments to continuous integration workflows and expands the library's capabilities with asynchronous operations and Tor communication via new feature flags and client structures.

Changes

Files Change Summary
.github/workflows/... Adjusted workflow configuration for Rust projects, including cache, toolchain setup, and testing.
src/async.rs Extended AsyncClient to support asynchronous operations with Tor integration.
src/lib.rs Expanded library to support anonymized async client with arti-hyper for Tor communication.

Assessment against linked issues

Objective Addressed Explanation
Add Tor support using arti-hyper with feature async-arti-hyper (#61)
Utilize Arti features for HTTP-based requests integration, aligning with async streams (#61)
Introduce async-arti-hyper feature flag for Tor support, maintaining compatibility with existing APIs (#61)
Align implementation with existing APIs and usage patterns of rust-esplora-client (#61)
Consider a long-term strategy for support of different transport layers using a consistent API approach (#61) It's unclear if a long-term strategy for transport layer support has been explicitly outlined.

This assessment concludes that the primary objectives have been largely met, with potential ambiguity regarding the strategic planning for future transport layer integrations.


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
Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@oleonardolima oleonardolima force-pushed the feat/add-tor-with-async-arti-hyper-feature branch from 0659252 to b9b0c1b Compare March 6, 2024 14:40
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 98edbc5 and b9b0c1b.
Files ignored due to path filters (1)
  • Cargo.toml is excluded by: !**/*.toml
Files selected for processing (3)
  • .github/workflows/cont_integration.yml (2 hunks)
  • src/async.rs (10 hunks)
  • src/lib.rs (26 hunks)
Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/cont_integration.yml
  • src/async.rs
Additional comments: 3
src/lib.rs (3)
  • 80-85: The new feature flags async-arti-hyper, async-arti-hyper-native, and async-arti-hyper-rustls are correctly introduced to enable the anonymized async client and its variations. This approach allows for flexible configuration and usage based on the user's needs and environment.
  • 99-108: The conditional compilation logic for the r#async module and the exposure of AsyncAnonymizedClient based on the async-arti-hyper feature is correctly implemented. This ensures that the anonymized async client is only available when the corresponding feature flag is enabled, maintaining modularity and feature flag consistency.
  • 195-212: The introduction of new error types specific to the anonymized async client (Hyper, InvalidUri, InvalidBody, ArtiClient, TlsConnector, ResponseDecoding) enhances error handling and provides more granular feedback to the users. It's crucial to ensure that these errors are adequately documented and that their handling is consistent across the client's usage.

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@oleonardolima oleonardolima force-pushed the feat/add-tor-with-async-arti-hyper-feature branch from b9b0c1b to e1893fa Compare August 20, 2024 21:05
Cargo.toml Outdated Show resolved Hide resolved
- rename the workflow from Rust to CI
- add name to build-test step of Build & Test
- adds two new jobs for `fmt` and `clippy`.
- use `dtolnay/rust-toolchain@v1` instead of `actions-rs/toolchain@v1`
- bumps the `edition` on `Cargo.toml` to `2021.
- add `.clippy.toml` with `msrv=1.63.0` file.
- apply some standard on `Cargo.toml` deps.
- minor docstring improvements, and fix missing docstrings.
- remove duplicated HTTP client code for handling GET and POST requests.
- adds a few new methods to `AsyncClient` implementation, the new
  methods are responsible to handle common HTTP requests and parsing. It
  was previously duplicated throughout the Esplora API implementation,
  but now it follows the same approach already implemented for
  blocking client (`BlockingClient`).
@oleonardolima oleonardolima force-pushed the feat/add-tor-with-async-arti-hyper-feature branch 2 times, most recently from f3360c0 to 75e32db Compare September 3, 2024 15:30
notmandatory added a commit that referenced this pull request Sep 3, 2024
1a4d5cf chore(rust+clippy): bump `edition` to 2021, and add `.clippy.toml` (Leonardo Lima)
b7636e8 fix(fmt): apply suggested fixes from `rustfmt` (Leonardo Lima)
3f2ca2f refactor(ci)!: add new `fmt` and `clippy` jobs (Leonardo Lima)
9f888c1 chore(deps): bump `actions/checkout` from v3 to v4 (Leonardo Lima)

Pull request description:

  <!-- You can erase any parts of this template not applicable to your Pull Request. -->

  ### Description

  This PR does some improvements on CI, these are some changes that I ended up doing on other refactoring and feature PRs (making them too convoluted), but had a specific CI scope so I'm moving them to a specific PR.

  This PR does:

  - bump the `actions/checkout@v3` to `actions/checkout@v4`.
  - adds two new jobs for `fmt` and `clippy` (clippy has been moved to a specific job).
  - fix the newly found `fmt` problems.
  - bump the rust edition to `2021`.
  - adds `.clippy.toml` file with `msrv=1.63.0`.

  <!-- Describe the purpose of this PR, what's being adding and/or fixed -->

  ### Notes to the reviewers

  I hope this PR reduces the scope convolution from the other ones #67 #93, and makes the review easier.

  <!-- In this section you can include notes directed to the reviewers, like explaining why some parts
  of the PR were done in a specific way -->

  ### Changelog notice

  - Bump the `actions/checkout@v3` to `actions/checkout@v4`.
  - Adds two new jobs for `fmt` and `clippy` (clippy has been moved to a specific job).
  - Multiple fixes for the newly found `fmt` problems.
  - Bump the rust edition to `2021`.
  - Adds `.clippy.toml` file with `msrv=1.63.0`.

  <!-- Notice the release manager should include in the release tag message changelog -->
  <!-- See https://keepachangelog.com/en/1.0.0/ for examples -->

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

ACKs for top commit:
  ValuedMammal:
    ACK 1a4d5cf
  notmandatory:
    ACK 1a4d5cf

Tree-SHA512: e693baeea112dffa12ccc576271f38f3188dc24669a70af7196e33e5eea08c5d82940792330682b8a4b1ec48ef98e1cbaa2f713736f393555744fdf44d79a26a
@oleonardolima oleonardolima force-pushed the feat/add-tor-with-async-arti-hyper-feature branch from 75e32db to f32c8d1 Compare September 6, 2024 20:43
- feat(tor): add new async client, `AsyncTorClient`, which uses
  `arti-client` to establish Tor connections, and `hyper` as HTTP client
  over custom Tor anonymized data stream.
- feat(tor): implements the common methods: `get_response`,
  `get_response_json`, `get_response_hex` and their `opt` versions too.
@oleonardolima oleonardolima force-pushed the feat/add-tor-with-async-arti-hyper-feature branch from f32c8d1 to 8f7fff7 Compare September 6, 2024 20:58
notmandatory added a commit that referenced this pull request Sep 25, 2024
…ntation improvements

1103936 chore(style+docs): style and docs retouch (Leonardo Lima)
442789c chore(style): update new methods style (Leonardo Lima)
565d79e refactor(async): add common GET and POST methods (Leonardo Lima)
31dfa4b chore(docs): minor improvements on docstrings (Leonardo Lima)

Pull request description:

  <!-- You can erase any parts of this template not applicable to your Pull Request. -->

  ### Description

  It builds on top of #95. Applies minor improvements on some docstrings, and Cargo.toml standard.

  The main change is adding the common HTTP methods for the `AsyncClient`, it removes duplicated code from each Esplora API request, and follows the approach done for `BlockingClient`.

  It makes it easier to extract these methods into an `AsyncEsploraClient` trait (to be done in another PR, initially done here 9cbc387), which the user can implement with any HTTP client of its choice. Also, makes it simpler to rebase and update the `AsyncAnonymizedClient` from #67.

  <!-- Describe the purpose of this PR, what's being adding and/or fixed -->

  ### Notes to the reviewers

  It has some commits from #95, as it builds on top of it and should be merged afterward. Please let me know what you think about the proposed changes and approach.

  <!-- In this section you can include notes directed to the reviewers, like explaining why some parts
  of the PR were done in a specific way -->

  ### Changelog notice

  - Applies minor improvements on documentation.
  - Add common `get_response` and `post_request` methods to `AsyncClient`, previously duplicated through the esplora API calls. It follows the approach done for `BlockinClient`.

  <!-- Notice the release manager should include in the release tag message changelog -->
  <!-- See https://keepachangelog.com/en/1.0.0/ for examples -->

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

ACKs for top commit:
  ValuedMammal:
    ACK 1103936
  notmandatory:
    ACK 1103936

Tree-SHA512: 5579e0cba105f553782e419a16c26fc75b38a2ab8ee523f5ce5e2b9a4560503ef7f81faac546429851802efb66cf125cb36b49f20f088969a6ad580e644d43e5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature: add tor support by using arti-hyper with new feature async-arti-hyper
3 participants