Commit Graph

39325 Commits

Author SHA1 Message Date
Greg Sanders
b67db52c39 RPC submitpackage: change return format to allow partial errors
Behavior prior to this commit allows some transactions to
enter into the local mempool but not be reported to the user
when encountering a PackageValidationResult::PCKG_TX result.

This is further compounded with the fact that any transactions
submitted to the mempool during this call would also not be
relayed to peers, resulting in unexpected behavior.

Fix this by, if encountering a package error, reporting all
wtxids, along with a new error field, and broadcasting every
transaction that was found in the mempool after submission.

Note that this also changes fees and vsize to optional,
which should also remove an issue with other-wtxid cases.
2023-11-29 12:56:26 -05:00
fanquake
1fdd832842
Merge bitcoin/bitcoin#28835: test: Check error details with assert_debug_log on the assumeutxo invalid hash dump - follow-up #28698
7de7685372 test, assumeutxo: Use assert_debug_log for error details (pablomartin4btc)

Pull request description:

  This is a follow-up on the invalid hash dump fix #28698, [suggested](https://github.com/bitcoin/bitcoin/pull/28698#pullrequestreview-1698178157) by theStack and agreed by Sjors and ryanofsky.

ACKs for top commit:
  Sjors:
    ACK 7de7685372
  maflcko:
    lgtm ACK 7de7685372

Tree-SHA512: 036b3cef3084e3ead8923e8dcabe4fa7ebe97fb514d223aa38bc38df10337e3fe3113e42322178b58fb03fcd4511af4b5b56bceecbb7ded5b9758842c70db3f2
2023-11-10 09:55:56 +00:00
pablomartin4btc
7de7685372 test, assumeutxo: Use assert_debug_log for error details
This is a follow-up on the invalid hash dump fix PR #28698.

https://github.com/bitcoin/bitcoin/pull/28698#pullrequestreview-1698178157
2023-11-09 18:54:27 -03:00
fanquake
b3898e946c
Merge bitcoin/bitcoin#28826: ci: Switch IWYU to clang_17 branch
9f208c0171 ci: Switch IWYU to `clang_17` branch (Hennadii Stepanov)

Pull request description:

  The IWYU version [0.21](https://github.com/include-what-you-use/include-what-you-use/releases/tag/0.21) has been tagged, and the `clang_17` branch is available now.

ACKs for top commit:
  maflcko:
    lgtm ACK 9f208c0171

Tree-SHA512: 8b8f8743d1c2719b6383b5a6a48356ac02a301d1ce9cee77f93cc04c12de22e9ac6b59e23550a589540e68292cfac0d85bacedc9ca26f6b589011d36ee1d38cf
2023-11-09 13:07:05 +00:00
Hennadii Stepanov
9f208c0171
ci: Switch IWYU to clang_17 branch 2023-11-09 12:04:17 +00:00
fanquake
88c3b100f0
Merge bitcoin/bitcoin#28829: ci: win64 task does use boost:process
5f0bf2ef69 ci: win64 task does use boost:process (fanquake)

Pull request description:

  It passes `--enable-external-signer`.

ACKs for top commit:
  maflcko:
    lgtm ACK 5f0bf2ef69

Tree-SHA512: 789877aac0d36429f31256adc07812d1914a8a059a43ef22416be97270b083902c253ff0561b3de28e76db005387f14b2712bfcfb1334f69b293c39ce0e7467c
2023-11-09 11:21:21 +00:00
fanquake
5f0bf2ef69
ci: win64 task does use boost:process
It passes `--enable-external-signer`.
2023-11-09 10:50:32 +00:00
fanquake
c2da8c583f
Merge bitcoin/bitcoin#28822: test: Add missing wait for version to be sent in add_outbound_p2p_connection
faa2ad88bc test: Add missing wait for version to be sent in add_outbound_p2p_connection (MarcoFalke)

Pull request description:

  Can be tested with:

  ```diff
  diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py
  index b1ed97b794..eb4f72c6b6 100755
  --- a/test/functional/test_framework/p2p.py
  +++ b/test/functional/test_framework/p2p.py
  @@ -205,6 +205,7 @@ class P2PConnection(asyncio.Protocol):
           assert not self._transport
           logger.debug("Connected & Listening: %s:%d" % (self.dstaddr, self.dstport))
           self._transport = transport
  +        import time;time.sleep(.1);
           if self.on_connection_send_msg:
               self.send_message(self.on_connection_send_msg)
               self.on_connection_send_msg = None  # Never used again
  ```

  Found and reported by mzumsande in https://github.com/bitcoin/bitcoin/pull/28782#pullrequestreview-1718560252

ACKs for top commit:
  mzumsande:
    ACK faa2ad88bc

Tree-SHA512: 863f06125dec40cccaa852d0d8ca2e2b9c0b74610205e9fd6c9c279bdf36801ff475e3d873fd1b18172eb8220e17b2caff60069ce63512e569934a43f27d03fd
2023-11-09 10:26:56 +00:00
glozow
d60ebea597
Merge bitcoin/bitcoin#28808: refactor: Miniminer package linearization followups
b4b01d3fb4 [refactor] updating miniminer comments to be more accurate (kevkevin)
83933eff00 [refactor] Miniminer var cached_descendants to descendants (kevkevin)
43423fd834 [refactor] Change MiniMinerMempoolEntry order (kevkevin)

Pull request description:

  ### Motivation
  In https://github.com/bitcoin/bitcoin/pull/28762 there were some post merge comments which are being addressed in this PR with the following commits

  ### [8d4c46f](8d4c46f54d) Reorganizing `MiniMinerMempoolEntry` to match the order we have elsewhere
  * https://github.com/bitcoin/bitcoin/pull/28762#discussion_r1381775670

  ### [7505ec2](7505ec2054) Renaming `cached_descendants` to `descendants` for simpler variable naming
  * https://github.com/bitcoin/bitcoin/pull/28762#discussion_r1381819567

  ### [b21f2f2](b21f2f2f55) Code comment modifications to be more accurate to what is actually happening
  * https://github.com/bitcoin/bitcoin/pull/28762#discussion_r1381902909 and
  * https://github.com/bitcoin/bitcoin/pull/28762#discussion_r1382002278 and
  * https://github.com/bitcoin/bitcoin/pull/28762#discussion_r1383041819

ACKs for top commit:
  murchandamus:
    reACK b4b01d3fb4
  theStack:
    LGTM ACK b4b01d3fb4

Tree-SHA512: 54f044a578fb203d8a3c1aa0bcd1fc4bcdff0bc9b024351925a4caf0ccece7c7736b0694ad1168c3cbb447bdb58a91f4cac365f46114da29a889fbc8ea595b82
2023-11-09 09:30:58 +00:00
kevkevin
b4b01d3fb4
[refactor] updating miniminer comments to be more accurate 2023-11-08 14:45:18 -06:00
Andrew Chow
3d7544b481
Merge bitcoin/bitcoin#28823: ci: remove note re M1 usage
8cbb619691 ci: remove note re M1 usage (fanquake)

Pull request description:

  M1 is now available in GitHub CI, but we don't currently have a plan to use it, so remove the comment.

ACKs for top commit:
  maflcko:
    lgtm ACK 8cbb619691
  achow101:
    ACK 8cbb619691
  hebasto:
    ACK 8cbb619691.

Tree-SHA512: 13bbd4ad2358b0df6781031d6bdba456ffe706f30bf273a317ea8031f28276ef5821b5f767e4fb47d444b4e9ad7b8b7f67563927838552d275aca481d0e2fc2f
2023-11-08 13:20:51 -05:00
Andrew Chow
19d1ba1b41
Merge bitcoin/bitcoin#28787: init: completely remove -zapwallettxes (remaining hidden option)
5039c346ca init: completely remove `-zapwallettxes` (remaining hidden option) (Sebastian Falbesoner)

Pull request description:

  The `-zapwallettxes` functionality has been removed in v0.21.0 (see commit 3340dbadd3 / PR #19671), with the parameter being kept as hidden option, to inform users via an exit error that `abandontransaction` should be used instead.

  As any guides that still suggest to use `-zapwallettxes` would refer to a Bitcoin Core version that is EOL since many years (i.e. <= v0.20.x), it is highly unlikely that the error caused by the option is still relevant for any user, hence it seems fine to remove it now.

ACKs for top commit:
  achow101:
    ACK 5039c346ca
  BrandonOdiwuor:
    ACK 5039c346ca
  fanquake:
    ACK 5039c346ca

Tree-SHA512: e3ccc6918e0f8fa68dbd1a7ec4999cc2a44e28038711919fcddaf0727648c73a9ba0fb77674317147592a113fad20755d4e727f48176bc17b048fbdebad2d6c9
2023-11-08 10:53:42 -05:00
fanquake
8cbb619691
ci: remove note re M1 usage
M1 is now available in GitHub CI, but we don't currently have a plan to
use it, so remove the comment.
2023-11-08 15:07:17 +00:00
fanquake
f1f3f2d9cc
Merge bitcoin/bitcoin#28815: fuzz: Avoid timeout and bloat in fuzz targets
fabb5046a7 fuzz: Avoid timeout and bloat in fuzz targets (MarcoFalke)

Pull request description:

  If the fuzz input contains invalid data *in a loop*, abort early. This will teach the fuzz engine to look for useful data and avoids bloating the fuzz input folder with useless (repeated) data.

ACKs for top commit:
  dergoegge:
    utACK fabb5046a7
  brunoerg:
    crACK fabb5046a7

Tree-SHA512: 26da100d7558ae6fdd5292fb146d8858b2af8f78c546ca2509b9d27b33a33e9462ecb6035de142f9f36dd5de32f8cbad099d6c7a697902d23e1bb621cd27dc88
2023-11-08 14:19:35 +00:00
glozow
9ad19fc7c7
Merge bitcoin/bitcoin#28155: net: improves addnode / m_added_nodes logic
0420f99f42 Create net_peer_connection unit tests (Jon Atack)
4b834f6499 Allow unit tests to access additional CConnman members (Jon Atack)
34b9ef443b net/rpc: Makes CConnman::GetAddedNodeInfo able to return only non-connected address on request (Sergi Delgado Segura)
94e8882d82 rpc: Prevents adding the same ip more than once when formatted differently (Sergi Delgado Segura)
2574b7e177 net/rpc: Check all resolved addresses in ConnectNode rather than just one (Sergi Delgado Segura)

Pull request description:

  ## Rationale

  Currently, `addnode` has a couple of corner cases that allow it to either connect to the same peer more than once, hence wasting outbound connection slots, or add redundant information to `m_added_nodes`, hence making Bitcoin iterate through useless data on a regular basis.

  ### Connecting to the same node more than once

  In general, connecting to the same node more than once is something we should try to prevent. Currently, this is possible via `addnode` in two different ways:

  1. Calling `addnode` more than once in a short time period, using two equivalent but distinct addresses
  2. Calling `addnode add` using an IP, and `addnode onetry` after with an address that resolved to the same IP

  For the former, the issue boils down to `CConnman::ThreadOpenAddedConnections` calling `CConnman::GetAddedNodeInfo` once, and iterating over the result to open connections (`CConman::OpenNetworkConnection`) on the same loop for all addresses.`CConnman::ConnectNode` only checks a single address, at random, when resolving from a hostname, and uses it to check whether we are already connected to it.

  An example to test this would be calling:

  ```
  bitcoin-cli addnode "127.0.0.1:port" add
  bitcoin-cli addnode "localhost:port" add
  ```

  And check how it allows us to perform both connections some times, and some times it fails.

  The latter boils down to the same issue, but takes advantage of `onetry` bypassing the `CConnman::ThreadOpenAddedConnections` logic and calling `CConnman::OpenNetworkConnection` straightaway. A way to test this would be:

  ```
  bitcoin-cli addnode "127.0.0.1:port" add
  bitcoin-cli addnode "localhost:port" onetry
  ```

  ### Adding the same peer with two different, yet equivalent, addresses

  The current implementation of `addnode` is pretty naive when checking what data is added to `m_added_nodes`. Given the collection stores strings, the checks at `CConnman::AddNode()` basically check wether the exact provided string is already in the collection. If so, the data is rejected, otherwise, it is accepted. However, ips can be formatted in several ways that would bypass those checks.

  Two examples would be `127.0.0.1` being equal to `127.1` and `[::1]` being equal to `[0:0:0:0:0:0:0:1]`. Adding any pair of these will be allowed by the rpc command, and both will be reported as connected by `getaddednodeinfo`, given they map to the same `CService`.

  This is less severe than the previous issue, since even tough both nodes are reported as connected by `getaddednodeinfo`, there is only a single connection to them (as properly reported by `getpeerinfo`). However, this adds redundant data to `m_added_nodes`, which is undesirable.

  ### Parametrize `CConnman::GetAddedNodeInfo`
  Finally, this PR also parametrizes `CConnman::GetAddedNodeInfo` so it returns either all added nodes info, or only info about the nodes we are **not** connected to. This method is used both for `rpc`, in `getaddednodeinfo`, in which we are reporting all data to the user, so the former applies, and to check what nodes we are not connected to, in `CConnman::ThreadOpenAddedConnections`, in which we are currently returning more data than needed and then actively filtering using `CService.fConnected()`

ACKs for top commit:
  jonatack:
    re-ACK 0420f99f42
  kashifs:
    > > tACK [0420f9](0420f99f42)
  sr-gi:
    > > > tACK [0420f9](0420f99f42)
  mzumsande:
    Tested ACK 0420f99f42

Tree-SHA512: a3a10e748c12d98d439dfb193c75bc8d9486717cda5f41560f5c0ace1baef523d001d5e7eabac9fa466a9159a30bb925cc1327c2d6c4efb89dcaf54e176d1752
2023-11-08 11:31:36 +00:00
MarcoFalke
faa2ad88bc
test: Add missing wait for version to be sent in add_outbound_p2p_connection 2023-11-08 11:36:24 +01:00
fanquake
d690f89b57
Merge bitcoin/bitcoin#28785: validation: return more helpful results for reconsiderable fee failures and skipped transactions
1147e00e59 [validation] change package-fee-too-low, return wtxid(s) and effective feerate (glozow)
10dd9f2441 [test] use CheckPackageMempoolAcceptResult in previous tests (glozow)
3979f1afcb [validation] add TxValidationResult::TX_RECONSIDERABLE, TX_UNKNOWN (glozow)
5c786a026a [refactor] use Wtxid for m_wtxids_fee_calculations (glozow)

Pull request description:

  Split off from #26711 (suggested in https://github.com/bitcoin/bitcoin/pull/26711#issuecomment-1786392253). This is part of #27463.

  - Add 2 new TxValidationResults
    - `TX_RECONSIDERABLE` helps us encode transactions who have failed fee checks that can be bypassed using package validation. This is distinguished from `TX_MEMPOOL_POLICY` so that we re-validate a transaction if and only if it is eligible for package CPFP. In the future, we will have a separate cache for reconsiderable rejects so these transactions don't go in `m_recent_rejects`.
    - `TX_UNKNOWN` helps us communicate that we aborted package validation and didn't finish looking at this transaction: it's not valid but it's also not invalid (i.e. don't cache it as a rejected tx)
  - Return effective feerate and the wtxids of transactions used to calculate that effective feerate when the error is `TX_SINGLE_FAILURE`. Previously, we would only provide this information if the transaction passed. Now that we have package validation, it's much more helpful to the caller to know how the failing feerate was calculated. This can also be used to improve our submitpackage RPC result (which is currently a bit unhelpful when things fail).
  - Use the newly added `CheckPackageMempoolAcceptResult` for existing package validation tests. This increases test coverage and helps test the changes made in this PR.

ACKs for top commit:
  instagibbs:
    reACK 1147e00e59
  achow101:
    ACK 1147e00e59
  murchandamus:
    reACK 1147e00e59
  ismaelsadeeq:
    ACK 1147e00e59

Tree-SHA512: ac1cd73c2b487a1b99d329875d39d8107c91345a5b0b241d54a6a4de67faf11be69a2721cc732c503024a9cca381dac33d61e187957279e3c82653bea118ba91
2023-11-08 10:17:05 +00:00
fanquake
059f131314
Merge bitcoin/bitcoin#28820: tests: Increase wallet_miniscript.py rpc timeout to 90 seconds
6559e4d27a tests: Increase wallet_miniscript.py rpc timeout to 90 seconds (Andrew Chow)

Pull request description:

  The signing test for the large miniscript can sometimes take longer than the 30 second timeout, depending on the load on my system. Increasing it to 90 seconds seems to be good enough.

ACKs for top commit:
  kevkevinpal:
    but increasing seems fine ACK [6559e4d](6559e4d27a)
  maflcko:
    lgtm ACK 6559e4d27a

Tree-SHA512: 1b7bf94c77f85a0deddb1384aacbeb934205d0a630fecc8e75a4a98d1946d77d9bca36692fb6c1ab8e9276392f617281aafc4c685c248a8d3b0c77f896cda624
2023-11-08 09:56:49 +00:00
fanquake
1162d046ec
Merge bitcoin/bitcoin#28782: test: Add missing sync on send_version in peer_connect
fa02598469 test: Add missing sync on send_version in peer_connect (MarcoFalke)

Pull request description:

  Without the sync, the logic will be racy. For example, `p2p_sendtxrcncl.py` is failing locally (and on CI occasionally), because non-version messages will be sent before the version message:

  ```py
          self.log.info('SENDTXRCNCL with version=0 triggers a disconnect')
          sendtxrcncl_low_version = create_sendtxrcncl_msg()
          sendtxrcncl_low_version.version = 0
          peer = self.nodes[0].add_p2p_connection(PeerNoVerack(), send_version=True, wait_for_verack=False)
          with self.nodes[0].assert_debug_log(["txreconciliation protocol violation"]):
              peer.send_message(sendtxrcncl_low_version)
              peer.wait_for_disconnect()
  ```

  ```
   test  2023-11-02T08:15:19.620000Z TestFramework (INFO): SENDTXRCNCL with version=0 triggers a disconnect
   test  2023-11-02T08:15:19.621000Z TestFramework.p2p (DEBUG): Connecting to Bitcoin Node: 127.0.0.1:11312
   test  2023-11-02T08:15:19.624000Z TestFramework.p2p (DEBUG): Connected & Listening: 127.0.0.1:11312
   test  2023-11-02T08:15:19.798000Z TestFramework.p2p (DEBUG): Send message to 127.0.0.1:11312: msg_sendtxrcncl(version=0, salt=2)
   test  2023-11-02T08:15:19.799000Z TestFramework.p2p (DEBUG): Send message to 127.0.0.1:11312: msg_version(nVersion=70016 nServices=9 nTime=Thu Nov  2 08:15:19 2023 addrTo=CAddress(nServices=1 net=IPv4 addr=127.0.0.1 port=11312) addrFrom=CAddress(nServices=1 net=IPv4 addr=0.0.0.0 port=0) nNonce=0x369AC031CDA96022 strSubVer=/python-p2p-tester:0.0.3/ nStartingHeight=-1 relay=1)
   node0 2023-11-02T08:15:19.804409Z [net] [net.cpp:3676] [CNode] [net] Added connection peer=0
   node0 2023-11-02T08:15:19.805256Z [net] [net.cpp:1825] [CreateNodeFromAcceptedSocket] [net] connection from 127.0.0.1:55964 accepted
   node0 2023-11-02T08:15:19.809861Z [msghand] [net_processing.cpp:3356] [ProcessMessage] [net] received: sendtxrcncl (12 bytes) peer=0
   node0 2023-11-02T08:15:19.810297Z [msghand] [net_processing.cpp:3582] [ProcessMessage] [net] non-version message before version handshake. Message "sendtxrcncl" from peer=0
   node0 2023-11-02T08:15:19.810928Z [msghand] [net_processing.cpp:3356] [ProcessMessage] [net] received: version (111 bytes) peer=0
  ...
   test  2023-11-02T09:35:20.166000Z TestFramework.utils (ERROR): wait_until() failed. Predicate: ''''
                                             def test_function():
                                                 if check_connected:
                                                     assert self.is_connected
                                                 return test_function_in()
                                     '''
   test  2023-11-02T09:35:20.187000Z TestFramework (ERROR): Assertion failed
                                     Traceback (most recent call last):
                                       File "/ci_container_base/ci/scratch/build/bitcoin-s390x-linux-gnu/test/functional/test_framework/test_framework.py", line 132, in main
                                         self.run_test()
                                       File "/ci_container_base/ci/scratch/build/bitcoin-s390x-linux-gnu/test/functional/p2p_sendtxrcncl.py", line 188, in run_test
                                         peer.wait_for_disconnect()
                                       File "/ci_container_base/ci/scratch/build/bitcoin-s390x-linux-gnu/test/functional/test_framework/p2p.py", line 478, in wait_for_disconnect
                                         self.wait_until(test_function, timeout=timeout, check_connected=False)
                                       File "/ci_container_base/ci/scratch/build/bitcoin-s390x-linux-gnu/test/functional/test_framework/p2p.py", line 470, in wait_until
                                         wait_until_helper_internal(test_function, timeout=timeout, lock=p2p_lock, timeout_factor=self.timeout_factor)
                                       File "/ci_container_base/ci/scratch/build/bitcoin-s390x-linux-gnu/test/functional/test_framework/util.py", line 275, in wait_until_helper_internal
                                         raise AssertionError("Predicate {} not true after {} seconds".format(predicate_source, timeout))
                                     AssertionError: Predicate ''''
                                             def test_function():
                                                 if check_connected:
                                                     assert self.is_connected
                                                 return test_function_in()
                                     ''' not true after 4800.0 seconds

ACKs for top commit:
  mzumsande:
    ACK fa02598469

Tree-SHA512: 78871f603d387e2df8c0acbdfa95441fa186f80e94593021bb219bbf1bc9dc7efc4e266bd254b5cc41114c38227ff3b7f6172335d9bb828427f0a2acffde752d
2023-11-08 09:55:53 +00:00
fanquake
b5d8f001a8
Merge bitcoin/bitcoin#28814: test: symbolizer improvements
49d953281d fuzz: explicitly specify llvm-symbolizer path in runner (fanquake)

Pull request description:

  It's not completely clear to me why this needs to be explicitly specified in some environments, and not in others, while at the same time that `llvm-symbolizer` is already in PATH, but this has fixed the 2 issues outlined in https://github.com/bitcoin/bitcoin/pull/28147.

  Use `LLVM_SYMBOLIZER_PATH` as the env var, as that is somewhat also used inside LLVM, but not consistently, i.e it's checked for in the asan_symbolize script, but not in in the ubsan_symbolize script, or from in compiler-rt.

  Alternative to #28804.

ACKs for top commit:
  maflcko:
    lgtm ACK 49d953281d

Tree-SHA512: c3d5bf1c3629793b342c70754a419b3c7a3cd39f800b9aa69ce3395cc2bf83b4d46f2b329974337b94b99573cd0b8600d3f147ed5c21387bf3812316570d1ee3
2023-11-08 09:46:51 +00:00
MarcoFalke
fabb5046a7
fuzz: Avoid timeout and bloat in fuzz targets
Also, fix iwyu
2023-11-08 09:51:54 +01:00
Andrew Chow
6559e4d27a tests: Increase wallet_miniscript.py rpc timeout to 90 seconds
The signing test for the large miniscript can sometimes take longer than
the 30 second timeout, depending on the load on my system. Increasing it
to 90 seconds seems to be good enough.
2023-11-07 18:32:28 -05:00
Andrew Chow
82ea4e787c
Merge bitcoin/bitcoin#28464: net: improve max-connection limits code
df69b22f2e doc: improve documentation around connection limit maximums (Amiti Uttarwar)
adc171edf4 scripted-diff: Rename connection limit variables (Amiti Uttarwar)
e9fd9c0225 net: add m_max_inbound to connman (Amiti Uttarwar)
c25e0e0555 net, refactor: move calculations for connection type limits into connman (Amiti Uttarwar)

Pull request description:

  This is joint work with amitiuttarwar.

  This has the first few commits of #28463. It is not strictly a prerequisite for that, but has changes that in our opinion make sense on their own.
  It improves the handling of maximum numbers for different connection types (that are set during init and don’t change after) by:
  * moving all calculations into one place, `CConnMan::Init()`. Before, they were dispersed between `Init`, `CConnman::Init` and other parts of `CConnman`, resulting in some duplicated test code.
  * removing the possibility of having a negative maximum of inbound connections, which is hard to argue about
  * renaming of variables and doc improvements

ACKs for top commit:
  amitiuttarwar:
    co-author review ACK df69b22f2e
  naumenkogs:
    ACK df69b22f2e
  achow101:
    ACK df69b22f2e

Tree-SHA512: 913d56136bc1df739978de50db67302f88bac2a9d34748ae96763288d97093e998fc0f94f9b6eff12867712d7e86225af6128f4170bf2b5b8ab76f024870a22c
2023-11-07 17:01:02 -05:00
Andrew Chow
962ea5c525
Merge bitcoin/bitcoin#28374: test: python cryptography required for BIP 324 functional tests
c534c08710 [test/crypto] Add FSChaCha20Poly1305 AEAD python implementation (stratospher)
c2a458f1c2 [test/crypto] Add FSChaCha20 python implementation (stratospher)
c4ea5f6288 [test/crypto] Add RFC 8439's ChaCha20Poly1305 AEAD (stratospher)
9fc6e0355e [test/crypto] Add Poly1305 python implementation (stratospher)
fec2ca6c9a [test/crypto] Use chacha20_block function in `data_to_num3072` (stratospher)
0cde60da3a [test/crypto] Add ChaCha20 python implementation (stratospher)
69d3f50ab6 [test/crypto] Add HMAC-based Key Derivation Function (HKDF) (stratospher)
08a4a56cbc [test] Move test framework crypto functions to crypto/ (stratospher)

Pull request description:

  split off from #24748 to keep commits related to cryptography and functional test framework changes separate.

  This PR adds python implementation and unit tests for HKDF, ChaCha20, Poly1305, ChaCha20Poly1305 AEAD, FSChaCha20 and FSChaCha20Poly1305 AEAD.

  They're based on cc177ab7bc/bip-0324/reference.py for easy review.

ACKs for top commit:
  sipa:
    utACK c534c08710
  achow101:
    ACK c534c08710
  theStack:
    re-ACK c534c08710

Tree-SHA512: 08a0a422d2937eadcf0edfede37e535e6bc4c2e4b192441bbf9bc26dd3f03fa3388effd22f0527c55af173933d0b50e5b2b3d36f2b62d0aca3098728ef06970e
2023-11-07 16:48:57 -05:00
Andrew Chow
c981771bc3
Merge bitcoin/bitcoin#28224: shutdown: Destroy kernel last, make test shutdown order consistent
c1144f0076 tests: Reset node context members on ~BasicTestingSetup (TheCharlatan)
9759af17ff shutdown: Destroy kernel last (TheCharlatan)

Pull request description:

  The destruction/resetting of node context members in the tests should roughly follow the behavior of the `Shutdown` function in `init.cpp`.

  This was originally requested by MarcoFalke in this [comment](https://github.com/bitcoin/bitcoin/pull/25065#discussion_r890161249) in response to the [original pull request](https://github.com/bitcoin/bitcoin/pull/25065) introducing the `kernel::Context`.

ACKs for top commit:
  maflcko:
    ACK c1144f0076 🗣
  achow101:
    ACK c1144f0076
  ryanofsky:
    Code review ACK c1144f0076. No code changes since last review, just updated commits and descriptions

Tree-SHA512: 819bb85ff82a5c6c60e429674d5684f3692fe9062500d00a87b361cc59e6bda145be21b5a4466dee6791faed910cbde4d26baab325bf6daa1813af13a63588ff
2023-11-07 16:17:29 -05:00
Andrew Chow
c8a883a412
Merge bitcoin/bitcoin#26839: Add support for RNDR/RNDRRS for AArch64 on Linux
aee5404e02 Add support for RNDR/RNDRRS for aarch64 on Linux (John Moffett)

Pull request description:

  This checks whether the ARMv8.5-A optional TRNG extensions [RNDR](https://developer.arm.com/documentation/ddi0601/2022-12/AArch64-Registers/RNDR--Random-Number) and [RNDRRS](https://developer.arm.com/documentation/ddi0601/2022-12/AArch64-Registers/RNDRRS--Reseeded-Random-Number) are available and, if they are, uses them for random entropy purposes.

  They are nearly functionally identical to the x86 RDRAND/RDSEED extensions and are used in a similar manner.

  Currently, there [appears to be](https://marcin.juszkiewicz.com.pl/download/tables/arm-socs.html) only one actual hardware implementation -- the Amazon Graviton 3. (See the `rnd` column in the link.) However, future hardware implementations may become available.

  It's not possible to directly query for the capability in userspace, but the Linux kernel [added support](1a50ec0b3b) for querying the extension via `getauxval` in version 5.6 (in 2020), so this is limited to Linux-only for now.

  Reviewers may want to launch any of the `c7g` instances from AWS to test the Graviton 3 hardware. Alternatively, QEMU emulates these opcodes for `aarch64` with CPU setting `max`.

  Output from Graviton 3 hardware:

  ```
  ubuntu@ip:~/bitcoin$ src/bitcoind -regtest
  2023-01-06T20:01:48Z Bitcoin Core version v24.99.0-3670266ce89a (release build)
  2023-01-06T20:01:48Z Using the 'arm_shani(1way,2way)' SHA256 implementation
  2023-01-06T20:01:48Z Using RNDR and RNDRRS as additional entropy sources
  2023-01-06T20:01:48Z Default data directory /home/ubuntu/.bitcoin
  ```

  Graviton 2 (doesn't support extensions):

  ```
  ubuntu@ip:~/bitcoin$ src/bitcoind -regtest
  2023-01-06T20:05:04Z Bitcoin Core version v24.99.0-3670266ce89a (release build)
  2023-01-06T20:05:04Z Using the 'arm_shani(1way,2way)' SHA256 implementation
  2023-01-06T20:05:04Z Default data directory /home/ubuntu/.bitcoin
  ```

  This partially closes #26796. As noted in that issue, OpenSSL [added support](https://github.com/openssl/openssl/pull/15361) for these extensions a little over a year ago.

ACKs for top commit:
  achow101:
    ACK aee5404e02
  laanwj:
    Tested ACK aee5404e02

Tree-SHA512: 1c1eb345d6690f5307a87e9bac8f06a0d1fdc7ca35db38fa22192510a44289a03252e4677dc7cbf731a27e6e3a9a4e42b6eb4149fe063bc1c905eb2536cdb1d3
2023-11-07 15:00:38 -05:00
Andrew Chow
e77339632e
Merge bitcoin/bitcoin#28136: refactor: move GetServicesNames from rpc/util.{h,cpp} to rpc/net.cpp
bbb68ffdbd refactor: drop protocol.h include header in rpc/util.h (Jon Atack)
1dd62c5295 refactor: move GetServicesNames from rpc/util.{h,cpp} to rpc/net.cpp (Jon Atack)

Pull request description:

  Move `GetServicesNames()` from `rpc/util` to `rpc/net.cpp`, as it is only called from that compilation unit and there is no reason for other ones to need it.

  Remove the `protocol.h` include in `rpc/util.h`, as it was only needed for `GetServicesNames()`, drop an unneeded forward declaration (the other IWYU suggestions would require more extensive changes in other files), and add 3 already-missing include headers in other translation units that are needed to compile without `protocol.h` in `rpc/util.h`, as `protocol.h` includes `netaddress.h`, which in turn includes `util/strencodings.h`.

ACKs for top commit:
  kevkevinpal:
    lgtm ACK [bbb68ff](bbb68ffdbd)
  ns-xvrn:
    ACK bbb68ff
  achow101:
    ACK bbb68ffdbd

Tree-SHA512: fcbe195874dd4aa9e86548685b6b28595a2c46f9869b79b6e2b3835f76b49cab4bef6a59c8ad6428063a41b7bb6f687229b06ea614fbd103e0531104af7de55d
2023-11-07 14:19:09 -05:00
Andrew Chow
0528cfd307
Merge bitcoin/bitcoin#28649: Do the SOCKS5 handshake reliably
af0fca530e netbase: use reliable send() during SOCKS5 handshake (Vasil Dimov)
1b19d1117c sock: change Sock::SendComplete() to take Span (Vasil Dimov)

Pull request description:

  The `Socks5()` function which does the SOCKS5 handshake with the SOCKS5 proxy sends bytes to the socket without retrying partial writes.

  `send(2)` may write only part of the provided data and return. In this case the caller is responsible for retrying the operation with the remaining data. Change `Socks5()` to do that. There is already a method `Sock::SendComplete()` which does exactly that, so use it in `Socks5()`.

  A minor complication for this PR is that `Sock::SendComplete()` takes `std::string` argument whereas `Socks5()` has `std::vector<uint8_t>`. Thus the necessity for the first commit. It is possible to do also in other ways - convert the data in `Socks5()` to `std::string` or have just one `Sock::SendComplete()` that takes `void*` and change the callers to pass `str.data(), str.size()` or `vec.data(), vec.size()`.

  This came up while testing https://github.com/bitcoin/bitcoin/pull/27375.

ACKs for top commit:
  achow101:
    ACK af0fca530e
  jonatack:
    ACK af0fca530e
  pinheadmz:
    ACK af0fca530e

Tree-SHA512: 1d4a53d0628f7607378038ac56dc3b8624ce9322b034c9547a0c3ce052eafb4b18213f258aa3b57bcb4d990a5e0548a37ec70af2bd55f6e8e6399936f1ce047a
2023-11-07 14:11:58 -05:00
fanquake
49d953281d
fuzz: explicitly specify llvm-symbolizer path in runner
It's not completely clear to me why this needs to be explicitly
specified in some environments, and not in others, while at the same time
that `llvm-symbolizer` is already in PATH, but this has fixed the 2 issues
outlined in #28147.

Use `LLVM_SYMBOLIZER_PATH` as the env var, as that is somewhat also used
inside LLVM, but not consistently, i.e it's checked for in the asan_symbolize
script, but not in in the ubsan_symbolize script, or from in compiler-rt.
2023-11-07 16:57:23 +00:00
Andrew Chow
3da69c464f
Merge bitcoin/bitcoin#28546: wallet: prevent bugs from invalid transaction heights with asserts, comments, and refactoring
f06016d77d wallet: Add asserts to detect unset transaction height values (Ryan Ofsky)
262a78b133 wallet, refactor: Add CWalletTx::updateState function (Ryan Ofsky)

Pull request description:

  Originally, this PR fixed a wallet migration bug that could cause the watchonly wallet created by legacy wallet migration to have incorrect transaction height values. A different fix for the bug was implemented in #28609, but that PR did not add any test coverage that would have caught the bug, and didn't include other changes from this PR intended to prevent problems from invalid transaction heights.

  This PR adds new asserts to catch invalid transaction heights, which would trigger test failures without bugfix in #28609. This PR also refactors code and adds comments to clarify assumptions and make it less likely a bug from invalid transaction height values would be introduced.

ACKs for top commit:
  achow101:
    ACK f06016d77d
  Sjors:
    utACK f06016d77d
  furszy:
    Code review ACK f06016d

Tree-SHA512: 82657c403724d60354f7676b53bcfcc95bdc5864e051a2eb8bfad09d8ad35615393b2d6b432b46f908def9be37bebded3a55ec9ae19e19371d35897fe842c92e
2023-11-07 11:29:29 -05:00
kevkevin
83933eff00
[refactor] Miniminer var cached_descendants to descendants
Refactored a variable name to be less confusing
2023-11-07 08:56:43 -06:00
kevkevin
43423fd834
[refactor] Change MiniMinerMempoolEntry order
Changes MiniMinerMempoolEntry order to match the order of the params
elsewhere in the codebase
2023-11-07 08:56:36 -06:00
glozow
1147e00e59 [validation] change package-fee-too-low, return wtxid(s) and effective feerate
With subpackage evaluation and de-duplication, it's not always the
entire package that is used in CheckFeerate. To be more helpful to the
caller, specify which transactions were included in the evaluation and
what the feerate was.

Instead of PCKG_POLICY (which is supposed to be for package-wide
errors), use PCKG_TX.
2023-11-07 11:26:17 +00:00
glozow
10dd9f2441 [test] use CheckPackageMempoolAcceptResult in previous tests
Increases test coverage (check every result field) and makes it easier
to test the changes in the next commit.
2023-11-07 11:23:07 +00:00
fanquake
2b3f43b96e
Merge bitcoin/bitcoin#28789: fuzz: Avoid utxo_total_supply timeout (take 2)
fa7ba92630 fuzz: Avoid utxo_total_supply timeout (MarcoFalke)

Pull request description:

  Looks like this still may take a long time to run large fuzz inputs. Thus, reduce it further, but still allow it to catch the regression, if re-introduced:

  ```diff
  diff --git a/src/consensus/tx_check.cpp b/src/consensus/tx_check.cpp
  index f949655909..4bdd15c5ee 100644
  --- a/src/consensus/tx_check.cpp
  +++ b/src/consensus/tx_check.cpp
  @@ -40,7 +40,7 @@ bool CheckTransaction(const CTransaction& tx, TxValidationState& state)
       std::set<COutPoint> vInOutPoints;
       for (const auto& txin : tx.vin) {
           if (!vInOutPoints.insert(txin.prevout).second)
  -            return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-inputs-duplicate");
  +            {}//return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-inputs-duplicate");
       }

       if (tx.IsCoinBase())
  ```

  This is the second take, see https://github.com/bitcoin/bitcoin/pull/27780. If in the future it still times out, I think the fuzz test can just be removed.

  Example input:

  ```
  JREROy5pcnAgQyw7IC4ODg4ODg4ODg4O0dEODg4ODg4ZDg4ODg4ODg4ODg7RDg4ODg4ODg4O0dEODg4ODg4ODg4ODg7R0Q4ODg4ODg4ODtHRDg4ODtHR0dEODg4O0dEODg7R0Q4ODg4ODg4ODtHRDg4ODg4ODg4ODg4O0dEODg4ODg4ODg7R0Q4ODg7R0Q4O0dEODg4ODg4ODg4ODg7R0Q4ODg4ODtHRDg4ODtHR

ACKs for top commit:
  dergoegge:
    ACK fa7ba92630
  brunoerg:
    utACK fa7ba92630

Tree-SHA512: 154a4895834babede6ce7b775562a7026637af1097e53e55676e92f6cf966ae0c092300ebf7e51a397eebd11f7b41d020586663e781f70d084efda1c0fe851b4
2023-11-07 11:17:00 +00:00
Andrew Chow
0387ca0774
Merge bitcoin/bitcoin#28612: Test: followups to #27823
5ab6419f38 test: randomized perturbing in feature_init (L0la L33tz)
64b80d5c5b test: simplify feature_init (Fabian Jahr)

Pull request description:

  Fixes #28603

  Added suggested simplifications and implemented randomization

ACKs for top commit:
  theStack:
    Light ACK 5ab6419f38
  maflcko:
    lgtm ACK 5ab6419f38
  achow101:
    ACK 5ab6419f38

Tree-SHA512: e6f43eef7f8dd12c7fccbe437cb430dc9d383825d7ab2caa0382d061f88dec6d28522e1ec78f3f58f26d35cba93512fa21e330c48d06b1d8141a16f07050af5a
2023-11-06 16:57:39 -05:00
Andrew Chow
0f5e31ce7d
Merge bitcoin/bitcoin#28799: wallet: cache descriptor ID to avoid repeated descriptor string creation
5e6bc6d830 test: remove custom rpc timeout for `wallet_miniscript.py`, reorder in test_runner (Sebastian Falbesoner)
f811a24421 wallet: cache descriptor ID to avoid repeated descriptor string creation (Sebastian Falbesoner)

Pull request description:

  Right now a wallet descriptor is converted to its string representation (via `Descriptor::ToString`) repeatedly at different instances:
  - on finding a `DescriptorScriptPubKeyMan` for a given descriptor (`CWallet::GetDescriptorScriptPubKeyMan`, e.g. used by the `importdescriptors` RPC); the string representation is created once for each spkm in the wallet and at each iteration again for the searched descriptor (`DescriptorScriptPubKeyMan::HasWalletDescriptor`)
  - whenever `DescriptorScriptPubKeyMan::GetID()` is called, e.g. in `TopUp` or any instances where a descriptor is written to the DB to determine the database key, also at less obvious places like `FastWalletRescanFilter` etc.

  As there is no good reason to calculate a fixed descriptor's string/ID more than once, add the ID as a field to `WalletDescriptor` and calculate it immediately at initialization (or deserialization). `HasWalletDescriptor` is changed to compare the spkm's and searched descriptor's ID instead of the string to take use of that.

  This speeds up the functional test `wallet_miniscript.py` by a factor of 5-6x on my machine (3m30.95s on master vs. 0m38.02s on PR). The recently introduced "max-size TapMiniscript" test-case introduced a descriptor that takes 2-3 seconds to create a string representation, so the repeated calls to that were significantly hurting the performance.

  Fixes https://github.com/bitcoin/bitcoin/issues/28800.

ACKs for top commit:
  Sjors:
    ACK 5e6bc6d830
  S3RK:
    Code Review ACK 5e6bc6d830
  achow101:
    ACK 5e6bc6d830
  BrandonOdiwuor:
    ACK 5e6bc6d830

Tree-SHA512: 98b43963a5dde6055bb26cecd3b878dadd837d6226af4c84142383310495da80b3c4bd552e73b9107f2f2ff1c11f5e18060c6fd3d9e44bbd5224114c4d245c1c
2023-11-06 15:18:45 -05:00
Andrew Chow
4cebad4833
Merge bitcoin/bitcoin#28363: doc: Add offline signing tutorial
3c208cc05e Add offline signing tutorial (Brandon Odiwuor)

Pull request description:

  This PR adds offline signing tutorial. Fixes https://github.com/bitcoin/bitcoin/issues/9492

  Although there currently exists tutorials on external-signer and on multisig implemented on #24519  . The external-signer tutorial assumes a connected device and the multisig tutorial is only for multisig transactions and does not include using an offline wallet

  - The tutorial uses signet(instead of regtest) to be as close as possible to mainnet

ACKs for top commit:
  achow101:
    ACK 3c208cc05e
  willcl-ark:
    ACK 3c208cc05e
  pinheadmz:
    ACK 3c208cc05e
  Zero-1729:
    ACK 3c208cc05e

Tree-SHA512: c1686043d9e9ed440e78d219a6b18d58d62efd05bdd535e74194d8cc2db0a91e94c6c619106453120a137e47220cf3ab27af3214e861f4e5cc419a73a8704dd6
2023-11-06 10:54:54 -05:00
glozow
3979f1afcb [validation] add TxValidationResult::TX_RECONSIDERABLE, TX_UNKNOWN
With package validation rules, transactions that fail individually may
sometimes be eligible for reconsideration if submitted as part of a
(different) package. For now, that includes trasactions that failed for
being too low feerate.  Add a new TxValidationResult type to distinguish
these failures from others.  In the next commits, we will abort package
validation if a tx fails for any other reason. In the future, we will
also decide whether to cache failures in recent_rejects based on this
result (we won't want to reject a package containing a transaction that
was rejected previously for being low feerate).

Package validation also sometimes elects to skip some transactions when
it knows the package will not be submitted in order to quit sooner. Add
a result to specify this situation; we also don't want to cache these
as rejections.
2023-11-06 14:41:56 +00:00
glozow
5c786a026a [refactor] use Wtxid for m_wtxids_fee_calculations 2023-11-06 14:33:32 +00:00
fanquake
21d985784f
Merge bitcoin/bitcoin#28788: test: bugfix CheckPackageMempoolAcceptResult return all error strings
5380f05513 test: bugfix CheckPackageMempoolAcceptResult return all error strings (Greg Sanders)

Pull request description:

  Noticed on follow-up testing work https://github.com/bitcoin/bitcoin/pull/28764/files#r1382150706

ACKs for top commit:
  glozow:
    utACK 5380f05513
  dergoegge:
    utACK 5380f05513

Tree-SHA512: abe122b5d702aaa0d731b45f6ba0f2f8ff9ecc14398cc087df56ee0980b5b483fc159d38ec36fe6360f82e5443673cfa80afc1c9cee6b840c95703b7dc8a8d3f
2023-11-06 14:25:47 +00:00
fanquake
f2cc718e69
Merge bitcoin/bitcoin#28798: build: Drop no longer needed MSVC warning suppressions
33223f9d55 build: Drop no longer needed MSVC warning suppressions (Hennadii Stepanov)

Pull request description:

ACKs for top commit:
  maflcko:
    lgtm ACK 33223f9d55

Tree-SHA512: 3757fce0a6900f6edc50a1b1298c5448059b100060e8a200bfc12d034852138084db12d100caefd2a19f170faa22bf4be9050094fd64f1273312541df7c81ef4
2023-11-06 09:54:40 +00:00
Sebastian Falbesoner
5e6bc6d830 test: remove custom rpc timeout for wallet_miniscript.py, reorder in test_runner 2023-11-05 23:54:02 +01:00
Sebastian Falbesoner
f811a24421 wallet: cache descriptor ID to avoid repeated descriptor string creation
Right now a wallet descriptor is converted to it's string representation
(via `Descriptor::ToString`) repeatedly at different instances:
- on finding a `DescriptorScriptPubKeyMan` for a given descriptor
  (`CWallet::GetDescriptorScriptPubKeyMan`, e.g. used by the
  `importdescriptors` RPC); the string representation is created once
  for each spkm in the wallet and at each iteration again for
  the searched descriptor (`DescriptorScriptPubKeyMan::HasWalletDescriptor`)
- whenever `DescriptorScriptPubKeyMan::GetID()` is called, e.g. in
  `TopUp` or any instances where a descriptor is written to the DB
  to determine the database key etc.

As there is no good reason to calculate a fixed descriptor's string/ID
more than once, add the ID as a field to `WalletDescriptor` and
calculate it immediately at initialization (or deserialization).
`HasWalletDescriptor` is changed to compare the spkm's and searched
descriptor's ID instead of the string to take use of that.

This speeds up the functional test `wallet_miniscript.py` by a factor of
5-6x on my machine (3m30.95s on master vs. 0m38.02s on PR). The recently
introduced "max-size TapMiniscript" test-case introduced a descriptor
that takes 2-3 seconds to create a string representation, so the
repeated calls to that were significantly hurting the performance.
2023-11-05 23:50:58 +01:00
fanquake
953d302a24
Merge bitcoin/bitcoin#28735: depends: Bump to capnproto-c++-1.0.1
3333f14efa depends: Bump to capnproto-c++-1.0.1 (MarcoFalke)

Pull request description:

  Reasons:
  * Debian is starting to ship this version in Trixie (https://packages.debian.org/trixie/capnproto), which will likely become the version shipped with Ubuntu 24.04 LTS. So testing with this version will help to find any issues before real users start to use those distro packages.
  * The feature is currently experimental, so bumping the version shouldn't cause any production issues.
  * With multiprocess begin a priority project for 27.0, it seems better to do build system changes/bumps early, rather than later, to allow for more time testing them.

ACKs for top commit:
  TheCharlatan:
    Re-ACK 3333f14efa
  fanquake:
    ACK 3333f14efa - the response from upstream is that [if we submit a PR, they can take a look](https://github.com/capnproto/capnproto/issues/1833#issuecomment-1792582206), so if anyone would like this to work for Windows, I'd suggest sending a patch.
  ryanofsky:
    Code review ACK 3333f14efa

Tree-SHA512: 7d53ad1536f042ab43dbc7847126b826e7fc76694f173c348b835fd1067b8f3dd682c5bcb4887f09ee85bab69130721cd7f8fb96b2e82053d4e28bd5c38bdc5f
2023-11-05 18:22:36 +00:00
fanquake
d2d53b4ac8
Merge bitcoin/bitcoin#28796: ci: Drop no longer needed "Fix Visual Studio installation" step
5bd1b8d4f1 ci: Drop no longer needed "Fix Visual Studio installation" step (Hennadii Stepanov)

Pull request description:

  The underlying issue has been [fixed](https://github.com/actions/runner-images/pull/8686) in the image version 20231029.

ACKs for top commit:
  maflcko:
    lgtm ACK 5bd1b8d4f1

Tree-SHA512: d0efef3086a147d863c9b5f45ba1142c6e7cc65e47d685b2094211e58036315fb7562253b7d7172b527fa1ded4b5a86634ba7c151e761ec20fe948145aff83fe
2023-11-05 18:15:38 +00:00
Hennadii Stepanov
33223f9d55
build: Drop no longer needed MSVC warning suppressions 2023-11-05 17:34:30 +00:00
Hennadii Stepanov
5bd1b8d4f1
ci: Drop no longer needed "Fix Visual Studio installation" step
The underlying issue has been fixed in the image version 20231029.
2023-11-05 10:01:56 +00:00
MarcoFalke
fa7ba92630
fuzz: Avoid utxo_total_supply timeout 2023-11-03 21:16:12 +01:00
Greg Sanders
5380f05513 test: bugfix CheckPackageMempoolAcceptResult return all error strings 2023-11-03 16:05:55 -04:00