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): include more data in logs on tx flow status #2657

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

kariy
Copy link
Member

@kariy kariy commented Nov 7, 2024

easier to understand why and which tx fails

Summary by CodeRabbit

  • New Features

    • Enhanced logging for transaction execution and validation, including transaction hashes for better tracking.
  • Bug Fixes

    • Improved clarity in logging statements related to transaction handling and errors within the pool.
  • Documentation

    • Added comments to clarify gas price handling and potential future enhancements.

Copy link

coderabbitai bot commented Nov 7, 2024

Walkthrough

Ohayo, sensei! This pull request introduces enhancements primarily focused on logging within the blockifier and pool modules. The execute_transactions method in the StarknetVMProcessor now logs transaction hashes for better clarity during execution and reversion. Additionally, the add_transaction method in the Pool struct has updated logging statements to include a target parameter, improving the categorization of transaction-related logs. Comments in the fill_block_env_from_header method suggest future enhancements regarding gas price handling.

Changes

File Path Change Summary
crates/katana/executor/src/implementation/blockifier/mod.rs - Updated execute_transactions method to log transaction hashes.
- Modified fill_block_env_from_header method to clarify gas price handling with updated comments.
crates/katana/pool/src/pool.rs - Enhanced logging in add_transaction method to include a target parameter for better log categorization.

Possibly related PRs

  • refactor(katana): remove events trace log #2570: This PR modifies the blockifier module, specifically the StarknetVMProcessor, which is directly related to the changes made in the main PR regarding logging enhancements in the execute_transactions method.
  • feat(katana): retain transactions in pool until mined #2630: This PR addresses transaction visibility in the pool, which is relevant to the execute_transactions method's logging improvements in the main PR, as both involve transaction handling and processing within the executor context.

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

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

🧹 Outside diff range and nitpick comments (4)
crates/katana/executor/src/implementation/blockifier/mod.rs (2)

194-194: Excellent logging enhancement, sensei!

The log message structure is well-formed with proper hex formatting. Consider extracting the format string "{hash:#x}" into a constant if it's used in multiple places for consistency.


Line range hint 91-92: Track gas price handling TODOs, sensei!

The TODOs raise important points about:

  1. Gas price enforcement
  2. L1 data gas price values
  3. Potential function alterations for block context

Would you like me to create GitHub issues to track these improvements?

Also applies to: 96-97, 100-103

crates/katana/pool/src/pool.rs (2)

167-167: Excellent addition of nonce context, sensei!

The inclusion of both transaction and current nonce values provides clear visibility into dependency issues. Consider adding this information to a metrics system in the future for better monitoring of nonce-related issues.


Line range hint 140-180: Consider adopting structured logging for better observability, sensei!

While the current logging improvements are excellent, consider adopting a more structured logging approach in the future. This could involve:

  1. Using consistent field names across log messages
  2. Adding common fields like pool_size
  3. Structuring error details in a machine-parseable format

This would enhance log aggregation and analysis capabilities.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between dddac32 and 5389dd0.

📒 Files selected for processing (2)
  • crates/katana/executor/src/implementation/blockifier/mod.rs (3 hunks)
  • crates/katana/pool/src/pool.rs (3 hunks)
🔇 Additional comments (4)
crates/katana/executor/src/implementation/blockifier/mod.rs (1)

184-184: Ohayo! Clean variable extraction, sensei!

The hash extraction is well-placed and follows good practices for improving log context.

crates/katana/pool/src/pool.rs (3)

140-140: Ohayo! LGTM on the transaction received log enhancement, sensei!

Adding the "pool" target parameter improves log categorization and filtering capabilities.


160-160: Nice enhancement to invalid transaction logging, sensei!

The addition of error details alongside the transaction hash provides better context for debugging invalid transactions.


178-180: Well-structured error handling and logging, sensei!

The pattern matching ensures the hash is available, and the error context provides valuable debugging information for validation failures.

@@ -201,7 +202,7 @@ impl<'a> BlockExecutor<'a> for StarknetVMProcessor<'a> {
}

ExecutionResult::Failed { error } => {
info!(target: LOG_TARGET, %error, "Executing transaction.");
info!(target: LOG_TARGET, hash = format!("{hash:#x}"), %error, "Executing transaction.");
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Adjust the log message for failed transactions, sensei!

The message "Executing transaction" doesn't accurately reflect that this is a failure case. Consider updating it to something more descriptive like "Transaction execution failed".

-                    info!(target: LOG_TARGET, hash = format!("{hash:#x}"), %error, "Executing transaction.");
+                    info!(target: LOG_TARGET, hash = format!("{hash:#x}"), %error, "Transaction execution failed.");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
info!(target: LOG_TARGET, hash = format!("{hash:#x}"), %error, "Executing transaction.");
info!(target: LOG_TARGET, hash = format!("{hash:#x}"), %error, "Transaction execution failed.");

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

Attention: Patch coverage is 44.44444% with 5 lines in your changes missing coverage. Please review.

Project coverage is 57.45%. Comparing base (c364d13) to head (5389dd0).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
crates/katana/pool/src/pool.rs 50.00% 3 Missing ⚠️
...tana/executor/src/implementation/blockifier/mod.rs 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2657      +/-   ##
==========================================
- Coverage   57.46%   57.45%   -0.01%     
==========================================
  Files         400      400              
  Lines       49963    49954       -9     
==========================================
- Hits        28709    28703       -6     
+ Misses      21254    21251       -3     

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

@kariy kariy merged commit ed8f546 into main Nov 7, 2024
13 of 14 checks passed
@kariy kariy deleted the katana/pool-log branch November 7, 2024 20:59
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