Skip to content

feat(multi): domains integration#1318

Merged
lok52 merged 5 commits into
mainfrom
lok52/multi-domains-integration
Apr 14, 2025
Merged

feat(multi): domains integration#1318
lok52 merged 5 commits into
mainfrom
lok52/multi-domains-integration

Conversation

@lok52

@lok52 lok52 commented Apr 9, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added support for domain lookups—users can now query domains and receive associated details such as name and expiry date.
    • Introduced a new API endpoint to list domain information, enhancing multi-chain search capabilities.
    • Enhanced search functionality to handle domain queries and improve address retrieval processes.
  • Refactor

    • Streamlined search and filtering processes to better integrate domain data into overall address queries for an improved user experience.

@lok52 lok52 added the feat New feature label Apr 9, 2025
@coderabbitai

coderabbitai Bot commented Apr 9, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This update applies a series of changes across multiple repositories and modules. In several Cargo.toml files, dependency declarations are refined by adding explicit version tags and integrating new dependencies like bens-proto and prost-wkt variants. The project's API client structure is expanded with a new bens client and associated modules to handle domain lookup and address retrieval. In the aggregator logic, updates replace the former ens_name with a new domain_info field and introduce a DomainInfo struct, thereby modifying data conversion and error handling. The search services now include a new configuration enum and functions to support domain-related queries, with corresponding adjustments in protobuf, Swagger, and API configuration files. Server initialization and settings are updated to incorporate the new bens_client and related protocols, and test cases have been enhanced with a mock server for domain lookup functionality.

Poem

I'm a rabbit bouncing through the code,
Hopping over changes on every node.
Dependencies tagged, and new paths unfurled,
Domain info now brightens our world.
With endpoints and clients in a dreamy parade,
I nibble on success—our work well-made!
🐇🥕 Hop to it, code, in every trade!


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2f83ac1 and 299d107.

⛔ Files ignored due to path filters (1)
  • multichain-aggregator/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • multichain-aggregator/Cargo.toml (1 hunks)
  • multichain-aggregator/multichain-aggregator-server/src/server.rs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • multichain-aggregator/multichain-aggregator-server/src/server.rs
  • multichain-aggregator/Cargo.toml

🪧 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@lok52 lok52 marked this pull request as ready for review April 9, 2025 16:43

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🧹 Nitpick comments (3)
multichain-aggregator/multichain-aggregator-logic/src/types/domains.rs (1)

37-46: Convert Domain to protobuf.

Field mappings are straightforward. However, using .expect("...") can terminate the process if protocol deserialization fails. Consider handling parse failure more gracefully.

For example, you could default to an empty JSON object if an unexpected error occurs:

- protocol: serde_json::from_value(v.protocol).expect("failed to deserialize protocol"),
+ protocol: serde_json::from_value(v.protocol).unwrap_or_default(),
multichain-aggregator/multichain-aggregator-server/src/services/multichain_aggregator.rs (1)

125-130: Passing BENS client and NonTokenSearch configuration.

Using bens_client with the NonTokenSearch config and setting a domain lookup limit of 1 is a practical initial approach. If broader TLD or multi-domain support is needed later, consider making the limit configurable or retrieving it from settings.

multichain-aggregator/multichain-aggregator-logic/src/services/search.rs (1)

30-33: TODO for chain-agnostic BENS handling.

The comment indicates an upcoming requirement to generalize domain resolution. Consider tracking this in an issue or roadmap to ensure it’s not overlooked.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e93c19b and 8b8e41f.

⛔ Files ignored due to path filters (2)
  • blockscout-ens/Cargo.lock is excluded by !**/*.lock
  • multichain-aggregator/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (22)
  • blockscout-ens/Cargo.toml (1 hunks)
  • multichain-aggregator/Cargo.toml (1 hunks)
  • multichain-aggregator/multichain-aggregator-logic/Cargo.toml (1 hunks)
  • multichain-aggregator/multichain-aggregator-logic/src/clients/bens.rs (1 hunks)
  • multichain-aggregator/multichain-aggregator-logic/src/clients/mod.rs (1 hunks)
  • multichain-aggregator/multichain-aggregator-logic/src/error.rs (1 hunks)
  • multichain-aggregator/multichain-aggregator-logic/src/repository/addresses.rs (2 hunks)
  • multichain-aggregator/multichain-aggregator-logic/src/services/search.rs (9 hunks)
  • multichain-aggregator/multichain-aggregator-logic/src/types/addresses.rs (4 hunks)
  • multichain-aggregator/multichain-aggregator-logic/src/types/batch_import_request.rs (1 hunks)
  • multichain-aggregator/multichain-aggregator-logic/src/types/domains.rs (1 hunks)
  • multichain-aggregator/multichain-aggregator-logic/src/types/mod.rs (1 hunks)
  • multichain-aggregator/multichain-aggregator-logic/src/types/search_results.rs (4 hunks)
  • multichain-aggregator/multichain-aggregator-proto/Cargo.toml (2 hunks)
  • multichain-aggregator/multichain-aggregator-proto/build.rs (2 hunks)
  • multichain-aggregator/multichain-aggregator-proto/proto/v1/api_config_http.yaml (1 hunks)
  • multichain-aggregator/multichain-aggregator-proto/proto/v1/multichain-aggregator.proto (5 hunks)
  • multichain-aggregator/multichain-aggregator-proto/swagger/v1/multichain-aggregator.swagger.yaml (6 hunks)
  • multichain-aggregator/multichain-aggregator-server/src/server.rs (2 hunks)
  • multichain-aggregator/multichain-aggregator-server/src/services/multichain_aggregator.rs (6 hunks)
  • multichain-aggregator/multichain-aggregator-server/src/settings.rs (5 hunks)
  • multichain-aggregator/multichain-aggregator-server/tests/quick_search.rs (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (6)
multichain-aggregator/multichain-aggregator-logic/src/types/search_results.rs (2)
multichain-aggregator/multichain-aggregator-logic/src/services/search.rs (11)
  • addresses (118-121)
  • addresses (423-426)
  • addresses (428-437)
  • addresses (438-442)
  • addresses (494-503)
  • addresses (530-533)
  • block_ranges (456-462)
  • domains (89-94)
  • domains (517-517)
  • hashes (198-201)
  • hashes (400-403)
blockscout-ens/graph-node/subgraphs/zeta-subgraph/generated/schema.ts (1)
  • Domain (14-294)
multichain-aggregator/multichain-aggregator-server/src/server.rs (4)
multichain-aggregator/multichain-aggregator-logic/src/clients/bens.rs (1)
  • new_client (5-8)
multichain-aggregator/multichain-aggregator-logic/src/clients/dapp.rs (1)
  • new_client (9-12)
multichain-aggregator/multichain-aggregator-logic/src/clients/token_info.rs (1)
  • new_client (10-13)
multichain-aggregator/multichain-aggregator-server/src/services/multichain_aggregator.rs (1)
  • new (28-47)
multichain-aggregator/multichain-aggregator-logic/src/types/addresses.rs (7)
multichain-aggregator/multichain-aggregator-logic/src/types/search_results.rs (1)
  • from (117-128)
multichain-aggregator/multichain-aggregator-logic/src/types/token_info.rs (1)
  • from (36-45)
multichain-aggregator/multichain-aggregator-logic/src/types/hashes.rs (2)
  • from (15-22)
  • from (38-44)
multichain-aggregator/multichain-aggregator-logic/src/types/dapp.rs (1)
  • from (28-36)
multichain-aggregator/multichain-aggregator-logic/src/types/chains.rs (3)
  • from (15-24)
  • from (28-35)
  • from (39-46)
multichain-aggregator/multichain-aggregator-logic/src/types/api_keys.rs (1)
  • from (33-38)
multichain-aggregator/multichain-aggregator-logic/src/types/block_ranges.rs (3)
  • from (13-21)
  • from (25-31)
  • from (41-46)
multichain-aggregator/multichain-aggregator-logic/src/repository/addresses.rs (2)
multichain-aggregator/multichain-aggregator-logic/src/services/search.rs (7)
  • addresses (118-121)
  • addresses (423-426)
  • addresses (428-437)
  • addresses (438-442)
  • addresses (494-503)
  • addresses (530-533)
  • token_types (49-54)
multichain-aggregator/multichain-aggregator-logic/src/types/search_results.rs (1)
  • chain_ids (76-80)
multichain-aggregator/multichain-aggregator-logic/src/services/search.rs (5)
multichain-aggregator/multichain-aggregator-logic/src/clients/bens.rs (2)
  • query (33-61)
  • query (89-99)
multichain-aggregator/multichain-aggregator-logic/src/types/search_results.rs (1)
  • chain_ids (76-80)
multichain-aggregator/multichain-aggregator-logic/src/types/addresses.rs (1)
  • try_from (49-61)
multichain-aggregator/multichain-aggregator-logic/src/types/domains.rs (1)
  • try_from (15-34)
multichain-aggregator/multichain-aggregator-logic/src/types/dapp.rs (1)
  • try_from (16-24)
multichain-aggregator/multichain-aggregator-logic/src/clients/bens.rs (2)
multichain-aggregator/multichain-aggregator-server/src/settings.rs (2)
  • default (57-62)
  • default (76-108)
libs/api-client-framework/src/endpoint.rs (1)
  • serialize_query (61-63)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Unit, doc and integration tests
🔇 Additional comments (77)
multichain-aggregator/multichain-aggregator-logic/src/types/mod.rs (1)

7-7: LGTM: New domains module added successfully

The addition of the domains module aligns with the PR objective of integrating domain functionality into the system.

multichain-aggregator/multichain-aggregator-logic/src/error.rs (1)

34-35: LGTM: JSON parsing error variant added

The addition of the Json error variant to handle JSON parsing errors is appropriate and follows the same pattern as existing error variants. This will be useful for processing domain-related JSON data.

multichain-aggregator/multichain-aggregator-proto/Cargo.toml (2)

11-12: LGTM: Protocol Buffer dependencies added

The addition of prost-wkt and prost-wkt-types is appropriate for handling Well-Known Types in Protocol Buffers, which will be useful for the domains integration.


21-21: LGTM: Protocol Buffer build dependency added

The addition of prost-wkt-build is consistent with the runtime dependencies and necessary for compiling Protocol Buffer definitions with Well-Known Types.

multichain-aggregator/multichain-aggregator-server/src/settings.rs (5)

43-44: LGTM: Optional bens_protocols field with default value

Adding the bens_protocols field with a default value is a good approach. This allows for configuration flexibility while providing sensible defaults.


96-98: LGTM: Default bens_client configuration

The default configuration for bens_client is consistent with other client defaults and provides a reasonable starting point.


105-105: LGTM: Default bens_protocols setting

Setting the default bens_protocols value is consistent with the rest of the defaults configuration.


125-127: LGTM: Default ENS protocol implementation

The default protocols implementation currently includes only "ens", which is a reasonable starting point for domain resolution. As more domain protocols are supported, this list can be expanded.


32-35:

Details

❓ Verification inconclusive

Good refactoring of client settings, but consider backward compatibility

Consolidating DappClientSettings and TokenInfoClientSettings into the generic HttpApiClientSettings type is a good refactoring. The addition of bens_client follows the same pattern.

However, this change might affect existing configuration files. Have you considered backward compatibility or migration steps for existing deployments?


🏁 Script executed:

#!/bin/bash
# Check if there are any existing configuration files that might be affected by the type change
find . -name "*.yaml" -o -name "*.yml" -o -name "*.json" -o -name "*.toml" | xargs grep -l "dapp_client\|token_info_client"

Length of output: 198


Action Required: Address Backward Compatibility for Client Settings

Great job on refactoring by consolidating DappClientSettings and TokenInfoClientSettings into the unified HttpApiClientSettings, along with adding the new bens_client. However, the discovery of an existing configuration file (multichain-aggregator/multichain-aggregator-server/config/example.toml) that references dapp_client (or token_info_client) suggests that deployments relying on older configuration settings may break.

  • Review Configuration Files: Verify that all consumers of the configuration (e.g., example.toml) are either updated or have a clear migration path.
  • Migration/Deprecation Strategy: Consider including migration steps, fallback mechanisms, or deprecation warnings to guide users through updating their configs.

Please address these concerns to ensure backward compatibility.

multichain-aggregator/multichain-aggregator-logic/src/clients/mod.rs (1)

1-1: Clean addition of the new bens module

This addition of the bens module integrates domain functionality into the client system. The module follows the established pattern of client module exports.

multichain-aggregator/multichain-aggregator-logic/Cargo.toml (1)

9-9: Appropriate addition of the bens-proto dependency

The dependency is correctly added with workspace = true, consistent with other dependencies in this project. This addition supports the new domain functionality being integrated.

multichain-aggregator/multichain-aggregator-proto/proto/v1/api_config_http.yaml (1)

37-39: Consistent addition of the new /api/v1/domains endpoint

The new HTTP endpoint for listing domains follows the same RESTful pattern as other endpoints in this service. The placement before the Health section maintains the logical organization of the API configuration.

multichain-aggregator/multichain-aggregator-logic/src/types/batch_import_request.rs (1)

56-56: Properly updated Address construction to use the new domain model

The code has been updated to initialize domain_info: None instead of the previous ens_name field, reflecting the architectural shift from a simple string field to a more structured representation of domain information.

multichain-aggregator/multichain-aggregator-server/src/server.rs (3)

16-16: Properly integrated the new bens client import

The import statement has been correctly updated to include the new bens client alongside the existing dapp and token_info clients.


72-72: Well-structured client initialization

The initialization of the bens_client follows the same pattern as the existing clients, maintaining code consistency.


78-82: Appropriate integration of the bens client in the MultichainAggregator constructor

Both the new bens_client and bens_protocols parameters have been correctly added to the MultichainAggregator::new() call, enabling the domain lookup functionality.

multichain-aggregator/Cargo.toml (3)

16-16: Correctly referenced the bens-proto dependency

The addition of the bens-proto dependency is appropriate for integrating the domain functionality.


28-30: Well-structured addition of prost-wkt dependencies

The addition of the prost-wkt, prost-wkt-types, and prost-wkt-build dependencies is appropriate for improved protocol buffer handling with well-known types.


20-20:

Details

❓ Verification inconclusive

Verify if removing the 'conversions' feature is intentional

The features = ["conversions"] attribute has been removed from the actix-prost-build dependency. Make sure this doesn't impact any functionality that might depend on these conversions.


🏁 Script executed:

#!/bin/bash
# Check if the "conversions" feature is used elsewhere or if it's redundant

# Search for references to actix-prost-build conversions
rg -A 3 -B 3 "conversions" --glob "*.rs" --glob "*.toml"

# Check if there are any compilation errors related to missing conversions
cargo check -p multichain-aggregator-proto 2>&1 | grep -i conversion

Length of output: 1655


ACTION: Verify that removing the 'conversions' feature does not introduce any hidden issues.

Based on the checks performed:

  • The cargo check -p multichain-aggregator-proto command produced no conversion-related compilation errors.
  • The rg command returned several references to "conversions" in unrelated modules (e.g., in tests and in other packages), but none of these clearly indicate a dependency on the actix-prost-build conversions feature.

It appears that the removal of features = ["conversions"] from the actix-prost-build dependency is likely intentional. However, because there are some conversion-related references elsewhere in the codebase, please perform a manual verification to ensure that no functionality relying on the now-disabled conversions is impacted.

multichain-aggregator/multichain-aggregator-server/tests/quick_search.rs (3)

23-28: Properly implemented mock bens server

The mock server for domain lookups has been correctly integrated into the test setup, following the same pattern as the existing mock servers.


47-52: Comprehensive test cases for domain functionality

The test assertions for both empty domains and a domain search query are well-structured and verify the expected behavior of the new functionality.


113-147: Well-structured mock implementation for bens server

The mock_bens_server function is well-implemented with a complete and realistic response payload that includes all the necessary fields for domain information. The mock follows the same pattern as the other mock servers in this file.

multichain-aggregator/multichain-aggregator-proto/build.rs (6)

3-7: Added appropriate imports for enhanced Protocol Buffer handling

The new imports for prost_wkt_build and additional standard library modules are correctly added to support the enhanced Protocol Buffer compilation process.


15-16: Well-structured output directory configuration

The output directory and file descriptor set path are properly configured using environment variables.


21-21: Appropriately configured file descriptor set path

The file descriptor set path is correctly added to the configuration, enabling additional protocol buffer processing.


29-29: Added proper serialization for Google Protocol Buffer types

The type attribute for .google.protobuf enables proper serialization and deserialization with serde, which is essential for correctly handling Protocol Buffer messages.


43-44: Correctly configured extern path for Google Protocol Buffer types

The extern_path configuration properly links the Google Protocol Buffer types to the prost-wkt-types crate.


47-50: Well-implemented serde support for Protocol Buffer types

The implementation to read the descriptor bytes, decode them, and add serde support for the generated types is correct and follows best practices.

multichain-aggregator/multichain-aggregator-logic/src/types/addresses.rs (6)

7-13: Add DomainInfo struct.

This new struct cleanly encapsulates domain-related data like address, name, expiry date, and names count. It appears well-structured and complements the existing address data model.


19-19: Attach domain_info to Address.

Adding domain_info as an optional field in Address aligns with evolving requirements to store richer domain information. This change looks coherent with the new domain-based approach.


33-33: Verify ENS name handling.

Setting ens_name to None abandons any previously stored ENS data. If there's a requirement to preserve or migrate ENS information, consider verifying the impact on existing records or providing a migration path.


53-53: Clarify ignoring domain_info from the database.

Currently assigning None to domain_info means the existing database records do not store or load domain details. If domain metadata will be persisted in the future, consider extending the model accordingly.


64-73: Implement From<DomainInfo> for proto::DomainInfo.

This straightforward field mapping consistently follows the code’s existing conversion pattern for protobuf structs. Implementation looks well-aligned with best practices.


79-79: Map domain_info to protobuf.

Using map(|d| d.into()) is a neat way to conditionally convert domain info. This approach avoids boilerplate and neatly handles the optional field.

blockscout-ens/Cargo.toml (1)

14-16: Pin dependencies to a specific tag.

Specifying tag = "v1.0.3" ensures reproducible builds and avoids unexpected upstream changes. This is a recommended practice for more predictable dependency management.

multichain-aggregator/multichain-aggregator-logic/src/types/domains.rs (2)

1-10: Introduce new Domain struct.

This struct neatly groups domain-related attributes including address, name, expiry date, and protocol. It provides a sound foundation for supporting domain-centric features.


12-35: Implement TryFrom<BensDomain> with error checks.

The conversion logic properly validates missing fields using ok_or_else, ensuring robust error handling. This design prevents invalid data from silently propagating.

multichain-aggregator/multichain-aggregator-logic/src/clients/bens.rs (2)

1-8: LGTM: Good setup for API client

The HTTP client setup and configuration initialization are properly implemented.


65-101: Good implementation of the GetAddress endpoint

Clean implementation of the Endpoint trait for the GetAddress struct. The path construction and query parameter handling are done correctly.

multichain-aggregator/multichain-aggregator-proto/swagger/v1/multichain-aggregator.swagger.yaml (6)

122-149: LGTM: Well-defined domains endpoint with proper parameters

The new /api/v1/domains endpoint is properly defined with appropriate query parameters for searching and pagination. The structure follows the same pattern as other endpoints in the API.


370-382: LGTM: Proper definition of protobufNullValue enum

The protobufNullValue enum is properly defined with good documentation explaining its purpose for JSON representation.


400-401: LGTM: Good replacement of ens_name with domain_info

The replacement of ens_name with domain_info referencing the v1DomainInfo schema is a good enhancement that will provide more comprehensive domain information.


454-476: LGTM: Well-structured domain schemas

The v1Domain and v1DomainInfo schemas are well-structured with appropriate fields for domain information.


538-547: LGTM: Properly defined ListDomainsResponse with pagination support

The v1ListDomainsResponse schema is correctly structured with an items array and pagination support, following the same pattern as other list response schemas.


637-641: LGTM: Properly added domains to QuickSearchResponse

The domains field is properly added to the QuickSearchResponse schema.

multichain-aggregator/multichain-aggregator-logic/src/repository/addresses.rs (3)

198-206: LGTM: Improved list function signature

The function signature has been improved by replacing option types with more straightforward vector types. This simplifies the API and makes the code more readable.


216-222: LGTM: Simplified chain_ids filtering logic

The conditional logic for applying chain_ids filter has been improved to directly check if the vector is non-empty.


229-241: LGTM: Improved addresses filtering implementation

The changes correctly update the address filtering logic to handle multiple addresses efficiently.

multichain-aggregator/multichain-aggregator-logic/src/types/search_results.rs (4)

1-9: LGTM: Good imports organization

The imports are well-organized, including the new Domain type from domains module.


19-20: LGTM: Added domains field to QuickSearchResult

The domains field has been correctly added to the QuickSearchResult struct.


31-33: LGTM: Updated merge method to include domains

The merge method has been properly updated to extend the domains vector.


125-126: LGTM: Updated QuickSearchResponse conversion

The From implementation for proto::QuickSearchResponse has been correctly updated to include the domains field.

multichain-aggregator/multichain-aggregator-server/src/services/multichain_aggregator.rs (4)

21-24: New fields added to support BENS client and protocols.

The introduction of bens_client and bens_protocols is a clean approach for domain lookups. Initialization within the struct and constructor is straightforward, and there are no obvious concurrency or maintainability issues.

Also applies to: 32-35, 42-45


163-164: NFT-specific address search logic.

Here, search::AddressSearchConfig::NFTSearch properly toggles token types. The pattern is consistent with the non-token search implementation above.

Also applies to: 166-166


228-231: Quick search domain support.

Extending quick_search to pass bens_client and bens_protocols ensures domain queries can be resolved in a unified manner alongside other resources.


326-350: New list_domains RPC method.

This addition seamlessly integrates domain search into the aggregator service, returning properly paginated data. The error propagation and pagination logic match existing patterns, making it maintainable and consistent.

multichain-aggregator/multichain-aggregator-proto/proto/v1/multichain-aggregator.proto (7)

7-7: Importing google/protobuf/struct.proto.

This import is necessary for storing arbitrary protocol data in the new Domain message.


22-22: Added ListDomains RPC.

The new RPC signature aligns with its server-side implementation. The pairing of ListDomainsRequest and ListDomainsResponse is consistent with existing methods.


43-49: New DomainInfo message.

This struct captures details about a domain. There’s no immediate concern, though be aware that “optional” in proto3 has nuances, and you might need to confirm how default/empty states are handled.


52-52: Replaced ENS field with domain_info.

Embedding domain details through DomainInfo is more flexible than a single ENS name string. This design supports multi-field expansions in the future.


91-97: New Domain message.

Including a google.protobuf.Struct protocol field allows flexible handling of domain protocol metadata. This is a good choice for unstructured data that may evolve.


144-144: domains field in QuickSearchResponse.

Augmenting quick search results with discovered domains expands the aggregator features. Ensure any front-end consumers can handle this new field gracefully.


232-242: ListDomainsRequest and ListDomainsResponse.

The request/response pairing for domain listings is consistent with the rest of the API. Paginated output supports large domain sets.

multichain-aggregator/multichain-aggregator-logic/src/services/search.rs (14)

2-5: New imports for BENS queries, domain types, and collections.

These additions cleanly bring in the required dependencies for domain lookups. The standard library’s OnceLock usage for regex initialization is also well-structured.

Also applies to: 10-13, 22-25


35-39: domain_name_regex initialization.

Using OnceLock<Regex> is a good pattern for performance and thread safety when repeatedly matching domain strings.


40-55: AddressSearchConfig enum integration.

Splitting search logic between NFTSearch and NonTokenSearch avoids scattering conditional checks. Delegating token type resolution to token_types() is clear.


59-60: Extended search_addresses with BENS params.

Adding bens_client and AddressSearchConfig broadens the search logic. No immediate concurrency or error-handling pitfalls are evident here.

Also applies to: 62-62


70-73: Closure-based address parsing.

This is a neat approach: either parse a valid address or treat it as a potential name-based query. No obvious concerns.


75-106: Conditional domain resolution.

When NonTokenSearch is used and the query looks like a domain, the code calls search_domains and retrieves addresses. This branching helps unify domain and direct address queries while avoiding extra domain lookups for non-domain inputs.


107-112: Loading addresses from DB and preloading domain info.

Passing addresses and optional contract_name_query is consistent for both domain-based and raw address searches. Post-processing with preload_domain_info is a logical next step, ensuring domain data is enriched.

Also applies to: 118-126


128-179: preload_domain_info usage and error handling.

Fetching domain info for each address in parallel is efficient. Logging failures ensures visibility without blocking the entire operation. Confirm that partial errors are acceptable for your use cases.


280-314: search_domains function.

This new function neatly mirrors the existing search pattern, returning domain objects and a next-page token. The error handling and usage of map_err match standard patterns.


321-324: Added BENS client and protocol arguments for quick_search.

Incorporating domain logic into your quick search broadens coverage for domain queries without complicating preexisting structures.


343-346: Concurrent join for quick search jobs.

This approach merges partial results from each search term. The concurrency pattern is standard and well-managed, folding results into a single structure.

Also applies to: 351-352


367-367: New Domain variant in SearchTerm and search context.

These changes extend your search domain to actual domains (pun intended). The usage is consistent with existing variants.

Also applies to: 375-375


507-542: SearchTerm::Domain branch logic.

Looks correct for retrieving domain-based addresses and then appending them to results.addresses while also populating results.domains. This ensures domain queries are fully reflected in the final quick search output.


624-632: New test for domain queries.

This test confirms that a domain-like string is parsed into the correct search terms, including the new SearchTerm::Domain. Great for ensuring future refactors don’t break domain detection.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 0

♻️ Duplicate comments (1)
multichain-aggregator/multichain-aggregator-logic/src/types/search_results.rs (1)

111-113: Balance entities update addresses previous review comment

The balance_entities macro call has been correctly updated to include the new domains field, addressing the comment from the previous review. This ensures domains are properly considered in the balancing logic.

🧹 Nitpick comments (1)
multichain-aggregator/multichain-aggregator-logic/src/types/search_results.rs (1)

35-88: Well-implemented filtering and sorting functionality

The new filter_and_sort_entities_by_priority method and its helper function are well-designed. The macro-based approach efficiently applies the filtering and sorting logic across multiple entity types. The implementation properly handles:

  1. Filtering to keep only one item per chain_id
  2. Sorting based on the priority defined by the order of chain IDs

However, I notice that domains is not included in the list of fields to filter and sort. Is this intentional? If domains have a chain_id field and should be filtered/sorted like other entities, consider including them.

If domains should be included in the filtering and sorting, update the macro call:

filter_and_sort_by_priority!(
    self,
    [
        addresses,
        blocks,
        transactions,
        block_numbers,
        dapps,
        tokens,
-       nfts
+       nfts,
+       domains
    ]
);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8b8e41f and 2f83ac1.

📒 Files selected for processing (1)
  • multichain-aggregator/multichain-aggregator-logic/src/types/search_results.rs (5 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
multichain-aggregator/multichain-aggregator-logic/src/types/search_results.rs (4)
multichain-aggregator/multichain-aggregator-logic/src/repository/addresses.rs (1)
  • addresses (234-237)
multichain-aggregator/multichain-aggregator-logic/src/services/search.rs (6)
  • addresses (118-121)
  • addresses (423-426)
  • addresses (428-437)
  • addresses (438-442)
  • addresses (494-503)
  • addresses (530-533)
multichain-aggregator/multichain-aggregator-server/src/services/multichain_aggregator.rs (1)
  • new (28-47)
multichain-aggregator/multichain-aggregator-logic/src/services/api_key_manager.rs (1)
  • new (12-14)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Unit, doc and integration tests
  • GitHub Check: Unit, doc and integration tests
🔇 Additional comments (3)
multichain-aggregator/multichain-aggregator-logic/src/types/search_results.rs (3)

1-8: Integration of Domain support looks good!

The addition of the domains field to QuickSearchResult struct and the corresponding import of domains::Domain are properly implemented. This is a necessary foundation for the domains integration feature.

Also applies to: 20-20


32-32: Proper update to merge method

The merge method has been correctly updated to extend the new domains vector when merging another QuickSearchResult instance, consistent with how other fields are handled.


127-127: Proto response mapping for domains is correct

The From implementation for converting to proto::QuickSearchResponse has been properly updated to include domain information in the response. This ensures the new domain data will be correctly exposed through the API.

Comment thread blockscout-ens/Cargo.toml Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants