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 concurrency issue for RBF #4258

Merged
merged 4 commits into from
Dec 11, 2023

Conversation

chenyukang
Copy link
Collaborator

@chenyukang chenyukang commented Dec 6, 2023

What problem does this PR solve?

Problem Summary:

When multiple conflicted tx are added into txpool at the same time, because multiple threads may access same old data, resolve_tx may not resolve the conflicted tx to Dead, then check_rbf will be skipped, spec test RbfConcurrency is added to reproduce this scenario.

What is changed and how it works?

In this PR, check_rbf is moved to submit_entry, which will be guarded with a write lock, this change will make sure there is no double-spending tx in Pending, and with an extra benefit that only tx passed verify_rtx may invoke check_rbf.

What's Changed:

Related changes

  • PR to update owner/repo:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code ci-runs-only: [ quick_checks,linters ]

Side effects

  • Performance regression
  • Breaking backward compatibility

Release note

Title Only: Include only the PR title in the release note.

@chenyukang chenyukang requested a review from a team as a code owner December 6, 2023 08:44
@chenyukang chenyukang requested review from zhangsoledad and removed request for a team December 6, 2023 08:44
@chenyukang chenyukang force-pushed the yukang-fix-rbf-parallel-issue branch 2 times, most recently from abf43cf to 55b13da Compare December 6, 2023 08:52
tx-pool/src/process.rs Outdated Show resolved Hide resolved
@chenyukang chenyukang force-pushed the yukang-fix-rbf-parallel-issue branch 5 times, most recently from 3e520a5 to cc32b91 Compare December 6, 2023 09:17
tx-pool/src/component/edges.rs Show resolved Hide resolved
tx-pool/src/component/pool_map.rs Outdated Show resolved Hide resolved
tx-pool/src/process.rs Outdated Show resolved Hide resolved
@chenyukang chenyukang force-pushed the yukang-fix-rbf-parallel-issue branch 2 times, most recently from 8902947 to 903a91e Compare December 7, 2023 07:40
tx-pool/src/component/edges.rs Outdated Show resolved Hide resolved
@quake quake enabled auto-merge December 11, 2023 02:45
@quake quake added this pull request to the merge queue Dec 11, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 11, 2023
@quake quake added this pull request to the merge queue Dec 11, 2023
Merged via the queue into nervosnetwork:develop with commit ddd1309 Dec 11, 2023
31 checks passed
@doitian doitian mentioned this pull request Dec 18, 2023
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.

None yet

4 participants