Commit graph

43449 commits

Author SHA1 Message Date
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
Greg Sanders
15b6cbf07f unit test: make dust index less magical 2024-11-20 13:44:49 -05:00
Greg Sanders
5fbcfd12b8 unit test: assert txid returned on CheckEphemeralSpends failures
Simplify nullopt checks
2024-11-20 12:49:03 -05:00
Greg Sanders
ef94d84b4e bench: remove unnecessary CMTxn constructors 2024-11-20 12:49:03 -05:00
Greg Sanders
c5c10fd317 ephemeral policy doxygen cleanup 2024-11-20 12:49:03 -05:00
Greg Sanders
dd9044b8d4 ephemeral policy: IWYU 2024-11-20 12:49:03 -05:00
Greg Sanders
c6859ce2de Move+rename GetDustIndexes -> GetDust
Use to replace HasDust and where appropraite
2024-11-20 12:48:03 -05:00
Ryan Ofsky
22ef95dbe3
Merge bitcoin/bitcoin#31288: Add destroy to BlockTemplate schema
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
9aa50152c1 Add destroy to BlockTemplate schema (Sjors Provoost)

Pull request description:

  This ensures that if a client no longer needs a block template, the node can clear its memory as soon as possible.

  A block template may hold on to transactions that are no longer in the mempool, so this can be significant.

  This has a trivial silent merge conflict with #31283 because it also used the number `@9` (gaps are not allowed). I'll rebase whichever is merged last.

ACKs for top commit:
  TheCharlatan:
    Re-ACK 9aa50152c1
  ryanofsky:
    Code review ACK 9aa50152c1

Tree-SHA512: 393571b4455969cba71c7572feaeff4503738205331ab198b9181c156c75eb65933a8e5ceff66fc06d1efb8f2528bdb254e5eee7df75735b912526de1e7b166d
2024-11-20 10:45:43 -05:00
Hodlinator
92d3d691f0
fuzz: Implement G_TEST_GET_FULL_NAME
When BasicTestingSetup is used in fuzz-tests it will now create test directories containing the fuzz target names. Example:
/tmp/test_common bitcoin/tx_package_eval/153d7906294f7d0606a7/

This is already implemented for bench and unit tests.
2024-11-20 15:08:33 +01:00
glozow
f34fe0806a
Merge bitcoin/bitcoin#31122: cluster mempool: Implement changeset interface for mempool
5736d1ddac tracing: pass if replaced by tx/pkg to tracepoint (0xb10c)
a4ec07f194 doc: add comments for CTxMemPool::ChangeSet (Suhas Daftuar)
83f814b1d1 Remove m_all_conflicts from SubPackageState (Suhas Daftuar)
d3c8e7dfb6 Ensure that we don't add duplicate transactions in rbf fuzz tests (Suhas Daftuar)
d7dc9fd2f7 Move CalculateChunksForRBF() to the mempool changeset (Suhas Daftuar)
284a1d33f1 Move prioritisation into changeset (Suhas Daftuar)
446b08b599 Don't distinguish between direct conflicts and all conflicts when doing cluster-size-2-rbf checks (Suhas Daftuar)
b53041021a Duplicate transactions are not permitted within a changeset (Suhas Daftuar)
b447416fdd Public mempool removal methods Assume() no changeset is outstanding (Suhas Daftuar)
2b30f4d36c Make RemoveStaged() private (Suhas Daftuar)
18829194ca Enforce that there is only one changeset at a time (Suhas Daftuar)
7fb62f7db6 Apply mempool changeset transactions directly into the mempool (Suhas Daftuar)
34b6c5833d Clean up FinalizeSubpackage to avoid workspace-specific information (Suhas Daftuar)
57983b8add Move LimitMempoolSize to take place outside FinalizeSubpackage (Suhas Daftuar)
01e145b975 Move changeset from workspace to subpackage (Suhas Daftuar)
802214c083 Introduce mempool changesets (Suhas Daftuar)
87d92fa340 test: Add unit test coverage of package rbf + prioritisetransaction (Suhas Daftuar)
15d982f91e Add package hash to package-rbf log message (Suhas Daftuar)

Pull request description:

  part of cluster mempool: #30289

  It became clear while working on cluster mempool that it would be helpful for transaction validation if we could consider a full set of proposed changes to the mempool -- consisting of a set of transactions to add, and a set of transactions (ie conflicts) to simultaneously remove -- and perform calculations on what the mempool would look like if the proposed changes were to be applied.  Two specific examples of where we'd like to do this:

  - Determining if ancestor/descendant/TRUC limits would be violated (in the future, cluster limits) if either a single transaction or a package of transactions were to be accepted
  - Determining if an RBF would make the mempool "better", however that idea is defined, both in the single transaction and package of transaction cases

  In preparation for cluster mempool, I have pulled this reworking of the mempool interface out of #28676 so it can be reviewed on its own.  I have not re-implemented ancestor/descendant limits to be run through the changeset, since with cluster mempool those limits will be going away, so this seems like wasted effort.  However, I have rebased #28676 on top of this branch so reviewers can see what the new mempool interface could look like in the cluster mempool setting.

  There are some minor behavior changes here, which I believe are inconsequential:
  - In the package validation setting, transactions would be added to the mempool before the `ConsensusScriptChecks()` are run. In theory, `ConsensusScriptChecks()` should always pass if the `PolicyScriptChecks()` have passed and it's just a belt-and-suspenders for us, but if somehow they were to diverge then there could be some small behavior change from adding transactions and then removing them, versus never adding them at all.
  - The error reporting on `CheckConflictTopology()` has slightly changed due to no longer distinguishing between direct conflicts and indirect conflicts. I believe this should be entirely inconsequential because there shouldn't be a logical difference between those two ideas from the perspective of this function, but I did have to update some error strings in some tests.
  - Because, in a package setting, RBFs now happen as part of the entire package being accepted, the logging has changed slightly because we do not know which transaction specifically evicted a given removed transaction.
    -  Specifically, the "package hash" is now used to reference the set of transactions that are being accepted, rather than any single txid. The log message relating to package RBF that happen in the `TXPACKAGES` category has been updated as well to include the package hash, so that it's possible to see which specific set of transactions are being referenced by that package hash.
    - Relatedly, the tracepoint logging in the package rbf case has been updated as well to reference the package hash, rather than a transaction hash.

ACKs for top commit:
  naumenkogs:
    ACK 5736d1ddac
  instagibbs:
    ACK 5736d1ddac
  ismaelsadeeq:
    reACK 5736d1ddac
  glozow:
    ACK 5736d1ddac

Tree-SHA512: 21810872e082920d337c89ac406085aa71c5f8e5151ab07aedf41e6601f60a909b22fbf462ef3b735d5d5881e9b76142c53957158e674dd5dfe6f6aabbdf630b
2024-11-20 07:48:29 -05:00
merge-script
b2d952c0f5
Merge bitcoin/bitcoin#31331: doc: add copyright header to p2p_headers_presync
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
7d3703dec3 doc: add copyright header to p2p_headers_presync (fanquake)

Pull request description:

  Add the missing copyright header.

ACKs for top commit:
  willcl-ark:
    ACK 7d3703dec3

Tree-SHA512: c1be62ac9ebb6ef0210670e80aa473da287b26c4f29e347a4f837652ed4c2bb71f952c83f14fc13f1b523f8712d79d78bda5dcdf5fd6fc61788c1d86a67a4729
2024-11-20 12:02:25 +00:00
fanquake
7d3703dec3
doc: add copyright header to p2p_headers_presync 2024-11-20 11:48:53 +00:00
merge-script
116b8c5573
Merge bitcoin/bitcoin#31213: fuzz: Fix difficulty target generation in p2p_headers_presync
a6ca8f3243 fuzz: Fix difficulty target generation in p2p_headers_presync (marcofleon)
fa327c77e3 util: Add ConsumeArithUInt256InRange fuzzing helper (marcofleon)

Pull request description:

  In the `p2p_headers_presync` fuzz target, this assertion failed:
  ```
   assert(total_work < chainman.MinimumChainWork());
   ```
  Input that triggered the failure: [p2ppresync_crash.txt](https://github.com/user-attachments/files/17620203/p2ppresync_crash.txt)

  The test previously used `ConsumeIntegralInRange` to generate header difficulty targets within a hardcoded range. The fuzzer found specific values in that range that correspond to very low thresholds due to how [`SetCompact`][setcompact-link] works. The total work of a long enough test chain ended up exceeding `MinimumChainWork`.

  Fix this by adding a new `ConsumeArithUInt256InRange` helper function and use it in the fuzz test to generate target values within the originally intended range. The target is then converted to an `nBits` value using `GetCompact()`.

  For some more context, see https://github.com/bitcoin/bitcoin/pull/30918.

  [setcompact-link]: 6463117a29/src/arith_uint256.h (L251-L271)

ACKs for top commit:
  instagibbs:
    ACK a6ca8f3243
  dergoegge:
    Code review ACK a6ca8f3243
  brunoerg:
    code review ACK a6ca8f3243

Tree-SHA512: 92013d9d37bd3f11992ee678ba9745196efbdc4d773fd14994116629260bea46ffc9fa3923d443af7b623d39c6211900ce98a349c62ad1976e12312c37ef9df0
2024-11-20 11:46:22 +00:00