dojo icon indicating copy to clipboard operation
dojo copied to clipboard

feat(torii): index whitelisted erc20/erc721

Open itzlambda opened this issue 1 year ago • 3 comments

combination of: #2442 #2483 #2491

to be merge after: #2460

Summary by CodeRabbit

  • New Features

    • Added support for flexible command-line argument handling in the Torii application, allowing optional inputs for world address and database path.
    • Introduced a new configuration file template for user customization of contract types and addresses.
    • Enhanced event processing capabilities with new processors for ERC20 and ERC721 contracts.
    • Updated deployment manifest with new contract addresses and models.
    • Integrated new dependencies for enhanced functionality, including support for temporary file handling.
  • Bug Fixes

    • Improved error handling and logging for database operations and message processing.
  • Documentation

    • Updated the .gitignore file to exclude additional log files from version control.

itzlambda avatar Oct 03 '24 14:10 itzlambda

Walkthrough

Ohayo, sensei! This pull request introduces several changes across multiple files in the project. The .gitignore file now includes a pattern to ignore all log files, enhancing file management. The Cargo.toml files for both the workspace and the torii package have been updated to include new members and dependencies. Significant modifications in main.rs enhance command-line argument parsing, while new configuration and executor modules have been added to streamline database operations and message processing. The event processing capabilities have also been improved in the engine.rs file.

Changes

File Change Summary
.gitignore Added **/*.log to ignore all log files.
Cargo.toml Added "scripts/verify_db_balances" to workspace members.
Cargo.toml (torii package) Reintroduced starknet, added toml and tempfile dependencies.
bin/torii/Cargo.toml Added tempfile as a workspace dependency.
bin/torii/src/main.rs Updated Args struct: made world_address optional, changed database default, added contracts and config fields. Added functions for verifying world address and parsing ERC contracts.
bin/torii/torii.toml Introduced a new example configuration file for Torii.
crates/torii/core/src/engine.rs Enhanced event processing with new processors for ERC20 and ERC721; added methods for improved data fetching and processing.
crates/torii/core/src/executor.rs Introduced a new executor module for handling database operations and message processing.
crates/torii/core/src/lib.rs Removed cache module, added executor module.
crates/torii/core/src/processors/erc20_legacy_transfer.rs Introduced Erc20LegacyTransferProcessor for handling ERC20 legacy transfer events.
crates/torii/core/src/sql/cache.rs Renamed cache field in ModelCache to model_cache, added LocalCache struct with new methods.
crates/torii/core/src/sql/erc.rs Added methods for handling ERC20 and ERC721 transfers, including metadata registration.
crates/torii/core/src/sql/mod.rs Refactored Sql struct to include local_cache, updated method signatures for contract handling.
crates/torii/core/src/sql/test.rs Updated tests to utilize temporary SQLite databases and improved database initialization logic.
crates/torii/graphql/Cargo.toml Updated dependencies: added starknet-crypto, reinstated tokio, and added tempfile.
crates/torii/graphql/src/tests/metadata_test.rs Modified tests to reflect new database initialization logic with HashMap.
crates/torii/graphql/src/tests/mod.rs Updated spinup_types_test to accept a path parameter for dynamic database configuration.
crates/torii/graphql/src/tests/subscription_test.rs Enhanced database interaction setup for subscription tests, updated utility functions.
crates/torii/grpc/src/server/tests/entities_test.rs Modified to use temporary SQLite database file and updated database execution logic.
crates/torii/libp2p/src/server/mod.rs Updated database interaction methods to use new utility functions and message-based execution.
crates/torii/libp2p/src/tests.rs Streamlined test setup by using temporary SQLite database and removed unused imports.

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 bb356e05eb93d24f23acd430e3762e0a8d4b0ffe and c12c279d80155861d6ac8a62df08c171a138c888.

📒 Files selected for processing (1)
  • scripts/compare-torii-data.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/compare-torii-data.py

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

coderabbitai[bot] avatar Oct 03 '24 14:10 coderabbitai[bot]

Codecov Report

Attention: Patch coverage is 33.79074% with 1158 lines in your changes missing coverage. Please review.

Project coverage is 67.74%. Comparing base (d039c6d) to head (c12c279). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/torii/core/src/sql/erc.rs 0.00% 286 Missing :warning:
crates/torii/core/src/executor.rs 20.48% 132 Missing :warning:
scripts/verify_db_balances/src/main.rs 0.00% 125 Missing :warning:
crates/torii/core/src/sql/query_queue.rs 0.00% 101 Missing :warning:
...rates/torii/graphql/src/object/erc/erc_transfer.rs 21.18% 93 Missing :warning:
crates/torii/core/src/sql/mod.rs 31.13% 73 Missing :warning:
crates/torii/graphql/src/object/erc/erc_balance.rs 25.60% 61 Missing :warning:
crates/torii/core/src/engine.rs 76.47% 60 Missing :warning:
bin/torii/src/main.rs 0.00% 58 Missing :warning:
...orii/core/src/processors/erc721_legacy_transfer.rs 8.82% 31 Missing :warning:
... and 8 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2494      +/-   ##
==========================================
- Coverage   68.82%   67.74%   -1.09%     
==========================================
  Files         377      388      +11     
  Lines       48930    50421    +1491     
==========================================
+ Hits        33677    34156     +479     
- Misses      15253    16265    +1012     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Oct 03 '24 14:10 codecov[bot]

to verify that this branch doesn't change world indexing.

torii.db is flippy-flop indexed on main and torii2.db is flippy-flop indexed along with 1 erc20 and 1 erc721 token.

contracts = [
    # flippyflop
    { type = "WORLD", address = "0x043cba5bc94f3ec38aee9841c8c45edf899e77ac944a88eb732b36ef3a4c2ca2" },
    # LORDS
    { type = "ERC20", address = "0x044e6bcc627e6201ce09f781d1aae44ea4c21c2fdef299e34fce55bef2d02210" },
    # LSVR
    { type = "ERC721", address = "0x0046506cccd3ffb110bc04445d25d94f1d26d645a30e6ac8a17c24e084bed08b" },
]

Screenshot 2024-10-04 at 06 52 30@2x

And also ran verify_db_balances script to check that the balances of erc20 and erc721 indexed token are correct.

itzlambda avatar Oct 04 '24 06:10 itzlambda