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: improve grpc get_balance response #6755

Merged

Conversation

hansieodendaal
Copy link
Contributor

@hansieodendaal hansieodendaal commented Jan 22, 2025

Description

  • Improved the wallet grpc method get_balance response by implementing an event-driven balance cache update. All events that could change the balance are monitored and consecutive calls to the wallet backend are only made when the balance changed.
  • Cleaned up unused events (events that were monitored somewhere but never set) in pub enum TransactionEvent.
  • Added a missing shutdown signal to grpc method async fn stream_transaction_events in the wallet grpc server.

Closes #6754

Motivation and Context

When calling the wallet grpc method get_balance repeatedly and quickly in succession on wallets with many outputs, resources are wasted in the wallet when nothing changes, and the client experiences unnecessary long response times.

How Has This Been Tested?

System-level testing on a large wallet with an external grpc client. See logs with response times below.

[wallet::ui::grpc::get_balance_debounced] TRACE start_event_monitor
[wallet::ui::grpc::get_balance_debounced] TRACE is_refresh_needed 'true'
[wallet::ui::grpc::get_balance_debounced] TRACE set_refresh_needed 'false'
[wallet::ui::grpc] TRACE 'get_balance' completed in 172.28ms
[wallet::ui::grpc::get_balance_debounced] TRACE is_refresh_needed 'false'
[wallet::ui::grpc] TRACE 'get_balance' completed in 29.40µs
[wallet::ui::grpc::get_balance_debounced] TRACE is_refresh_needed 'false'
[wallet::ui::grpc] TRACE 'get_balance' completed in 36.00µs
[wallet::ui::grpc::get_balance_debounced] TRACE is_refresh_needed 'false'
[wallet::ui::grpc] TRACE 'get_balance' completed in 26.40µs
[wallet::ui::grpc::get_balance_debounced] TRACE set_refresh_needed 'true'
[wallet::ui::grpc::get_balance_debounced] TRACE is_refresh_needed 'true'
[wallet::ui::grpc::get_balance_debounced] TRACE set_refresh_needed 'false'
[wallet::ui::grpc] TRACE 'get_balance' completed in 145.39ms
[wallet::ui::grpc::get_balance_debounced] TRACE is_refresh_needed 'false'
[wallet::ui::grpc] TRACE 'get_balance' completed in 22.00µs
[wallet::ui::grpc::get_balance_debounced] TRACE is_refresh_needed 'false'
[wallet::ui::grpc] TRACE 'get_balance' completed in 33.70µs
[wallet::ui::grpc::get_balance_debounced] TRACE is_refresh_needed 'false'
[wallet::ui::grpc] TRACE 'get_balance' completed in 25.40µs
[wallet::ui::grpc::get_balance_debounced] TRACE set_refresh_needed 'true'
[wallet::ui::grpc::get_balance_debounced] TRACE is_refresh_needed 'true'
[wallet::ui::grpc::get_balance_debounced] TRACE set_refresh_needed 'false'
[wallet::ui::grpc] TRACE 'get_balance' completed in 156.75ms
[wallet::ui::grpc::get_balance_debounced] TRACE is_refresh_needed 'false'
[wallet::ui::grpc] TRACE 'get_balance' completed in 35.70µs
[wallet::ui::grpc::get_balance_debounced] TRACE is_refresh_needed 'false'
[wallet::ui::grpc] TRACE 'get_balance' completed in 23.40µs

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

System-level testing with an external grpc client.

Breaking Changes

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

- Improved grpc `get_balance` response by implementing an event driven balance cache update.
- Cleaned up unused events (events that were monotored somewhere but never set) in
  `pub enum TransactionEvent`.
- Added a missing shutdown signal to grpc method `async fn stream_transaction_events` in
  the wallet grpc server.
Copy link

Test Results (CI)

    3 files    129 suites   36m 40s ⏱️
1 350 tests 1 350 ✅ 0 💤 0 ❌
4 048 runs  4 048 ✅ 0 💤 0 ❌

Results for commit 97cad31.

Copy link

Test Results (Integration tests)

 2 files  + 2  11 suites  +11   38m 49s ⏱️ + 38m 49s
36 tests +36  35 ✅ +35  0 💤 ±0  1 ❌ +1 
38 runs  +38  36 ✅ +36  0 💤 ±0  2 ❌ +2 

For more details on these failures, see this check.

Results for commit 97cad31. ± Comparison against base commit f0cf697.

Copy link
Collaborator

@SWvheerden SWvheerden left a comment

Choose a reason for hiding this comment

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

just one question

@SWvheerden SWvheerden merged commit 9de0906 into tari-project:development Jan 23, 2025
15 checks passed
@hansieodendaal hansieodendaal deleted the ho_grpc_get_balance branch January 24, 2025 07:33
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.

wallet grpc call get balance very slow
2 participants