Commit graph

2661 commits

Author SHA1 Message Date
Andrew Poelstra
9ac62395d7 Merge e45fb7e0d2 into merged_master (Bitcoin PR #18877) 2020-11-26 01:08:42 +00:00
Andrew Poelstra
bda1054131 Merge 7a5767423f into merged_master (Bitcoin PR #18808) 2020-11-26 01:08:41 +00:00
Andrew Poelstra
34d072006e Merge 376294cde6 into merged_master (Bitcoin PR #18866) 2020-11-26 01:08:40 +00:00
Andrew Poelstra
bb1ada83c9 Merge 3930014abc into merged_master (Bitcoin PR #18864) 2020-11-26 01:08:40 +00:00
Andrew Poelstra
e42dc5493b Merge 7bcc42b403 into merged_master (Bitcoin PR #18873) 2020-11-26 01:08:39 +00:00
Andrew Poelstra
d4711bdf91 Merge 23c926d859 into merged_master (Bitcoin PR #18699) 2020-11-26 01:08:37 +00:00
Andrew Poelstra
e58322b8aa Merge 2e6a16b968 into merged_master (Bitcoin PR #18855) 2020-11-26 01:08:36 +00:00
Andrew Poelstra
cdc4c006f4 Merge cce034b028 into merged_master (Bitcoin PR #18839) 2020-11-26 01:08:36 +00:00
Andrew Poelstra
c0fda0cc05 Merge ddc0a600b3 into merged_master (Bitcoin PR #18617)
For reasons I do not really grok, this PR changes the timing behavior of the
functional tests to reliably expose a deadlock in the claimpegin RPC that has
existed since the 0.17 rebase.

The mechanism is: in `claimpegin` in src/wallet/rpcwallet.cpp:5873, we call
`AcceptToMemoryPoolWorker`. This requires cs_main to be locked, which it is
not (contrast Core's `testmempoolaccept` RPC, which similarly calls
`AcceptToMemoryPoolWorker` from the RPC thread, and locks cs_main immediately
before).

We do *say* that it is locked, in the `LockAssertion` one the line above, but
this was added in ad3d496d78 during the 0.17
rebase (PR #620), apparently to shut up some linter on OSX, and as near as I
can tell it was never true.

Anyway, `AcceptToMemoryPoolWorker` calls through a couple layers which assume
cs_main is locked, to `AcceptSingleTransaction`, which locks m_pool.cs on line
src/validation.cpp:1101. It then calls `PreChecks`, which on line 784 calls
::ChainActive(), which _actually_ locks cs_main, though only briefly. This
line is the deadlock, because we locked m_pool.cs followed by cs_main...

...meanwhile, in src/net_processing.cpp, we lock cs_main at the top of the
`PeerLogicValidation::SendMessages` loop (src/net_processing.cpp:3628). In the
same loop, in the `feefilter` message processing, we call CTxMemPool::GetMinFee
(src/net_processing.cpp:4137), which locks m_pool.cs. Deadlock.

Anyway, that explains the change to locking behavior that I added to an
otherwise test-only PR.
2020-11-26 01:08:36 +00:00
Andrew Poelstra
2d0adcc65b Merge 844d2070a2 into merged_master (Bitcoin PR #18828) 2020-11-26 01:08:35 +00:00
Andrew Poelstra
503f615f81 Merge a66ba6d029 into merged_master (Bitcoin PR #18576) 2020-11-26 01:08:35 +00:00
Andrew Poelstra
87ae5b27e7 Merge 36c0abd8f6 into merged_master (Bitcoin PR #18726) 2020-11-26 01:08:34 +00:00
Andrew Poelstra
252c3a223c Merge 978c5a2122 into merged_master (Bitcoin PR #18485) 2020-11-26 01:08:33 +00:00
Andrew Poelstra
733d5cf974 Merge e302830fae into merged_master (Bitcoin PR #18774) 2020-11-26 01:08:33 +00:00
Andrew Poelstra
e5f1b2cdaa Merge 0ef0d33f75 into merged_master (Bitcoin PR #18038) 2020-11-26 01:08:33 +00:00
Andrew Poelstra
48d43d0a8a Merge ba348dbc51 into merged_master (Bitcoin PR #18805) 2020-11-26 01:08:33 +00:00
Andrew Poelstra
8ef5b8bb7f Merge 6a60bfc76c into merged_master (Bitcoin PR #18765) 2020-11-26 01:08:32 +00:00
Andrew Poelstra
1c12ae1719 Merge eef90c14ed into merged_master (Bitcoin PR #16528)
This is the 43-commit descriptor wallet PR. It was remarkably easy to merge, given
its magnitude. With this commit Elements supports importing Bitcoin descriptors
and deriving (Bitcoin) addresses, though of course it does not support blinding
yet. That is a post-rebase project.

The material changes were:

1. Changing constants in the tests (super annoying but nothing surprising)

2. Adding a missing "skip if this coin is not ours" check in src/script/sign.cpp
   which was causing us to erroneously remove existing witnesses from transactions.
   This wasn't a problem before this commit since we would only ask specific
   scriptpubkeymans to sign, and we'd never ask any to sign inputs we didn't
   own. Andy simplified the logic here to always try every scriptpubkeyman,
   which means they have to play a bit more nicely with each other.

Other than that, this was a big diff with many conflicts but literally all of
them were "we both added code" and the resolution was to take both sides.
2020-11-26 01:08:31 +00:00
Andrew Poelstra
e678252c81 Merge 9ddfce6712 into merged_master (Bitcoin PR #18753) 2020-11-26 01:08:31 +00:00
Andrew Poelstra
56711e565a Merge 3cf464de2e into merged_master (Bitcoin PR #18770) 2020-11-26 01:08:31 +00:00
Andrew Poelstra
b066f21047 Merge fd48e7ad99 into merged_master (Bitcoin PR #18585) 2020-11-26 01:08:30 +00:00
Andrew Poelstra
b6af50f657 Merge 5f19155e5b into merged_master (Bitcoin PR #18724) 2020-11-26 01:08:30 +00:00
Andrew Poelstra
b50c37d404 Merge a215c61333 into merged_master (Bitcoin PR #18756) 2020-11-26 01:08:29 +00:00
Andrew Poelstra
6ecadd8588 Merge 29637a5c56 into merged_master (Bitcoin PR #18745) 2020-11-26 01:08:29 +00:00
Andrew Poelstra
c8bf2c631b Merge d1aa0ae1ad into merged_master (Bitcoin PR #18712) 2020-11-26 01:08:29 +00:00
Andrew Poelstra
f2f45831bf Merge 85bae24d06 into merged_master (Bitcoin PR #18752) 2020-11-26 01:08:29 +00:00
Andrew Poelstra
26e416f0b6 Merge 64139803f1 into merged_master (Bitcoin PR #18690) 2020-11-26 01:08:29 +00:00
Andrew Poelstra
acdc05d56c Merge 47b94a337e into merged_master (Bitcoin PR #18732) 2020-11-26 01:08:28 +00:00
Andrew Poelstra
82c6828181 Merge b6a5dc90bf into merged_master (Bitcoin PR #18384) 2020-11-26 01:08:27 +00:00
Andrew Poelstra
e234a42a47 Merge 9ea4d8326a into merged_master (Bitcoin PR #18704) 2020-11-26 01:08:26 +00:00
Andrew Poelstra
11c3deeb82 Merge 977328338e into merged_master (Bitcoin PR #18721) 2020-11-26 01:08:26 +00:00
Andrew Poelstra
042d703f0b Merge 4ad6144ed0 into merged_master (Bitcoin PR #18672) 2020-11-26 01:08:26 +00:00
Andrew Poelstra
2a59ec026d Merge da4cbb7927 into merged_master (Bitcoin PR #18544) 2020-11-26 01:08:25 +00:00
Andrew Poelstra
3d19543983 Merge dc5da7fe7b into merged_master (Bitcoin PR #18691) 2020-11-26 01:08:25 +00:00
Andrew Poelstra
96af3c5b23 Merge d2882a012b into merged_master (Bitcoin PR #18610) 2020-11-26 01:08:25 +00:00
Andrew Poelstra
b7307be8cd Merge b470c75847 into merged_master (Bitcoin PR #15761) 2020-11-26 01:08:25 +00:00
Andrew Poelstra
353b2ff233 Merge b690b24eb2 into merged_master (Bitcoin PR #18633) 2020-11-26 01:08:24 +00:00
Andrew Poelstra
11125c2961 Merge 6ae99aab5d into merged_master (Bitcoin PR #18692) 2020-11-26 01:08:24 +00:00
Andrew Poelstra
9192999921 Merge bbb1ba1814 into merged_master (Bitcoin PR #17219)
This modifies the CreateTransaction loop in a way not remotely worth the complexity,
and includes an absurdly fragile test where I had to add a bunch of trace statements
and tweak pretty-much every single hardcoded number. Not to name names, but it was
Sjors. (In fairness, the PR is a pure simplification of the CreateTransaction logic,
and it wasn't hard to merge even. It was just the test that caused my grief.)

Adapting the "use a dummy CTxDestination in the case that we cannot retrieve one from
the wallet" logic to our `mapScriptChange` map was not trivial. On my first attempt I
incorrectly assigned a positive vout index to the dummy script, which caused us to
call `ReturnDestination` later on the (unused) dummy destination. This is harmless now,
but when descriptor wallets are introduced in #16528, they introduce an edge case where
returning a null destination can incorrectly mark the 0th key of a BIP32 range as
unused. This triggered a test failure much later, in #19504, which uses descriptor
wallets in fundrawtransaction. The bug was that we'd import a descriptor, mark the
first key as being used, lock the wallet, call `fundrawtransaction` on a transaction
that did not require change (incorrectly marking the first key as unused but leaving
it in the descriptor ScriptPubKeyMan's cache), then call `fundrawtransaction` again
on a transaction that *did* require change. The wallet would then incorrectly retrieve
the "unused" key from cache and use it for change, rather than correctly failing and
advising the user that it could not produce change with a locked wallet and empty
keypool. This was not a fun bug to track down.

Another interesting observation is that branch-and-bound uses the CT size-overestimate
for change when trying to create changeless outputs, while our normal dust detection
uses Core's unchanged "an output is 133 bytes" logic. So when BnB is used we're willing
to delete a far bigger change output than we are when we don't use BnB.

Lest you think this works in Core, they're also inconsistent because BnB uses a
normal fee estimate for gauging change cost, while non-BnB uses the discardfee rate.

My advice is to hold your nose, pull stuff in from Core as it comes in, and thanks
to Andy's efforts things are getting better. Don't bother reviewing this too closely.
2020-12-03 00:58:01 +00:00
Andrew Poelstra
a9956489b2 Merge c54295c1a2 into merged_master (Bitcoin PR #18641) 2020-11-26 01:08:24 +00:00
Andrew Poelstra
86082b9846 Merge 244daa4821 into merged_master (Bitcoin PR #18607) 2020-11-26 01:08:23 +00:00
Andrew Poelstra
fd37b7c5d6 Merge 54f812d9d2 into merged_master (Bitcoin PR #18673) 2020-11-26 01:08:23 +00:00
Andrew Poelstra
a1367df7d3 Merge c2e53ff064 into merged_master (Bitcoin PR #18467) 2020-11-26 01:08:23 +00:00
Andrew Poelstra
7acaa0481b Merge c189bfd260 into merged_master (Bitcoin PR #17824) 2020-11-26 01:08:22 +00:00
Andrew Poelstra
bc49e22548 Merge f0d97cdf70 into merged_master (Elements PR #861) 2020-11-26 01:08:22 +00:00
Andrew Poelstra
fd4ce54b94 Merge 661e8df1b6 into merged_master (Bitcoin PR #18653) 2020-11-26 01:08:21 +00:00
Andrew Poelstra
c63e500dfd Merge 20c0e2e0f0 into merged_master (Bitcoin PR #18628) 2020-11-26 01:08:20 +00:00
Andrew Poelstra
0dc35ccd83 Merge 6110ae8326 into merged_master (Bitcoin PR #18451) 2020-11-26 01:08:18 +00:00
Andrew Poelstra
3ad3ea7e75 Merge e28e5353c4 into merged_master (Bitcoin PR #18545) 2020-11-26 01:08:18 +00:00
Andrew Poelstra
c67b9f0c92 Merge d9fd7b5a67 into merged_master (Bitcoin PR #18596) 2020-11-26 01:08:18 +00:00