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): only update curor when required #2438

Merged
merged 1 commit into from
Sep 17, 2024
Merged

Conversation

lambda-0x
Copy link
Contributor

@lambda-0x lambda-0x commented Sep 17, 2024

Summary by CodeRabbit

  • New Features
    • Introduced new methods for managing last pending block transactions, enhancing transaction state management.
  • Bug Fixes
    • Simplified the set_head method to improve clarity and focus on updating the blockchain head.
  • Refactor
    • Refactored transaction handling for better modularity and maintainability.

Copy link

coderabbitai bot commented Sep 17, 2024

Walkthrough

Ohayo, sensei! The changes in this pull request focus on refactoring the set_head method in the engine.rs and sql.rs files. The set_head method has been simplified by removing unnecessary parameters related to pending transactions, and two new methods have been introduced for handling last pending block transactions independently. This restructuring aims to enhance the clarity and modularity of the code, particularly in managing blockchain state updates.

Changes

Files Change Summary
crates/torii/core/src/engine.rs Simplified set_head method calls by removing pending transaction parameters; refactored handling of last pending transactions.
crates/torii/core/src/sql.rs Refactored set_head to focus solely on updating the head field; added methods for updating last pending transactions separately.

Possibly related PRs


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 generate interesting stats about this repository and render them as a table.
    -- @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.
Early access features: enabled

We are currently testing the following features in early access:

  • OpenAI o1 for code reviews: OpenAI's new o1 model is being tested for generating code suggestions in code reviews.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b391948 and d6ebe9e.

Files selected for processing (2)
  • crates/torii/core/src/engine.rs (4 hunks)
  • crates/torii/core/src/sql.rs (1 hunks)
Additional comments not posted (3)
crates/torii/core/src/engine.rs (2)

429-438: Maintain consistency in awaiting database operations

Please ensure that you await all asynchronous database method calls here as well to prevent any potential issues.


478-481: Efficiently reset pending transaction pointers

Great work resetting the pending transaction pointers after processing the range data. This keeps the system state clean and prevents stale data from causing issues. Keep it up, sensei!

crates/torii/core/src/sql.rs (1)

113-121: Ohayo, sensei! Simplified set_head method looks good

The refactoring of the set_head method to update only the head field enhances code clarity and adheres to the single-responsibility principle.

Please ensure that all calls to set_head in the codebase have been updated to match the new signature.

Run the following script to find any outdated usage:

Verification successful

Ohayo, sensei! It seems our previous attempt didn't yield the results we were looking for. Let's dig a bit deeper to make sure we're not missing anything. I'll run a few more scripts to gather more information about the set_head usage in our codebase.


Ohayo, sensei! I've got some good news for you about our set_head method!

All set_head usages are up-to-date and consistent with the new signature

After a thorough investigation of the codebase, I can confirm that all calls to set_head are using the new signature with a single argument. Here's a quick summary of what I found:

  • The set_head method is defined in crates/torii/core/src/sql.rs with the signature pub fn set_head(&mut self, head: u64).
  • There are four usages of set_head in crates/torii/core/src/engine.rs, all of which use a single argument.
  • No outdated usages or comments suggesting recent changes were found.

It looks like our codebase is in perfect harmony with the new set_head implementation. Great job on maintaining consistency!

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all function calls to `set_head` with the old signature (more than one argument).

# Search for calls to `set_head` with multiple arguments.
ast-grep --lang rust --pattern 'set_head($_, $_)'

Length of output: 51


Script:

#!/bin/bash
# Search for any usage of set_head
echo "Searching for set_head usage:"
rg "set_head" -n

# Look for the definition of set_head
echo -e "\nSearching for set_head definition:"
ast-grep --lang rust --pattern 'fn set_head($$$)'

# Search for comments mentioning set_head
echo -e "\nSearching for comments mentioning set_head:"
rg "set_head" -n --type-add 'rust:*.rs' --type rust -g '!target' --multiline --context 2

Length of output: 3439

crates/torii/core/src/engine.rs Show resolved Hide resolved
crates/torii/core/src/engine.rs Show resolved Hide resolved
crates/torii/core/src/sql.rs Show resolved Hide resolved
Copy link

codecov bot commented Sep 17, 2024

Codecov Report

Attention: Patch coverage is 58.53659% with 17 lines in your changes missing coverage. Please review.

Project coverage is 68.21%. Comparing base (b391948) to head (d6ebe9e).

Files with missing lines Patch % Lines
crates/torii/core/src/engine.rs 19.04% 17 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2438   +/-   ##
=======================================
  Coverage   68.20%   68.21%           
=======================================
  Files         365      365           
  Lines       48002    48022   +20     
=======================================
+ Hits        32742    32757   +15     
- Misses      15260    15265    +5     

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

Copy link
Collaborator

@Larkooo Larkooo left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@Larkooo Larkooo merged commit 21ec45e into main Sep 17, 2024
14 of 15 checks passed
@Larkooo Larkooo deleted the spr/main/6ff455c9 branch September 17, 2024 11:06
@kariy kariy mentioned this pull request Sep 19, 2024
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