Commit graph

43513 commits

Author SHA1 Message Date
Sjors Provoost
ad224429f8
net: additional disconnection logging
Use the word "disconnecting" everywhere for easier grep.
2024-11-26 13:22:55 +01:00
Sebastian Falbesoner
160799d913 test: refactor: introduce create_ephemeral_dust_package helper 2024-11-25 21:19:19 +01:00
Sebastian Falbesoner
61e18dec30 doc: ephemeral policy: add missing closing double quote 2024-11-25 21:05:11 +01:00
glozow
32fc59796f rpc: Allow single transaction through submitpackage
And under the hood suppoert single transactions
in AcceptPackage. This simplifies user experience
and paves the way for reducing number of codepaths
for transaction acceptance in the future.

Co-Authored-By: instagibbs <gsanders87@gmail.com>
2024-11-25 14:26:42 -05:00
Lőrinc
3305972f7b refactor: Fix remaining clang-tidy performance-unnecessary-copy-initialization errors 2024-11-25 20:11:54 +01:00
Lőrinc
11f3bc229c refactor: Reserve vectors in fuzz tests
* Since the main LIMITED_WHILE stated `outpoints.size() < 200'000`, I've presized outpoints accordingly.
* `tx_mut.vin` and `tx_mut.vout` weren't caught by the clang-tidy, but addressed them anyway.
2024-11-25 20:09:44 +01:00
Lőrinc
152fefe7a2 refactor: Preallocate PrevectorFillVector(In)Direct without vector resize
The prevector benchmarks were likely not trying to measure vector resize performance.
2024-11-25 20:09:44 +01:00
Lőrinc
a774c7a339 refactor: Fix remaining clang-tidy performance-inefficient-vector errors 2024-11-25 20:09:44 +01:00
glozow
f7144b24be
Merge bitcoin/bitcoin#31279: policy: ephemeral dust followups
Some checks are pending
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
466e4df3fb assert_mempool_contents: assert not duplicates expected (Greg Sanders)
ea5db2f269 functional: only generate required blocks for test (Greg Sanders)
d033acb608 fuzz: package_eval: let fuzzer run out input in main tx creation loop (Greg Sanders)
ba35a570c5 CheckEphemeralSpends: return boolean, and set child state and txid outparams (Greg Sanders)
cf0cee1617 func: add note about lack of 1P1C propagation in tree submitpackage (Greg Sanders)
8424290304 unit test: ephemeral_tests is using a dust relay rate, not minrelay (Greg Sanders)
d9cfa5fc4e CheckEphemeralSpends: no need to iterate inputs if no parent dust (Greg Sanders)
87b26e3dc0 func: rename test_free_relay to test_no_minrelay_fee (Greg Sanders)
e5709a4a41 func: slight elaboration on submitpackage restriction (Greg Sanders)
08e969bd10 RPC: only enforce dust rules on priority when standardness active (Greg Sanders)
ca050d12e7 unit test: adapt to changing MAX_DUST_OUTPUTS_PER_TX (Greg Sanders)
7c3490169c fuzz: package_eval: move last_tx inside txn ctor (Greg Sanders)
445eaed182 fuzz: use optional status instead of should_rbf_eph_spend (Greg Sanders)
4dfdf615b9 fuzz: remove unused TransactionsDelta validation interface (Greg Sanders)
09ce926e4a func: cleanup reorg test comment (Greg Sanders)
768a0c1889 func: cleanup test_dustrelay comments (Greg Sanders)
bedca1cb66 fuzz: Directly place transactions in vector (Greg Sanders)
c041ad6ecc fuzz: explain package eval coin tracking better (Greg Sanders)
bc0d98ea61 fuzz: remove dangling reference to GetEntry (Greg Sanders)
15b6cbf07f unit test: make dust index less magical (Greg Sanders)
5fbcfd12b8 unit test: assert txid returned on CheckEphemeralSpends failures (Greg Sanders)
ef94d84b4e bench: remove unnecessary CMTxn constructors (Greg Sanders)
c5c10fd317 ephemeral policy doxygen cleanup (Greg Sanders)
dd9044b8d4 ephemeral policy: IWYU (Greg Sanders)
c6859ce2de Move+rename GetDustIndexes -> GetDust (Greg Sanders)
62016b3230 Use std::ranges for ephemeral policy checks (Greg Sanders)
3ed930a1f4 Have HasDust and PreCheckValidEphemeralTx take CTransaction (Greg Sanders)
04a614bf9a Rename CheckValidEphemeralTx to PreCheckEphemeralTx (Greg Sanders)
cbf1a47d60 CheckEphemeralSpends: only compute txid of tx when needed (Greg Sanders)

Pull request description:

  Follow-up to https://github.com/bitcoin/bitcoin/pull/30239

  Here are the parent PR's comments that should be addressed by this PR:

  https://github.com/bitcoin/bitcoin/pull/30239/files#r1834529646
  https://github.com/bitcoin/bitcoin/pull/30239/files#r1831247308
  https://github.com/bitcoin/bitcoin/pull/30239/files#r1832622481
  https://github.com/bitcoin/bitcoin/pull/30239/files#r1831195216
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1835805164
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1835805164
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1834639096
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1834624976
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1834619709
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1834610434
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1834504436
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1834500036
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1832985488
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1830929809
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1832376920
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1832755799
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1832492686
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1832980576
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1832784278
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1837989979
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1830996993
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1830997947
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1830012890
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1830037288
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1830977092
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1832622481
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1834726168
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1832453654
  https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1848488226

ACKs for top commit:
  naumenkogs:
    ACK 466e4df3fb
  hodlinator:
    ACK 466e4df3fb
  theStack:
    lgtm ACK 466e4df3fb
  glozow:
    utACK 466e4df3fb

Tree-SHA512: 89106f695755c238b84e0996b89446c0733e10a94c867f656d516d26697d2efe38dfc332188b8589a0a26a3d2bd2c88c6ab70c108e187ce5bfcb91bbf3fb0391
2024-11-25 13:47:44 -05:00
TheCharlatan
c288c790cd
interpreter: Use the same type for SignatureHash in the definition
This was missed during the original PR switching the nHashType argument
to int32_t in SignatureHash in bc52cda1f3.

The problem was discovered after running into a linker error when
attempting to link this code as a static library using the header as a
declaration with a riscv32 bare metal toolchain. The compiler would
error with:

/opt/riscv-ilp32/lib/gcc/riscv32-unknown-elf/13.2.0/../../../../riscv32-unknown-elf/bin/ld: build_kernel_riscv/src/libbitcoin_consensus.a(interpreter.cpp.o): in function `GenericTransactionSignatureChecker<CTransaction>::CheckECDSASignature(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, CScript const&, SigVersion) const':
/home/user/bitcoin/build_kernel_riscv/./script/interpreter.cpp:2043:(.text._ZNK34GenericTransactionSignatureCheckerI12CTransactionE19CheckECDSASignatureERKSt6vectorIhSaIhEES6_RK7CScript10SigVersion[_ZNK34GenericTransactionSignatureCheckerI12CTransactionE19CheckECDSASignatureERKSt6vectorIhSaIhEES6_RK7CScript10SigVersion]+0xee): undefined reference to `uint256 SignatureHash<CTransaction>(CScript const&, CTransaction const&, unsigned int, int, long long const&, SigVersion, PrecomputedTransactionData const*)'
2024-11-25 15:36:05 +01:00
dergoegge
b031b7910d [ci] Split out native fuzz jobs for macOS and windows 2024-11-25 10:41:17 +00:00
Hennadii Stepanov
6f4128e3a8
cmake, qt: Use absolute paths for includes in MOC-generated files
This change resolves build issues that occur when the source or build
directory is symlinked.
2024-11-24 15:14:14 +00:00
Hennadii Stepanov
ab5c63edcc
cmake: Build secp256k1 only when required 2024-11-23 15:31:39 +00:00
Hennadii Stepanov
76a3a540a4
cmake: Ensure script correctness when no targets are specified 2024-11-23 15:17:18 +00:00
Sebastian Falbesoner
988721d37a test: avoid internet traffic in rpc_net.py
Can be tested by running

```
$ sudo tcpdump -i eth0 host 11.22.33.44
```

and verifying that no packets appear in the tcpdump output.

Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
2024-11-22 18:28:07 +01:00
fanquake
e8f50c5deb
guix: swap moreutils for just sponge
We build the only moreutils utility we actually need (sponge), have less
unused stuff in the Guix environment, and, the dependency graph is
simplified. i.e we no-longer have a dependency on perl, docbook etc, for
this package.
2024-11-22 10:54:13 +00:00
Hennadii Stepanov
01a7298818
build: Avoid using the -ffile-prefix-map compiler option
The `-ffile-prefix-map` compiler option implies `-fprofile-prefix-map`
on GCC or `-fcoverage-prefix-map` on Clang, which can lead to issues
with coverage builds.

This change applies only the options necessary for build reproducibility
and accurate source location messages.
2024-11-22 10:21:13 +00:00
Ava Chow
2638fdb4f9
Merge bitcoin/bitcoin#31338: test: Deduplicate assert_mempool_contents()
Some checks failed
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Has been cancelled
CI / test each commit (push) Has been cancelled
CI / Win64 native, VS 2022 (push) Has been cancelled
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Has been cancelled
a0eafc10f9 functional test: Deduplicate assert_mempool_contents() (Hodlinator)

Pull request description:

  Recently added `mempool_util` implementation probably evolved in parallel with the package RBF one before being submitted as part of ephemeral dust in e2e30e89ba (related comments: https://github.com/bitcoin/bitcoin/pull/30239#discussion_r1825278134, https://github.com/bitcoin/bitcoin/pull/31279#pullrequestreview-2445579323).

ACKs for top commit:
  instagibbs:
    ACK a0eafc10f9
  achow101:
    ACK a0eafc10f9
  l0rinc:
    ACK a0eafc10f9
  theStack:
    ACK a0eafc10f9

Tree-SHA512: 25ea807d7c041c18be0e4f424131419365d7c1e0fc6c4fb7ac7289c2f8196fd341ff2a2a3ea88df2c3a389edb4571a5fb889efc1b0204c65f7e09ef8f608d0d3
2024-11-21 19:11:27 -05:00
TheCharlatan
73db95c65c
kernel: Make bitcoin-chainstate's block validation mirror submitblock's
The behaviour of submitblock was changed in the previous commit, so
change it here too.
2024-11-21 22:18:36 +01:00
Greg Sanders
bb53ce9bda
tests: Add functional test for submitting a previously pruned block
This tests the new submitblock behaviour that is introduced in the
previous commit: Submitting a previously pruned block should persist the
block's data again.
2024-11-21 22:18:35 +01:00
TheCharlatan
1f7fc73825
rpc: Remove submitblock duplicate pre-check
The duplicate checks are repeated early in the contextual checks of
ProcessNewBlock. If duplicate blocks are detected much of their
validation is skipped. Depending on the constitution of the block,
validating the merkle root of the block is part of the more intensive
workload when validating a block. This could be an argument for moving
the pre-checks into block processing. In net_processing this would have
a smaller effect however, since the block mutation check, which also
validates the merkle root, is done before.

A side effect of this change is that a duplicate block is persisted
again on disk even when pruning is activated. This is similar to the
behaviour with getblockfrompeer. Add a release note for this change in
behaviour.

Testing spamming a node with valid, but duplicate unrequested blocks
seems to exhaust a CPU thread, but does not seem to significantly impact
keeping up with the tip. The benefits of adding these checks to
net_processing are questionable, especially since there are other ways
to trigger the more CPU-intensive checks without submitting a duplicate
block. Since these DOS concerns apply even less to the RPC interface,
which does not have banning mechanics built in, remove them too.

---

With the introduction of a mining ipc interface and the potential future
introduction of a kernel library API it becomes increasingly important
to offer common behaviour between them. An example of this is
ProcessNewBlock, which is used by ipc, rpc, net_processing and
(potentially) the kernel library. Having divergent behaviour on
suggested pre-checks and checks for these functions is confusing to both
developers and users and is a maintenance burden.

The rpc interface for ProcessNewBlock (submitblock) currently pre-checks
if the block has a coinbase transaction and whether it has been
processed before. While the current example binary for how to use the
kernel library, bitcoin-chainstate, imitates these checks, the other
interfaces do not.
2024-11-21 22:18:33 +01:00
TheCharlatan
e62a8abd7d
rpc: Remove submitblock invalid-duplicate precheck
ProcessNewBlock fails if an invalid duplicate block is passed in through
its call to AcceptBlock and AcceptBlockHeader. The failure in
AcceptBlockHeader makes AcceptBlock return early. This makes the
pre-check in submitblock redundant.

---

With the introduction of a mining ipc interface and the potential future
introduction of a kernel library API it becomes increasingly important
to offer common behaviour between them. An example of this is
ProcessNewBlock, which is used by ipc, rpc, net_processing and
(potentially) the kernel library. Having divergent behaviour on
suggested pre-checks and checks for these functions is confusing to both
developers and users and is a maintenance burden.

The rpc interface for ProcessNewBlock (submitblock) currently pre-checks
if the block has a coinbase transaction and whether it has been
processed before. While the current example binary for how to use the
kernel library, bitcoin-chainstate, imitates these checks, the other
interfaces do not.
2024-11-21 22:18:31 +01:00
TheCharlatan
36dbebafb9
rpc: Remove submitblock coinbase pre-check
The coinbase check is repeated again early during ProcessNewBlock.
Pre-checking it may also shadow more fundamental problems with a block.
In most cases the block header is checked first, before validating the
transactions. Checking the coinbase first therefore masks potential
issues with the header. Fix this by removing the pre-check.

The pre-check was likely introduced on top of
ada0caa165 to fix UB in
GetWitnessCommitmentIndex in case a block's transactions are empty. This
code path could only be reached because of the call to
UpdateUncommittedBlockStructures in submitblock, but cannot be reached
through net_processing.

Add some functional test cases to cover the previous conditions that
lead to a "Block does not start with a coinbase" json rpc error being
returned.

---

With the introduction of a mining ipc interface and the potential future
introduction of a kernel library API it becomes increasingly important
to offer common behaviour between them. An example of this is
ProcessNewBlock, which is used by ipc, rpc, net_processing and
(potentially) the kernel library. Having divergent behaviour on
suggested pre-checks and checks for these functions is confusing to both
developers and users and is a maintenance burden.

The rpc interface for ProcessNewBlock (submitblock) currently pre-checks
if the block has a coinbase transaction and whether it has been
processed before. While the current example binary for how to use the
kernel library, bitcoin-chainstate, imitates these checks, the other
interfaces do not.
2024-11-21 22:16:43 +01:00
merge-script
17834bd197
Merge bitcoin/bitcoin#31333: fuzz: Implement G_TEST_GET_FULL_NAME
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
92d3d691f0 fuzz: Implement G_TEST_GET_FULL_NAME (Hodlinator)

Pull request description:

  Catching up to bench & unit tests. Makes for more orderly paths for fuzz tests using `BasicTestingSetup`.

  ### Before
  ```
  /tmp/test_common bitcoin/0748ae43ef8fa80703bc/regtest/blocks/xor.dat
  ```
  ### After
  ```
  /tmp/test_common bitcoin/tx_pool_standard/f18b3744625e0600eb0c/regtest/blocks/xor.dat
  ```

ACKs for top commit:
  kevkevinpal:
    ACK [92d3d69](92d3d691f0)
  furszy:
    utACK 92d3d691f0
  tdb3:
    ACK 92d3d691f0
  dergoegge:
    utACK 92d3d691f0
  brunoerg:
    code review ACK 92d3d691f0

Tree-SHA512: 5e83970b111232adece10f79e3a43d0c3c49ab635763e2a4b420f1336cbb8fee94aab751264ddec01ac8363166636e3b29cfe3b2969fc28c8dd6b31bda351950
2024-11-21 13:57:17 +00:00
merge-script
cf57722788
Merge bitcoin/bitcoin#31335: macOS: swap docs & CI from pkg-config to pkgconf
fe3457ccff ci: note that we should install pkgconf in future (fanquake)
8d203480b3 doc: migrate from pkg-config to pkgconf in macOS build docs (fanquake)

Pull request description:

  Migrate the macOS build docs and CI from `pkg-config` to `pkgconf`. As the former now just redirects to the later.

  Upstream is currently mass-migrating its formula. i.e https://github.com/Homebrew/homebrew-core/pull/198317.

  Fixes #31334.

ACKs for top commit:
  maflcko:
    ACK fe3457ccff 🍭
  hebasto:
    re-ACK fe3457ccff.

Tree-SHA512: 6e337acb6767d163491149b6ae7181d7d7042bc11cdc745eb6f52d4df6d7a19c4f6daa000b314acd9178f97e670aba145f829e48b1b3033117d7e39cdd3af177
2024-11-21 13:37:46 +00:00
fanquake
fe3457ccff
ci: note that we should install pkgconf in future
As pkg-config is now just redirected to the later, but changing this likely
depends on the GHA image being updated first.
2024-11-21 11:08:02 +00:00
Hodlinator
a0eafc10f9
functional test: Deduplicate assert_mempool_contents()
Recently added mempool_util implementation probably evolved in parallel with the package RBF one before being submitted as part of ephemeral dust in e2e30e89ba.
2024-11-21 12:01:34 +01:00
fanquake
8d203480b3
doc: migrate from pkg-config to pkgconf in macOS build docs
Brew has migrated to using the later:
```bash
brew info pkg-config
==> pkgconf: stable 2.3.0 (bottled), HEAD
Package compiler and linker metadata toolkit
https://github.com/pkgconf/pkgconf
```
2024-11-21 10:28:44 +00:00
Hodlinator
bffd92f00f
args: Support -nopid 2024-11-20 22:55:26 +01:00
Hodlinator
12f8d848fd
args: Disallow -nodatadir
Does not make sense to run without a datadir.

Prior to this change it would be interpreted as a mix of unset and as a relative path of "0".
2024-11-20 22:55:25 +01:00
Hodlinator
6ff9662760
scripted-diff: Avoid printing version information for -noversion
-BEGIN VERIFY SCRIPT-
sed -i --regexp-extended 's/\b(gArgs|args)\.IsArgSet\("-version"\)/\1.GetBoolArg("-version", false)/g' $(git grep -l '-version')
-END VERIFY SCRIPT-
2024-11-20 22:55:23 +01:00
Greg Sanders
466e4df3fb assert_mempool_contents: assert not duplicates expected 2024-11-20 13:49:41 -05:00
Greg Sanders
ea5db2f269 functional: only generate required blocks for test 2024-11-20 13:49:41 -05:00
Greg Sanders
d033acb608 fuzz: package_eval: let fuzzer run out input in main tx creation loop 2024-11-20 13:49:41 -05:00
Greg Sanders
ba35a570c5 CheckEphemeralSpends: return boolean, and set child state and txid outparams 2024-11-20 13:49:41 -05:00
Greg Sanders
cf0cee1617 func: add note about lack of 1P1C propagation in tree submitpackage 2024-11-20 13:49:41 -05:00
Greg Sanders
8424290304 unit test: ephemeral_tests is using a dust relay rate, not minrelay 2024-11-20 13:49:41 -05:00
Greg Sanders
d9cfa5fc4e CheckEphemeralSpends: no need to iterate inputs if no parent dust 2024-11-20 13:49:41 -05:00
Greg Sanders
87b26e3dc0 func: rename test_free_relay to test_no_minrelay_fee 2024-11-20 13:49:41 -05:00
Greg Sanders
e5709a4a41 func: slight elaboration on submitpackage restriction 2024-11-20 13:49:41 -05:00
Greg Sanders
08e969bd10 RPC: only enforce dust rules on priority when standardness active 2024-11-20 13:49:41 -05:00
Greg Sanders
ca050d12e7 unit test: adapt to changing MAX_DUST_OUTPUTS_PER_TX 2024-11-20 13:49:41 -05:00
Greg Sanders
7c3490169c fuzz: package_eval: move last_tx inside txn ctor 2024-11-20 13:49:41 -05:00
Greg Sanders
445eaed182 fuzz: use optional status instead of should_rbf_eph_spend 2024-11-20 13:49:41 -05:00
Greg Sanders
4dfdf615b9 fuzz: remove unused TransactionsDelta validation interface 2024-11-20 13:44:49 -05:00
Greg Sanders
09ce926e4a func: cleanup reorg test comment 2024-11-20 13:44:49 -05:00
Greg Sanders
768a0c1889 func: cleanup test_dustrelay comments 2024-11-20 13:44:49 -05:00
Greg Sanders
bedca1cb66 fuzz: Directly place transactions in vector 2024-11-20 13:44:49 -05:00
Greg Sanders
c041ad6ecc fuzz: explain package eval coin tracking better 2024-11-20 13:44:49 -05:00
Greg Sanders
bc0d98ea61 fuzz: remove dangling reference to GetEntry 2024-11-20 13:44:49 -05:00