Commit graph

34827 commits

Author SHA1 Message Date
Hennadii Stepanov
3442865360
build: Use Link Time Optimization for Qt code on Linux
See: https://www.qt.io/blog/2019/01/02/qt-applications-lto
2022-07-15 23:58:45 +01:00
fanquake
ebce66e532
build: pass -fno-lto when building expat
Otherwise it's autoconf endianess check will fail to determine what the
endianess is..
2022-07-15 23:57:49 +01:00
Andrew Chow
826fae6a0f
Merge bitcoin/bitcoin#25618: Release notes for Miniscript support in P2WSH descriptors
d751beb7ac Release notes for Miniscript support in P2WSH descriptors (Antoine Poinsot)

Pull request description:

  Changelog for #24148.

ACKs for top commit:
  Sjors:
    ACK d751beb7ac
  achow101:
    ACK d751beb7ac
  w0xlt:
    ACK d751beb7ac

Tree-SHA512: 5ecdc8501fdacca35b33f7425dbc192860e3e061bc9287b682c55d6da210cc5c0ff7154629e453a9a8d528bad518c35c49de31d114acab77bf27449940e9ca04
2022-07-15 18:25:32 -04:00
Hennadii Stepanov
6decdedaf9
Merge bitcoin-core/gui#469: Load Base64 PSBT string from file
2c3ee4c347 gui: Load Base64 PSBT string from file (Andrew Chow)

Pull request description:

  Some .psbt files may have the PSBT as a base64 string instead of in binary. We should be able to load those files.

ACKs for top commit:
  jarolrod:
    tACK 2c3ee4c347
  shaavan:
    ACK 2c3ee4c347

Tree-SHA512: 352b0611693c8989ea7d1b8d494ea58c69dc15cf81b8d62271541832e74b0a0399cb6ed4e686ab7c741cb4e5374527e054a9ecfe7355bc6f77d8fdd13569ab76
2022-07-15 21:18:58 +01:00
Carl Dong
cb3e9a1e3f Move {Load,Dump}Mempool to kernel namespace
Also:
1. Add the newly introduced kernel/mempool_persist.cpp to IWYU CI script
2. Add chrono mapping for iwyu
2022-07-15 12:26:20 -04:00
Carl Dong
aa30676541 Move DEFAULT_PERSIST_MEMPOOL out of libbitcoinkernel
It is no longer used by anything inside libbitcoinkernel, move it to
node/mempool_persist_args.h where it belongs.
2022-07-15 12:26:20 -04:00
Carl Dong
06b88ffb8a LoadMempool: Pass in load_path, stop using gArgs
Also:
1. Have CChainState::LoadMempool and ::ThreadImport take in paths and
   pass it through untouched to LoadMempool.
2. Make LoadMempool exit early if the load_path is empty.
3. Adjust the call to ::ThreadImport in ::AppInitMain to correctly pass
   in an empty path if mempool persistence is disabled.
2022-07-15 12:26:20 -04:00
Carl Dong
b857ac60d9 test/fuzz: Invoke LoadMempool via CChainState
Not only does this increase coverage, it is also more correct in that
when ::LoadMempool is called with a mempool and chainstate, it calls
AcceptToMemoryPool with just the chainstate.

AcceptToMemoryPool will then act on the chainstate's mempool via
CChainState::GetMempool, which may be different from the mempool
originally passed to ::LoadMempool. (In this fuzz test's case, it
definitely is different)

Also, move DummyChainstate to its own file since it's now used by the
validation_load_mempool fuzz test to replace CChainState's m_mempool.
2022-07-15 12:26:00 -04:00
Carl Dong
b3267258b0 Move FopenFn to fsbridge namespace
[META] In a future commit in this patchset, it will be used by more than
       just validation, and it needs to align with fopen anyway.
2022-07-15 12:25:51 -04:00
Andrew Chow
4c495413e1 Disallow encryption of watchonly wallets
Watchonly wallets do not have any private keys to encrypt. It does not
make sense to encrypt such wallets, so disable the option to encrypt
them.

This avoids an assertion that can be hit when encrypting watchonly descriptor
wallets.
2022-07-15 11:41:43 -04:00
Carl Dong
ae1e8e3756 mempool: Use NodeClock+friends for LoadMempool 2022-07-15 11:35:13 -04:00
Carl Dong
f9e8e5719f mempool: Improve comments for [GS]etLoadTried
Also change the param name for SetLoadTried to load_tried.
2022-07-15 11:35:13 -04:00
Carl Dong
813962da0b scripted-diff: Rename m_is_loaded -> m_load_tried
m_is_loaded/IsLoaded() doesn't actually indicate whether or not the
mempool was successfully, loaded, but rather if a load has been
attempted and did not result in a catastrophic ShutdownRequested.

-BEGIN VERIFY SCRIPT-
find_regex="\bm_is_loaded\b" \
    && git grep -l -E "$find_regex" \
        | xargs sed -i -E "s@$find_regex@m_load_tried@g"

find_regex="\bIsLoaded\b" \
    && git grep -l -E "$find_regex" \
        | xargs sed -i -E "s@$find_regex@GetLoadTried@g"

find_regex="\bSetIsLoaded\b" \
    && git grep -l -E "$find_regex" \
        | xargs sed -i -E "s@$find_regex@SetLoadTried@g"
-END VERIFY SCRIPT-
2022-07-15 11:35:13 -04:00
fanquake
a969b2fcd3
Merge bitcoin/bitcoin#25551: refactor: Throw exception on invalid Univalue pushes over silent ignore
fa277cd55d univalue: Throw exception on invalid pushes over silent ignore (MacroFake)
ccccc17b91 refactor: Default options in walletcreatefundedpsbt to VOBJ instead of VNULL (MacroFake)

Pull request description:

  The return value of the `push*` helpers is never used, but important to determine if the operation was successful. One way to fix this would be to add the "nodiscard" attribute. However, this would make the code (and this diff) overly verbose for no reason.

  So fix it by removing the never used return value. Also, fail verbosely in case of a programming mistake.

ACKs for top commit:
  furszy:
    code ACK fa277cd5

Tree-SHA512: ef212a5bf5ae6bbad20acc4dafa3715521e81544185988d1eab724f440e4864a27e686aff51d5bc51b3017892c2eb8e577bcb8f37e8ddbaa0d8833bb622f2f9c
2022-07-15 16:33:55 +01:00
Carl Dong
413f4bb52b DumpMempool: Pass in dump_path, stop using gArgs
Also introduce node::{ShouldPersistMempool,MempoolPath} helper functions
in node/mempool_persist_args.{h,cpp} which are used by non-kernel
DumpMempool callers to determine whether or not to automatically dump
the mempool and where to dump it to.
2022-07-15 11:30:50 -04:00
Carl Dong
bd4407817e DumpMempool: Use std::chrono instead of weird int64_t arthmetics
This makes it so that DumpMempool doesn't depend on MICRO anymore
2022-07-15 11:30:47 -04:00
Antoine Poinsot
d751beb7ac
Release notes for Miniscript support in P2WSH descriptors 2022-07-15 14:20:26 +02:00
Andrew Chow
85b601e043
Merge bitcoin/bitcoin#24148: Miniscript support in Output Descriptors
ffc79b8e49 qa: functional test Miniscript watchonly support (Antoine Poinsot)
bfb036756a Miniscript support in output descriptors (Antoine Poinsot)
4a082887be qa: better error reporting on descriptor parsing error (Antoine Poinsot)
d25d58bf5f miniscript: add a helper to find the first insane sub with no child (Antoine Poinsot)
c38c7c5817 miniscript: don't check for top level validity at parsing time (Antoine Poinsot)

Pull request description:

  This adds Miniscript support for Output Descriptors without any signing logic (yet). See the OP of #24147 for a description of Miniscript and a rationale of having it in Bitcoin Core.
  On its own, this PR adds "watchonly" support for Miniscript descriptors in the descriptor wallet. A follow-up adds signing support.

  A minified corpus of Miniscript Descriptors for the `descriptor_parse` fuzz target is available at https://github.com/bitcoin-core/qa-assets/pull/92.
  The Miniscript descriptors used in the unit tests here and in #24149 were cross-tested against the Rust implementation at https://github.com/rust-bitcoin/rust-miniscript.

  This PR contains code and insights from Pieter Wuille.

ACKs for top commit:
  Sjors:
    re-utACK ffc79b8e49
  achow101:
    ACK ffc79b8e49
  w0xlt:
    reACK ffc79b8e49

Tree-SHA512: 02d919d38bb626d3c557eca3680ce71117739fa161b7a92cfdb6c9c432ed88870b1ed127ba24248574c40c7428217d7e9bdd986fd8cd7c51fae8c776e1271fb9
2022-07-14 14:54:19 -04:00
Marnix
743a84a5f6 fix gettxout help text 2022-07-14 20:53:23 +02:00
MacroFake
02ede4f1fd
Merge bitcoin/bitcoin#25607: [kernel 3d/n] Misc ChainstateManager::Options fixups
ce8b0f971b Use designated initializers for ChainstateManager::Options (Carl Dong)
3837700267 Move ChainstateManagerOpts into kernel:: namespace (Carl Dong)

Pull request description:

  This is part of the `libbitcoinkernel` project: #24303, https://github.com/bitcoin/bitcoin/projects/18

  This PR is **_NOT_** dependent on any other PRs.

  -----

  Places `ChainstateManager::Options` into the `kernel::` namespace and use designated initializers for construction.

ACKs for top commit:
  ryanofsky:
    Code review ACK ce8b0f971b

Tree-SHA512: 16a11b5051a2432ca4b6fa7b253376606fef619ace499dfe64d033c8fbe3e1a1875a7c946d7cd54bd908363886244ddf3a192e2f0c801ffbed40d60aad65e442
2022-07-14 17:20:55 +02:00
John Newbery
8d8eeb422e [net processing] Remove CNode::nLocalServices 2022-07-14 15:25:15 +02:00
dergoegge
5961f8eea1 [net] Return CService from GetLocalAddrForPeer and GetLocalAddress 2022-07-14 15:24:00 +02:00
John Newbery
d9079fe18d [net processing] Remove CNode::nServices
Use Peer::m_their_services instead
2022-07-14 14:50:44 +02:00
John Newbery
7d1c036934 [net processing] Replace fHaveWitness with CanServeWitnesses() 2022-07-14 14:49:31 +02:00
John Newbery
f65e83d51b [net processing] Remove fClient and m_limited_node
fClient is replaced by CanServeBlocks(), and m_limited_node is replaced
by IsLimitedPeer().
2022-07-14 14:48:41 +02:00
John Newbery
fc5eb528f7 [tests] Connect peer in outbound_slow_chain_eviction by sending p2p messages
Prior to this commit, the peer was connected, and then the services and
connectivity fields in the CNode object were manually set. Instead, send
p2p `version` and `verack` messages, and have net_processing's internal
logic set the state of the node.

This ensures that the node's internal state is consistent with how it
would be set in the live code.

Prior to this commit, `dummyNode1.nServices` was set to `NODE_NONE`
which was not a problem since `CNode::fClient` and
`CNode::m_limited_node` are default initialised to false. Now that we
are doing the actual version handshake, the values of `fClient` and
`m_limited_node` are set during the handshake and cause the test to fail
if we do not set `dummyNode1.nServices` to a reasonable value
(NODE_NETWORK | NODE_WITNESS).
2022-07-14 14:44:44 +02:00
John Newbery
1f52c47d5c [net processing] Add m_our_services and m_their_services to Peer
Track services offered by us and the peer in the Peer object.
2022-07-14 14:44:44 +02:00
Carl Dong
ce8b0f971b Use designated initializers for ChainstateManager::Options
This wasn't available at the time when ChainstateManager::Options was
introduced but is helpful to be explicit and ensure correctness.
2022-07-14 08:35:23 -04:00
Carl Dong
3837700267 Move ChainstateManagerOpts into kernel:: namespace
It should have been there in the first place.
2022-07-14 08:27:54 -04:00
MacroFake
fa23c19750
univalue: Avoid narrowing and verbose int constructors
As UniValue provides several constructors for integral types, the
compiler is unable to select one if the passed type does not exactly
match. This is unintuitive for developers and forces them to write
verbose and brittle code.

For example, there are many places where an unsigned int is cast to a
signed int. While the cast is safe in practice, it is still needlessly
verbose and confusing as the value can never be negative. In fact it
might even be unsafe if the unsigned value is large enough to map to a
negative signed one.
2022-07-14 12:20:50 +02:00
Antoine Poinsot
ffc79b8e49
qa: functional test Miniscript watchonly support 2022-07-14 12:11:44 +02:00
Antoine Poinsot
bfb036756a
Miniscript support in output descriptors
Miniscript descriptors are defined under P2WSH context (either `wsh()`
or `sh(wsh())`).
Only sane Miniscripts are accepted, as insane ones (although valid by
type) can have surprising behaviour with regard to malleability
guarantees and resources limitations.
As Miniscript descriptors are longer and more complex than "legacy"
descriptors, care was taken in error reporting to help a user determine
for what reason a provided Miniscript is insane.

Co-authored-by: Pieter Wuille <pieter.wuille@gmail.com>
2022-07-14 12:11:44 +02:00
Antoine Poinsot
4a082887be
qa: better error reporting on descriptor parsing error
A nit, but was helpful when writing unit tests for Miniscript parsing
2022-07-14 12:03:50 +02:00
Antoine Poinsot
d25d58bf5f
miniscript: add a helper to find the first insane sub with no child
This is helpful for finer grained descriptor parsing error: when there
are multiple errors to report in a Miniscript descriptor start with the
"smallest" fragments: the ones closer to be a leaf.

Co-Authored-By: Pieter Wuille <pieter@wuille.net>
2022-07-14 12:03:49 +02:00
Antoine Poinsot
c38c7c5817
miniscript: don't check for top level validity at parsing time
Letting the caller perform the checks allows for finer-grained error
reporting.
2022-07-14 12:03:49 +02:00
MacroFake
fa3a9a1e8d
rpc: Select int-UniValue constructor for enum value in upgradewallet RPC
UniValue does not have a constructor for enum values, however the
compiler will decay the enum into an int and select that constructor.
Avoid this compiler magic and clarify the code by explicitly selecting
the int-constructor.

This is needed for the next commit.
2022-07-14 11:56:13 +02:00
MacroFake
062b9db0cc
Merge bitcoin/bitcoin#25594: refactor: Return BResult from restoreWallet
fa475e9c79 refactor: Return BResult from restoreWallet (MacroFake)
fa8de09edc Prepare BResult for non-copyable types (MacroFake)

Pull request description:

  This avoids the `error` in-out param (and if `warnings` is added to `BResult`, it will avoid passing that in-out param as well).

  Also, as it is needed for this change, prepare `BResult` for non-copyable types.

ACKs for top commit:
  w0xlt:
    reACK fa475e9c79
  ryanofsky:
    Code review ACK fa475e9c79. Changes since last review were replacing auto with explicit type and splitting commits

Tree-SHA512: 46350883572f13721ddd198f5dfb88d2fa58ebcbda416f74da3563ea15c920fb1e6ff30558526a4ac91c36c21e6afe27751a4e51b7b8bcbcbe805209f4e9014b
2022-07-14 10:04:42 +02:00
MacroFake
8efa73e7ce
Merge bitcoin/bitcoin#25557: p2p: Eliminate atomic for m_last_getheaders_timestamp
613e221149 test: remove unnecessary parens (Suhas Daftuar)
e939cf2b76 Remove atomic for m_last_getheaders_timestamp (Suhas Daftuar)

Pull request description:

  Eliminate the unnecessary atomic guarding `m_last_getheaders_timestamp`, which is only accessed in a single thread (thanks to MarcoFalke for pointing this out).

  Also address a nit that came up in #25454.

ACKs for top commit:
  MarcoFalke:
    review ACK 613e221149
  vasild:
    ACK 613e221149

Tree-SHA512: 6d6c473735b450b8ad43aae5cf16ed419154d72f4a05c0a6ce6f26caecab9db2361041398b70bf9395611c107d50897f501fa5fdbabb2891144bbc2b479dfdad
2022-07-14 09:55:44 +02:00
MacroFake
fa277cd55d
univalue: Throw exception on invalid pushes over silent ignore 2022-07-13 18:05:39 +02:00
MacroFake
ccccc17b91
refactor: Default options in walletcreatefundedpsbt to VOBJ instead of VNULL
This should not change behavior and makes the code consistent with other
places.
2022-07-13 18:04:23 +02:00
MacroFake
31c6309cc6
Merge bitcoin/bitcoin#25596: scripted-diff: [test] Rename BIP125_SEQUENCE_NUMBER to MAX_BIP125_RBF_SEQUENCE
faace13b71 test: Remove duplicate MAX_BIP125_RBF_SEQUENCE constant (MacroFake)
fa0404dbb7 scripted-diff: [test] Rename BIP125_SEQUENCE_NUMBER to MAX_BIP125_RBF_SEQUENCE (MacroFake)

Pull request description:

  Not sure why the python constant is named differently than the constant in the C++ source code.

  Especially, if we use this in context of MAX+1 (https://github.com/bitcoin/bitcoin/pull/25575#discussion_r918569813) the rename makes sense, in my eyes.

ACKs for top commit:
  theStack:
    Code-review ACK faace13b71
  glozow:
    concept ACK faace13b71

Tree-SHA512: 1dc8cd0f067717f6ace8121b660e99f2d0f8c485c0d61b80413e07e7830e7dfaf9ce2c922c63ba2c6b42e805d59d88cd0d9c80a4b4a2fca47e77a3aba6cd4ec6
2022-07-13 17:21:01 +02:00
fanquake
c30b3e90f0
Merge bitcoin/bitcoin#25472: build: Increase MS Visual Studio minimum version
630c1711b4 refactor: Drop no longer needed `util/designator.h` (Hennadii Stepanov)
88ec5d40dc build: Increase MS Visual Studio minimum version (Hennadii Stepanov)
555f9dd5d3 rpc, refactor: Add `decodepsbt_outputs` (Hennadii Stepanov)
0c432cbbfa rpc, refactor: Add `decodepsbt_inputs` (Hennadii Stepanov)
01d95a3964 rpc, refactor: Add `getblock_prevout` (Hennadii Stepanov)

Pull request description:

  Visual Studio 2022 with `/std:c++20` supports [designated initializers](https://github.com/bitcoin/bitcoin/pull/24531).

ACKs for top commit:
  sipsorcery:
    reACK 630c1711b4.

Tree-SHA512: 5b8933940dd69061c6b077512168bebb6fea05d429b63ffbab191950798b4c825e8484b1a651db0ae13f97eae481097d3c16395659c0f3b9f847af2aaf44b65d
2022-07-13 16:18:44 +01:00
fanquake
081965ccc3
Merge bitcoin/bitcoin#25464: rpc: Reduce Univalue push_backV peak memory usage in listtransactions
fa8a1c0696 rpc: Fix Univalue push_backV OOM in listtransactions (MacroFake)

Pull request description:

  Related to, but not intended as a fix for #25229.

  Currently the RPC will have the same data stored thrice:

  * `UniValue ret` (memory filled by `ListTransactions`)
  * `std::vector<UniValue> vec` (constructed by calling `push_backV`)
  * `UniValue result` (the actual result, memory filled by `push_backV`)

  Fix this by filling the memory only once:

  * `std::vector<UniValue> ret` (memory filled by `ListTransactions`)
  * Pass iterators to `push_backV` instead of creating a full copy
  * Move memory into `UniValue result` instead of copying it

ACKs for top commit:
  shaavan:
    Code Review ACK fa8a1c0696

Tree-SHA512: 1c3ca40fc8497134a4141195160e4aa9fe72b3c00c5998c972b58ad0eb498ebea05013f9105bb80e7264c9db1d0e7a2032396a8a4af1f326d831fbee20f32ea3
2022-07-13 15:58:53 +01:00
fanquake
718d29af23
depends: update urls for dmg tools
These repos have migrated from https://github.com/al45tair/ to
https://github.com/dmgbuild/, so update our URLs to point to the new
location. Note that GitHub is also already performing the redirect
automatically.
2022-07-13 12:47:20 +01:00
Carl Dong
c84390b741 test/mempool_persist: Test manual savemempool when -persistmempool=0 2022-07-12 22:37:17 -04:00
Suhas Daftuar
613e221149 test: remove unnecessary parens 2022-07-12 13:38:14 -04:00
Suhas Daftuar
e939cf2b76 Remove atomic for m_last_getheaders_timestamp
This variable is only used in a single thread, so no atomic or mutex is
necessary to guard it.
2022-07-12 13:38:14 -04:00
MacroFake
fa475e9c79
refactor: Return BResult from restoreWallet 2022-07-12 19:20:01 +02:00
MacroFake
fa8de09edc
Prepare BResult for non-copyable types 2022-07-12 19:19:49 +02:00
MacroFake
faace13b71
test: Remove duplicate MAX_BIP125_RBF_SEQUENCE constant 2022-07-12 18:51:18 +02:00