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-sqlite): executor broker messages & ipfs logging #2923

Merged
merged 6 commits into from
Jan 21, 2025

Conversation

Larkooo
Copy link
Collaborator

@Larkooo Larkooo commented Jan 17, 2025

Summary by CodeRabbit

  • Refactor

    • Simplified IPFS content fetching by removing explicit retry parameters
    • Updated transaction handling logic in the Executor
    • Modified logging for IPFS content retrieval errors
  • Bug Fixes

    • Adjusted message processing and transaction management timing

The changes primarily focus on streamlining IPFS content fetching and transaction management, with improved error logging and simplified function interfaces.

Copy link

codecov bot commented Jan 20, 2025

Codecov Report

Attention: Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.

Project coverage is 55.80%. Comparing base (ec00eca) to head (090b3f0).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
crates/torii/sqlite/src/utils.rs 0.00% 5 Missing ⚠️
...es/torii/indexer/src/processors/metadata_update.rs 0.00% 2 Missing ⚠️
crates/torii/server/src/artifacts.rs 0.00% 1 Missing ⚠️
crates/torii/sqlite/src/executor/erc.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2923      +/-   ##
==========================================
- Coverage   55.99%   55.80%   -0.20%     
==========================================
  Files         449      444       -5     
  Lines       58020    57316     -704     
==========================================
- Hits        32491    31986     -505     
+ Misses      25529    25330     -199     

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

@Larkooo Larkooo marked this pull request as ready for review January 20, 2025 09:54
@Larkooo Larkooo changed the title refactor(torii): ipfs fetch fix(torii-sqlite): executor broker messages & ipfs logging Jan 20, 2025
Copy link

coderabbitai bot commented Jan 20, 2025

Walkthrough

Ohayo, sensei! This pull request introduces modifications across multiple files in the Torii project, primarily focusing on simplifying IPFS content fetching and transaction management. The changes involve removing the IPFS_CLIENT_MAX_RETRY constant, updating function signatures for fetch_content_from_ipfs, and adjusting transaction handling logic in the Executor struct. These modifications streamline the IPFS interaction process and potentially change how transactions are managed during message processing.

Changes

File Change Summary
crates/torii/indexer/src/processors/metadata_update.rs Removed IPFS_CLIENT_MAX_RETRY from fetch_content_from_ipfs function calls
crates/torii/server/src/artifacts.rs Removed import of IPFS_CLIENT_MAX_RETRY and simplified IPFS content fetching
crates/torii/sqlite/src/executor/erc.rs Removed IPFS_CLIENT_MAX_RETRY constant and simplified IPFS content fetching
crates/torii/sqlite/src/executor/mod.rs Modified transaction handling logic in execute method
crates/torii/sqlite/src/utils.rs Updated fetch_content_from_ipfs function signature and retry logging

Sequence Diagram

sequenceDiagram
    participant Caller
    participant FetchFunction
    participant IPFSClient
    
    Caller->>FetchFunction: Call fetch_content_from_ipfs(cid)
    FetchFunction->>IPFSClient: Attempt to fetch content
    alt Fetch successful
        IPFSClient-->>FetchFunction: Return content
        FetchFunction-->>Caller: Return content
    else Fetch failed
        IPFSClient--xFetchFunction: Return error
        FetchFunction->>FetchFunction: Retry fetch
        alt Retries exhausted
            FetchFunction--xCaller: Return error
        end
    end
Loading

Possibly related PRs

Suggested reviewers

  • glihm

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

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: 0

🧹 Nitpick comments (2)
crates/torii/sqlite/src/utils.rs (1)

56-73: Ohayo! Nice improvements to the IPFS fetching logic, sensei!

The changes improve the function's interface and error reporting. The warning logs now provide better context with error details and remaining attempts.

Consider adding exponential backoff instead of fixed 3-second delays between retries:

-                tokio::time::sleep(Duration::from_secs(3)).await;
+                let backoff = Duration::from_secs(2u64.pow(IPFS_CLIENT_MAX_RETRY - retries));
+                tokio::time::sleep(backoff).await;
crates/torii/sqlite/src/executor/erc.rs (1)

292-292: Clean adaptation to the new IPFS fetching interface, sensei!

The code correctly uses the simplified fetch_content_from_ipfs function while maintaining robust error handling.

Consider extracting the URI scheme handling into a separate function for better maintainability:

async fn fetch_by_scheme(uri: &str) -> Result<serde_json::Value> {
    match uri {
        uri if uri.starts_with("ipfs") => fetch_from_ipfs(uri).await,
        uri if uri.starts_with("http") || uri.starts_with("https") => fetch_from_http(uri).await,
        uri if uri.starts_with("data") => fetch_from_data_uri(uri).await,
        uri => Err(anyhow::anyhow!("Unsupported URI scheme: {}", uri))
    }
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4b6d473 and fb5103f.

📒 Files selected for processing (5)
  • crates/torii/indexer/src/processors/metadata_update.rs (2 hunks)
  • crates/torii/server/src/artifacts.rs (2 hunks)
  • crates/torii/sqlite/src/executor/erc.rs (2 hunks)
  • crates/torii/sqlite/src/executor/mod.rs (1 hunks)
  • crates/torii/sqlite/src/utils.rs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: docs
  • GitHub Check: build
  • GitHub Check: ensure-wasm
🔇 Additional comments (4)
crates/torii/sqlite/src/executor/mod.rs (1)

779-781: Ohayo, sensei! Moving message publishing after transaction commit ensures consistency.

By sending broker messages only after the transaction has been successfully committed, we prevent potential inconsistencies where messages could be published for transactions that are not yet persisted or could fail. This change enhances data integrity across the system.

crates/torii/indexer/src/processors/metadata_update.rs (2)

109-109: Ohayo, sensei! Simplified IPFS content fetching aligns with the updated interface.

Removing the retries parameter from the fetch_content_from_ipfs call in the metadata function reflects the revised function signature and streamlines the code.


120-120: Ohayo, sensei! Updated fetch_image function adheres to the new IPFS fetching logic.

The code now correctly calls fetch_content_from_ipfs without the retries parameter, aligning with the recently updated function definition and simplifying error handling.

crates/torii/server/src/artifacts.rs (1)

207-207: Ohayo, sensei! Updated IPFS image retrieval matches the new function signature.

By removing the retries parameter from the fetch_content_from_ipfs call, the fetch_and_process_image function now aligns with the updated IPFS content fetching interface, ensuring consistency across the codebase.

@Larkooo Larkooo enabled auto-merge (squash) January 21, 2025 03:11
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