Skip to content

feat: limit txs searches#7236

Merged
SWvheerden merged 4 commits intotari-project:developmentfrom
SWvheerden:sw_max_limits
Jun 20, 2025
Merged

feat: limit txs searches#7236
SWvheerden merged 4 commits intotari-project:developmentfrom
SWvheerden:sw_max_limits

Conversation

@SWvheerden
Copy link
Copy Markdown
Collaborator

@SWvheerden SWvheerden commented Jun 20, 2025

Description

adds the option to limit transaction searches and not read the entire completed transactions database.
Limits the console wallet to only view the latest 500 txs.

Summary by CodeRabbit

  • New Features

    • Added the ability to limit the number of completed and cancelled transactions returned in wallet queries and API calls, improving performance and usability for large transaction histories.
    • Introduced support for specifying a maximum number of transactions to retrieve when using wallet FFI functions.
  • Refactor

    • Simplified and optimized the retrieval of cancelled transactions by ID for external integrations.

adds the options to limit tx searches
@SWvheerden SWvheerden requested a review from a team as a code owner June 20, 2025 11:53
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jun 20, 2025

Walkthrough

This change introduces a max_limit parameter across the wallet's transaction retrieval APIs, database queries, FFI functions, and gRPC endpoints. The parameter allows callers to specify the maximum number of completed or cancelled transactions to return, enabling paginated or limited queries throughout the system. Method signatures, enum variants, and database queries are updated accordingly.

Changes

File(s) Change Summary
applications/minotari_console_wallet/src/automation/commands.rs Updated call to get_completed_transactions to include a 0 max limit parameter.
applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs Added limit parameter to transaction retrieval gRPC handlers and adjusted request extraction order.
applications/minotari_console_wallet/src/ui/state/app_state.rs Set explicit limits (500/100) when fetching completed/cancelled transactions in UI state refresh.
base_layer/wallet/src/transaction_service/handle.rs Added max_limit to TransactionServiceRequest variants and updated handle methods to accept/pass the limit.
base_layer/wallet/src/transaction_service/service.rs Updated request handling to pass max_limit to database methods; refined error reporting for missing txs.
base_layer/wallet/src/transaction_service/storage/database.rs Added max_limit parameter to trait methods, enum variants, and transaction retrieval functions.
base_layer/wallet/src/transaction_service/storage/sqlite_db.rs Added max_limit to DB queries, enum variants, and query builders; updated method signatures accordingly.
base_layer/wallet_ffi/src/lib.rs Added max_search_limit parameter to FFI transaction retrieval functions; refactored cancelled tx by ID logic.
base_layer/wallet/tests/transaction_service_tests/{service.rs,storage.rs,transaction_protocols.rs} Updated test calls to get_completed_transactions and get_cancelled_completed_transactions to include 0 limit.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant WalletAPI
    participant TransactionService
    participant Database

    Caller->>WalletAPI: get_completed_transactions(max_limit)
    WalletAPI->>TransactionService: get_completed_transactions(..., max_limit)
    TransactionService->>Database: fetch_completed_transactions(..., max_limit)
    Database-->>TransactionService: Vec<CompletedTransaction> (up to max_limit)
    TransactionService-->>WalletAPI: Vec<CompletedTransaction>
    WalletAPI-->>Caller: Vec<CompletedTransaction>
Loading

Possibly related PRs

  • tari-project/tari#7025: Extends get_completed_transactions with a block_hash filter parameter, related as it modifies the same method signature.
  • tari-project/tari#7113: Adds a gRPC method for paginated retrieval of completed transactions, closely related through the shared focus on transaction pagination and limits.
  • tari-project/tari#6993: Introduces filtering of completed transactions by payment ID, related as it modifies the same transaction retrieval methods for different filtering capabilities.

Poem

A hop and a skip through the wallet’s new gate,
Now rabbits can fetch just the right plate.
With limits in paw, not a byte more,
Transactions come sorted, never a bore.
From FFI to SQL, the changes are neat—
Pagination for all, a bunny-sized treat!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.38.1)
base_layer/wallet_ffi/src/lib.rs
✨ 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.

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

🔭 Outside diff range comments (1)
base_layer/wallet_ffi/src/lib.rs (1)

9069-9093: Inefficient implementation for single transaction lookup

This function fetches a single transaction by ID but still uses get_completed_transactions with a limit parameter and then searches through the results. This is inefficient and the max_search_limit parameter doesn't make sense for a by-ID lookup.

Consider using get_any_transaction directly, similar to the refactored wallet_get_cancelled_transaction_by_id:

-let completed_transactions =
-    (*wallet)
-        .runtime
-        .block_on((*wallet).wallet.transaction_service.get_completed_transactions(
-            None,
-            None,
-            None,
-            max_search_limit,
-        ));
-
-match completed_transactions {
-    Ok(completed_transactions) => {
+let transaction = (*wallet).runtime.block_on(
+    (*wallet)
+        .wallet
+        .transaction_service
+        .get_any_transaction(transaction_id.into()),
+);
+
+match transaction {
+    Ok(Some(WalletTransaction::Completed(tx))) => {
+        Box::into_raw(Box::new(tx))
+    },
+    Ok(Some(_)) | Ok(None) => {
+        *error_out = LibWalletError::from(WalletError::TransactionServiceError(
+            TransactionServiceError::TransactionDoesNotExist,
+        )).code;
+        ptr::null_mut()
+    },
+    Err(e) => {
+        *error_out = LibWalletError::from(WalletError::TransactionServiceError(e)).code;
+        ptr::null_mut()
+    },
+}
♻️ Duplicate comments (2)
base_layer/wallet_ffi/src/lib.rs (2)

9133-9162: Same inefficiency for pending inbound transaction lookup

This function has the same issue - it fetches multiple transactions and filters by ID instead of using a direct lookup.


9214-9243: Same inefficiency for pending outbound transaction lookup

This function follows the same inefficient pattern.

🧹 Nitpick comments (5)
applications/minotari_console_wallet/src/ui/state/app_state.rs (2)

757-757: Consider making the transaction limit configurable.

The hardcoded limit of 500 transactions aligns with the PR objective, but consider making this configurable through the wallet configuration to allow users to adjust based on their needs.

Additionally, ensure users are aware that only the latest 500 transactions are displayed, as this could impact user experience if they expect to see their complete transaction history.

Consider adding a configuration parameter:

-                .get_completed_transactions(None, None, None, 500)
+                .get_completed_transactions(None, None, None, self.wallet_config.max_displayed_transactions.unwrap_or(500))

764-764: The cancelled transaction limit appears reasonable but consider consistency.

The limit of 100 for cancelled transactions is reasonable given their typically lower frequency compared to completed transactions. However, like the completed transactions limit, this hardcoded value could benefit from being configurable.

Consider maintaining consistency with the completed transactions approach if you decide to make limits configurable.

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

185-185: Consider validating max_limit parameter values.

The enum variants now include max_limit parameters, which is correct for the feature. However, consider adding validation to ensure reasonable limit values.

The u64 type allows very large values that could potentially cause performance issues or memory exhaustion. Consider:

// Add validation helper function
fn validate_max_limit(limit: u64) -> Result<u64, TransactionStorageError> {
    const MAX_REASONABLE_LIMIT: u64 = 100_000; // Adjust as needed
    if limit == 0 {
        Err(TransactionStorageError::InvalidArgument("max_limit cannot be zero".to_string()))
    } else if limit > MAX_REASONABLE_LIMIT {
        Err(TransactionStorageError::InvalidArgument(format!("max_limit {} exceeds maximum allowed {}", limit, MAX_REASONABLE_LIMIT)))
    } else {
        Ok(limit)
    }
}

Also applies to: 188-188


225-225: Improve debugging by including max_limit values in Debug output.

The Debug implementation ignores the max_limit parameter values, which reduces debugging utility when investigating query behavior.

-            CompletedTransactions(_) => {
-                write!(f, "CompletedTransactions ")
-            },
+            CompletedTransactions(limit) => {
+                write!(f, "CompletedTransactions(limit: {})", limit)
+            },
-            CancelledCompletedTransactions(_) => {
-                write!(f, "CancelledCompletedTransactions")
-            },
+            CancelledCompletedTransactions(limit) => {
+                write!(f, "CancelledCompletedTransactions(limit: {})", limit)
+            },

Also applies to: 234-234


858-858: Consider including max_limit values in Display output for better observability.

Similar to the Debug implementation, the Display implementation ignores the max_limit parameter values, which could be helpful for logging and monitoring.

-            DbKey::CompletedTransactions(_) => f.write_str("All Complete Transactions"),
+            DbKey::CompletedTransactions(limit) => write!(f, "All Complete Transactions (limit: {})", limit),
-            DbKey::CancelledCompletedTransactions(_) => f.write_str("All Cancelled Complete Transactions"),
+            DbKey::CancelledCompletedTransactions(limit) => write!(f, "All Cancelled Complete Transactions (limit: {})", limit),

Also applies to: 861-861

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 83969f3 and 3f7b1e2.

📒 Files selected for processing (8)
  • applications/minotari_console_wallet/src/automation/commands.rs (1 hunks)
  • applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs (4 hunks)
  • applications/minotari_console_wallet/src/ui/state/app_state.rs (1 hunks)
  • base_layer/wallet/src/transaction_service/handle.rs (4 hunks)
  • base_layer/wallet/src/transaction_service/service.rs (3 hunks)
  • base_layer/wallet/src/transaction_service/storage/database.rs (10 hunks)
  • base_layer/wallet/src/transaction_service/storage/sqlite_db.rs (8 hunks)
  • base_layer/wallet_ffi/src/lib.rs (23 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Cucumber tests / FFI
  • GitHub Check: Cucumber tests / Base Layer
  • GitHub Check: cargo check with stable
  • GitHub Check: test (testnet, esmeralda)
  • GitHub Check: test (mainnet, stagenet)
  • GitHub Check: test (nextnet, nextnet)
  • GitHub Check: ci
🔇 Additional comments (26)
applications/minotari_console_wallet/src/automation/commands.rs (1)

796-798: ```shell
#!/bin/bash

Inspect the implementation of find_completed_transactions_filter_payment_id_block_hash

rg -n "fn find_completed_transactions_filter_payment_id_block_hash" -C30 base_layer/wallet/src/transaction_service/storage/sqlite_db.rs

Search for the use of .limit in the completed transactions queries

rg -n ".limit" -C5 base_layer/wallet/src/transaction_service/storage/sqlite_db.rs


</details>
<details>
<summary>base_layer/wallet/src/transaction_service/service.rs (3)</summary>

`897-905`: **LGTM: Clean implementation of transaction limit feature**

The addition of the `max_limit` parameter to the `GetCompletedTransactions` request and its proper passing to the database layer is well implemented and aligns with the PR objective to limit transaction searches for improved performance.

---

`923-927`: **LGTM: Consistent implementation of transaction limit**

The `GetCancelledCompletedTransactions` case correctly implements the same `max_limit` pattern as the completed transactions, maintaining consistency across the transaction retrieval APIs.

---

`1034-1034`: **LGTM: Improved error specificity**

The refinement from a parameterless `DbKey::CompletedTransactions` variant to `DbKey::CompletedTransactions(1)` provides better error context and appears to be a logical improvement in error handling specificity.

</details>
<details>
<summary>applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs (5)</summary>

`1103-1103`: **LGTM: Properly maintains unlimited search for specific transaction queries.**

The addition of the fourth parameter with value `0` (indicating no limit) is correct for this specific transaction search endpoint, maintaining existing behavior while supporting the new limiting feature.

---

`1209-1209`: **Good: Request extraction moved earlier to access the limit field.**

Moving the request extraction before the service calls allows proper access to the `req.limit` field used in subsequent method calls.

---

`1217-1217`: **LGTM: Correctly passes request limit for general transaction retrieval.**

The use of `req.limit` as the fourth parameter appropriately applies the requested limit for the `get_all_completed_transactions` endpoint, which aligns with the PR's goal of limiting transaction searches.

---

`1227-1227`: **LGTM: Consistent limit application for cancelled transactions.**

The limit parameter is properly passed to `get_cancelled_completed_transactions`, ensuring both completed and cancelled transactions respect the same limit when fetching all transactions.

---

`1334-1334`: **LGTM: Maintains unlimited search for block height specific queries.**

Similar to the general `get_completed_transactions`, using `0` for the limit parameter preserves the existing behavior for block height specific searches while supporting the new limiting infrastructure.

</details>
<details>
<summary>base_layer/wallet_ffi/src/lib.rs (1)</summary>

`9311-9332`: **Excellent refactoring using `get_any_transaction`**

This refactoring simplifies the code and improves efficiency by using a single lookup instead of searching through multiple transaction lists. The conversion logic properly handles all transaction types.

This pattern should be applied to the other by-ID lookup functions as well.

</details>
<details>
<summary>base_layer/wallet/src/transaction_service/handle.rs (5)</summary>

`82-87`: **LGTM! Consistent parameter addition.**

The `max_limit` parameter is correctly added to the `GetCompletedTransactions` variant, maintaining consistency with the existing optional filter parameters.

---

`94-94`: **LGTM! Appropriate variant transformation.**

The change from a unit variant to a parameterized variant `GetCancelledCompletedTransactions(u64)` is consistent with the approach of adding limits across transaction retrieval methods.

---

`230-230`: **LGTM! Display implementation correctly updated.**

The `fmt::Display` implementation properly handles the new parameterized variant format for `GetCancelledCompletedTransactions`.

---

`1006-1026`: **LGTM! Method signature and call properly updated.**

The `get_completed_transactions` method correctly:
- Adds the `max_limit: u64` parameter to the signature
- Passes the parameter through to the service request
- Maintains consistency with the existing method structure

---

`1046-1058`: **LGTM! Method signature and call properly updated.**

The `get_cancelled_completed_transactions` method correctly:
- Adds the `max_limit: u64` parameter to the signature  
- Passes the parameter through to the service request using the new parameterized variant
- Maintains consistency with the other transaction retrieval methods

</details>
<details>
<summary>base_layer/wallet/src/transaction_service/storage/sqlite_db.rs (5)</summary>

`180-183`: **LGTM! Correct handling of parameterized enum variants.**

The addition of the underscore pattern matching for the new parameterized `DbKey` variants is correct, and returning `OperationNotSupported` is appropriate for these collection-level operations.

---

`297-304`: **LGTM! Consistent implementation of limit parameter.**

The fetch method correctly extracts the `max_limit` parameter from the `DbKey` variants and passes it to the SQL query methods. The implementation is consistent between both completed and cancelled transaction cases.



Also applies to: 321-328

---

`377-380`: **LGTM! Appropriate contains() behavior for limited collections.**

Returning `false` for the `contains()` method on limited collection keys is semantically correct, as checking containment doesn't make sense for a collection that may only return a subset of items.

---

`1147-1172`: **LGTM! Consistent limit implementation across query methods.**

The `find_completed_transactions_filter_payment_id_block_hash` method correctly implements the same limit pattern as other query methods. The logic for handling `max_limit = 0` as "no limit" and applying the limit to the query is consistent and correct.

---

`872-886`: **Check for potential overflow in limit conversion.**

The implementation correctly applies the limit parameter and handles the special case where `max_limit = 0` means no limit. However, consider validating that large `u64` values don't overflow when cast to `i64`.




```shell
#!/bin/bash
# Search for similar u64 to i64 conversions in the codebase to check for consistent overflow handling
rg "as i64" --type rust -A 2 -B 2
base_layer/wallet/src/transaction_service/storage/database.rs (6)

165-165: LGTM - Parameter addition to trait method.

The max_limit parameter is correctly added to the trait method signature, maintaining consistency with the PR objective to limit transaction searches.


503-510: LGTM - Method signature and implementation are consistent.

The max_limit parameter is properly added to the method signature and correctly passed through to the backend implementation.


625-625: LGTM - Parameter threading is correct.

The max_limit parameter is properly added to the public method and correctly passed to the internal implementation.

Also applies to: 627-627


639-644: LGTM - Method signature update is consistent.

The method now accepts max_limit and correctly passes it through to the internal implementation, maintaining consistency with other similar methods.


671-671: LGTM - Internal method properly updated.

The internal get_completed_transactions_by_cancelled method correctly incorporates the max_limit parameter in both the signature and enum variant construction.

Also applies to: 674-674, 676-676


693-698: LGTM - Backend call properly updated.

The call to find_completed_transactions_filter_payment_id_block_hash correctly includes the new max_limit parameter, maintaining consistency across the trait implementation.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 20, 2025

Test Results (Integration tests)

 2 files  1 errors  1 suites   15m 45s ⏱️
 8 tests 7 ✅ 0 💤 1 ❌
10 runs  7 ✅ 0 💤 3 ❌

For more details on these parsing errors and failures, see this check.

Results for commit e03a7a8.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 20, 2025

Test Results (CI)

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

Results for commit 2ef6433.

♻️ This comment has been updated with latest results.

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 (1)
base_layer/wallet/tests/transaction_service_tests/storage.rs (1)

366-438: Consider adding test coverage for transaction limiting functionality.

While the current changes correctly update the API calls for existing functionality, consider adding specific test cases to verify the transaction limiting behavior introduced by this PR. Tests should verify:

  1. When max_limit is set to a specific number (e.g., 2), only that many transactions are returned
  2. When max_limit is 0, all transactions are returned (confirming unlimited behavior)
  3. When max_limit exceeds available transactions, all available transactions are returned

Example test addition:

+    // Test transaction limiting functionality
+    let limited_completed_txs = db.get_completed_transactions(None, None, None, 2).unwrap();
+    assert!(limited_completed_txs.len() <= 2, "Should respect max_limit parameter");
+    
+    let limited_cancelled_txs = db.get_cancelled_completed_transactions(1).unwrap();
+    assert!(limited_cancelled_txs.len() <= 1, "Should respect max_limit parameter");
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3f7b1e2 and e03a7a8.

📒 Files selected for processing (5)
  • base_layer/wallet/src/transaction_service/storage/sqlite_db.rs (11 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 (21 hunks)
✅ Files skipped from review due to trivial changes (1)
  • base_layer/wallet/tests/transaction_service_tests/transaction_protocols.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • base_layer/wallet_ffi/src/lib.rs
  • base_layer/wallet/src/transaction_service/storage/sqlite_db.rs
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: test (mainnet, stagenet)
  • GitHub Check: test (nextnet, nextnet)
  • GitHub Check: test (testnet, esmeralda)
  • GitHub Check: ci
  • GitHub Check: Cucumber tests / Base Layer
  • GitHub Check: cargo check with stable
  • GitHub Check: Cucumber tests / FFI
🔇 Additional comments (6)
base_layer/wallet/tests/transaction_service_tests/storage.rs (2)

366-366: LGTM: API signature updates are consistent.

The updates to get_completed_transactions method calls correctly include the new max_limit parameter with value 0, which appears to represent unlimited retrieval appropriate for comprehensive testing.

Also applies to: 424-424, 432-432


426-426: LGTM: Cancelled transaction method calls updated correctly.

The get_cancelled_completed_transactions method calls have been properly updated to include the max_limit parameter with value 0 for unlimited retrieval in tests.

Also applies to: 438-438

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

2286-2286: LGTM! Correctly updated method signature to include max_limit parameter.

The addition of the 0 parameter aligns with the new get_completed_transactions method signature that requires a max_limit: u64 argument. Using 0 as the limit is appropriate for tests where you want to retrieve all transactions without pagination.


2391-2391: LGTM! Consistent parameter updates across all transaction service calls.

All three calls to get_completed_transactions have been consistently updated with the new max_limit parameter set to 0. This ensures the test can retrieve all transactions to properly validate the expected counts (4 for Alice, 3 for Bob, 1 for Carol).

Also applies to: 2395-2395, 2400-2400


5581-5581: LGTM! Transaction broadcast test properly updated for new API.

Both calls in the transaction_service_tx_broadcast test function correctly include the new max_limit parameter. Using 0 allows the test to retrieve all completed transactions to verify transaction status and behavior during the broadcast process.

Also applies to: 5689-5689


6363-6363: LGTM! Ordering test correctly adapted for pagination parameter.

The test_completed_transactions_ordering test appropriately includes the new max_limit parameter. Using 0 ensures all 4 test transactions are retrieved to properly validate the timestamp-based ordering logic.

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.

Hi, looking good, some comments though.

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

♻️ Duplicate comments (3)
base_layer/wallet_ffi/src/lib.rs (3)

8752-8752: Parameter ordering remains inconsistent across FFI functions.

The max_search_limit parameter positioning is still inconsistent across functions:

  • Bulk retrieval functions: 2nd parameter (before error_out)
  • By-ID functions: 3rd parameter (after error_out)

This inconsistency makes the API harder to use and more error-prone.

Also applies to: 8818-8818, 8898-8898, 8970-8970, 9127-9127, 9208-9208


9127-9127: Remove unnecessary max_search_limit parameter from by-ID functions.

The max_search_limit parameter doesn't make sense for functions that retrieve a single transaction by ID, as these functions return at most one transaction.

Also applies to: 9208-9208


8750-8754: Breaking API change: parameter order modification not addressed.

Adding max_search_limit as the second parameter still breaks backward compatibility. Existing code calling wallet_get_completed_transactions(wallet, error_out) will fail.

Consider adding the new parameter at the end of the parameter list to maintain backward compatibility.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e03a7a8 and 2ef6433.

📒 Files selected for processing (1)
  • base_layer/wallet_ffi/src/lib.rs (20 hunks)
⏰ 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
🔇 Additional comments (1)
base_layer/wallet_ffi/src/lib.rs (1)

9084-9105: Verify the inverted logic in transaction status check.

The refactored function returns transactions that are NOT Completed or Broadcast status, which seems counterintuitive for a function named wallet_get_completed_transaction_by_id. This may not be equivalent to the previous implementation.

-            if completed_transaction.status != TransactionStatus::Completed &&
-                completed_transaction.status != TransactionStatus::Broadcast
+            if completed_transaction.status == TransactionStatus::Completed ||
+                completed_transaction.status == TransactionStatus::Broadcast

Please verify this logic aligns with the expected behavior and past implementation.

@SWvheerden SWvheerden merged commit 6c6f47f into tari-project:development Jun 20, 2025
15 checks passed
@SWvheerden SWvheerden deleted the sw_max_limits 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.

2 participants