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

chore(drive): logs and metrics for withdrawal daily limit #2192

Merged
merged 4 commits into from
Oct 2, 2024

Conversation

shumkov
Copy link
Member

@shumkov shumkov commented Oct 1, 2024

Issue being fixed or feature implemented

To test withdrawal limits we need some additional visibility on the withdrawal logic

What was done?

  • Added logging of withdrawal limit in action
  • Added Prometheus metrics for withdrawal total and available limit

How Has This Been Tested?

None

Breaking Changes

None

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features

    • Introduced a new WithdrawalLimitInfo struct to provide detailed withdrawal limit information.
    • Enhanced withdrawal limit calculations to return comprehensive data, including daily maximums and amounts withdrawn.
    • Added new metrics for tracking credit withdrawal limits.
  • Bug Fixes

    • Improved clarity in withdrawal transaction handling and logging messages.
  • Documentation

    • Updated comments and method documentation for better understanding of withdrawal processing and limits.

Copy link
Contributor

coderabbitai bot commented Oct 1, 2024

Walkthrough

The changes in this pull request enhance the functionality and clarity of withdrawal transaction handling within the codebase. Key updates include the introduction of a new struct for withdrawal limit information, the enhancement of withdrawal processing methods to incorporate metrics, and adjustments to existing method signatures to reflect these changes. Overall, the modifications provide more detailed insights into withdrawal limits while refining the control flow for processing withdrawal transactions.

Changes

File Path Change Summary
packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v1/mod.rs Enhanced logic in pool_withdrawals_into_transactions_queue_v1 to manage withdrawal limits and integrate Prometheus metrics for tracking available and total limits. Updated comments for clarity on document processing.
packages/rs-drive/src/drive/identity/withdrawals/calculate_current_withdrawal_limit/mod.rs Introduced WithdrawalLimitInfo struct to encapsulate daily withdrawal limits. Modified calculate_current_withdrawal_limit method to return WithdrawalLimitInfo instead of just credits, enhancing the information provided.

Possibly related PRs

🐰 In the meadow where bunnies play,
New limits and metrics brighten the day.
With withdrawals now clear and bright,
Transactions flow with pure delight!
Hooray for the changes, let’s hop and cheer,
For a smoother journey, year after year! 🌼✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 920dc2b and 604578e.

📒 Files selected for processing (1)
  • packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v1/mod.rs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v1/mod.rs

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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
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 and nitpick comments (9)
packages/rs-drive/src/drive/identity/withdrawals/transaction/queue/dequeue_untied_withdrawal_transactions/mod.rs (1)

12-13: Documentation update looks good, but consider adding more details.

The updated documentation clearly describes the purpose of the method. However, to improve clarity and align with the PR objectives, consider adding information about logging and metrics.

Consider expanding the documentation to include:

  1. Mention of any logging that occurs during the dequeuing process.
  2. Information about metrics that are updated, if any.
  3. The significance of the limit parameter in relation to withdrawal limits.

Example:

/// Dequeue specified amount of untied withdrawal transactions
/// and move them to broadcasted queue.
/// This operation logs the withdrawal limit in action and updates
/// Prometheus metrics for total withdrawal amount and available limit.
/// The `limit` parameter controls the maximum number of transactions to dequeue.
packages/rs-drive/src/drive/identity/withdrawals/calculate_current_withdrawal_limit/v0/mod.rs (2)

45-45: Approve signature change, but update function documentation.

The change in return type from Result<Credits, Error> to Result<WithdrawalLimitInfo, Error> enhances the function's output by providing more detailed information about the withdrawal limit. This aligns well with the PR objective of improving visibility into the withdrawal logic.

However, the function's documentation (comments above the function) needs to be updated to reflect this change in the return type and explain the new WithdrawalLimitInfo structure.

Could you please update the function's documentation to accurately describe the new return type and its contents?


84-87: Approve return statement change, suggest minor improvement for consistency.

The new return statement using WithdrawalLimitInfo provides more comprehensive information about the withdrawal limit, including both the daily maximum and the amount already withdrawn. This change aligns well with the PR objective of adding metrics for withdrawal limits.

For improved consistency and clarity, consider updating the field name in the return statement:

 Ok(WithdrawalLimitInfo {
     daily_maximum,
-    withdrawals_amount: withdrawal_amount_in_last_day,
+    withdrawal_amount_in_last_day,
 })

This change makes the field name consistent with the variable name used in the function body, enhancing readability and maintaining a clear connection between the calculated value and the returned field.

packages/rs-drive-abci/src/metrics.rs (2)

32-35: LGTM: New gauge metric constants added correctly.

The addition of GAUGE_CREDIT_WITHDRAWAL_LIMIT_AVAILABLE and GAUGE_CREDIT_WITHDRAWAL_LIMIT_TOTAL is consistent with the PR objectives. The naming and visibility are appropriate.

Consider adding "in credits" to the end of both comments for consistency with the constant names:

- /// Withdrawal daily limit available credits
+ /// Withdrawal daily limit available in credits
- /// Total withdrawal daily limit in credits
+ /// Total withdrawal daily limit available in credits

217-227: LGTM: New gauge metrics correctly registered.

The new gauge metrics for credit withdrawal limits are properly registered using the describe_gauge! macro. The implementation is consistent with other metrics in the function.

For consistency with other metric descriptions in this function, consider adding the unit of measurement to the descriptions:

 describe_gauge!(
     GAUGE_CREDIT_WITHDRAWAL_LIMIT_AVAILABLE,
-    "Available withdrawal limit for last 24 hours in credits"
+    metrics::Unit::Count,
+    "Available withdrawal limit for last 24 hours in credits"
 );

 describe_gauge!(
     GAUGE_CREDIT_WITHDRAWAL_LIMIT_TOTAL,
-    "Total withdrawal limit for last 24 hours in credits"
+    metrics::Unit::Count,
+    "Total withdrawal limit for last 24 hours in credits"
 );
packages/rs-drive/src/drive/identity/withdrawals/calculate_current_withdrawal_limit/mod.rs (2)

18-23: Consider adding unit tests for available method.

Adding unit tests for the available method in WithdrawalLimitInfo would ensure it correctly calculates the available credits under various scenarios, such as when the withdrawals_amount exceeds the daily_maximum.


Line range hint 24-51: Update method documentation to reflect the new return type.

The documentation for calculate_current_withdrawal_limit still references Ok(Credits) as the return type. Please update it to reflect the new return type Ok(WithdrawalLimitInfo) and adjust the description accordingly.

Apply this diff to correct the documentation:

 /// # Returns
 ///
-/// * `Ok(Credits)`: The calculated current withdrawal limit, representing the maximum amount that can still be withdrawn in the current 24-hour window.
+/// * `Ok(WithdrawalLimitInfo)`: The calculated withdrawal limit information, including the daily maximum and the amount already withdrawn.
 /// * `Err(Error)`: Returns an error if the version specified in `platform_version` is not supported or if there is an issue in the version-specific calculation.
packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v1/mod.rs (1)

84-87: Improve clarity of warning message.

Consider rephrasing the warning message to enhance clarity and readability.

You might consider changing it to:

 tracing::warn!(
-    "Pooling is limited due to daily withdrawals limit. {} credits left",
+    "Pooling is limited due to the daily withdrawal limit. {} credits remaining",
     current_withdrawal_limit
 );
packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs (1)

340-340: Add the missing article in the comment

The comment on line 340 is missing an article and should read "to update the daily withdrawal limit."

Suggested fix:

-// to update daily withdrawal limit
+// to update the daily withdrawal limit
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 023ff85 and e4c9826.

📒 Files selected for processing (7)
  • packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs (3 hunks)
  • packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v0/mod.rs (1 hunks)
  • packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v1/mod.rs (5 hunks)
  • packages/rs-drive-abci/src/metrics.rs (3 hunks)
  • packages/rs-drive/src/drive/identity/withdrawals/calculate_current_withdrawal_limit/mod.rs (2 hunks)
  • packages/rs-drive/src/drive/identity/withdrawals/calculate_current_withdrawal_limit/v0/mod.rs (3 hunks)
  • packages/rs-drive/src/drive/identity/withdrawals/transaction/queue/dequeue_untied_withdrawal_transactions/mod.rs (1 hunks)
🧰 Additional context used
📓 Learnings (2)
packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v0/mod.rs (1)
Learnt from: QuantumExplorer
PR: dashpay/platform#2182
File: packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v0/mod.rs:71-73
Timestamp: 2024-09-28T22:25:00.684Z
Learning: When retrieving the `AMOUNT` property in withdrawal documents, it is guaranteed to be present and valid, so additional error handling when calling `get_integer` is not necessary.
packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v1/mod.rs (1)
Learnt from: QuantumExplorer
PR: dashpay/platform#2182
File: packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v0/mod.rs:71-73
Timestamp: 2024-09-28T22:25:00.684Z
Learning: When retrieving the `AMOUNT` property in withdrawal documents, it is guaranteed to be present and valid, so additional error handling when calling `get_integer` is not necessary.
🔇 Additional comments (12)
packages/rs-drive/src/drive/identity/withdrawals/calculate_current_withdrawal_limit/v0/mod.rs (3)

2-2: LGTM: New import aligns with the function's updated return type.

The addition of the WithdrawalLimitInfo import is consistent with the changes made to the function's return type. This import ensures that the new structure is available for use within the module.


Line range hint 1-87: Verify implementation of logging for withdrawal limits.

The changes successfully enhance the metrics for withdrawal limits by introducing the WithdrawalLimitInfo structure, which aligns with one of the PR objectives. However, the PR summary also mentions adding logging for the withdrawal limit, which is not evident in this function.

Could you please confirm if logging for withdrawal limits has been implemented elsewhere? If not, consider adding appropriate logging statements to this function to fully meet the PR objectives. For example:

log::info!("Withdrawal limit calculated: daily_maximum={}, withdrawal_amount_in_last_day={}", daily_maximum, withdrawal_amount_in_last_day);

This logging statement could be added just before the return statement to provide visibility into the calculated withdrawal limits.


Line range hint 1-87: Summary of review for calculate_current_withdrawal_limit_v0

The changes in this file enhance the withdrawal limit calculation by introducing the WithdrawalLimitInfo structure, which provides more detailed metrics about withdrawal limits. This aligns well with the PR objectives of improving visibility into the withdrawal logic.

Key points:

  1. The function signature and return type have been updated appropriately.
  2. The new return statement provides more comprehensive information about withdrawal limits.
  3. The changes partially fulfill the PR objectives by enhancing metrics for withdrawal limits.

Suggestions for improvement:

  1. Update the function's documentation to reflect the new return type and explain the WithdrawalLimitInfo structure.
  2. Consider adding logging statements to fully meet the PR objectives of adding logging for withdrawal limits.
  3. Make the field name in the return statement consistent with the variable name used in the function body for improved clarity.

Overall, the changes are well-implemented and contribute positively to the codebase's functionality and clarity.

packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v0/mod.rs (4)

22-23: Improved comment clarity on quorum selection.

The updated comment provides valuable insight into why the first quorum is used. This explanation enhances code maintainability by clearly stating the relationship between the platform and Core, which is crucial for understanding this implementation.


27-28: Improved consistency in warning message.

The updated warning message now uses "do not pool withdrawals" instead of "not making withdrawals". This change:

  1. Aligns better with the method's name and purpose.
  2. Provides more precise information about the action being skipped.
  3. Maintains consistency in terminology throughout the code.

Good job on improving clarity without altering functionality.


33-36: Consistent terminology in debug message.

The debug message has been updated to maintain consistency with the earlier warning message:

  1. "do not pool withdrawals" is now used instead of "not making withdrawals".
  2. This change reinforces the precise nature of the skipped action.
  3. The slight formatting adjustment (moving the position to a new line) enhances readability.

These modifications contribute to a more cohesive and clear codebase.


22-36: Overall improvement in code clarity and consistency.

The changes in this file focus on enhancing the clarity of comments and log messages related to the withdrawal pooling process. Key points:

  1. Improved explanation of quorum selection logic, providing crucial context for future maintenance.
  2. Consistent use of terminology across warning and debug messages ("do not pool withdrawals").
  3. No functional changes to the code logic, maintaining the original behavior.

These updates align well with the PR objectives of enhancing visibility for withdrawal logic. While no new logging or metrics have been added in this specific file, the improved messages contribute to a better understanding of the withdrawal process.

The changes are approved as they improve code maintainability without introducing any security issues or performance impacts.

packages/rs-drive-abci/src/metrics.rs (2)

9-9: LGTM: Import statement updated correctly.

The addition of describe_gauge to the import statement is appropriate and necessary for the new gauge metrics being introduced in this file.


Line range hint 1-338: Overall changes align well with PR objectives.

The additions to this file successfully implement new gauge metrics for credit withdrawal limits, which aligns with the PR's goal of enhancing visibility into the withdrawal logic. The changes are well-integrated into the existing metrics system and maintain consistency with the file's structure and coding style.

To ensure that these new metrics are being utilized correctly, it would be beneficial to verify their usage in the withdrawal logic implementation. Could you provide the relevant code where these metrics are updated?

✅ Verification successful

Metrics Integration Verified

The new gauge metrics for credit withdrawal limits are properly defined and utilized within the withdrawal logic implementation. The integration aligns with the PR's objectives of enhancing visibility into the withdrawal logic without altering existing functionalities.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of the new gauge metrics in the codebase
rg "GAUGE_CREDIT_WITHDRAWAL_LIMIT_(AVAILABLE|TOTAL)" --type rust

Length of output: 1130

packages/rs-drive/src/drive/identity/withdrawals/calculate_current_withdrawal_limit/mod.rs (1)

52-52: ⚠️ Potential issue

Potential breaking change: Method return type modified.

The return type of calculate_current_withdrawal_limit has changed from Result<Credits, Error> to Result<WithdrawalLimitInfo, Error>. This alteration may impact existing code that relies on this method. Ensure that all callers are updated to handle the new return type.

Run the following script to locate all usages of calculate_current_withdrawal_limit:

✅ Verification successful

Return type modification verified successfully.

All call sites have been updated to handle the new WithdrawalLimitInfo return type appropriately, ensuring no existing code is impacted.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all call sites of `calculate_current_withdrawal_limit` and display their context.

rg --type rust -A 3 -B 3 'calculate_current_withdrawal_limit\('

Length of output: 2194


Script:

#!/bin/bash
# Description: Retrieve the lines following each call to `calculate_current_withdrawal_limit` to inspect handling of the new return type.

rg --type rust 'calculate_current_withdrawal_limit\(' -A 5

Length of output: 1807

packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs (2)

356-356: Verify that BlockExecutionContextV0 includes epoch_info field

The epoch_info field is added to the initialization of BlockExecutionContextV0. Please ensure that the BlockExecutionContextV0 struct has been updated to include the epoch_info field.

To automate this verification, you can run:

#!/bin/bash
# Description: Check if `BlockExecutionContextV0` struct includes `epoch_info` field.

# Use `ast-grep` to find the struct definition with `epoch_info`
ast-grep --lang rust --pattern '
struct BlockExecutionContextV0 {
    $_block_state_info,
    epoch_info: $_,
    $$$
}
'

334-334: Verify function signature matches updated parameters

The function pool_withdrawals_into_transactions_queue is now called with an additional parameter last_committed_platform_state. Please ensure that the function's definition has been updated to accept this new parameter.

To automate this verification, you can run:

✅ Verification successful

Function signature verified

The pool_withdrawals_into_transactions_queue function in packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/mod.rs includes the updated parameter last_committed_platform_state: &PlatformState.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if `pool_withdrawals_into_transactions_queue` accepts `last_committed_platform_state` as a parameter.

# Use `ast-grep` to find the function definition including `last_committed_platform_state`
ast-grep --lang rust --pattern '
    fn pool_withdrawals_into_transactions_queue(
        &self,
        $_block_info,
        last_committed_platform_state: $_,
        $_transaction,
        $_platform_version
    ) $_body
'

Length of output: 291


Script:

#!/bin/bash
# Description: Check if `pool_withdrawals_into_transactions_queue` accepts `last_committed_platform_state` as a parameter.

# Use `ast-grep` to find the function definition including `last_committed_platform_state`
ast-grep --lang rust --pattern 'fn pool_withdrawals_into_transactions_queue(&self, $_block_info, last_committed_platform_state: $_, $_transaction, $_platform_version) $_body'

Length of output: 521


Script:

#!/bin/bash
# Description: Verify if `pool_withdrawals_into_transactions_queue` includes `last_committed_platform_state` as a parameter with a flexible pattern.

# Use `ast-grep` with a less restrictive pattern to match the function definition
ast-grep --lang rust --pattern 'fn pool_withdrawals_into_transactions_queue(&self, $$$, last_committed_platform_state: $_, $$$) $_'

Length of output: 478


Script:

#!/bin/bash
# Description: Search for the `pool_withdrawals_into_transactions_queue` function and verify the presence of `last_committed_platform_state` parameter.

# Use `rg` to find the function definition
rg 'fn\s+pool_withdrawals_into_transactions_queue\s*\(' --glob '*.rs' -A 5

Length of output: 1011

Copy link
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

🧹 Outside diff range and nitpick comments (2)
packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v1/mod.rs (2)

53-61: LGTM: Withdrawal limit calculation and metrics.

The added code for calculating the current withdrawal limit and storing metrics using Prometheus gauges aligns well with the PR objectives. This will enhance the visibility of the withdrawal logic as intended.

Consider adding a debug log statement to output the calculated withdrawal limit for easier troubleshooting:

tracing::debug!("Current withdrawal limit calculated: {}", current_withdrawal_limit);

82-87: LGTM: Enhanced withdrawal processing logic.

The modifications to stop processing when the total withdrawal amount exceeds the current limit and the addition of a debug log are good improvements. These changes align well with the PR objectives of enhancing the withdrawal logic.

Consider using string interpolation for better readability in the debug log:

tracing::debug!(
    "Pooling is limited due to daily withdrawals limit. {current_withdrawal_limit} credits left"
);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e4c9826 and 920dc2b.

📒 Files selected for processing (2)
  • packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v1/mod.rs (5 hunks)
  • packages/rs-drive/src/drive/identity/withdrawals/calculate_current_withdrawal_limit/mod.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/rs-drive/src/drive/identity/withdrawals/calculate_current_withdrawal_limit/mod.rs
🧰 Additional context used
📓 Learnings (1)
packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v1/mod.rs (1)
Learnt from: QuantumExplorer
PR: dashpay/platform#2182
File: packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v0/mod.rs:71-73
Timestamp: 2024-09-28T22:25:00.684Z
Learning: When retrieving the `AMOUNT` property in withdrawal documents, it is guaranteed to be present and valid, so additional error handling when calling `get_integer` is not necessary.
🔇 Additional comments (3)
packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v1/mod.rs (3)

2-2: LGTM: New imports for metrics.

The added imports for metrics are appropriate for the new functionality being introduced in this file.

Also applies to: 13-15


35-38: Acknowledged: TODO for future optimization.

The TODO comment suggests a potential optimization for querying documents. As discussed in a previous review, an issue has been created to track this improvement (Issue #2197). This ensures the optimization will be addressed in a future PR.


Line range hint 26-180: Overall assessment: Good implementation of withdrawal limit logging and metrics.

The changes in this PR successfully implement logging and metrics for withdrawal limits, aligning well with the stated objectives. Key improvements include:

  1. Addition of Prometheus metrics for available and total withdrawal limits.
  2. Enhanced logic to stop processing when the total withdrawal amount exceeds the current limit.
  3. Debug logging to indicate when pooling is limited due to the daily withdrawal limit.

These changes will significantly improve the visibility of the withdrawal process and facilitate testing of withdrawal limits. The implementation is correct and doesn't introduce breaking changes.

One suggestion for future improvement:

  • Consider implementing the optimization mentioned in the TODO comment (querying documents less than the current limit) in a future PR to further enhance efficiency.

@shumkov shumkov merged commit 5eacc13 into v1.4-dev Oct 2, 2024
36 checks passed
@shumkov shumkov deleted the feat/drive/withdrawal-limit-logs branch October 2, 2024 10:12
@thephez thephez added this to the v1.4.0 milestone Oct 30, 2024
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.

3 participants