Skip to content

feat: add gprc methods to get fees#7235

Merged
SWvheerden merged 2 commits intotari-project:developmentfrom
SWvheerden:sw_feat_grpc_imporve
Jun 20, 2025
Merged

feat: add gprc methods to get fees#7235
SWvheerden merged 2 commits intotari-project:developmentfrom
SWvheerden:sw_feat_grpc_imporve

Conversation

@SWvheerden
Copy link
Copy Markdown
Collaborator

@SWvheerden SWvheerden commented Jun 20, 2025

Description

Add grpc methods to get fee estimates for tx and mempool
Add user_payment_id to the transaction events

Fixes: #7093

Summary by CodeRabbit

  • New Features

    • Added the ability to estimate transaction fees based on amount, fee per gram, and output count.
    • Introduced a new feature to retrieve fee per gram statistics over recent blocks, including average, minimum, and maximum values.
  • Enhancements

    • Improved transaction event details by distinguishing between raw and user-specific payment identifiers.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jun 20, 2025

"""

Walkthrough

The code introduces two new gRPC methods to the Wallet service for fee estimation and fee statistics. The proto definitions and server implementation are updated accordingly. The TransactionEvent message and related Rust code are modified to split the payment_id field into raw_payment_id and user_payment_id, enhancing payment ID handling.

Changes

File(s) Change Summary
applications/minotari_app_grpc/proto/wallet.proto Added GetFeeEstimate and GetFeePerGramStats RPCs; introduced new messages for fee estimation/stats; split payment_id into raw_payment_id and user_payment_id in TransactionEvent.
applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs Implemented get_fee_estimate and get_fee_per_gram_stats gRPC methods; updated event handling for split payment IDs.
applications/minotari_console_wallet/src/grpc/mod.rs Modified convert_to_transaction_event to split payment_id into raw_payment_id and user_payment_id.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant WalletGrpcServer
    participant OutputManagerService
    participant TransactionService

    Client->>WalletGrpcServer: GetFeeEstimate(request)
    WalletGrpcServer->>OutputManagerService: fee_estimate(amount, fee_per_gram, output_count)
    OutputManagerService-->>WalletGrpcServer: estimated_fee
    WalletGrpcServer-->>Client: GetFeeEstimateResponse(estimated_fee)

    Client->>WalletGrpcServer: GetFeePerGramStats(request)
    WalletGrpcServer->>TransactionService: get_fee_per_gram_stats_per_block(block_count)
    TransactionService-->>WalletGrpcServer: fee_per_gram_stats
    WalletGrpcServer-->>Client: GetFeePerGramStatsResponse(fee_per_gram_stats)
Loading

Assessment against linked issues

Objective (Issue #) Addressed Explanation
Add fee estimate gRPC call (#7093)

Assessment against linked issues: Out-of-scope changes

Code Change (file_path) Explanation
Split payment_id into raw_payment_id and user_payment_id in TransactionEvent (wallet.proto, wallet_grpc_server.rs, mod.rs) This change is unrelated to the fee estimate gRPC call and not mentioned in the linked issue.

Suggested reviewers

  • hansieodendaal

Poem

A hop, a skip, a fee to see—
New gRPC calls, as quick as can be!
With payment IDs now split in two,
Estimations and stats, all shiny and new.
The bunny approves, with a twitch of its nose,
For this wallet’s progress, the excitement grows!
🐇✨
"""


📜 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 3f6fbb2 and 6dc85db.

📒 Files selected for processing (2)
  • applications/minotari_console_wallet/src/grpc/mod.rs (3 hunks)
  • applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • applications/minotari_console_wallet/src/grpc/mod.rs
  • applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: test (mainnet, stagenet)
  • GitHub Check: test (testnet, esmeralda)
  • GitHub Check: test (nextnet, nextnet)
  • GitHub Check: cargo check with stable
  • GitHub Check: ci
  • GitHub Check: Cucumber tests / FFI
  • GitHub Check: Cucumber tests / Base Layer
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 20, 2025

Test Results (CI)

    3 files    126 suites   39m 35s ⏱️
1 351 tests 1 351 ✅ 0 💤 0 ❌
4 051 runs  4 051 ✅ 0 💤 0 ❌

Results for commit 6dc85db.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

Test Results (Integration tests)

 2 files  10 suites   1h 19m 52s ⏱️
30 tests 24 ✅ 1 💤  5 ❌
39 runs  25 ✅ 1 💤 13 ❌

For more details on these failures, see this check.

Results for commit 3f6fbb2.

Copy link
Copy Markdown
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.

See comments below

Comment on lines +54 to +55
raw_payment_id: vec![],
user_payment_id: vec![],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We could fill in payment id here as well

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

its not going to be correct, payment_id is only finalised when it reaches completed.

Comment on lines +43 to +44
raw_payment_id: vec![],
user_payment_id: vec![],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We could fill in payment id here as well

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

its not going to be correct, payment_id is only finalised when it reaches completed.

amount.into(),
selection_criteria,
fee_per_gram.into(),
1, // We assume 1 input for simplicity
Copy link
Copy Markdown
Contributor

@hansieodendaal hansieodendaal Jun 20, 2025

Choose a reason for hiding this comment

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

We might as well provide the amount of outputs inputs here and to the request

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

outputs are below?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Read inputs

@SWvheerden SWvheerden merged commit 83969f3 into tari-project:development Jun 20, 2025
15 checks passed
@SWvheerden SWvheerden deleted the sw_feat_grpc_imporve branch June 20, 2025 13:37
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.

Add fee estimate to grpc

2 participants