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(mempool): provide finalize result for invalid transactions #1307

Conversation

sdbondi
Copy link
Member

@sdbondi sdbondi commented Feb 24, 2025

Description

fix(mempool): provide finalize result for invalid transactions

Motivation and Context

If an invalid transaction is submitted to the mempool, the final execution result is not set. This causes the queried result of the transaction to still be pending. This PR creates an execution result for the invalid transaction.

How Has This Been Tested?

Submitting a transaction that calls a non-existant template.

What process can a PR reviewer use to test or verify this change?

As above

Breaking Changes

  • None
  • Requires data directory to be deleted
  • Other - Please specify

Summary by CodeRabbit

  • New Features
    • Introduced an enhanced transaction finalization mechanism that provides more consistent handling of failed validations, ensuring improved management of error states.
  • Refactor
    • Refined system logging to offer clearer, more nuanced operational feedback during runtime processes.

Copy link

coderabbitai bot commented Feb 24, 2025

Walkthrough

This update refines logging and transaction error handling. In the mempool service, the log message now indicates conditional unsubscription and the transaction handler replaces a direct abort call with abort_and_finalize. A new public method has been added to the transaction record, encapsulating abort logic and updating execution details without changing the core service logic.

Changes

File(s) Change Summary
applications/.../mempool/service.rs Updated log message in the run method for conditional unsubscription; replaced abort with abort_and_finalize in handle_new_transaction.
dan_layer/.../transaction.rs Added a new public method abort_and_finalize in the TransactionRecord struct that encapsulates abort logic and updates execution result fields.

Sequence Diagram(s)

sequenceDiagram
    participant MS as MempoolService
    participant TR as TransactionRecord
    MS->>TR: handle_new_transaction(invalidTx)
    Note right of TR: Replace abort() with abort_and_finalize(reason)
    TR->>TR: call abort(reason)
    TR->>TR: Update execution_result, final_decision, and finalized_time
    TR-->>MS: Return updated TransactionRecord
Loading

Poem

In the digital garden, I hop with glee,
Logs now whisper possibilities conditionally.
Transactions end with a graceful, final twist,
A method reborn, hard to resist!
My bunny heart leaps through each refined byte,
Celebrating code carrots in pixel light! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aad784a and 9915767.

📒 Files selected for processing (2)
  • applications/tari_validator_node/src/p2p/services/mempool/service.rs (2 hunks)
  • dan_layer/storage/src/consensus_models/transaction.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: test
  • GitHub Check: machete
  • GitHub Check: check stable
  • GitHub Check: check nightly
  • GitHub Check: clippy
🔇 Additional comments (3)
dan_layer/storage/src/consensus_models/transaction.rs (1)

178-191: LGTM! The implementation correctly finalizes invalid transactions.

The new abort_and_finalize method effectively combines abort and finalize operations, ensuring that invalid transactions have their execution result and final decision properly set. This addresses the PR objective of fixing the issue where invalid transactions in the mempool don't have a final execution result set.

applications/tari_validator_node/src/p2p/services/mempool/service.rs (2)

108-108: LGTM! Improved log message clarity.

The updated log message better reflects that unsubscription from gossip is conditional.


230-233: LGTM! Properly finalizes invalid transactions.

The change from abort to abort_and_finalize ensures that invalid transactions have their final execution result set, which aligns with the PR objective.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

Test Results (CI)

617 tests  ±0   617 ✅ +1   3h 37m 13s ⏱️ - 20m 23s
 67 suites ±0     0 💤 ±0 
  2 files   ±0     0 ❌  - 1 

Results for commit 9915767. ± Comparison against base commit aad784a.

@sdbondi sdbondi merged commit 9f882b0 into tari-project:development Feb 24, 2025
14 checks passed
sdbondi added a commit to ksrichard/tari-dan that referenced this pull request Feb 25, 2025
* development:
  fix(mempool): provide finalize result for invalid transactions (tari-project#1307)
  fix(wallet): correct version for vaults in substates table (tari-project#1308)
  fix(indexer): list_substates can also list nfts (tari-project#1302)
  chore(bindings): update package.lock (tari-project#1306)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants