Skip to content

feat: add block height to query#7033

Merged
SWvheerden merged 1 commit intotari-project:developmentfrom
hansieodendaal:ho_add_grpc_block_heght
May 7, 2025
Merged

feat: add block height to query#7033
SWvheerden merged 1 commit intotari-project:developmentfrom
hansieodendaal:ho_add_grpc_block_heght

Conversation

@hansieodendaal
Copy link
Copy Markdown
Contributor

@hansieodendaal hansieodendaal commented May 7, 2025

Description

Added block height to the grpc query to get completed transactions.

Motivation and Context

Some clients need to query transactions in a block by height.

How Has This Been Tested?

System-level testing [TBD]

What process can a PR reviewer use to test or verify this change?

Code review
System-level testing

Breaking Changes

  • None
  • Requires data directory on base node to be deleted
  • Requires hard fork
  • Other - Please specify

Summary by CodeRabbit

  • New Features

    • Added support for filtering completed transactions by block height in wallet queries and APIs.
  • Bug Fixes

    • Updated all relevant interfaces and test cases to ensure compatibility with the new block height filter option.

Added block height to the grpc query to get completed transactions
@hansieodendaal hansieodendaal requested a review from a team as a code owner May 7, 2025 10:25
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented May 7, 2025

Walkthrough

This change extends the completed transactions query functionality across the wallet and its interfaces by adding support for filtering by an optional block height. The new parameter is integrated throughout the gRPC API, backend storage, service logic, and all relevant method signatures, as well as updated in tests and FFI interfaces.

Changes

File(s) Change Summary
applications/minotari_app_grpc/proto/wallet.proto Added an optional block_height field to GetCompletedTransactionsRequest and updated RPC documentation accordingly.
applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs Extracts and forwards the new block_height field from gRPC requests to the transaction service handle.
applications/minotari_console_wallet/src/ui/state/app_state.rs Updates method calls to get_completed_transactions to include the new third argument for block_height.
base_layer/wallet/src/transaction_service/handle.rs Adds block_height: Option<u64> to the request enum and updates the handle method signature to accept and forward this argument.
base_layer/wallet/src/transaction_service/service.rs Modifies the service request handling and database calls to include the new block_height parameter for filtering.
base_layer/wallet/src/transaction_service/storage/database.rs Propagates block_height through trait, method signatures, and internal logic for completed transaction filtering.
base_layer/wallet/src/transaction_service/storage/sqlite_db.rs Extends the SQLite backend query logic and method signatures to support filtering by block_height.
base_layer/wallet/tests/transaction_service_tests/service.rs Updates all test calls to get_completed_transactions to include the new third argument.
base_layer/wallet/tests/transaction_service_tests/storage.rs Updates test calls to get_completed_transactions to include the new third argument.
base_layer/wallet/tests/transaction_service_tests/transaction_protocols.rs Updates test calls to get_completed_transactions to include the new third argument.
base_layer/wallet_ffi/src/lib.rs Adds a third None argument to all internal calls to get_completed_transactions within FFI interface functions.
integration_tests/tests/steps/wallet_steps.rs Adds explicit block_height: None to all GetCompletedTransactionsRequest constructions in integration test step functions.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant gRPC_Server
    participant TransactionServiceHandle
    participant TransactionService
    participant Database

    Client->>gRPC_Server: GetCompletedTransactionsRequest(payment_id, block_hash, block_height)
    gRPC_Server->>TransactionServiceHandle: get_completed_transactions(payment_id, block_hash, block_height)
    TransactionServiceHandle->>TransactionService: GetCompletedTransactions(payment_id, block_hash, block_height)
    TransactionService->>Database: get_completed_transactions(payment_id, block_hash, block_height)
    Database-->>TransactionService: CompletedTransactions
    TransactionService-->>TransactionServiceHandle: CompletedTransactions
    TransactionServiceHandle-->>gRPC_Server: CompletedTransactions
    gRPC_Server-->>Client: CompletedTransactions
Loading

Possibly related PRs

  • tari-project/tari#7025: Adds block hash filtering to completed transactions queries, similar to this PR's addition of block height filtering.

Suggested reviewers

  • SWvheerden

Poem

In the warren of code, a new tunnel appears,
Block heights now filter completed frontiers.
From proto to backend, the message is clear—
Transactions by height, with logic sincere.
Tests and requests all hop in a row,
This rabbit approves—let the new queries flow! 🐇✨

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

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.

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

🧹 Nitpick comments (2)
base_layer/wallet/tests/transaction_service_tests/service.rs (1)

2307-6335: Consider adding specific tests for the block_height filter functionality

While all existing calls have been correctly updated to include the new parameter, there are no tests that specifically verify the block height filtering works as expected. Consider adding test cases that use non-None values for this parameter to verify the filtering functionality.

applications/minotari_app_grpc/proto/wallet.proto (1)

343-349: Update RPC documentation to reference block_height in summary and examples
The high-level description on line 319 still mentions filtering by payment_id and/or block_hash only. Please update it to include block_height, and extend the sample JavaScript usage to show how to set block_height (e.g., block_height: 12345).

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 25e99d8 and cd92578.

📒 Files selected for processing (12)
  • applications/minotari_app_grpc/proto/wallet.proto (2 hunks)
  • applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs (1 hunks)
  • applications/minotari_console_wallet/src/ui/state/app_state.rs (1 hunks)
  • base_layer/wallet/src/transaction_service/handle.rs (2 hunks)
  • base_layer/wallet/src/transaction_service/service.rs (1 hunks)
  • base_layer/wallet/src/transaction_service/storage/database.rs (5 hunks)
  • base_layer/wallet/src/transaction_service/storage/sqlite_db.rs (2 hunks)
  • base_layer/wallet/tests/transaction_service_tests/service.rs (5 hunks)
  • base_layer/wallet/tests/transaction_service_tests/storage.rs (2 hunks)
  • base_layer/wallet/tests/transaction_service_tests/transaction_protocols.rs (8 hunks)
  • base_layer/wallet_ffi/src/lib.rs (6 hunks)
  • integration_tests/tests/steps/wallet_steps.rs (9 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
base_layer/wallet/tests/transaction_service_tests/storage.rs (1)
base_layer/wallet/src/transaction_service/storage/database.rs (2)
  • get_cancelled_completed_transactions (614-616)
  • get_cancelled_completed_transaction (425-430)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: test (mainnet, stagenet)
  • GitHub Check: test (nextnet, nextnet)
  • GitHub Check: ci
  • GitHub Check: test (testnet, esmeralda)
  • GitHub Check: cargo check with stable
  • GitHub Check: Cucumber tests / FFI
  • GitHub Check: Cucumber tests / Base Layer
🔇 Additional comments (26)
applications/minotari_console_wallet/src/ui/state/app_state.rs (1)

757-757: Updated method call to include new block_height parameter.

The call to get_completed_transactions has been updated to include a third None parameter for the new optional block height filter, matching the extended method signature.

applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs (1)

941-945: Properly implemented block height filtering for completed transactions.

The implementation correctly extracts the optional block height from the incoming gRPC request message and passes it to the transaction service method, enabling the new filtering capability as intended by the PR.

base_layer/wallet/tests/transaction_service_tests/transaction_protocols.rs (1)

858-858: Updated test calls to match new method signature.

All calls to get_completed_transactions have been properly updated to include the new None parameter for block_height, ensuring the tests continue to fetch all transactions without any block height filtering.

Also applies to: 893-893, 946-946, 1084-1085, 1105-1105, 1275-1275, 1392-1392

base_layer/wallet/tests/transaction_service_tests/service.rs (7)

2307-2307: Updated method call to include new block_height parameter

The call to get_completed_transactions has been updated to include the new block_height parameter with a value of None, maintaining backward compatibility.


2412-2412: Updated method call to include new block_height parameter

The call has been correctly updated to match the new method signature which includes the optional block height filter.


2416-2416: Updated method call to include new block_height parameter

The bob_ts instance's call to get_completed_transactions has been properly updated with the third parameter.


2421-2421: Updated method call to include new block_height parameter

The carol_ts instance's call has been correctly updated to match the new method signature.


5591-5591: Updated method call to include new block_height parameter

The call in the transaction_service_tx_broadcast test has been correctly updated.


5699-5699: Updated method call to include new block_height parameter

Another instance in the same test correctly updated to the new signature.


6335-6335: Updated method call to include new block_height parameter

The call in test_completed_transactions_ordering has been properly updated.

base_layer/wallet/tests/transaction_service_tests/storage.rs (1)

361-361: Updates to match new signature with block_height parameter

These changes update the test calls to db.get_completed_transactions with an additional None parameter to match the new method signature that includes the optional block_height parameter.

Also applies to: 419-419, 427-427

integration_tests/tests/steps/wallet_steps.rs (1)

165-165: Updates to all GetCompletedTransactionsRequest instances

All instances of GetCompletedTransactionsRequest construction have been updated to include the new block_height: None field, ensuring the integration tests properly handle the new parameter for filtering transactions by block height.

Also applies to: 503-503, 556-556, 977-977, 1037-1037, 1256-1256, 2672-2672, 2827-2827, 2854-2854

applications/minotari_app_grpc/proto/wallet.proto (1)

1185-1185: Verify that the BlockHeight type is defined and imported
The new field uses a BlockHeight message. Ensure this type is declared in one of the imported proto files (e.g., sidechain_types.proto or types.proto). If it’s missing, add the proper import or define BlockHeight (e.g., message BlockHeight { uint64 height = 1; }).

base_layer/wallet_ffi/src/lib.rs (1)

8300-8300: Consistently updated method calls with new block_height parameter

All calls to get_completed_transactions have been correctly updated to include the new optional block_height parameter (passed as None in all instances). This is consistent with the described feature enhancement to support filtering transactions by block height.

Also applies to: 8371-8371, 8443-8443, 8600-8600, 8664-8664, 8740-8740

base_layer/wallet/src/transaction_service/handle.rs (3)

83-86: LGTM: Block height filter addition to GetCompletedTransactions enum variant

The addition of the block_height field to the GetCompletedTransactions enum variant is well-structured as an optional parameter, consistent with the existing filter fields.


967-972: Function signature correctly updated with block height parameter

The get_completed_transactions method signature has been properly extended to include the new optional block height parameter, maintaining API compatibility.


973-979: Implementation correctly passes block height parameter to request

The implementation properly includes the block height parameter in the request structure, ensuring it will be passed to the underlying service layer.

base_layer/wallet/src/transaction_service/service.rs (1)

894-901: Implementation looks good for block height filtering parameter.

The addition of the block_height parameter to the GetCompletedTransactions request variant properly extends the transaction querying functionality to filter by block height. This change is consistent with the existing optional parameters (payment_id and block_hash), allowing for flexible filtering of completed transactions.

base_layer/wallet/src/transaction_service/storage/sqlite_db.rs (2)

1051-1056: Implementation looks good - adding block height filtering capability.

The signature change adds an optional parameter to filter transactions by block height, which aligns well with the existing filtering capabilities for payment ID and block hash.


1067-1069: Implementation correctly adds block height filtering.

The implementation follows the same pattern as the existing filters, properly handling the optional nature of the parameter and adding the SQL filter condition only when a block height is provided.

base_layer/wallet/src/transaction_service/storage/database.rs (6)

159-164: Proper trait extension for block height filtering.

This change correctly extends the TransactionBackend trait to include the new block height parameter, ensuring all implementations will provide this filtering capability.


487-496: Method correctly propagates new block height parameter.

The method has been updated to include and pass along the block height parameter to the underlying database implementation.


605-612: Public API correctly exposes block height filtering.

The change properly extends the public-facing API to include block height filtering, passing the parameter down to the implementation method.


614-616: Explicitly passes None for unused filters in cancelled transactions method.

This change makes the code more explicit, clearly showing that cancelled transactions aren't filtered by any of the available filter parameters.


637-643: Internal implementation properly handles block height parameter.

The method has been correctly updated to accept and handle the new block height parameter.


649-668: Filter checking logic properly includes block height.

The conditional logic has been updated to check all three filter parameters (payment_id, block_hash, and block_height) before deciding which database method to call. This follows the existing pattern and works correctly.

@github-actions
Copy link
Copy Markdown

github-actions bot commented May 7, 2025

Test Results (CI)

1 074 tests   1 069 ✅  11m 40s ⏱️
   30 suites      0 💤
    1 files        5 ❌

For more details on these failures, see this check.

Results for commit cd92578.

@SWvheerden SWvheerden merged commit 50c2839 into tari-project:development May 7, 2025
12 of 16 checks passed
@hansieodendaal hansieodendaal deleted the ho_add_grpc_block_heght branch May 8, 2025 11:31
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.

2 participants