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

fix(torii-grpc): subscribe indexer #2563

Merged
merged 2 commits into from
Oct 22, 2024
Merged

fix(torii-grpc): subscribe indexer #2563

merged 2 commits into from
Oct 22, 2024

Conversation

Larkooo
Copy link
Collaborator

@Larkooo Larkooo commented Oct 21, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced data retrieval by modifying the subscription process to fetch all fields from the contracts table.
  • Bug Fixes

    • Improved query logic to ensure accurate filtering of contract addresses.

Copy link

coderabbitai bot commented Oct 21, 2024

Walkthrough

Ohayo! This pull request modifies the SQL query in the add_subscriber method of the IndexerManager struct to select all columns from the contracts table instead of a specific subset. The conditional logic for the contract_address remains unchanged, ensuring that the query still filters appropriately when needed. Overall, the structure and flow of the IndexerManager and Service implementations are preserved, with no changes to public entity declarations.

Changes

File Path Change Summary
crates/torii/grpc/src/server/subscriptions/... Modified SQL query in add_subscriber to select all columns from contracts table.

Possibly related PRs

  • refactor-opt(torii-grpc): subscriptions no db fetch #2455: This PR involves refactoring subscription handling to eliminate database fetching, which relates to the changes in the add_subscriber method of the IndexerManager in the main PR, as both involve subscription management and data retrieval processes.
  • refactor: subscription updates ordered #2507: This PR modifies the IndexerManager and Service structures to enhance update handling, which is directly related to the changes made in the add_subscriber method of the IndexerManager in the main PR, as both focus on managing subscriptions and updates.
  • refactor(torii): different tasks for torii services #2552: This PR enhances the concurrency model of the server components, which may indirectly relate to the overall subscription handling and performance improvements discussed in the main PR, particularly in the context of managing multiple subscribers efficiently.

Suggested reviewers

  • glihm

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c29524c and 0df6efc.

📒 Files selected for processing (1)
  • crates/torii/grpc/src/server/subscriptions/indexer.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/torii/grpc/src/server/subscriptions/indexer.rs

🪧 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.

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

@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: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between fac93b0 and c29524c.

📒 Files selected for processing (1)
  • crates/torii/grpc/src/server/subscriptions/indexer.rs (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
crates/torii/grpc/src/server/subscriptions/indexer.rs (1)

Line range hint 1-190: Ohayo again, sensei! The rest of the file looks good.

The change to the SQL query is the only modification in this file. The overall structure and logic of the IndexerManager and Service implementations remain intact. Keep up the good work!

@@ -47,7 +47,7 @@ impl IndexerManager {
let (sender, receiver) = channel(1);

let mut statement =
"SELECT head, tps, last_block_timestamp, contract_address FROM contracts".to_string();
"SELECT * FROM contracts".to_string();
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Ohayo, sensei! It's best to specify the needed columns instead of using SELECT *:

  1. Performance: Retrieving all columns can slow down the query, especially if some columns are large or not needed.
  2. Maintainability: Explicitly listing columns makes the code clearer and less prone to breakage if the table structure changes in the future.
🔗 Analysis chain

Ohayo, sensei! Consider the implications of selecting all columns.

The change from selecting specific columns to SELECT * simplifies the query, but it might have some drawbacks:

  1. Performance: Retrieving all columns could impact performance, especially if the contracts table has many columns or large data types.
  2. Future-proofing: If the table structure changes in the future, this query might retrieve unexpected columns.

To assess the impact, let's check the contracts table structure:

Consider reverting to selecting specific columns or using a view if you need flexibility in the future.


Ohayo, sensei! Let's delve deeper into the contracts table structure to evaluate the use of SELECT *.

To fully understand the implications of selecting all columns, we need to know which columns exist in the contracts table.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the structure of the contracts table
# Expected result: List of columns in the contracts table

# Search for the contracts table definition
rg -i 'create\s+table\s+contracts'

Length of output: 129


Script:

#!/bin/bash
# Description: Extract the full CREATE TABLE statement for contracts
# Expected result: Full table definition including all columns

rg -A 20 -i 'CREATE\s+TABLE\s+contracts\s*\(' crates/torii/migrations/20240829114436_merge_worlds_and_indexer.sql

Length of output: 692

Copy link

codecov bot commented Oct 21, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 69.80%. Comparing base (fac93b0) to head (0df6efc).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...tes/torii/grpc/src/server/subscriptions/indexer.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2563      +/-   ##
==========================================
+ Coverage   69.77%   69.80%   +0.03%     
==========================================
  Files         400      400              
  Lines       51171    51182      +11     
==========================================
+ Hits        35704    35729      +25     
+ Misses      15467    15453      -14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Larkooo Larkooo merged commit db767df into main Oct 22, 2024
14 of 15 checks passed
@Larkooo Larkooo deleted the Larkooo-patch-2 branch October 22, 2024 18:57
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.

2 participants