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

change(mempool): Return verification result after attempting to insert transactions in the mempool #8901

Merged

Conversation

arya2
Copy link
Contributor

@arya2 arya2 commented Sep 30, 2024

Motivation

We want to return a verification result from the mempool after a transaction has been inserted into its verified set (or has failed some final checks in the mempool).

Solution

  • Moves timeout from mempool to mempool's Download struct
  • Sends the final result to the response channel after attempting to insert a transaction into the mempool storage instead of after a transaction is successfully verified

Tests

Updates the mempool_responds_to_await_output test to expect the mempool storage to include a transaction immediately after receiving its verification result.

PR Author's Checklist

  • The PR name will make sense to users.
  • The PR provides a CHANGELOG summary.
  • The solution is tested.
  • The documentation is up to date.
  • The PR has a priority label.

PR Reviewer's Checklist

  • The PR Author's checklist is complete.
  • The PR resolves the issue.

@arya2 arya2 added C-cleanup Category: This is a cleanup I-usability Zebra is hard to understand or use A-concurrency Area: Async code, needs extra work to make it work properly. A-mempool Area: Memory pool transactions P-Low ❄️ labels Sep 30, 2024
@arya2 arya2 self-assigned this Sep 30, 2024
@github-actions github-actions bot added the C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG label Sep 30, 2024
@arya2 arya2 requested a review from conradoplg September 30, 2024 22:55
@mpguerra
Copy link
Contributor

mpguerra commented Oct 1, 2024

Is there a related issue for this PR?

@arya2
Copy link
Contributor Author

arya2 commented Oct 9, 2024

Is there a related issue for this PR?

It's related to #8778.

Zebra began returning errors from the sendrawtransaction RPC method when verifying the transaction fails or was cancelled in #8788, but in one of the tests for #8857, we noticed that it sends the success response too early because:

  • There are duplicate spend and mempool size checks that could still fail, or
  • Re-verifying the transaction could fail if the chain tip changes during verification and the update best chain spends or reveals relevant outputs or nullifiers.

@oxarbitrage oxarbitrage added the do-not-merge Tells Mergify not to merge this PR label Oct 10, 2024
@mpguerra
Copy link
Contributor

Do we still want to do this one? Otherwise we should just close for now

Base automatically changed from verify-orphaned-mempool-txs to main November 18, 2024 12:16
@mpguerra mpguerra removed the do-not-merge Tells Mergify not to merge this PR label Nov 18, 2024
@arya2 arya2 force-pushed the mempool-verification-errors branch from b3b88b4 to 7c4ad87 Compare November 19, 2024 06:17
@arya2 arya2 changed the base branch from main to avoid-reverifying-mined-mempool-txs November 19, 2024 06:18
@arya2 arya2 force-pushed the avoid-reverifying-mined-mempool-txs branch from e1a3691 to e0861ec Compare November 22, 2024 19:53
@arya2 arya2 force-pushed the mempool-verification-errors branch from 7c4ad87 to 89a747a Compare November 22, 2024 23:54
@arya2 arya2 marked this pull request as ready for review November 22, 2024 23:54
@arya2 arya2 requested review from a team as code owners November 22, 2024 23:54
@arya2 arya2 requested review from oxarbitrage and removed request for a team November 22, 2024 23:54
@arya2
Copy link
Contributor Author

arya2 commented Nov 23, 2024

Do we still want to do this one? Otherwise we should just close for now

We should still do it, it's ready for review now it makes it easier to debug the sendrawtransaction method (the branch has already been used to rule out a possible category of bug here).

@mpguerra mpguerra linked an issue Nov 25, 2024 that may be closed by this pull request
@arya2 arya2 removed the C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG label Nov 29, 2024
Copy link
Contributor

@oxarbitrage oxarbitrage 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, thanks.

@mpguerra
Copy link
Contributor

mpguerra commented Dec 2, 2024

@mergify queue

Copy link
Contributor

mergify bot commented Dec 2, 2024

queue

🟠 Waiting for conditions to match

  • -closed [📌 queue requirement]
  • any of: [🔀 queue conditions]
    • all of: [📌 queue conditions of queue batched]
      • base=main
    • all of: [📌 queue conditions of queue urgent]
      • base=main
  • -conflict [📌 queue requirement]
  • -draft [📌 queue requirement]
  • any of: [📌 queue -> configuration change requirements]
    • -mergify-configuration-changed
    • check-success = Configuration changed
  • any of: [📌 queue requirement]
    • check-neutral = Mergify Merge Protections
    • check-skipped = Mergify Merge Protections
    • check-success = Mergify Merge Protections

@mpguerra mpguerra merged commit 9eb8a99 into avoid-reverifying-mined-mempool-txs Dec 2, 2024
143 checks passed
@mpguerra mpguerra deleted the mempool-verification-errors branch December 2, 2024 09:46
arya2 added a commit that referenced this pull request Dec 3, 2024
…t transactions in the mempool (#8901)

* respond with mempool verification result after a transaction has been inserted or has failed to be inserted into the mempool

* returns mempool verification errors early, and fixes handling for cancellations or timeouts.

* Adds a comment in test warning against code reuse with buffered services.
mergify bot pushed a commit that referenced this pull request Dec 4, 2024
…t transactions in the mempool (#9067)

* change(mempool): Return verification result after attempting to insert transactions in the mempool (#8901)

* respond with mempool verification result after a transaction has been inserted or has failed to be inserted into the mempool

* returns mempool verification errors early, and fixes handling for cancellations or timeouts.

* Adds a comment in test warning against code reuse with buffered services.

* De-duplicates handling for timeout errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-concurrency Area: Async code, needs extra work to make it work properly. A-mempool Area: Memory pool transactions C-cleanup Category: This is a cleanup I-usability Zebra is hard to understand or use P-Low ❄️
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return verification errors from sendrawtransaction RPC method
3 participants