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 tip info for getting height #255

Merged
merged 3 commits into from
Feb 26, 2025
Merged

Conversation

stringhandler
Copy link
Contributor

@stringhandler stringhandler commented Feb 13, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a new service endpoint that provides enhanced tip information, allowing clients to access up-to-date share chain data and base node details.
    • Streamlined the block submission process for clearer handling of cases when no new tip is available.
  • Chores

    • Updated dependency configurations to integrate the latest sources for ongoing development improvements.
    • Specified the installation of version 0.7.0 of the cargo-machete tool in the CI workflow.

Copy link

coderabbitai bot commented Feb 13, 2025

Walkthrough

This update modifies dependency declarations in the Cargo.toml file by replacing specific commit revisions with a new commit hash for several dependencies related to the tari project. Additionally, new gRPC functionality is introduced in the p2pool module, including the get_tip_info method and its associated request and response types. The changes also reorganize the block submission logic within the same file, incorporating enhanced error handling and notifications. Furthermore, the CI workflow is updated to install a specific version of the cargo-machete tool.

Changes

File Change Summary
Cargo.toml Updated dependencies (minotari_app_grpc, minotari_node_grpc_client, tari_common, tari_common_types, tari_core, tari_script, tari_shutdown) to use a new commit hash (b3dc63f79e7bedd19854c17e5d9809deb652e61d) from the tari repository instead of a previous commit hash.
src/server/grpc/p2pool.rs Added new gRPC endpoint get_tip_info with corresponding GetTipInfoRequest and GetTipInfoResponse types. Reorganized the submission logic in submit_share_chain_block and enhanced error handling, including rejection notifications when a new tip is not found.
.github/workflows/ci.yml Updated installation command for cargo-machete to specify version 0.7.0 instead of installing the latest version.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant gRPCServer as ShaP2PoolGrpc
    participant RXChain as RandomXChain
    participant SHA3x as SHA3xChain
    participant BaseNode

    Client->>gRPCServer: get_tip_info(request)
    gRPCServer->>RXChain: Retrieve tip info
    RXChain-->>gRPCServer: [RandomX tip data]
    gRPCServer->>SHA3x: Retrieve tip info
    SHA3x-->>gRPCServer: [SHA3x tip data]
    gRPCServer->>BaseNode: Retrieve tip info
    BaseNode-->>gRPCServer: [Base node tip data]
    gRPCServer->>Client: get_tip_info(response)
Loading

Poem

I’m a rabbit on a coding spree,
Hopping through branches, setting dependencies free.
With new gRPC hops and tip info in flight,
My little paws tap keys all through the night.
Code blooms like carrots fresh and bright,
Cheers to change, in byte and delight!
🐇💻🌟


📜 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 6283158 and 3762c84.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: test (esmeralda)
  • GitHub Check: machete
  • GitHub Check: clippy
  • GitHub Check: cargo check with stable
🔇 Additional comments (1)
.github/workflows/ci.yml (1)

111-112: Pinning cargo-machete to version 0.7.0

This explicit version pinning promotes consistency in the CI process by ensuring that breaks or unexpected behaviors due to tool updates are avoided. Please verify that version 0.7.0 of cargo-machete is compatible with the updated tari dependencies and new gRPC functionalities introduced elsewhere in the codebase.


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:

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

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.

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/server/grpc/p2pool.rs (2)

160-168: Minor nitpick: Expand logging when appending uncles.
The code correctly assembles a list of uncles and appends them to new_blocks. Consider adding a debug or info log statement with the count of appended uncles for troubleshooting.

 let mut uncles = share_chain
     .get_blocks(&block.uncles)
     .await
     .into_iter()
     .map(Arc::<P2Block>::unwrap_or_clone)
     .collect();
+ debug!(target: LOG_TARGET, "Appending {} uncles to the new block", uncles.len());
 new_blocks.append(&mut uncles);

197-246: Consider reusing the base node connection and handling partial errors more gracefully.
The new get_tip_info method is generally well-structured and uses a timeout for reliability. However, reconnecting to the base node each time can incur overhead. Caching the gRPC client or gracefully handling partial fetch failures (e.g., still return share-chain tip data if base node fetch fails) could enhance robustness.

Cargo.toml (1)

46-48: Consider pinning dependency revisions for deterministic builds.
Switching from a fixed commit to a branch reference is suitable for ongoing development; however, it can introduce build unpredictability. If stability is a priority, pin each dependency with a commit SHA for reproducible builds.

- minotari_app_grpc = { git = "https://github.com/stringhandler/tari.git", branch = "st-add-p2pool-tip-info" }
+ minotari_app_grpc = { git = "https://github.com/stringhandler/tari.git", rev = "f0f95a5" }

Also applies to: 53-55, 57-58

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4fe3a7d and 0eab9d4.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • Cargo.toml (1 hunks)
  • src/server/grpc/p2pool.rs (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: machete
  • GitHub Check: test (esmeralda)
  • GitHub Check: clippy
  • GitHub Check: cargo check with stable
🔇 Additional comments (2)
src/server/grpc/p2pool.rs (2)

19-19: New imports for gRPC requests and responses look good.
They integrate well with the get_tip_info method below without introducing breaking changes.

Also applies to: 23-24


178-180: Block rejection path is handled effectively.
Calling send_miner_block_rejected on the stats broadcast upon a missed tip is appropriate. No concerns here.

@stringhandler stringhandler requested a review from a team as a code owner February 26, 2025 14:15
@stringhandler stringhandler merged commit 9c9323e into development Feb 26, 2025
14 checks passed
@stringhandler stringhandler deleted the st-new-tip-info branch February 26, 2025 14:34
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