Skip to content

Comments

fix: use plain string for grpc address#6881

Merged
SWvheerden merged 12 commits intotari-project:developmentfrom
stringhandler:st-better-grpc-address
Mar 28, 2025
Merged

fix: use plain string for grpc address#6881
SWvheerden merged 12 commits intotari-project:developmentfrom
stringhandler:st-better-grpc-address

Conversation

@stringhandler
Copy link
Contributor

@stringhandler stringhandler commented Mar 17, 2025

Summary by CodeRabbit

  • New Features
    • Users are now prompted for necessary gRPC addresses during configuration if not already provided.
  • Refactor
    • Streamlined address handling by switching from a complex multi-address approach to a simpler string-based method.
    • Simplified connection workflows and endpoint initialization across components.
  • Chores
    • Updated dependencies with explicit versions and features.
    • Refined logging output to include additional context while reducing verbosity.
  • Bug Fixes
    • Corrected the format of gRPC addresses from TCP to HTTP for improved connectivity.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 17, 2025

Walkthrough

The changes refactor how gRPC addresses are handled across multiple components. The old function that computed a socket address from a multi-address has been removed and replaced with simpler user prompt functions that return string representations of the addresses. Several configuration types have been updated to use strings instead of multi-address types. Additionally, dependency declarations and the logging configuration have been updated, and endpoint initialization has been streamlined by switching from a from_str to a new method.

Changes

File(s) Change Summary
applications/minotari_app_utilities/src/parse_miner_input.rs Removed base_node_socket_address and added prompt_for_base_node_address and prompt_for_p2pool_address to handle user input for gRPC addresses; minor import formatting updated.
applications/minotari_merge_mining_proxy/Cargo.toml Updated dependency declarations for tonic (with feature tls-webpki-roots) and tracing, explicitly specifying version numbers and features.
applications/minotari_merge_mining_proxy/log4rs_sample.yml Modified the logging pattern to include file name and line number, and changed the root logging level from debug to info.
applications/minotari_merge_mining_proxy/src/config.rs,
applications/minotari_miner/src/config.rs
Changed gRPC address types from Option<Multiaddr> to Option<String> in configuration structs.
applications/minotari_merge_mining_proxy/src/run_merge_miner.rs,
applications/minotari_miner/src/run_miner.rs
Simplified address handling by removing socket address construction; now directly uses configured string addresses or prompts for them; updated endpoint initialization from Endpoint::from_str to Endpoint::new and refined error handling.
clients/rust/wallet_grpc_client/src/lib.rs Updated gRPC channel creation to use Endpoint::new(addr.to_string()) instead of Endpoint::from_str(addr).
applications/minotari_miner/Cargo.toml Added "prost" to the ignored list under the [package.metadata.cargo-machete] section.

Possibly related PRs

  • chore: simplify premine spending process #6845: The changes in the main PR, which involve the removal of the base_node_socket_address function and the introduction of new functions for prompting user input for addresses, are directly related to the modifications in the run_merge_miner.rs file of the retrieved PR, where the new prompting functions are utilized for address handling.
  • feat: remove static moneroD response #6867: The changes in the main PR are related to the modifications in the run_merge_miner.rs file, where the newly added functions prompt_for_base_node_address and prompt_for_p2pool_address are utilized, which directly connects to the changes made in the main PR regarding address handling.
  • feat: add p2pool tip info and better mmproxy template handling #6795: The changes in the main PR, which involve the removal of the base_node_socket_address function and the introduction of two new functions for prompting user input for addresses, are directly related to the changes in the retrieved PR, as both involve modifications to how base node and p2pool addresses are handled, specifically through the use of the newly added prompt_for_base_node_address and prompt_for_p2pool_address functions.

Suggested reviewers

  • SWvheerden

Poem

I'm a bunny with a curious heart,
Hopping through code, playing my part.
With prompts replacing old socket art,
And logs that now show file and line chart.
I celebrate these changes—oh what a start! 🐇
Happy coding from my little rabbit heart!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 603cfaa and 954cc71.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • applications/minotari_miner/Cargo.toml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • applications/minotari_miner/Cargo.toml
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: test (testnet, esmeralda)
  • GitHub Check: test (mainnet, stagenet)
  • GitHub Check: Cucumber tests / FFI
  • GitHub Check: test (nextnet, nextnet)
  • GitHub Check: ci
  • GitHub Check: cargo check with stable
  • GitHub Check: Cucumber tests / Base Layer

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@github-actions
Copy link

github-actions bot commented Mar 17, 2025

Test Results (Integration tests)

36 tests  +36   36 ✅ +36   16m 25s ⏱️ + 16m 25s
11 suites +11    0 💤 ± 0 
 2 files   + 2    0 ❌ ± 0 

Results for commit 954cc71. ± Comparison against base commit aa7e286.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Mar 17, 2025

Test Results (CI)

    3 files    129 suites   43m 16s ⏱️
1 352 tests 1 352 ✅ 0 💤 0 ❌
4 054 runs  4 054 ✅ 0 💤 0 ❌

Results for commit 954cc71.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@hansieodendaal hansieodendaal left a comment

Choose a reason for hiding this comment

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

Please update the related config toml files as well for base_node_grpc_address and p2pool_node_grpc_address:

  • f_merge_mining_proxy.toml
  • g_miner.toml
    I suppose these are also affected:
  • e_validator_node.toml
  • h_collectibles.toml
  • i_indexer.toml

Copy link
Contributor

@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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
applications/minotari_app_utilities/src/parse_miner_input.rs (1)

71-82: New P2Pool address prompt with hardcoded port

Good addition that follows the same pattern as the base node address prompt.

Note that the port 18145 is hardcoded here. Consider whether this port should be obtained from a configuration constant or function similar to how grpc_default_port is used for the base node, to improve maintainability.

- .default(format!("http://127.0.0.1:{}", 18145))
+ .default(format!("http://127.0.0.1:{}", grpc_default_port(ApplicationType::ShaP2Pool, network)))
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 06ac1cb and dac4e53.

📒 Files selected for processing (3)
  • applications/minotari_app_utilities/src/parse_miner_input.rs (1 hunks)
  • applications/minotari_merge_mining_proxy/src/run_merge_miner.rs (3 hunks)
  • applications/minotari_miner/src/run_miner.rs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • applications/minotari_miner/src/run_miner.rs
  • applications/minotari_merge_mining_proxy/src/run_merge_miner.rs
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: ci
🔇 Additional comments (2)
applications/minotari_app_utilities/src/parse_miner_input.rs (2)

54-69: New function simplifies base node address handling

Good change. This function simplifies the interface by returning a string representation of the address instead of converting to a SocketAddr. This aligns with the PR title's intention to use plain strings for gRPC addresses, which is more appropriate for gRPC's HTTP/2-based implementation.

A few notes:

  • The function returns early within the loop, meaning the loop will only execute once
  • No validation is performed on the address format beyond whitespace trimming

23-42:

Details

❓ Verification inconclusive

Consider removing unused imports

With the removal of the base_node_socket_address function, some imports may no longer be used directly in this file, such as multiaddr_to_socketaddr and possibly SocketAddr and Multiaddr.


🏁 Script executed:

#!/bin/bash
# Check for unused imports in the file
rg --no-line-number --no-filename "use .*?\{(.+?)\}" applications/minotari_app_utilities/src/parse_miner_input.rs | 
  sed 's/use .*?\{//g; s/\};//g' | 
  tr ',' '\n' | 
  sed 's/^[ \t]*//g; s/[ \t]*$//g' | 
  grep -v "^$" | 
  while read -r import; do
    if ! rg -q "\b${import}\b" --type rust applications/minotari_app_utilities/src/parse_miner_input.rs; then
      echo "Potentially unused import: $import"
    fi
  done

Length of output: 272


Review Update: Verify Unused Imports Manually

The automated check for unused imports encountered a regex error. Please confirm if the following imports in the file are indeed unused:

  • multiaddr_to_socketaddr (from tari_comms::utils::multiaddr)
  • SocketAddr (from std::net)
  • Multiaddr (from tari_comms)

It appears that with the removal of the base_node_socket_address function, these imports might no longer be required. However, since our automated script returned an error, please manually verify their usage in non-import code within the file before making any removals.

Copy link
Contributor

@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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
applications/minotari_app_utilities/src/parse_miner_input.rs (1)

78-94: New function to prompt for p2pool address using string format.

This function follows the same pattern as prompt_for_base_node_address, providing a consistent approach for user interaction. It has a hardcoded default port (18145) which might be worth extracting to a constant or configuration if it's used elsewhere in the codebase.

Consider extracting the hardcoded port 18145 to a named constant for better maintainability:

+const DEFAULT_P2POOL_PORT: u16 = 18145;

 pub fn prompt_for_p2pool_address() -> Result<String, ParseInputError> {
     loop {
         let mut address = InputPrompt::<String>::new()
             .with_prompt("Please enter 'p2pool-grpc-address' ('quit' or 'exit' to quit) ")
-            .default(format!("http://127.0.0.1:{}", 18145))
+            .default(format!("http://127.0.0.1:{}", DEFAULT_P2POOL_PORT))
             .interact()
             .unwrap();
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dac4e53 and 6d0c732.

📒 Files selected for processing (4)
  • applications/minotari_app_utilities/src/parse_miner_input.rs (3 hunks)
  • applications/minotari_merge_mining_proxy/src/run_merge_miner.rs (3 hunks)
  • applications/minotari_miner/src/run_miner.rs (4 hunks)
  • clients/rust/wallet_grpc_client/src/lib.rs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • clients/rust/wallet_grpc_client/src/lib.rs
  • applications/minotari_miner/src/run_miner.rs
🧰 Additional context used
🧬 Code Definitions (1)
applications/minotari_merge_mining_proxy/src/run_merge_miner.rs (1)
applications/minotari_app_utilities/src/parse_miner_input.rs (2) (2)
  • prompt_for_base_node_address (57-76)
  • prompt_for_p2pool_address (78-94)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: ci
🔇 Additional comments (8)
applications/minotari_merge_mining_proxy/src/run_merge_miner.rs (5)

262-262: Variable name should be more specific.

The variable base_node_addr is misleading in this context as it's being used for the p2pool address. Consider renaming it to p2pool_node_addr for clarity.

-    let base_node_addr;
+    let p2pool_node_addr;

263-267: Address handling changed to use string representation.

The code now properly checks for p2pool_node_grpc_address in the configuration and falls back to prompting the user if not provided. This aligns with the PR objective of using plain strings for gRPC addresses, making the code more straightforward.


228-232: Address handling simplified to use string representation.

The code now properly checks for base_node_grpc_address in the configuration and falls back to prompting the user if not provided. This change simplifies the address handling by using direct string representations rather than converting from multi-addresses.


235-235: Endpoint creation method changed from from_str to new.

The code now uses Endpoint::new() instead of Endpoint::from_str(), which is more appropriate for working with string addresses directly. This is a good change that aligns with the PR objective.


269-269: Endpoint creation method changed from from_str to new.

Consistent with the change for base node endpoint creation, the code now uses Endpoint::new() instead of Endpoint::from_str() for p2pool as well. This provides a consistent approach across the codebase.

applications/minotari_app_utilities/src/parse_miner_input.rs (3)

23-23: Import simplified to only include necessary functionality.

The import has been simplified to only include FromStr, removing unnecessary imports related to multiaddress handling since the code now works with plain strings.


42-46: Tonic imports updated to support URI validation.

The imports have been updated to include Uri for validating addresses as URIs, which is a better approach for gRPC addresses than using multiaddresses. This is aligned with the PR objective.


57-76: New function to prompt for base node address using string format.

This new function replaces the previous base_node_socket_address function, simplifying the address handling by:

  1. Returning a string instead of a socket address
  2. Using Uri::from_str for validation instead of complex multiaddress handling
  3. Using HTTP format by default, which is more intuitive for gRPC addresses

The implementation is clean and handles error cases appropriately.

stringhandler and others added 3 commits March 19, 2025 13:50
Co-authored-by: Hansie Odendaal <39146854+hansieodendaal@users.noreply.github.com>
Copy link
Contributor

@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.

Actionable comments posted: 1

♻️ Duplicate comments (1)
applications/minotari_merge_mining_proxy/src/run_merge_miner.rs (1)

262-268: ⚠️ Potential issue

Fix variable name inconsistency.

The variable is declared as p2pool_node_addr but then base_node_addr is incorrectly used in the subsequent lines. This will cause runtime errors.

let p2pool_node_addr;
if let Some(ref a) = config.p2pool_node_grpc_address {
-    base_node_addr = a.clone();
+    p2pool_node_addr = a.clone();
} else {
-    base_node_addr = prompt_for_p2pool_address()?;
+    p2pool_node_addr = prompt_for_p2pool_address()?;
};
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a158be1 and 2be16d9.

📒 Files selected for processing (2)
  • applications/minotari_merge_mining_proxy/src/run_merge_miner.rs (3 hunks)
  • applications/minotari_miner/src/run_miner.rs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • applications/minotari_miner/src/run_miner.rs
🧰 Additional context used
🧬 Code Definitions (1)
applications/minotari_merge_mining_proxy/src/run_merge_miner.rs (1)
applications/minotari_app_utilities/src/parse_miner_input.rs (2)
  • prompt_for_base_node_address (57-76)
  • prompt_for_p2pool_address (78-94)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: test (testnet, esmeralda)
  • GitHub Check: cargo check with stable
  • GitHub Check: file licenses
  • GitHub Check: ci
  • GitHub Check: test (mainnet, stagenet)
  • GitHub Check: Cucumber tests / Base Layer
  • GitHub Check: Cucumber tests / FFI
🔇 Additional comments (3)
applications/minotari_merge_mining_proxy/src/run_merge_miner.rs (3)

28-31: LGTM: Import changes align with new functionality.

The new imports for prompt_for_base_node_address and prompt_for_p2pool_address correctly support the changes in address handling throughout this file.


227-232: LGTM: Improved address handling.

The code now properly checks for a configured base node address and falls back to user prompting if not available. This simplifies address management by using string representations directly.


235-235: LGTM: Streamlined endpoint creation.

Changed from Endpoint::from_str(&base_node_addr) to Endpoint::new(base_node_addr) which is more direct and aligns with the move to string-based addresses.

@SWvheerden SWvheerden merged commit 61eda04 into tari-project:development Mar 28, 2025
17 checks passed
@stringhandler stringhandler deleted the st-better-grpc-address branch March 28, 2025 11:15
sdbondi added a commit to sdbondi/tari that referenced this pull request Apr 2, 2025
* development: (412 commits)
  chore: new release v1.13.1-pre.0 (tari-project#6898)
  fix: excess sig order in the tx tab (tari-project#6897)
  chore: ensure thread safety (tari-project#6896)
  fix: peer order (tari-project#6894)
  fix: use plain string for grpc address (tari-project#6881)
  fix: startup arg (tari-project#6889)
  feat: add num connections to network state (tari-project#6884)
  refactor: reduce logging to make it less noisy (tari-project#6882)
  feat: check coinbase count (tari-project#6880)
  chore(deps): bump dorny/test-reporter from 1 to 2 (tari-project#6883)
  chore: update readme (tari-project#6878)
  fix:  libtor cli option (tari-project#6877)
  chore: new version v1.13.0-pre.0 (tari-project#6875)
  chore: reset network (tari-project#6874)
  fix:  prune mode validation (tari-project#6873)
  perf: remove duplicate metadata signature verification (tari-project#6866)
  feat: remove static moneroD response (tari-project#6867)
  chore(ci): updates to pull version from workspace (tari-project#6868)
  chore(ci): binaries build continue-on-error when release (tari-project#6865)
  chore: handle seed words env var (tari-project#6855)
  ...
@coderabbitai coderabbitai bot mentioned this pull request Apr 29, 2025
4 tasks
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.

4 participants