Skip to content

feat: get_all_completed_transactions bitflag status filtering#7161

Merged
SWvheerden merged 4 commits intotari-project:developmentfrom
mmrrnn:get_all_completed_txs_bitflag_filtering
Jun 3, 2025
Merged

feat: get_all_completed_transactions bitflag status filtering#7161
SWvheerden merged 4 commits intotari-project:developmentfrom
mmrrnn:get_all_completed_txs_bitflag_filtering

Conversation

@mmrrnn
Copy link
Copy Markdown
Contributor

@mmrrnn mmrrnn commented Jun 3, 2025

Description

  • return all txs when 0 bitflag passes
  • return filtered txs by passed bitflag

Motivation and Context

How Has This Been Tested?

locally, using nodejs client:

  transactions: [
    {
      input_commitments: [],
      output_commitments: [Array],
      tx_id: '486069054555219532',
      source_address: <Buffer 00 01 e4 07 de be 8a 2b 22 25 3b 58 e5 b5 06 61 2c de fa bf 54 1a b2 c9 4a f0 32 f5 81 21 fb 9e 38 03 36 f8 71 b4 cc c3 22 ba 79 7e d0 78 1c ef 03 2e ... 17 more bytes>,
      dest_address: <Buffer 00 01 c2 d6 4e 45 6c 1b 85 4e ed be ed 6c 47 b0 da 70 e9 a0 dd f7 7f 5e 42 f9 b4 b4 0d 2c 1d eb cf 33 3a bd b9 35 e5 2d 35 6a 3c 72 01 64 c6 b6 40 af ... 17 more bytes>,
      status: 'TRANSACTION_STATUS_ONE_SIDED_CONFIRMED',
      direction: 'TRANSACTION_DIRECTION_INBOUND',
      amount: '20000',
      fee: '0',
      is_cancelled: false,
      excess_sig: <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>,
      timestamp: '1748606772',
      raw_payment_id: <Buffer 03 20 4e 00 00 00 00 00 00 00 00 00 05 80 00 01 e4 07 de be 8a 2b 22 25 3b 58 e5 b5 06 61 2c de fa bf 54 1a b2 c9 4a f0 32 f5 81 21 fb 9e 38 03 36 f8 ... 35 more bytes>,
      mined_in_block_height: '17813',
      user_payment_id: <Buffer 4c 61 6c 61>
    },
    {
      input_commitments: [],
      output_commitments: [Array],
      tx_id: '8663099122238597301',
      source_address: <Buffer 00 01 e4 07 de be 8a 2b 22 25 3b 58 e5 b5 06 61 2c de fa bf 54 1a b2 c9 4a f0 32 f5 81 21 fb 9e 38 03 36 f8 71 b4 cc c3 22 ba 79 7e d0 78 1c ef 03 2e ... 17 more bytes>,
      dest_address: <Buffer 00 01 c2 d6 4e 45 6c 1b 85 4e ed be ed 6c 47 b0 da 70 e9 a0 dd f7 7f 5e 42 f9 b4 b4 0d 2c 1d eb cf 33 3a bd b9 35 e5 2d 35 6a 3c 72 01 64 c6 b6 40 af ... 17 more bytes>,
      status: 'TRANSACTION_STATUS_ONE_SIDED_CONFIRMED',
      direction: 'TRANSACTION_DIRECTION_INBOUND',
      amount: '20000',
      fee: '0',
      is_cancelled: false,
      excess_sig: <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>,
      timestamp: '1748605941',
      raw_payment_id: <Buffer 03 20 4e 00 00 00 00 00 00 00 00 00 05 80 00 01 e4 07 de be 8a 2b 22 25 3b 58 e5 b5 06 61 2c de fa bf 54 1a b2 c9 4a f0 32 f5 81 21 fb 9e 38 03 36 f8 ... 34 more bytes>,
      mined_in_block_height: '17808',
      user_payment_id: <Buffer 54 23 32>
    },
    ...

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

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 status using a bitflag when retrieving all completed transactions via gRPC. This allows users to more precisely select which transaction statuses to view.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jun 3, 2025

Walkthrough

A new optional status_bitflag field of type uint64 was added to the GetAllCompletedTransactionsRequest message in the wallet gRPC proto definition. The gRPC server now filters completed transactions by this bitflag, returning only those matching the specified status bits before applying pagination.

Changes

File(s) Change Summary
applications/minotari_app_grpc/proto/wallet.proto Added optional uint64 status_bitflag field to GetAllCompletedTransactionsRequest.
applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs Added filtering logic in get_all_completed_transactions to return only transactions matching status_bitflag if set.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant gRPC_Server
    participant TransactionStore

    Client->>gRPC_Server: GetAllCompletedTransactionsRequest(status_bitflag)
    gRPC_Server->>TransactionStore: Fetch all completed transactions
    TransactionStore-->>gRPC_Server: Return transaction list
    gRPC_Server->>gRPC_Server: Filter transactions by status_bitflag
    gRPC_Server-->>Client: Return filtered transactions
Loading

Possibly related PRs

Suggested reviewers

  • SWvheerden

Poem

In the garden of bits, a flag now appears,
Filtering transactions, as the request steers.
Only those matching, by status they show,
The gRPC wallet lets the right ones flow.
With a hop and a skip, the rabbit approves—
Bitflags in code, with elegant moves!
🐇✨


📜 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 0a0af9f and fa70ca4.

📒 Files selected for processing (1)
  • applications/minotari_app_grpc/proto/wallet.proto (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • applications/minotari_app_grpc/proto/wallet.proto
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Cucumber tests / Base Layer
  • GitHub Check: test (nextnet, nextnet)
  • GitHub Check: test (mainnet, stagenet)
  • GitHub Check: test (testnet, esmeralda)
  • GitHub Check: ci
  • GitHub Check: file licenses
  • GitHub Check: cargo check with stable

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.

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: 0

🧹 Nitpick comments (2)
applications/minotari_app_grpc/proto/wallet.proto (1)

1427-1431: Add documentation for the status_bitflag field

Include a comment above the new field to explain its purpose and default behavior:

 message GetAllCompletedTransactionsRequest {
   uint64 offset = 1;
   uint64 limit = 2;
-  uint32 status_bitflag = 3;
+  // Optional bitmask to filter returned transactions by their status flags.
+  // If zero (default or omitted), all completed transactions are returned;
+  // otherwise, only transactions for which (status & status_bitflag) != 0 are included.
+  uint32 status_bitflag = 3;
 }
applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs (1)

1205-1205: Optimize the bitflag filtering implementation and add validation.

The bitflag filtering logic is correct, but there are several improvements that can be made:

  1. Remove the unnecessary .clone() call on tx.status since enum-to-u32 casting doesn't require cloning
  2. Add validation for the status_bitflag value to prevent potential overflow
  3. Add documentation to explain the bitflag filtering logic

Apply this diff to optimize and improve the implementation:

-            .filter(|tx| req.status_bitflag == 0 || (req.status_bitflag & (1 << (tx.status.clone() as u32))) != 0)
+            .filter(|tx| {
+                // If status_bitflag is 0, return all transactions (no filtering)
+                // Otherwise, check if the transaction's status bit is set in the bitflag
+                req.status_bitflag == 0 || (req.status_bitflag & (1 << (tx.status as u32))) != 0
+            })

Additionally, consider adding validation near the beginning of the method to ensure the bitflag value is reasonable:

// Validate status_bitflag to prevent potential overflow (assuming status enum has < 32 variants)
if req.status_bitflag != 0 && req.status_bitflag >= (1 << 32) {
    return Err(Status::invalid_argument("status_bitflag value is too large"));
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between da7cd26 and 195fa9d.

📒 Files selected for processing (2)
  • applications/minotari_app_grpc/proto/wallet.proto (1 hunks)
  • applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: test (mainnet, stagenet)
  • GitHub Check: test (nextnet, nextnet)
  • GitHub Check: cargo check with stable

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 3, 2025

Test Results (CI)

371 tests   370 ✅  7m 39s ⏱️
 20 suites    0 💤
  1 files      1 ❌

For more details on these failures, see this check.

Results for commit 0a0af9f.

@SWvheerden SWvheerden merged commit 7248e18 into tari-project:development Jun 3, 2025
11 of 15 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jun 4, 2025
4 tasks
SWvheerden pushed a commit that referenced this pull request Jun 12, 2025
Description
---
For some reason it was removed while merging.

Origin: #7161

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added the ability to filter completed transactions by status when
viewing transaction history.

- **Enhancements**
- Improved transaction history pagination to work with filtered results.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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