Commit graph

1367 commits

Author SHA1 Message Date
Ava Chow
4b301666ff Merge bitcoin/bitcoin#33050: net, validation: don't punish peers for consensus-invalid txs
876dbdfb4702410dfd4037614dc9298a0c09c63e tests: drop expect_disconnect behaviour for tx relay (Anthony Towns)
b29ae9efdfeeff774e32ee433ce67d8ed8ecd49f validation: only check input scripts once (Anthony Towns)
266dd0e10d08c0bfde63205db15d6c210a021b90 net_processing: drop MaybePunishNodeForTx (Anthony Towns)

Pull request description:

  Because we do not discourage nodes for transactions we consider non-standard, we don't get any DoS protection from this check in adversarial scenarios, so remove the check entirely both to simplify the code and reduce the risk of splitting the network due to changes in tx relay policy.

  Then, because we no longer make use of the distinction between consensus and standardness failures during script validation, don't re-validate each script with only-consensus rules, reducing the cost to us of transactions that we won't relay.

ACKs for top commit:
  achow101:
    ACK 876dbdfb4702410dfd4037614dc9298a0c09c63e
  darosior:
    re-ACK 876dbdfb4702410dfd4037614dc9298a0c09c63e
  sipa:
    re-ACK 876dbdfb4702410dfd4037614dc9298a0c09c63e
  glozow:
    ACK 876dbdfb4702410dfd4037614dc9298a0c09c63e

Tree-SHA512: 8bb0395766dde54fc48f7077b80b88e35581aa6e3054d6d65735965147abefffa7348f0850bb3d46f6c2541fd384ecd40a00a57fa653adabff8a35582e2d1811
2025-11-26 10:22:33 +00:00
merge-script
53dc403306
Merge ElementsProject/elements#1514: Mitigate disk filling attacks by rate limiting Log writing
d23b6c86d0 [log] Introduce log rate limiter class (Niklas Gögge)
817c68a64f Merge bitcoin/bitcoin#24464: logging: Add severity level to logs (laanwj)

Pull request description:

  Mitigation of [CVE-2025-54604](https://bitcoincore.org/en/2025/10/24/disclose-cve-2025-54604/) and [CVE-2025-54605 - Disk filling from invalid blocks](https://bitcoincore.org/en/2025/10/24/disclose-cve-2025-54605/)

  Port of https://github.com/bitcoin/bitcoin/pull/21603 (the later PR merged for inclusion in bitcoin v30 https://github.com/bitcoin/bitcoin/pull/32604 relies on `std::source_location` in C++20). 21603 implements `SourceLocation ` and `SourceLocationHasher` for use with C++17.

  Dependent on: bitcoin/bitcoin#24464: logging: Add severity level to logs

ACKs for top commit:
  delta1:
    ACK d23b6c86d0

Tree-SHA512: 0e49eb9fa46e65c7f5deb5f4cc40f25812756510fbe7eb16140e482e0259c91b4584e65cb43a7d83b7aa9dcf586fd26436aed4efa2757de32cc3f3c3a71acbf0
2025-11-26 11:59:16 +02:00
Niklas Gögge
d23b6c86d0 [log] Introduce log rate limiter class
The LogRatelimiter class implements a fixed window rate limiter. The
rate limiter allows a fixed amount of bytes to be consumed within a
fixed time window.

[log] Introduce source location type

The SourceLocation type stores the filename and line of a source code
location.
In a later commit we use this type as the key type in an unordered map
and set to keep track of rate limters for each location.

[config] Add -ratelimitlogging config option

The -ratelimitlogging can be used to enable/disable the rate limiting to
disk. Rate limiting is enabled by default.

[log] Add two new categories for unconditional logging

We create two new categories `UNCONDITIONAL_ALWAYS` and
`UNCONDITIONAL_RATE_LIMITED` that are always enabled by default.

LogPrintf now logs using the `UNCONDITIONAL_RATE_LIMITED` category which
will start to apply rate limiting in a later commit.

For some log locations it might be safe to allow more frequent logging
without rate limiting. These locations should use the
`UNCONDITIONAL_ALWAYS` category.

[validation] Exempt UpdateTipLog from rate limiting

UpdateTipLog logs everytime a new tip is activated. This occurs at an
increased frequency during IBD and should therefore be exempt from rate
limiting.

[log] Add rate limiting to LogPrintf

To mitigate disk filling attacks caused by unsafe usages of LogPrintf,
we rate limit LogPrintf by using the fixed window rate limiter
(BCLog::LogRatelimiter) introduced in an earlier commit.

The rate limiting logic is applied per source location instead of
globally. A source location is allowed to log up to 1 MiB per hour.
Source locations that violate the limit will have their logs supressed
for up to one hour.

[test util] Mark ~DebugLogHelper as noexcept(false)

We mark ~DebugLogHelper as noexcept(false) to be able to catch the
exception it throws. This lets us use it in test in combination with
BOOST_CHECK_THROW and BOOST_CHECK_NO_THROW to check that certain log
messages are (not) logged.

[test] Check for expected log rate limiting messages

[test] Test for expected file size changes when rate limiting is enabled

[test] Check that log rate limiting is disabled for exempt source locations

[test] Check that rate limiting can be disabled
2025-11-24 13:36:23 +00:00
merge-script
0cb5c660bb Merge bitcoin/bitcoin#33105: validation: detect witness stripping without re-running Script checks
27aefac42505e9c083fa131d3d7edbec7803f3c0 validation: detect witness stripping without re-running Script checks (Antoine Poinsot)
2907b58834ab011f7dd0c42d323e440abd227c25 policy: introduce a helper to detect whether a transaction spends Segwit outputs (Antoine Poinsot)
eb073209db9efdbc2c94bc1f535a27ec6b20d954 qa: test witness stripping in p2p_segwit (Antoine Poinsot)

Pull request description:

  Since it was introduced in 4eb515574e (#18044), the detection of a stripped witness relies on running the Script checks 3 times. In the worst case, this consists in running Script validation for every single input 3 times.

  Detection of a stripped witness is necessary because in this case wtxid==txid, and the transaction's wtxid must not be added to the reject filter or it could allow a malicious peer to interfere with txid-based orphan resolution as used in 1p1c package relay.

  However it is not necessary to run Script validation to detect a stripped witness (much less so doing it 3 times in a row). There are 3 types of witness program: defined program types (Taproot, P2WPKH and P2WSH), undefined types, and the Pay-to-anchor carve-out.

  For defined program types, Script validation with an empty witness will always fail (by consensus). For undefined program types, Script validation is always going to fail regardless of the witness (by standardness). For P2A, an empty witness is never going to lead to a failure.

  Therefore it holds that we can always detect a stripped witness without re-running Script validation. However this might lead to more "false positives" (cases where we return witness stripping for an otherwise invalid transaction) than the existing implementation. For instance a transaction with one P2PKH input with an invalid signature and one P2WPKH input with its witness stripped. The existing implementation would treat it as consensus invalid while the implementation in this PR would always consider it witness stripped.

  h/t AJ: this essentially implements a variant of https://github.com/bitcoin/bitcoin/pull/33066#issuecomment-3135258539.

ACKs for top commit:
  sipa:
    re-ACK 27aefac42505e9c083fa131d3d7edbec7803f3c0
  Crypt-iQ:
    re-ACK 27aefac42505e9c083fa131d3d7edbec7803f3c0
  glozow:
    reACK 27aefac42505e9c083fa131d3d7edbec7803f3c0

Tree-SHA512: 70cf76b655b52bc8fa2759133315a3f11140844b6b80d9de3c95f592050978cc01a87bd2446e3a9c25cc872efea7659d6da3337b1a709511771fece206e9f149
2025-11-21 00:13:00 +00:00
Tom Trevethan
a937d53a23 moved acceptunlimitedissuances to chainparams and set defaults 2025-09-26 14:15:46 +01:00
Byron Hambly
93c84a97f9
fix: unblinded re/issuance for non-policy asset greater than 21 million (#1445)
* test: add test for unblinded re/issuance greater than 21 million

Co-authored-by: Mihailo Milenkovic <mihailo.milenkovic84@gmail.com>

* fix: unblinded re/issuance for greater than 21 million

Co-authored-by: Mihailo Milenkovic <mihailo.milenkovic84@gmail.com>

* enable with param config

* change range check to policy with config option

* refactoring, additional error messages and test extension

---------

Co-authored-by: Mihailo Milenkovic <mihailo.milenkovic84@gmail.com>
Co-authored-by: Tom Trevethan <ttrevethan@blockstream.com>
2025-09-23 13:17:02 +02:00
Tom Trevethan
e145690b42
apply mandatory coinbase only to policyAsset (#1488)
Co-authored-by: Tom Trevethan <ttrevethan@blockstream.com>
2025-09-19 11:44:39 +01:00
Russell O'Connor
ddda11cb6a Unconditionally accept Simplicity spends in the mempool
Taproot and other soft-forks historically in Bitcoin have not gated mempool access.
2025-07-23 17:26:53 -04:00
Russell O'Connor
bcd508f409 Add Simplicity Deployment structure 2024-10-07 14:39:10 -04:00
James Dorfman
b4185c7008 CI: fix asan lock issues 2024-05-21 16:56:01 +00:00
James Dorfman
c6aba4ac06 CI: fix integer underflow bug 2024-05-21 16:56:01 +00:00
Pablo Greco
c28c5ce619 Allow untrimming headers when needed 2024-05-21 05:34:30 +00:00
Pablo Greco
afc16e8f84 Allow gaps while trimming headers 2024-05-21 05:34:30 +00:00
Pablo Greco
d8e1fe7fac Avoid trimming on shutdown 2024-05-21 05:34:30 +00:00
Pablo Greco
423715b048 Avoid pruning headers that have not been saved to disk yet 2024-05-21 05:34:30 +00:00
Pablo Greco
283f47b38d Move initialization of setTrimmableBlockIndex 2024-05-21 05:34:30 +00:00
Byron Hambly
b7b2288a74
discount: implement mempool logic 2024-05-14 19:03:36 +02:00
Byron Hambly
591749d9f1
build: fix issues from ASAN in CI 2023-09-01 17:17:44 +02:00
Byron Hambly
88d211dbfd Merge de942511a6 into merged_master (Elements PR #1239)
bitcoin/bitcoin#23381 refactored PolicyScriptChecks to store the
precomputed txdata in the workspace, so I have added the genesis hash to
the transform of the workspaces in AcceptMultipleTransactions.

I don't think there was a specific test for this, so during review it
may be worth checking this thoroughly. We also need a test to cover
this.
2023-07-03 13:32:10 +00:00
Byron Hambly
b2b09ea422 Merge c7da61dcc3 into merged_master (Bitcoin PR bitcoin/bitcoin#24403) 2023-07-02 16:55:32 +00:00
Byron Hambly
0e89b30f95 Merge 8add59d77d into merged_master (Bitcoin PR bitcoin/bitcoin#24367) 2023-07-02 07:33:56 +00:00
Byron Hambly
a7beef6e4a Merge bc49650b7c into merged_master (Bitcoin PR bitcoin/bitcoin#24310) 2023-07-02 06:52:34 +00:00
Byron Hambly
e08d177be5 Merge 2b0735d183 into merged_master (Bitcoin PR bitcoin/bitcoin#23907) 2023-07-01 06:45:48 +00:00
Byron Hambly
d1e5100b7a Merge 922c49a138 into merged_master (Bitcoin PR bitcoin/bitcoin#23819) 2023-06-30 20:36:30 +00:00
Byron Hambly
56b4063490 Merge 03c8c6937e into merged_master (Bitcoin PR bitcoin/bitcoin#24177) 2023-06-30 18:17:42 +00:00
Byron Hambly
9de9d8ac60 Merge 8ac79973f8 into merged_master (Bitcoin PR bitcoin/bitcoin#24196) 2023-06-30 11:03:12 +00:00
Byron Hambly
8ce619fa31 Merge f7a36477a6 into merged_master (Bitcoin PR bitcoin/bitcoin#24227) 2023-06-30 09:37:45 +00:00
Byron Hambly
46be1c5f43 Merge ad05e68e17 into merged_master (Bitcoin PR bitcoin/bitcoin#24103) 2023-06-29 13:57:20 +00:00
Byron Hambly
a992ccaac2 Merge 196b459920 into merged_master (Bitcoin PR bitcoin/bitcoin#23438) 2023-06-29 08:37:35 +00:00
Byron Hambly
522ba1a6a8 Merge 0147278e37 into merged_master (Bitcoin PR bitcoin/bitcoin#21464) 2023-06-21 09:23:39 +00:00
Byron Hambly
d3405a9759 Merge 417e7503f8 into merged_master (Bitcoin PR bitcoin/bitcoin#23804) 2023-06-21 09:15:45 +00:00
Byron Hambly
d1115c4741 Merge e3de7cb903 into merged_master (Bitcoin PR bitcoin/bitcoin#24102) 2023-06-20 13:41:28 +00:00
Byron Hambly
6c233fcb76 Merge 06b6369766 into merged_master (Bitcoin PR bitcoin/bitcoin#23976) 2023-06-20 11:58:11 +00:00
Byron Hambly
8ef51ea1f8 Merge dfe1341c57 into merged_master (Bitcoin PR bitcoin/bitcoin#24033) 2023-06-20 11:18:44 +00:00
Byron Hambly
e6b8c52041 Merge 1f7acfdcca into merged_master (Bitcoin PR bitcoin/bitcoin#24024) 2023-06-19 09:48:16 +00:00
Byron Hambly
7878ba47b9 Merge c561f2f06e into merged_master (Bitcoin PR bitcoin/bitcoin#23497) 2023-06-19 09:28:31 +00:00
Byron Hambly
78a8032c1e Merge 4ada74206a into merged_master (Bitcoin PR bitcoin/bitcoin#23974) 2023-06-15 13:21:10 +00:00
Byron Hambly
72bd6c92e7 Merge 2f37b221d1 into merged_master (Bitcoin PR bitcoin/bitcoin#23581) 2023-06-14 19:21:05 +00:00
Byron Hambly
ba233174c1 Merge 75a227e39e into merged_master (Bitcoin PR bitcoin/bitcoin#23683) 2023-06-14 17:57:12 +00:00
Byron Hambly
daf1fea319 Merge 8b5a4de904 into merged_master (Bitcoin PR bitcoin/bitcoin#23795) 2023-06-14 17:09:33 +00:00
Byron Hambly
7aff9c20e3 Merge 6535772510 into merged_master (Bitcoin PR bitcoin/bitcoin#23882) 2023-06-14 16:52:33 +00:00
Byron Hambly
47626b5a64 Merge 623745ca74 into merged_master (Bitcoin PR bitcoin/bitcoin#23912) 2023-06-14 15:44:11 +00:00
Byron Hambly
413786c613 Merge 8c0bd871fc into merged_master (Bitcoin PR bitcoin/bitcoin#23785) 2023-06-13 14:30:53 +00:00
Byron Hambly
39e670c88c Merge 216f4ca9e7 into merged_master (Bitcoin PR bitcoin/bitcoin#22674) 2023-06-13 13:17:01 +00:00
Byron Hambly
6179a5a04e Merge b67115dd04 into merged_master (Bitcoin PR bitcoin/bitcoin#23174) 2023-06-13 11:41:51 +00:00
Byron Hambly
d1b42f9929 Merge 767c012665 into merged_master (Bitcoin PR bitcoin/bitcoin#23738) 2023-06-13 08:34:23 +00:00
James Dorfman
67a5234365 Merge a063647413 into merged_master (Bitcoin PR bitcoin/bitcoin#23280) 2023-06-12 17:58:49 +00:00
Byron Hambly
b0b2f3deff Merge f6013265b7 into merged_master (Bitcoin PR bitcoin/bitcoin#20295) 2023-06-06 09:10:04 +00:00
Byron Hambly
f97b7f0c64 Merge 84d921e79c into merged_master (Bitcoin PR bitcoin/bitcoin#23465) 2023-06-06 09:00:13 +00:00
Byron Hambly
6089b0123d Merge dca9ab48b8 into merged_master (Bitcoin PR bitcoin/bitcoin#23661) 2023-06-02 08:54:50 +00:00