Skip to content

Automatically deregister payment tracking, even if there's an exception or unexpected error#37

Draft
glitch003 wants to merge 10 commits intomasterfrom
feature/NODE-4864-deregister-payment-tracker-on-exception
Draft

Automatically deregister payment tracking, even if there's an exception or unexpected error#37
glitch003 wants to merge 10 commits intomasterfrom
feature/NODE-4864-deregister-payment-tracker-on-exception

Conversation

@glitch003
Copy link
Copy Markdown
Contributor

Use the RAII pattern to automatically deregister payment usage when the request goes out of scope and it's variables are dropped

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 10, 2025

PASS [ 43.246s] (3/3) lit_node::test toxiproxy::perf_tests::load_with_no_latency
PASS [ 43.398s] (2/3) lit_node::test toxiproxy::perf_tests::load_with_50ms_latency_single_link
PASS [ 84.083s] (1/3) lit_node::test toxiproxy::perf_tests::load_with_50ms_latency_all_links

Copy link
Copy Markdown
Contributor

@hwrdtm hwrdtm left a comment

Choose a reason for hiding this comment

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

lgtm, and agree with @GTC6244 about using rocket fairings alternatively

Copy link
Copy Markdown
Contributor

@DashKash54 DashKash54 left a comment

Choose a reason for hiding this comment

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

Left a comment regarding the test

async fn test_payment_tracker_usage_tracking() {
// This test verifies that:
// 1. Pricing increases with concurrency (usage percentage)
// 2. After requests complete, usage tracking correctly returns to 0%
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 should also be verifying that the usage decreases regardless of the error status of the requests i.e. even if the request throws an exception?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sure, but how do i throw an exception? we patch all the exceptions as we find them, haha.

resource_ability_requests.clone(),
Some(self_pay_user.wallet.clone()),
None,
Some(initial_price),
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.

Since the nodes are receiving multiple requests concurrently the max_price should be increased to account for the price increase otherwise the requests will fail?

Comment on lines +1442 to +1445
// Give some time for all guards to drop and deregister
tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;

// Check that price has returned to initial (or close to it)
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.

This is a pretty simple test so we should rather assert for absolute zero instead of tolerance by just waiting longer say 10 sec?

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.

4 participants