Page MenuHomePhabricator

[validation] de-duplicate package transactions already in mempool
ClosedPublic

Authored by PiRK on Nov 14 2022, 09:51.

Details

Summary

As node operators are free to set their mempool policies however they
please, it's possible for package transaction(s) to already be in the
mempool. We definitely don't want to reject the entire package in that
case (as that could be a censorship vector).

We should still return the successful result to the caller, so add
another result type to MempoolAcceptResult.

This concludes backport of core#22674
https://github.com/bitcoin/bitcoin/pull/22674/commits/e12fafda2dfbbdf63f125e5af797ecfaa6488f66
https://github.com/bitcoin/bitcoin/pull/22674/commits/046e8ff264be6b888c0f9a9d822e32aa74e19b78 (partial)

Depends on D12480

Notes:

  • because eCash does not have RBF, our constructor for MempoolAcceptResult (success case) would have the exact same signature as the new constructor (already-in-mempool). So in stead of adding a new constructor I made the existing one more generic to handle both cases. The rest of the codebase does not directly call this constructor, it always uses either MempoolAcceptResult::MempoolTx or MempoolAcceptResult::Success.
  • We do not need to handle the same-txid-diff-wtxid case, so the code in AcceptPackage is simplified for Bitcoin ABC.
Test Plan

ninja all check-all

Event Timeline

PiRK requested review of this revision.Nov 14 2022, 09:51
Fabien added inline comments.
src/validation.cpp
1093 ↗(On Diff #36267)

See question in D12480, the same applies here

Tail of the build log:

wallet_importmulti.py                     | ✓ Passed  | 5 s
wallet_importprunedfunds.py               | ✓ Passed  | 2 s
wallet_importprunedfunds.py --descriptors | ✓ Passed  | 3 s
wallet_keypool.py                         | ✓ Passed  | 3 s
wallet_keypool_topup.py                   | ✓ Passed  | 4 s
wallet_keypool_topup.py --descriptors     | ✓ Passed  | 5 s
wallet_labels.py                          | ✓ Passed  | 2 s
wallet_labels.py --descriptors            | ✓ Passed  | 2 s
wallet_listreceivedby.py                  | ✓ Passed  | 8 s
wallet_listsinceblock.py                  | ✓ Passed  | 6 s
wallet_listsinceblock.py --descriptors    | ✓ Passed  | 8 s
wallet_listtransactions.py                | ✓ Passed  | 4 s
wallet_listtransactions.py --descriptors  | ✓ Passed  | 3 s
wallet_multiwallet.py                     | ✓ Passed  | 18 s
wallet_multiwallet.py --usecli            | ✓ Passed  | 16 s
wallet_reorgsrestore.py                   | ✓ Passed  | 5 s
wallet_resendwallettransactions.py        | ✓ Passed  | 14 s
wallet_send.py                            | ✓ Passed  | 8 s
wallet_startup.py                         | ✓ Passed  | 3 s
wallet_txn_clone.py                       | ✓ Passed  | 4 s
wallet_txn_clone.py --mineblock           | ✓ Passed  | 4 s
wallet_txn_doublespend.py                 | ✓ Passed  | 3 s
wallet_txn_doublespend.py --mineblock     | ✓ Passed  | 4 s
wallet_watchonly.py                       | ✓ Passed  | 2 s
wallet_watchonly.py --usecli              | ✓ Passed  | 2 s

ALL                                       | ✓ Passed  | 1819 s (accumulated) 
Runtime: 365 s

[33/481] Test Bitcoin RPC authentication...
...
----------------------------------------------------------------------
Ran 3 tests in 0.004s

OK
[34/481] cd /work/contrib/devtools/chainparams && /usr/bin/python3.9 ./test_make_chainparams.py
.....
----------------------------------------------------------------------
Ran 5 tests in 0.001s

OK
[196/481] Running seeder test suite
PASSED: seeder test suite
[218/481] Running pow test suite
PASSED: pow test suite
[371/481] bitcoin: testing txpackage_tests
FAILED: src/test/CMakeFiles/check-bitcoin-txpackage_tests 
cd /work/abc-ci-builds/build-debug/src/test && /usr/bin/cmake -E make_directory /work/abc-ci-builds/build-debug/test/junit && /usr/bin/cmake -E make_directory /work/abc-ci-builds/build-debug/test/log && /usr/bin/cmake -E env /work/cmake/utils/log-and-print-on-failure.sh /work/abc-ci-builds/build-debug/test/log/bitcoin-txpackage_tests.log /work/abc-ci-builds/build-debug/src/test/test_bitcoin --run_test=txpackage_tests --logger=HRF,message:JUNIT,message,bitcoin-txpackage_tests.xml --catch_system_errors=no
Running 4 test cases...
Assertion failed: lock cs_main held in ../../src/validation.cpp:4516; locks held:
'cs_main' in ../../src/test/txpackage_tests.cpp:244 (in thread '')
Aborted (core dumped)
[452/481] Running avalanche test suite
PASSED: avalanche test suite
[458/481] Running bitcoin-qt test suite
PASSED: bitcoin-qt test suite
[478/481] Running secp256k1 test suite
PASSED: secp256k1 test suite
ninja: build stopped: cannot make progress due to previous errors.
Build build-debug failed with exit code 1

rebase and add missing lock (now that D12480 no longer locks cs_main for the whole test)

This revision is now accepted and ready to land.Nov 16 2022, 10:56