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

feat(katana): revert blockifier bump #2979

Merged
merged 4 commits into from
Feb 1, 2025
Merged

Conversation

kariy
Copy link
Member

@kariy kariy commented Jan 31, 2025

This is essentially branch blockifier:blockifier/v0.8.0-rc3 (what we're using prior to #2879) but with Cairo dependencies bumped to version 2.9.2.

The current version of blockifier that we're using, includes extra stuff that are not expected in the v0.13.3 version. This may results in different computed fees for some transactions when they are compared with the snos Cairo program.

Reason for this downgrade is to ensure transactions and fees are being computed similarly in both snos and katana. But mainly in snos as it performs the computation twice - (1) computed using blockifier where the outputs are used as the 'predicted' values for the Cairo program run, and (2) the Cairo program also execute the transactions again and will

@kariy kariy changed the title feat(blockifier): downgrade to previous version feat(katana): revert blockifier bump Jan 31, 2025
Copy link

coderabbitai bot commented Jan 31, 2025

Walkthrough

Ohayo, sensei! This pull request introduces several interconnected changes across the Katana project, focusing on dependency updates, gas price handling, and transaction processing. The modifications span multiple crates, including core executor, primitives, and RPC-related components. Key updates involve switching from specific commit references to newer commit references for dependencies, refining gas price calculations to ensure non-zero values, and updating entry point type representations to streamline the conversion processes.

Changes

File Change Summary
crates/katana/cairo/Cargo.toml Updated starknet_api dependency from rev = "802c5dc" to rev = "adae779"
crates/katana/core/src/backend/gas_oracle.rs Modified sampled_starknet() to return GasPrices { eth: 1, strk: 1 }, removed zero() method
crates/katana/core/tests/backend.rs Updated GasOracle instantiation from zero() to sampled_starknet()
crates/katana/executor/Cargo.toml Updated blockifier dependency from rev = "802c5dc" to rev = "adae779"
crates/katana/executor/src/implementation/blockifier/error.rs Modified error handling for ExecutionFailed variant
crates/katana/executor/src/implementation/blockifier/mod.rs Updated gas price handling to use NonZeroU128 and streamlined assignments
crates/katana/executor/src/implementation/blockifier/state.rs Changed get_compiled_class to get_compiled_contract_class, updated return type
crates/katana/executor/src/implementation/blockifier/utils.rs Altered transact function signature and refined transaction execution logic
crates/katana/pool/src/validation/stateful.rs Updated transaction validation logic and error handling
crates/katana/primitives/src/block.rs Added new Default implementation for GasPrices with non-zero values
crates/katana/primitives/src/conversion/rpc.rs Replaced EntryPointV0 with EntryPoint in entry point conversions
crates/katana/rpc/rpc-types/src/class.rs Updated entry point type in RpcLegacyContractClass

Sequence Diagram

sequenceDiagram
    participant Executor
    participant StateReader
    participant TransactionPool
    participant BlockInfo

    Executor->>StateReader: Request compiled contract class
    StateReader-->>Executor: Return contract class
    Executor->>TransactionPool: Validate transaction
    TransactionPool->>BlockInfo: Check gas prices
    BlockInfo-->>TransactionPool: Provide non-zero gas prices
    TransactionPool-->>Executor: Transaction validation result
Loading

The sequence diagram illustrates the updated flow of transaction execution, highlighting the changes in gas price handling and contract class retrieval across different components of the Katana system.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4cb0210 and 4440856.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • crates/katana/cairo/Cargo.toml (1 hunks)
  • crates/katana/executor/Cargo.toml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/katana/cairo/Cargo.toml
  • crates/katana/executor/Cargo.toml
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: fmt

🪧 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 (1)
crates/katana/executor/src/implementation/blockifier/state.rs (1)

53-54: Consider implementing the TODO comment for cache management.

The TODO comment suggests implementing class compilation caching at the executor level. This could improve performance by avoiding redundant compilations.

Would you like me to help implement a caching mechanism for compiled classes at the executor level?

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f4b733d and 4cb0210.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (12)
  • crates/katana/cairo/Cargo.toml (1 hunks)
  • crates/katana/core/src/backend/gas_oracle.rs (1 hunks)
  • crates/katana/core/tests/backend.rs (1 hunks)
  • crates/katana/executor/Cargo.toml (1 hunks)
  • crates/katana/executor/src/implementation/blockifier/error.rs (2 hunks)
  • crates/katana/executor/src/implementation/blockifier/mod.rs (4 hunks)
  • crates/katana/executor/src/implementation/blockifier/state.rs (5 hunks)
  • crates/katana/executor/src/implementation/blockifier/utils.rs (18 hunks)
  • crates/katana/pool/src/validation/stateful.rs (2 hunks)
  • crates/katana/primitives/src/block.rs (2 hunks)
  • crates/katana/primitives/src/conversion/rpc.rs (2 hunks)
  • crates/katana/rpc/rpc-types/src/class.rs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: fmt
🔇 Additional comments (26)
crates/katana/cairo/Cargo.toml (1)

21-21: Verify the compatibility of starknet_api branch with Cairo 2.9.2.

Ohayo, sensei! The dependency has been updated to use a specific branch targeting blockifier v0.8.0-rc3 with Cairo 2.9.1, but the PR description mentions Cairo 2.9.2.

Let's verify the compatibility:

✅ Verification successful

Branch content is compatible with Cairo 2.9.2 despite the misleading name

Ohayo, sensei! While the branch name suggests Cairo 2.9.1, I've verified that the actual dependencies in the branch's Cargo.toml are using Cairo 2.9.2, so it's fully compatible! 🎉

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check the Cairo version in the specified branch
curl -s "https://raw.githubusercontent.com/dojoengine/sequencer/blockifier/v0.8.0-rc3_cairo-2.9.1/Cargo.toml" | grep -A 5 "cairo-lang"

Length of output: 372

crates/katana/executor/Cargo.toml (1)

18-18: Ensure consistent branch references across dependencies.

Ohayo again, sensei! The blockifier dependency is now using the same branch as starknet_api, which is good for consistency.

crates/katana/primitives/src/conversion/rpc.rs (2)

8-8: LGTM! Import changes align with the downgrade.

The import changes correctly reflect the move from EntryPointV0 to EntryPoint.


37-37: Verify function signature changes are consistent.

The changes to to_rpc_entry_points and collect_entry_points signatures align with the downgrade.

Let's check for any missed references:

Also applies to: 40-40

✅ Verification successful

Ohayo sensei! Function signatures are consistent across the codebase

The changes to both to_rpc_entry_points and collect_entry_points are properly aligned, with consistent usage of EntryPoint type throughout the conversion flow.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining EntryPointV0 references
rg "EntryPointV0" -A 2

Length of output: 22


Script:

#!/bin/bash
# Search for the specific functions and their usage
rg "to_rpc_entry_points|collect_entry_points" -A 3

# Also search for EntryPoint type usage
ast-grep --pattern 'EntryPoint'

Length of output: 1933

crates/katana/rpc/rpc-types/src/class.rs (1)

10-10: LGTM! Type changes are consistent with the downgrade.

The changes to use EntryPoint instead of EntryPointV0 in both the imports and struct definition are consistent with the changes in other files.

Also applies to: 129-129

crates/katana/executor/src/implementation/blockifier/utils.rs (6)

2-44: Ohayo sensei, your newly introduced imports look consistent!
They cleanly manage references for NonZeroU128, BlockInfo, GasPrices, ExecutionMode, and the rest. Everything aligns well with the subsequent usage below.


66-120: Ohayo sensei, nice addition of simulation_flags!
Extracting validate, charge_fee, and nonce_check from simulation_flags is logical. Please ensure there's adequate test coverage for these scenarios so no corner case is missed.


154-177: Ohayo sensei, verify resource limiting logic.
The TODO note about setting limit_steps_by_resources to false if fees are disabled is key. Confirm that fee-less modes won't trigger resource constraints inadvertently.

Sensei, let me know if you'd like a quick script to locate all references to limit_steps_by_resources so we can confirm there's no oversight.


Line range hint 182-373: Ohayo sensei, transaction conversion logic is well-structured!
Distinct handling for InvokeTx, DeployAccountTx, DeclareTx, and L1HandlerTx looks consistent. Keeping only_query: false uniform across cases is a nice touch.


Line range hint 395-529: Ohayo sensei, good fallback for zero gas prices.
Using unwrap_or(NonZeroU128::new(1).unwrap()) protects against invalid zero values. If you foresee dynamic fallback needs, ensure it’s documented and tested.


Line range hint 536-807: Ohayo sensei, well-rounded helper functions and thorough tests!
get_fee_type_from_tx neatly categorizes fee types, and the expansions in to_class ensure correct class info for fee calculations. The nested event test approach is commendable.

crates/katana/core/tests/backend.rs (1)

39-39: Ohayo sensei, switching from GasOracle::zero to GasOracle::sampled_starknet is a solid move!
This ensures realistic non-zero gas prices during tests, mirroring the production environment more closely.

crates/katana/executor/src/implementation/blockifier/error.rs (1)

2-2: Ohayo sensei, enhanced error reporting with format_panic_data.
Generating more detailed info for ExecutionFailed eases debugging. Ensure the underlying error_data never includes sensitive data in case it's displayed publicly.

Also applies to: 35-36

crates/katana/pool/src/validation/stateful.rs (1)

169-170: LGTM! Transaction type handling has been updated.

The changes correctly adapt to the new transaction type variants from the blockifier downgrade.

Also applies to: 181-181

crates/katana/executor/src/implementation/blockifier/mod.rs (4)

8-14: LGTM! Import changes reflect the new gas price handling.

The imports have been updated to use NonZeroU128 and simplified block-related imports.


105-111: Ohayo, sensei! Gas price handling has been improved.

The changes ensure that gas prices are never zero by defaulting to 1, which aligns with the blockifier's behavior.


113-115: Consider addressing the TODO comments.

These TODOs might need attention for better state management.

Would you like me to help implement functions for altering the block context?


123-126: LGTM! Gas price assignments are consistent.

The gas price assignments in both the block info and block environment are now consistent.

Also applies to: 231-244

crates/katana/core/src/backend/gas_oracle.rs (1)

68-68: LGTM! Gas prices now default to 1.

The change ensures consistency with the blockifier's behavior of requiring non-zero gas prices.

crates/katana/primitives/src/block.rs (2)

57-58: LGTM! Documentation clarifies gas price requirements.

The TODO comment effectively explains the rationale for non-zero gas prices.

Also applies to: 60-60


78-82: LGTM! Default implementation ensures non-zero gas prices.

The implementation aligns with blockifier's requirements by defaulting to 1 instead of 0.

crates/katana/executor/src/implementation/blockifier/state.rs (5)

49-62: Ohayo! The method signature change aligns with the blockifier downgrade.

The change from get_compiled_class to get_compiled_contract_class with the new return type ContractClass reflects the downgrade to blockifier v0.8.0-rc3. The implementation correctly handles error cases and maintains proper error propagation.


220-224: LGTM! Consistent implementation in CachedState.

The CachedState implementation correctly delegates to the inner state, maintaining consistency with the updated method signature.


353-369: Test cases properly validate the new contract class behavior, sensei!

The test cases have been updated to use the new method name and verify both regular and legacy class handling. The assertions correctly validate the contract class conversion and compilation.


425-432: Test setup properly handles class conversion.

The test setup correctly uses utils::to_class followed by contract_class() to match the new implementation's behavior.


545-545: Error case testing is properly updated.

The test for non-existent data correctly verifies the error case with the new method name.

Copy link

codecov bot commented Feb 1, 2025

Codecov Report

Attention: Patch coverage is 88.62559% with 24 lines in your changes missing coverage. Please review.

Project coverage is 57.01%. Comparing base (a9e65a3) to head (ee8963e).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...na/executor/src/implementation/blockifier/utils.rs 86.07% 22 Missing ⚠️
...na/executor/src/implementation/blockifier/error.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2979      +/-   ##
==========================================
- Coverage   57.04%   57.01%   -0.03%     
==========================================
  Files         425      425              
  Lines       56301    56185     -116     
==========================================
- Hits        32115    32033      -82     
+ Misses      24186    24152      -34     

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

@kariy kariy merged commit 12d9c8d into main Feb 1, 2025
15 checks passed
@kariy kariy deleted the katana/downgrade-blockifier branch February 1, 2025 13:12
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.

1 participant