-
Notifications
You must be signed in to change notification settings - Fork 0
Update payment tracker to not update any capacities if they are zero. #106
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -154,7 +154,20 @@ pub async fn usage_processor( | |
| .as_u64(), | ||
| global_max_capacity: config.global_max_capacity.as_u64(), | ||
| }; | ||
| payment_tracker_for_capacity.update_node_capacity_config(node_capacity_config); | ||
| if node_capacity_config.global_max_capacity > 0 | ||
| && node_capacity_config.pkp_sign_max_concurrency > 0 | ||
| && node_capacity_config.enc_sign_max_concurrency > 0 | ||
| && node_capacity_config.lit_action_max_concurrency > 0 | ||
| && node_capacity_config.sign_session_key_max_concurrency > 0 | ||
| { | ||
| payment_tracker_for_capacity | ||
| .update_node_capacity_config(node_capacity_config); | ||
| } else { | ||
| warn!( | ||
| "Invalid node capacity config ( will not update payment tracker ): {:?}", | ||
| node_capacity_config | ||
| ); | ||
| } | ||
|
Comment on lines
+157
to
+170
|
||
| } | ||
| Err(e) => { | ||
| error!("Failed to get node capacity config: {:?}", e); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation prevents updating the payment tracker with zero values, which is good for preventing the immediate update. However, this creates a critical problem: if the payment tracker was initialized with default values (all zeros) and this validation prevents the first valid update from being applied, the payment tracker will remain in an invalid state with zeros. This will cause division by zero panics when:
get_op_capacity()dividesglobal_max_capacityby any of the concurrency values (lines 29-36 in payment_tracker.rs)get_usage_percentage()divides byglobal_max_capacity(line 74 in payment_tracker.rs)These methods are called during normal operation when registering/deregistering usage. Consider either:
NodeCapacityConfig::new()instead ofDefault::default(), or