a4df12323c
doc: add release notes (Sjors Provoost)c75872ffdd
test: use DIFF_1_N_BITS in tool_signet_miner (tdb3)4131f322ac
test: check difficulty adjustment using alternate mainnet (Sjors Provoost)c4f68c12e2
Use OP_0 for BIP34 padding in signet and tests (Sjors Provoost)cf0a62878b
rpc: add next to getmininginfo (Sjors Provoost)2d18a078a2
rpc: add target and bits to getchainstates (Sjors Provoost)f153f57acc
rpc: add target and bits to getblockchaininfo (Sjors Provoost)baa504fdfa
rpc: add target to getmininginfo result (Sjors Provoost)2a7bfebd5e
Add target to getblock(header) in RPC and REST (Sjors Provoost)341f932516
rpc: add GetTarget helper (Sjors Provoost)d20d96fa41
test: use REGTEST_N_BITS in feature_block (tdb3)7ddbed4f9f
rpc: add nBits to getmininginfo (Sjors Provoost)ba7b9f3d7b
build: move pow and chain to bitcoin_common (Sjors Provoost)c4cc9e3e9d
consensus: add DeriveTarget() to pow.h (Sjors Provoost) Pull request description: **tl&dr for consensus-code only reviewers**: the first commit splits `CheckProofOfWorkImpl()` in order to create a `DeriveTarget()` helper. The rest of this PR does not touch consensus code. There are three ways to represent the proof-of-work in a block: 1. nBits 2. Difficulty 3. Target The latter notation is useful when you want to compare share work against either the pool target (to get paid) or network difficulty (found an actual block). E.g. for difficulty 1 which corresponds to an nBits value of `0x00ffff`: ``` share hash: f6b973257df982284715b0c7a20640dad709d22b0b1a58f2f88d35886ea5ac45 target: 7fffff0000000000000000000000000000000000000000000000000000000000 ``` It's immediately clear that the share is invalid because the hash is above the target. This type of logging is mostly done by the pool software. It's a nice extra convenience, but not very important. It impacts the following RPC calls: 1. `getmininginfo` displays the `target` for the tip block 2. `getblock` and `getblockheader` display the `target` for a specific block (ditto for their REST equivalents) The `getdifficulty` method is a bit useless in its current state, because what miners really want to know if the difficulty for the _next_ block. So I added a boolean argument `next` to `getdifficulty`. (These values are typically the same, except for the first block in a retarget period. On testnet3 / testnet4 they change when no block is found after 20 minutes). Similarly I added a `next` object to `getmininginfo` which shows `bit`, `difficulty` and `target` for the next block. In order to test the difficulty transition, an alternate mainnet chain with 2016 blocks was generated and used in `mining_mainnet.py`. The chain is deterministic except for its timestamp and nonce values, which are stored in `mainnet_alt.json`. As described at the top, this PR introduces a helper method `DeriveTarget()` which is split out from `CheckProofOfWorkImpl`. The proposed `checkblock` RPC in #31564 needs this helper method internally to figure out the consensus target. Finally, this PR moves `pow.cpp` and `chain.cpp` from `bitcoin_node` to `bitcoin_common`, in order to give `rpc/util.cpp` (which lives in `bitcoin_common`) access to `pow.h`. ACKs for top commit: ismaelsadeeq: re-ACKa4df12323c
tdb3: code review re ACKa4df12323c
ryanofsky: Code review ACKa4df12323c
. Only overall changes since last review were dropping new `gettarget` method and dropping changes to `getdifficulty`, but there were also various internal changes splitting and rearranging commits. Tree-SHA512: edef5633590379c4be007ac96fd1deda8a5b9562ca6ff19fe377cb552b5166f3890d158554c249ab8345977a06da5df07866c9f42ac43ee83dfe3830c61cd169
MIN
macro to _TRACEPOINT_TEST_MIN
in log_raw_p2p_msgs
Bitcoin Core integration/staging tree
For an immediately usable, binary version of the Bitcoin Core software, see https://bitcoincore.org/en/download/.
What is Bitcoin Core?
Bitcoin Core connects to the Bitcoin peer-to-peer network to download and fully validate blocks and transactions. It also includes a wallet and graphical user interface, which can be optionally built.
Further information about Bitcoin Core is available in the doc folder.
License
Bitcoin Core is released under the terms of the MIT license. See COPYING for more information or see https://opensource.org/licenses/MIT.
Development Process
The master
branch is regularly built (see doc/build-*.md
for instructions) and tested, but it is not guaranteed to be
completely stable. Tags are created
regularly from release branches to indicate new official, stable release versions of Bitcoin Core.
The https://github.com/bitcoin-core/gui repository is used exclusively for the development of the GUI. Its master branch is identical in all monotree repositories. Release branches and tags do not exist, so please do not fork that repository unless it is for development reasons.
The contribution workflow is described in CONTRIBUTING.md and useful hints for developers can be found in doc/developer-notes.md.
Testing
Testing and code review is the bottleneck for development; we get more pull requests than we can review and test on short notice. Please be patient and help out by testing other people's pull requests, and remember this is a security-critical project where any mistake might cost people lots of money.
Automated Testing
Developers are strongly encouraged to write unit tests for new code, and to
submit new unit tests for old code. Unit tests can be compiled and run
(assuming they weren't disabled during the generation of the build system) with: ctest
. Further details on running
and extending unit tests can be found in /src/test/README.md.
There are also regression and integration tests, written
in Python.
These tests can be run (if the test dependencies are installed) with: build/test/functional/test_runner.py
(assuming build
is your build directory).
The CI (Continuous Integration) systems make sure that every pull request is built for Windows, Linux, and macOS, and that unit/sanity tests are run automatically.
Manual Quality Assurance (QA) Testing
Changes should be tested by somebody other than the developer who wrote the code. This is especially important for large or high-risk changes. It is useful to add a test plan to the pull request description if testing the changes is not straightforward.
Translations
Changes to translations as well as new translations can be submitted to Bitcoin Core's Transifex page.
Translations are periodically pulled from Transifex and merged into the git repository. See the translation process for details on how this works.
Important: We do not accept translation changes as GitHub pull requests because the next pull from Transifex would automatically overwrite them again.