Skip to content

feat(katana): trace gas usage - #3133

Merged
glihm merged 2 commits into
mainfrom
trace_gas
Apr 14, 2025
Merged

feat(katana): trace gas usage#3133
glihm merged 2 commits into
mainfrom
trace_gas

Conversation

@notV4l

@notV4l notV4l commented Mar 27, 2025

Copy link
Copy Markdown
Contributor

I think there is still some issues with gas computation, l1_data_gas is always 0.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Enhanced transaction logging now captures detailed resource metrics, including gas consumption and fee breakdowns, offering clearer insights into transaction performance.
    • Updated data mapping for gas usage ensures more accurate reporting in transaction summaries.

@coderabbitai

coderabbitai Bot commented Mar 27, 2025

Copy link
Copy Markdown
Contributor

Ohayo, sensei! Please find the detailed breakdown below.

Walkthrough

This pull request updates the logging functionality in multiple modules by modifying the log_resources function signature to accept an additional receipt parameter. The change enhances the logging details by including transaction receipt information such as fees and gas metrics. In addition, field references in the to_exec_info function have been updated from l1_data_gas to l1_gas. The overall control flows remain unchanged, with adjustments solely aimed at extending the available logging context.

Changes

File Path(s) Change Summary
crates/katana/executor/src/implementation/blockifier/mod.rs
crates/katana/executor/src/utils.rs
Modified log_resources calls and definitions to include an additional receipt parameter. The changes enhance logging by capturing detailed gas metrics and transaction fees.
crates/katana/executor/src/implementation/blockifier/utils.rs Updated field assignments in the to_exec_info function, replacing references from l1_data_gas to l1_gas for both the da_gas and gas structures.

Possibly related PRs

  • fix(katana): data gas prices #3001: The changes in the main PR are related to the modifications in the log_resources function, which is also referenced in the retrieved PR, indicating a direct connection at the code level.
  • refactor(katana): make gas oracle a critical task #2859: The changes in the main PR, which involve modifying the log_resources function to include an additional receipt parameter, are related to the changes in the retrieved PR that also involve logging enhancements, specifically in the context of gas metrics and error handling.
  • feat(katana): include more data in logs on tx flow status #2657: The changes in the main PR, which enhance the log_resources function by adding a receipt parameter, are related to the modifications in the retrieved PR that also improve logging within the execute_transactions method of the StarknetVMProcessor.

Suggested labels

contributor


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between ccf459f and 99bda1a.

📒 Files selected for processing (1)
  • crates/katana/executor/src/utils.rs (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
crates/katana/executor/src/utils.rs (2)
crates/katana/executor/src/abstraction/mod.rs (2)
  • receipt (145-150)
  • fee (76-78)
crates/katana/primitives/src/receipt.rs (1)
  • fee (170-177)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: fmt
🔇 Additional comments (1)
crates/katana/executor/src/utils.rs (1)

12-12: Function signature updated to include receipt parameter

Ohayo sensei! Good modification to the function signature by adding the receipt parameter. This change enables the function to access transaction fee and gas information, which aligns perfectly with the PR objective of tracing gas usage.


🪧 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 plan to trigger planning for file edits and PR creation.
  • @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 coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ecf6889 and 0d6bfdb.

📒 Files selected for processing (3)
  • crates/katana/executor/src/implementation/blockifier/mod.rs (1 hunks)
  • crates/katana/executor/src/implementation/blockifier/utils.rs (1 hunks)
  • crates/katana/executor/src/utils.rs (2 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
crates/katana/executor/src/implementation/blockifier/mod.rs (2)
crates/katana/executor/src/utils.rs (1)
  • log_resources (12-43)
crates/katana/executor/src/abstraction/mod.rs (2)
  • trace (153-158)
  • receipt (145-150)
🪛 GitHub Actions: ci
crates/katana/executor/src/utils.rs

[error] 24-24: Rust formatting check failed. Run 'rustfmt' to fix code style issues in this file.

🔇 Additional comments (4)
crates/katana/executor/src/implementation/blockifier/mod.rs (1)

253-253: Ohayo! Updated function call to pass receipt to log_resources

The function call has been properly updated to match the new signature of log_resources which now accepts an additional receipt parameter. This change enhances the logging functionality by providing more detailed gas usage information.

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

590-590: Field mapping corrected for data availability gas

Good change, sensei! You've updated the field reference from l1_data_gas to l1_gas to correctly map the data availability gas metrics. This ensures accurate gas usage reporting.


594-594: Field mapping corrected for total gas consumed

Consistent with the previous change, you've properly updated the field reference for total gas consumed from l1_data_gas to l1_gas. This ensures all gas metrics are correctly tracked and reported.

crates/katana/executor/src/utils.rs (1)

12-12: Function signature updated to include receipt parameter

Ohayo! You've correctly updated the function signature to include the additional receipt parameter, which allows accessing fee and gas consumption data for enhanced logging.

Comment thread crates/katana/executor/src/utils.rs
@codecov

codecov Bot commented Mar 27, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.62%. Comparing base (35ace89) to head (99bda1a).
Report is 23 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3133      +/-   ##
==========================================
- Coverage   56.87%   55.62%   -1.25%     
==========================================
  Files         442      443       +1     
  Lines       61505    62976    +1471     
==========================================
+ Hits        34979    35033      +54     
- Misses      26526    27943    +1417     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kariy kariy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

tbh not a really a fan of logging out the tx resources.. i think that's what the starknet_getReceipt rpc is for.

it make sense for local dev when there's only a few txs at a time, but when there's a bunch of txs coming in, the logs just become noise (and a waste of computation). it's fine for now tho, but i'll try to come up with a better solution in the new katana repo.

Comment on lines -590 to +594
l1_gas: exec_info.transaction_receipt.da_gas.l1_data_gas,
l1_gas: exec_info.transaction_receipt.da_gas.l1_gas,
l1_data_gas: exec_info.transaction_receipt.da_gas.l1_data_gas,
},
total_gas_consumed: L1Gas {
l1_gas: exec_info.transaction_receipt.gas.l1_data_gas,
l1_gas: exec_info.transaction_receipt.gas.l1_gas,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice catch on this

@glihm
glihm enabled auto-merge (squash) April 14, 2025 20:35
@glihm

glihm commented Apr 14, 2025

Copy link
Copy Markdown
Contributor

tbh not a really a fan of logging out the tx resources.. i think that's what the starknet_getReceipt rpc is for.

it make sense for local dev when there's only a few txs at a time, but when there's a bunch of txs coming in, the logs just become noise (and a waste of computation). it's fine for now tho, but i'll try to come up with a better solution in the new katana repo.

Maybe if the --dev is enabled, only then the log may happen. But generally agree with your take, and thanks for the flexibility on it. Let's get this for current debug and as you mentioned let's on the new repo what could be done there. 👍

@glihm
glihm merged commit cb2ee12 into main Apr 14, 2025
@glihm
glihm deleted the trace_gas branch April 14, 2025 20:58
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.

3 participants