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(stats): account abstraction wallets charts #1201

Merged
merged 9 commits into from
Jan 28, 2025

Conversation

bragov4ik
Copy link
Contributor

@bragov4ik bragov4ik commented Jan 21, 2025

lots of copypasting; I was quite careful but hopefully didn't miss smth 🙈
closes #1183

Summary by CodeRabbit

Release Notes

  • New Features

    • Added comprehensive tracking and analytics for Account Abstraction (ERC-4337) wallets.
    • Introduced new metrics including total wallets, new wallets, active wallets, and wallet growth.
  • Metrics Added

    • Total Account Abstraction Wallets counter.
    • New Account Abstraction Wallets chart.
    • Active Account Abstraction Wallets chart.
    • Account Abstraction Wallets Growth chart.
    • Monthly and yearly metrics for new and active wallets.
  • Scheduled Updates

    • New schedules for monitoring new and active account abstraction wallets.
  • Performance

    • Enhanced system monitoring capabilities for the blockchain wallet ecosystem.

Copy link
Contributor

coderabbitai bot commented Jan 21, 2025

Walkthrough

This pull request introduces comprehensive metrics for tracking Account Abstraction (AA) wallets in the Blockscout statistics system. The changes span multiple configuration and source files to implement four key metrics: new AA wallets, AA wallets growth, total AA wallets, and active AA wallets. The implementation involves creating new JSON configuration entries, updating runtime setup, adding chart source implementations, and extending test coverage. The modifications enable granular tracking of AA wallet metrics across daily, weekly, monthly, and yearly resolutions, providing a detailed view of account abstraction wallet adoption and activity.

Assessment against linked issues

Objective Addressed Explanation
New AA wallets per day
AA wallets growth
Total AA wallets
Active AA wallets

Possibly related PRs

Poem

🐰 Hopping through blockchain's maze,
Account Abstraction charts ablaze!
Wallets dancing, metrics bright,
Tracking growth with pure delight,
CodeRabbit's stats now shine so clear! 🚀


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@bragov4ik bragov4ik linked an issue Jan 21, 2025 that may be closed by this pull request
4 tasks
@bragov4ik bragov4ik force-pushed the bragov4ik/stats-aa-charts branch from 9cbe3b4 to 1e101e5 Compare January 22, 2025 13:18
Base automatically changed from bragov4ik/stats-active-guys-charts to main January 22, 2025 14:12
@bragov4ik bragov4ik force-pushed the bragov4ik/stats-aa-charts branch from 1e101e5 to 3fcea7c Compare January 22, 2025 14:14
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

🧹 Nitpick comments (5)
stats/stats/src/charts/lines/user_ops/new_aa_wallets.rs (1)

166-185: Consider adding documentation for type aliases

Adding documentation comments for the type aliases (e.g., NewAccountAbstractionWallets, NewAccountAbstractionWalletsWeekly, etc.) would enhance code readability and maintainability.

You can add Rust doc comments to explain the purpose and usage of each alias.

stats/stats/src/charts/lines/user_ops/active_aa_wallets.rs (1)

72-87: Consider enhancing test coverage.

While the test structure is good, consider:

  1. Adding more diverse test data (e.g., multiple wallets per day, days with no activity)
  2. Adding edge cases (e.g., invalid dates, null values)
 async fn update_active_account_abstraction_wallets() {
     simple_test_chart::<ActiveAccountAbstractionWallets>(
         "update_active_account_abstraction_wallets",
         vec![
             ("2022-11-09", "1"),
             ("2022-11-10", "1"),
             ("2022-11-11", "1"),
             ("2022-11-12", "1"),
             ("2022-12-01", "1"),
             ("2023-02-01", "1"),
+            // Multiple wallets per day
+            ("2023-03-01", "3"),
+            // Gap in activity
+            ("2023-03-15", "2"),
+            // Recent date
+            ("2024-01-01", "5"),
         ],
     )
     .await;
 }
stats/stats/src/charts/lines/user_ops/aa_wallets_growth.rs (1)

68-112: Consider enhancing test coverage.

While the tests cover all time resolutions, consider adding more test cases to verify:

  • Edge cases (e.g., date transitions)
  • Different growth patterns
  • Boundary conditions

Example test cases to add:

// Test date transition
vec![
    ("2022-12-31", "10"),
    ("2023-01-01", "15"),
],

// Test rapid growth
vec![
    ("2022-11-09", "1"),
    ("2022-11-10", "100"),
    ("2022-11-11", "1000"),
],

// Test zero growth
vec![
    ("2022-11-09", "10"),
    ("2022-11-10", "10"),
],
stats/config/charts.json (2)

72-75: Consider adding the "enabled" flag for consistency.

The counter definition looks good, but consider adding the "enabled" flag to match other counters (e.g., total_operational_txns, total_native_coin_holders).

 "total_account_abstraction_wallets": {
+    "enabled": true,
     "title": "Total AA wallets",
     "description": "Number of account abstraction wallets (ERC-4337) that sent at least 1 user operation"
 }

178-189: Consider adding the "enabled" flag to new chart definitions.

The line chart definitions are well-structured, but consider adding the "enabled" flag to maintain consistency with other charts (e.g., active_recurring_accounts_60_days).

 "new_account_abstraction_wallets": {
+    "enabled": true,
     "title": "New AA wallets",
     "description": "Number of newly added account abstraction wallets (ERC-4337)"
 },
 "account_abstraction_wallets_growth": {
+    "enabled": true,
     "title": "Number of AA wallets",
     "description": "Cumulative account abstraction wallets (ERC-4337) growth over time"
 },
 "active_account_abstraction_wallets": {
+    "enabled": true,
     "title": "Active AA wallets",
     "description": "Active account abstraction wallets (ERC-4337) number per period"
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c99d6a7 and 3fcea7c.

📒 Files selected for processing (14)
  • stats/config/charts.json (2 hunks)
  • stats/config/layout.json (2 hunks)
  • stats/config/update_groups.json (1 hunks)
  • stats/stats-server/src/runtime_setup.rs (2 hunks)
  • stats/stats-server/tests/it/chart_endpoints/counters.rs (1 hunks)
  • stats/stats-server/tests/it/chart_endpoints/lines.rs (1 hunks)
  • stats/stats/src/charts/counters/mod.rs (2 hunks)
  • stats/stats/src/charts/counters/total_aa_wallets.rs (1 hunks)
  • stats/stats/src/charts/lines/mod.rs (1 hunks)
  • stats/stats/src/charts/lines/user_ops/aa_wallets_growth.rs (1 hunks)
  • stats/stats/src/charts/lines/user_ops/active_aa_wallets.rs (1 hunks)
  • stats/stats/src/charts/lines/user_ops/mod.rs (1 hunks)
  • stats/stats/src/charts/lines/user_ops/new_aa_wallets.rs (1 hunks)
  • stats/stats/src/update_groups.rs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Unit, doc and integration tests
🔇 Additional comments (20)
stats/stats/src/charts/lines/user_ops/new_aa_wallets.rs (3)

43-102: Implementation of NewAccountAbstractionWalletsStatement looks good

The SQL statement is correctly constructed to retrieve new account abstraction wallets, ensuring accurate data collection and filtering based on the specified date range.


105-131: NewAccountAbstractionWalletsQueryBehaviour is properly implemented

The remote query behavior handles data retrieval efficiently, ensuring that results are sorted and trimmed according to the specified range.


187-231: Enhance test coverage and clarity

The test module includes tests for updating new account abstraction wallets across different resolutions. Ensure that these tests cover edge cases and validate the correctness of the data aggregation logic.

Do you want assistance in identifying additional test cases or improving test coverage?

stats/stats/src/charts/counters/total_aa_wallets.rs (2)

13-30: Properties struct and implementations look solid

The Properties struct correctly implements Named and ChartProperties, defining the chart characteristics such as resolution, chart type, and missing date policy.


32-34: Definition of TotalAccountAbstractionWallets is appropriate

The type alias appropriately sets up the chart source using the last point of the account abstraction wallets growth data.

stats/stats-server/tests/it/chart_endpoints/counters.rs (1)

29-29: totalAccountAbstractionWallets added to expected counters

The new counter totalAccountAbstractionWallets is properly included in the list of expected counters in the test, ensuring that the API returns the correct set of counters.

stats/stats/src/charts/counters/mod.rs (1)

8-8: LGTM! Module and export follow established patterns.

The new module total_aa_wallets and its export TotalAccountAbstractionWallets are well-integrated and follow the existing module structure and naming conventions.

Also applies to: 33-33

stats/stats/src/charts/lines/user_ops/mod.rs (2)

1-3: Great documentation! Clear explanation of the module's purpose.

The documentation comments effectively explain the context of user operations and their relation to ERC 4337 (Account Abstraction).


4-8: LGTM! Well-organized module structure.

The new AA wallet-related modules are logically organized alongside existing user operation modules.

stats/stats/src/charts/lines/user_ops/active_aa_wallets.rs (1)

27-36: LGTM! Clean implementation of statement generation.

The ActiveAccountAbstractionWalletsStatement implementation correctly uses the common counting function with appropriate filtering by sender.

stats/stats-server/tests/it/chart_endpoints/lines.rs (1)

61-63: LGTM! Comprehensive test coverage for new metrics.

The new line names are well-integrated into the test suite, ensuring API endpoint testing for all new AA wallet metrics.

stats/stats/src/charts/lines/user_ops/aa_wallets_growth.rs (3)

1-18: Well-organized imports!

The imports are logically grouped and follow Rust conventions. All necessary dependencies for chart functionality are properly included.


20-37: Properties implementation follows established patterns.

The implementation correctly:

  • Uses camelCase naming convention for chart name
  • Sets appropriate chart type as Line
  • Uses FillPrevious policy which is suitable for growth metrics

39-66: Type definitions are well-structured.

The implementation properly defines chart sources for different time resolutions with appropriate batch sizes and data aggregation strategies.

stats/stats/src/charts/lines/mod.rs (1)

22-25: Exports are well-organized.

The new AA wallet-related exports are properly grouped and follow the module's organization pattern.

Also applies to: 29-29, 33-36

stats/stats/src/update_groups.rs (1)

21-24: Update groups are properly structured.

The new AA wallet-related groups are correctly integrated:

  • ActiveAccountAbstractionWallets is added to singleton groups
  • NewAccountAbstractionWalletsGroup includes all necessary charts for tracking AA wallets

Also applies to: 167-179

stats/stats-server/src/runtime_setup.rs (1)

306-306: Runtime setup properly integrates new groups.

The AA wallet-related update groups are correctly added to the runtime setup in a logical order.

Also applies to: 342-342

stats/config/update_groups.json (1)

40-40: LGTM! Schedule configuration looks good.

The new schedules for AA wallet metrics are well-positioned and properly staggered with existing user operation related tasks.

Also applies to: 43-43

stats/config/layout.json (2)

17-17: LGTM! Counter placement is appropriate.

The total_account_abstraction_wallets counter is well-positioned after total_user_ops, maintaining logical grouping.


95-97: LGTM! Chart ordering follows best practices.

The new AA wallet charts follow a logical progression (new → growth → active) and are properly grouped with other user operation metrics.

@bragov4ik bragov4ik force-pushed the bragov4ik/stats-aa-charts branch from 3fcea7c to ad5e3fc Compare January 23, 2025 13:52
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

🧹 Nitpick comments (2)
stats/stats/src/charts/lines/user_ops/aa_wallets_growth.rs (1)

68-111: Comprehensive test coverage with proper database handling.

The test suite:

  • Covers all time resolutions
  • Properly marks database dependency with #[ignore]
  • Uses consistent test data structure

However, consider adding more test cases with different dates and values to ensure robust handling of edge cases.

stats/config/charts.json (1)

178-189: Well-structured line chart configurations.

The line charts for AA wallets:

  • Follow consistent naming patterns
  • Provide clear descriptions
  • Cover all necessary metrics (new, growth, active)

Consider adding units field for consistency with other charts that have measurable values.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3fcea7c and ad5e3fc.

📒 Files selected for processing (14)
  • stats/config/charts.json (2 hunks)
  • stats/config/layout.json (2 hunks)
  • stats/config/update_groups.json (1 hunks)
  • stats/stats-server/src/runtime_setup.rs (2 hunks)
  • stats/stats-server/tests/it/chart_endpoints/counters.rs (1 hunks)
  • stats/stats-server/tests/it/chart_endpoints/lines.rs (1 hunks)
  • stats/stats/src/charts/counters/mod.rs (2 hunks)
  • stats/stats/src/charts/counters/total_aa_wallets.rs (1 hunks)
  • stats/stats/src/charts/lines/mod.rs (1 hunks)
  • stats/stats/src/charts/lines/user_ops/aa_wallets_growth.rs (1 hunks)
  • stats/stats/src/charts/lines/user_ops/active_aa_wallets.rs (1 hunks)
  • stats/stats/src/charts/lines/user_ops/mod.rs (1 hunks)
  • stats/stats/src/charts/lines/user_ops/new_aa_wallets.rs (1 hunks)
  • stats/stats/src/update_groups.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (11)
  • stats/stats-server/tests/it/chart_endpoints/counters.rs
  • stats/stats/src/charts/counters/mod.rs
  • stats/stats-server/tests/it/chart_endpoints/lines.rs
  • stats/stats/src/update_groups.rs
  • stats/stats-server/src/runtime_setup.rs
  • stats/config/update_groups.json
  • stats/config/layout.json
  • stats/stats/src/charts/lines/mod.rs
  • stats/stats/src/charts/counters/total_aa_wallets.rs
  • stats/stats/src/charts/lines/user_ops/active_aa_wallets.rs
  • stats/stats/src/charts/lines/user_ops/new_aa_wallets.rs
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Linting / lint
  • GitHub Check: Unit, doc and integration tests
🔇 Additional comments (5)
stats/stats/src/charts/lines/user_ops/mod.rs (2)

1-2: Documentation clearly explains the module's purpose.

Good job on providing context about account abstraction and ERC 4337 in the documentation.


4-8: Well-organized module structure for AA wallet metrics.

The module organization logically separates different aspects of AA wallet tracking:

  • Growth metrics
  • Active wallets tracking
  • New wallets monitoring
stats/stats/src/charts/lines/user_ops/aa_wallets_growth.rs (2)

20-37: LGTM! Properties implementation follows best practices.

The implementation:

  • Uses descriptive naming for the chart
  • Correctly specifies line chart type
  • Appropriately handles missing dates with FillPrevious policy

48-66: Well-structured type aliases for different time resolutions.

Good job on:

  • Using appropriate source types for different resolutions
  • Implementing proper batching parameters
  • Maintaining consistency across weekly, monthly, and yearly resolutions
stats/config/charts.json (1)

72-75: LGTM! Clear and consistent counter configuration.

The total AA wallets counter is well-defined with:

  • Clear title using consistent abbreviation (AA)
  • Descriptive explanation referencing ERC-4337

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

🧹 Nitpick comments (2)
stats/stats/src/charts/counters/pending_txns.rs (1)

Line range hint 1-102: Consider architectural implications for AA wallet metrics.

Given that this PR introduces new AA wallet metrics and the author mentioned code duplication concerns, consider extracting common patterns from this counter implementation that could be reused for the new AA wallet counters.

The current implementation of PendingTxns30m demonstrates good practices that could be applied to AA wallet metrics:

  1. Clear separation of database query logic (PendingTxnsStatement)
  2. Flexible time range handling
  3. Strong typing with proper error handling
  4. Configurable properties through traits

Consider creating shared abstractions to reduce the mentioned code duplication in the AA wallet implementations.

stats/stats/src/charts/lines/user_ops/new_aa_wallets.rs (1)

173-211: Consider enhancing test coverage.

While the tests cover all time resolutions, consider adding:

  1. Multiple data points per test to verify aggregation
  2. Edge cases (e.g., empty ranges, boundary dates)

Example enhancement for the daily test:

 simple_test_chart::<NewAccountAbstractionWallets>(
     "update_new_account_abstraction_wallets",
-    vec![("2022-11-09", "1")],
+    vec![
+        ("2022-11-09", "1"),
+        ("2022-11-10", "2"),
+        ("2022-11-11", "0"),  // Edge case: day with no new wallets
+    ],
 )
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ad5e3fc and ae3fb20.

📒 Files selected for processing (4)
  • stats/stats/src/charts/counters/pending_txns.rs (1 hunks)
  • stats/stats/src/charts/counters/total_txns.rs (1 hunks)
  • stats/stats/src/charts/lines/accounts/new_accounts.rs (1 hunks)
  • stats/stats/src/charts/lines/user_ops/new_aa_wallets.rs (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • stats/stats/src/charts/lines/accounts/new_accounts.rs
  • stats/stats/src/charts/counters/total_txns.rs
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Unit, doc and integration tests
🔇 Additional comments (7)
stats/stats/src/charts/counters/pending_txns.rs (2)

101-101: LGTM! Test parameters preserved.

The test parameters remain unchanged, maintaining the same test coverage for the basic functionality.


96-96: Verify the test helper function change.

The change from simple_test_counter_with_migration_variants to simple_test_counter might affect test coverage of migration scenarios.

Let's verify the test helper function changes:

✅ Verification successful

The test helper change is appropriate and safe.

The codebase maintains robust migration testing coverage through various specialized helpers. The simpler simple_test_counter is sufficient for pending transaction tests, while migration-specific testing is preserved where needed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if migration-related test coverage is maintained elsewhere

# Search for any remaining usage of the old test helper
rg "simple_test_counter_with_migration_variants" -A 5

# Search for alternative migration testing
rg "migration.*test" --type rust

Length of output: 7042

stats/stats/src/charts/lines/user_ops/new_aa_wallets.rs (5)

1-35: LGTM! Well-organized imports and clear documentation.

The file structure is clean with logically grouped imports and clear documentation explaining its purpose.


43-48: LGTM! Smart approach to range filtering.

The implementation correctly uses min_timestamp to consider all transactions from the beginning, ensuring accurate identification of new wallets by checking their first activity.


73-101: LGTM! Robust query behavior implementation.

The implementation properly handles:

  • Data querying with error handling
  • Sorting of results
  • Range trimming

111-155: LGTM! Well-structured type definitions following established patterns.

The implementation maintains consistency with the NewAccounts pattern, providing clear type definitions for different time resolutions.


50-70: Consider adding an index for better query performance.

The query uses DISTINCT ON with ordering by sender and timestamp. Adding a composite index on (sender, timestamp) could improve query performance.

Let's check if the index already exists:

@bragov4ik bragov4ik merged commit ad1927c into main Jan 28, 2025
7 checks passed
@bragov4ik bragov4ik deleted the bragov4ik/stats-aa-charts branch January 28, 2025 12: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.

stats: account abstraction charts
2 participants