Commit graph

91 commits

Author SHA1 Message Date
ivanlele
0b3b9db42b
Merge 6f24662eb9 into merged_master (Bitcoin PR bitcoin/bitcoin#31175) 2026-04-08 11:05:48 +00:00
ivanlele
d4e0018418
Merge 4a31f8ccc9 into merged_master (Bitcoin PR bitcoin/bitcoin#31156) 2026-04-02 09:53:30 +00:00
Tom Trevethan
3a7b163ecb Merge 5116dd4b83 into merged_master (Bitcoin PR bitcoin/bitcoin#30698) 2026-03-13 14:42:43 +00:00
Tom Trevethan
f60016e6ad Merge 338b9d82dc into merged_master (Bitcoin PR bitcoin/bitcoin#30681) 2026-03-13 13:51:41 +00:00
ivanlele
aa41e29f97
Merge 3a29ff5dea into merged_master (Bitcoin PR bitcoin/bitcoin#30463) 2026-03-09 16:54:19 +00:00
ivanlele
62e3eef45b
Merge 3c88eac28e into merged_master (Bitcoin PR bitcoin/bitcoin#29736) 2026-02-18 16:50:21 +00:00
Byron Hambly
2e41574d5a Merge ecb20563b6 into merged_master (Bitcoin PR bitcoin/bitcoin#28123) 2025-07-04 18:23:38 +02:00
Byron Hambly
9b1ff12050 Merge 79954903b2 into merged_master (Bitcoin PR bitcoin/bitcoin#27620) 2025-07-03 08:57:49 +02:00
Byron Hambly
a81ae75df3 Merge b22408df16 into merged_master (Bitcoin PR bitcoin/bitcoin#27603) 2025-06-27 11:42:32 +02:00
Byron Hambly
b4405ba453 Merge e9262ea32a into merged_master (Bitcoin PR bitcoin/bitcoin#26750) 2025-03-31 16:37:52 +02:00
Byron Hambly
ca0a68b350
Merge UP TO 551c8e9526 into merged_master (UP TO bitcoin/bitcoin#26349)
Includes FIXMEs for a few functional tests
2025-02-05 09:50:17 +02:00
Ava Chow
6f24662eb9
Merge bitcoin/bitcoin#31175: rpc: Remove submitblock pre-checks
73db95c65c kernel: Make bitcoin-chainstate's block validation mirror submitblock's (TheCharlatan)
bb53ce9bda tests: Add functional test for submitting a previously pruned block (Greg Sanders)
1f7fc73825 rpc: Remove submitblock duplicate pre-check (TheCharlatan)
e62a8abd7d rpc: Remove submitblock invalid-duplicate precheck (TheCharlatan)
36dbebafb9 rpc: Remove submitblock coinbase pre-check (TheCharlatan)

Pull request description:

  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.

  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.

  Similary 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.

  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.

  Finally, also remove the pre-checks from `bitcoin-chainstate.cpp`.

  ---

  This PR is part of the [libbitcoinkernel project](https://github.com/bitcoin/bitcoin/issues/27587).

ACKs for top commit:
  Sjors:
    re-utACK 73db95c65c
  achow101:
    ACK 73db95c65c
  instagibbs:
    ACK 73db95c65c
  mzumsande:
    ACK 73db95c65c

Tree-SHA512: 2d02e851cf402ecf6a1968c058df3576aac407e200cbf922a1a6391b7f97b4f42c6d9f6b0a78b9d1af0a6d40bdd529a7b11a1e6d88885bd7b8b090f6d1411861
2024-12-03 17:38:41 -05: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
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
Martin Zumsande
fc7dfb3df5 test: Don't enforce BIP94 on regtest unless specified by arg
The added regtest option -test=bip94 is only used in the functional
test for BIP94.
This is done because the default regtest consensus rules
should aim to follow to mainnet, not testnet.
2024-10-28 11:38:38 -04:00
Greg Sanders
31378d44f4 test: Add time-timewarp-attack boundary cases 2024-08-22 12:43:13 -04:00
Sjors Provoost
59ff17e5af
miner: adjust clock to timewarp rule 2024-08-20 18:51:37 +02:00
Sjors Provoost
e929054e12
Add timewarp attack mitigation test 2024-08-20 18:49:59 +02:00
James Dorfman
c40923460a Fix test/functional/mining_basic which broke in merge of bitcoin/bitcoin#24753 in 372f1a3c25.
Please review the last merge (not this commit) carefully. The bitcoin merge of bitcoin/bitcoin#24753
did not lead to any changes in the mining_basic functional test, so it's possible I made a mistake
which caused this test to be affected.
2024-07-29 15:23:45 +00:00
Hennadii Stepanov
a0473442d1
scripted-diff: Add __file__ argument to BitcoinTestFramework.init()
-BEGIN VERIFY SCRIPT-
sed -i -e 's/\s*().main\s*()/(__file__).main()/' $(git ls-files test/functional/*.py)
sed -i -e 's/def __init__(self)/def __init__(self, test_file)/' test/functional/test_framework/test_framework.py
-END VERIFY SCRIPT-
2024-07-16 22:06:47 +01:00
Sergi Delgado Segura
c4f857cc30 test: Extends wait_for_getheaders so a specific block hash can be checked
Previously, `wait_for_getheaders` would check whether a node had received **any**
getheaders message. This implied that, if a test needed to check for a specific block
hash within a headers message, it had to make sure that it was checking the desired message.
This normally involved having to manually clear `last_message`. This method, apart from being
too verbose, was error prone, given an undesired `getheaders` would make tests pass.

This adds the ability to check for a specific block_hash within the last `getheaders` message.
2024-04-04 13:36:45 +02:00
Byron Hambly
b59e244da3
lint: fix issues from lint-python.sh 2023-09-01 16:04:39 +02:00
Luke Dashjr
5e3e83b005 RPC/Mining: Document template_request better for getblocktemplate 2023-07-22 01:29:11 +00:00
Sebastian Falbesoner
bbbb89d238 test: miner: add coverage for -blockmintxfee setting
Co-authored-by: glozow <gloriajzhao@gmail.com>
2023-07-07 15:56:24 +02:00
Byron Hambly
1df9b75777 Merge e00e990606 into merged_master (Bitcoin PR bitcoin/bitcoin#23978) 2023-06-15 07:29:23 +00:00
Byron Hambly
bd68371fb6 Merge ffdab41f94 into merged_master (Bitcoin PR bitcoin/bitcoin#23474) 2023-05-26 10:32:04 +00:00
Byron Hambly
af3fe60b69 Merge 94db963de5 into merged_master (Bitcoin PR bitcoin/bitcoin#23300) 2023-05-17 13:44:36 +00:00
kevkevin
a7b46a1fea
test: added coverage to mining_basic.py
Included a test that checks if we call submitblock with
block.vtx.empty() then it throws an rpc deserialization error, currently
we only test if !block.vtx->IsCoinBase() throws an rpc deserialization
error
2023-05-10 07:50:46 -05:00
James Dorfman
ae89c4bc51 Merge a5d00d4baf into merged_master (Bitcoin PR bitcoin/bitcoin#22788) 2023-04-21 04:02:55 +00:00
Byron Hambly
e7704c0b25 Merge 38975eccd4 into merged_master (Bitcoin PR bitcoin/bitcoin#22229) 2023-04-10 10:17:32 +00:00
James Dorfman
17e6efe7fe Merge 5d83e7d714 into merged_master (Bitcoin PR bitcoin/bitcoin#21090)
We comment out a newly-added assert from the Bitcoin
side, because it's unclear how to replicate it
correctly in Elements.

Co-authored-by: Glenn Willen <gwillen@nerdnet.org>
2023-03-22 01:11:20 +00:00
Hennadii Stepanov
306ccd4927
scripted-diff: Bump copyright headers
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-

Commits of previous years:
- 2021: f47dda2c58
- 2020: fa0074e2d8
- 2019: aaaaad6ac9
2022-12-24 23:49:50 +00:00
MacroFake
fafc96aaf4
test: Test year 2106 block timestamps
* Use maximum timestamp in getblocktemplate test
* Mine block with maximum timestamp and MTP in blockchain test
2022-10-20 14:45:50 +02:00
Sebastian Falbesoner
7746606cfa test: use MiniWallet for mining_basic.py
This test can now be run even with the Bitcoin Core wallet disabled.
2022-01-04 19:39:23 +01:00
MarcoFalke
fac23c2114
scripted-diff: Bump copyright headers
The previous diff touched most files in ./test/, so bump the headers to
avoid having to touch them again for a bump later.

-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./test/
-END VERIFY SCRIPT-
2021-11-10 11:10:24 +01:00
MarcoFalke
facc352648
test: Implicitly sync after generate*, unless opted out 2021-10-29 13:34:52 +02:00
MarcoFalke
fa0b916971
scripted-diff: Use generate* from TestFramework
-BEGIN VERIFY SCRIPT-
 sed --regexp-extended -i \
     's/((self\.)?(nodes\[[^]]+\]|[a-z_]*(wallet|node)[0-9a-z_]*))\.(generate(|toaddress|block|todescriptor)(\(|, ))/self.\5\1, /g' \
     $(git grep -l generate ./test | grep -v 'test_framework/' | grep -v 'feature_rbf')
-END VERIFY SCRIPT-
2021-09-02 10:34:35 +02:00
fanquake
68faa87881
test: use f-strings in mining_*.py tests 2021-08-18 12:39:20 +08:00
Dhruv Mehta
eba5b1cd64 [test] remove or move tests using -segwitheight=-1 2021-07-07 22:12:04 -07:00
Andrew Poelstra
10ea7f1e54 Merge 83363f7b62 into merged_master (Bitcoin PR #20167) 2020-12-01 17:32:41 +00:00
Andrew Poelstra
6f267e338a Merge 47fc883106 into merged_master (Bitcoin PR #19967) 2020-12-01 14:36:58 +00:00
Andrew Poelstra
52c2d8e525 Merge 78f912c901 into merged_master (Bitcoin PR #19804) 2020-11-29 21:58:22 +00:00
Andrew Poelstra
66ad009d69 Merge e80e5b3e4f into merged_master (Bitcoin PR #19760) 2020-11-28 13:25:26 +00:00
Andrew Poelstra
511c24864c Merge 45a6811d36 into merged_master (Bitcoin PR #19206) 2020-11-26 01:09:03 +00:00
Andrew Poelstra
d5082ffa37 Merge 39afe5b1c6 into merged_master (Bitcoin PR #19082) 2020-11-26 01:08:58 +00:00
Andrew Poelstra
fd37b7c5d6 Merge 54f812d9d2 into merged_master (Bitcoin PR #18673) 2020-11-26 01:08:23 +00:00
Andrew Poelstra
11487538e9 Merge df2b743759 into merged_master (Bitcoin PR #17675) 2020-11-14 16:51:55 +00:00
Andrew Poelstra
b24be4b1a7 Merge 59c138d2f1 into merged_master (Bitcoin PR #16898) 2020-11-09 21:20:27 +00:00
Andrew Poelstra
67d718b048 Merge a74d588f21 into merged_master (Bitcoin PR #14954) 2020-10-27 22:32:24 +00:00
MarcoFalke
fa9b48549c
test: Add test for -blockversion 2020-10-26 16:31:25 +01:00