Commit graph

35332 commits

Author SHA1 Message Date
MacroFake
fa95315655
Use new Join() helper for ListBlockFilterTypes() 2022-08-24 10:15:32 +02:00
MacroFake
fa1c716955
Make Join() util work with any container type
Also, remove helper that is only used in tests.
2022-08-24 10:15:11 +02:00
MacroFake
713ea7a418
Merge bitcoin/bitcoin#25906: test: add coverage for invalid parameters for rescanblockchain
d1a0004621 test: add coverage for invalid parameters for `rescanblockchain` (brunoerg)

Pull request description:

  This PR adds test coverage for the following errors:
  2bd9aa5a44/src/wallet/rpc/transactions.cpp (L880-L894)

ACKs for top commit:
  w0xlt:
    reACK d1a0004621

Tree-SHA512: c357fbda3d261e4d06a29d2a5350482db5f97a815adf59abdac1971eb19b69cfd4d54e4d21836851e2e3b116aa2a820ea1437c7aededf86b06df435cca16ac90
2022-08-24 08:51:40 +02:00
Jon Atack
9b6f5fafa9 net: update hardcoded mainnet seeds for 24.x
following the steps in contrib/seeds/README.md
2022-08-24 00:04:00 +02:00
Jon Atack
7fd9028017 contrib: make-seeds updates for 24.x 2022-08-24 00:00:53 +02:00
Jon Atack
6075a0be3c net: update manual hardcoded mainnet seeds for 24.x
torv3/i2p/cjdns seeds selected for reachability, uptime and service bit 1
2022-08-24 00:00:52 +02:00
Andrew Chow
207abc147c doc: Add my key to SECURITY.md 2022-08-23 16:57:46 -04:00
brunoerg
d1a0004621 test: add coverage for invalid parameters for rescanblockchain 2022-08-23 17:13:52 -03:00
Pieter Wuille
ed470940cd Add functions to construct locators without CChain
This introduces an insignificant performance penalty, as it means locator
construction needs to use the skiplist-based CBlockIndex::GetAncestor()
function instead of the lookup-based CChain, but avoids the need for
callers to have access to a relevant CChain object.
2022-08-23 16:05:00 -04:00
Pieter Wuille
84852bb6bb Add bitdeque, an std::deque<bool> analogue that does bit packing. 2022-08-23 11:34:10 -04:00
Suhas Daftuar
1d4cfa4272 Add function to validate difficulty changes
The rule against difficulty adjustments changing by more than a factor of 4 can
be helpful for anti-DoS measures in contexts where we lack a full headers
chain, so expose this functionality separately and in the narrow case where we
only know the height, new value, and old value.

Includes fuzz test by Martin Zumsande.
2022-08-23 11:34:10 -04:00
Ryan Ofsky
7bc33a88f7 refactor: Move ChainstateManager options into m_options struct
Move ChainstateManager options into m_options struct to simplify class
initialization, organize class members, and to name external option variables
differently than internal state variables.

This change was originally in #25862, but it was suggested to split off in
https://github.com/bitcoin/bitcoin/pull/25862#discussion_r951459817 so it could
be merged earlier and reduce conflicts with other PRs.
2022-08-22 13:19:15 -04:00
Andrew Chow
2bd9aa5a44
Merge bitcoin/bitcoin#25647: wallet: return change from SelectionResult
4fef534428 wallet: use GetChange() when computing waste (S3RK)
87e0ef9031 wallet: use GetChange() in tx building (S3RK)
15e97a6886 wallet: add SelectionResult::GetChange (S3RK)
72cad28da0 wallet: calculate and store min_viable_change (S3RK)
e3210a7225 wallet: account for preselected inputs in target (S3RK)
f8e796348b wallet: add SelectionResult::Merge (S3RK)
06f558e4e2 wallet: accurate SelectionResult::m_target (S3RK)
c8cf08ea74 wallet: ensure m_min_change_target always covers change fee (S3RK)

Pull request description:

  Benefits:
  1. more accurate waste calculation for knapsack. Waste calculation is now consistent with tx building code. Before we always assumed change for knapsack even when the solution is changeless4.
  2. simpler tx building code. Only create change output when it's needed
  3. makes it easier to correctly account for fees for CPFP inputs (should be done in a follow up)

  In the first three commits we fix the code to accurately track selection target in `SelectionResult::m_target`
  Then we introduce new variable `min_change` that represents the minimum viable change amount
  Then we introduce `SelectionResult::GetChange()` which incapsulates dropping change for fee logic and uses correct values of `SelectionResult::m_target`
  Then we use `SelectionResult::GetChange()` in both tx building and waste calculation code

  This PR is a refactoring and shouldn't change the behaviour.
  There is only one known small change (arguably a bug fix). Before we dropped change output if it's smaller than `cost_of_change` after paying change fees. This is incorrect as `cost_of_change` already includes `change_fee`.

ACKs for top commit:
  achow101:
    ACK 4fef534428
  Xekyo:
    crACK 4fef534428
  furszy:
    Code review ACK 4fef5344
  w0xlt:
    ACK 4fef534428

Tree-SHA512: 31a7455d4129bc39a444da0f16ad478d690d4d9627b2b8fdb5605facc6488171926bf02f5d7d9a545b2b59efafcf5bb3d404005e4da15c7b44b3f7d441afb941
2022-08-22 12:42:36 -04:00
MacroFake
92bb7001d8
Merge bitcoin/bitcoin#25902: fixups for BIP125 doc cleanup
375ebadbf8 fixups for BIP125 doc cleanup (glozow)

Pull request description:

  Followups from #25775:

  - https://github.com/bitcoin/bitcoin/pull/25775#discussion_r951250404
  - https://github.com/bitcoin/bitcoin/pull/25775#discussion_r951250909
  - https://github.com/bitcoin/bitcoin/pull/25775#discussion_r951251041
  - https://github.com/bitcoin/bitcoin/pull/25775#discussion_r950868039

ACKs for top commit:
  t-bast:
    ACK 375ebadbf8
  ariard:
    ACK 375ebad

Tree-SHA512: 66f240a020a2f6994a3b3bcce446bc07655b5714eab18aac4a3223d35226e57902c475fc60a57e3511b2f176741d6c93d7ebfe90574793813f90ceca33d44669
2022-08-22 17:25:48 +02:00
glozow
375ebadbf8
fixups for BIP125 doc cleanup
Grammar and readability fixups.
Clarifies "bip125-replaceable" helpstrings.
2022-08-22 14:59:58 +01:00
fanquake
c5f0cbefa3
Merge bitcoin/bitcoin#25775: docs: remove non-signaling mentions of BIP125
1dc03dda05 [doc] remove non-signaling mentions of BIP125 (glozow)
32024d40f0 scripted-diff: remove mention of BIP125 from non-signaling var names (glozow)

Pull request description:

  We have pretty thorough documentation of our RBF policy in doc/policy/mempool-replacements.md. It enumerates each rule with several sentences of rationale. Also, each rule pretty much has its own function (3 and 4 share one), with extensive comments. The doc states explicitly that our rules are similar but differ from BIP125, and contains a record of historical changes to RBF policy.

  We should not use "BIP125" as synonymous with our RBF policy because:
  - Our RBF policy is different from what is specified in BIP125, for example:
      - the BIP does not mention our rule about the replacement feerate being higher (our Rule 6)
      - the BIP uses minimum relay feerate for Rule 4, while we have used incremental relay feerate since #9380
      - the "inherited signaling" question (CVE-2021-31876). Call it discrepancy, ambiguous wording, doc misinterpretation, or implementation details, I would recommend users refer to doc/policy/mempool-replacements.md
      - the signaling policy is configurable, see #25353
  - Our RBF policy may change further
  - We have already marked BIP125 as only "partially implemented" in docs/bips.md since 1fd49eb498
  - See comments from people who are not me recently:
      - https://github.com/bitcoin/bitcoin/pull/25038#discussion_r909507429
      - https://github.com/bitcoin/bitcoin/pull/25575#issuecomment-1179519204

  This PR removes all non-signaling mentions of BIP125 (if people feel strongly, we can remove all mentions of BIP125 period). It may be useful to refer to the concept of "tx opts in to RBF if it has at least one nSequence less than (0xffffffff - 1)" as "BIP125 signaling" because:
  - It is succint.
  - It has already been widely marketed as BIP125 opt-in signaling.
  - Our API uses it when referring to signaling (e.g. getmempoolentry["bip125-replaceable"] and wallet error message "not BIP 125 replaceable"). Changing those is more invasive.
  - If/when we have other ways to signal in the future, we can disambiguate them this way. See #25038 which proposes another way of signaling, and where I pulled these commits from.

  Alternatives:
  - Changing our policy to match BIP125. This doesn't make sense as, for example, we would have to remove the requirement that a replacement tx has a higher feerate (Rule 6).
  - Changing BIP125 to match what we have. This doesn't make sense as it would be a significant change to a BIP years after it was finalized and already used as a spec to implement RBF in other places.
  - Document our policy as a new BIP and give it a number. This might make sense if we don't expect things to change a lot, and can be done as a next step.

ACKs for top commit:
  darosior:
    ACK 1dc03dda05
  ariard:
    ACK 1dc03dda
  t-bast:
    ACK 1dc03dda05

Tree-SHA512: a3adc2039ec5785892d230ec442e50f47f7062717392728152bbbe27ce1c564141f85253143f53cb44e1331cf47476d74f5d2f4b3cd873fc3433d7a0aa783e02
2022-08-22 10:35:26 +01:00
fanquake
607d5a46aa
Merge bitcoin/bitcoin#23202: wallet: allow psbtbumpfee to work with txs with external inputs
c3b099ace0 wallet, tests: Test bumpfee's max input weight calculation (Andrew Chow)
116a620ce7 Make DUMMY_CHECKER availble outside of script/sign.cpp (Andrew Chow)
ff638323d1 test, bumpfee: Check that psbtbumpfee can bump txs with external inputs (Andrew Chow)
1bc8106d4c bumpfee: be able to bump fee of a tx with external inputs (Andrew Chow)
31dd3dc9e5 bumpfee: Clear scriptSigs and scriptWitnesses before calculated max size (Andrew Chow)
a0c3afb898 bumpfee: extract weights of external inputs when bumping fee (Andrew Chow)
612f1e44fe bumpfee: Calculate fee by looking up UTXOs (Andrew Chow)

Pull request description:

  This PR allows `psbtbumpfee` to return a PSBT for transactions that contain external inputs. This does not work for bumping in the GUI nor `bumpfee` because these need private keys available to sign and send the transaction. But `psbtbumpfee` returns a psbt, so it is fine to not be able to sign.

  In order to correctly estimate the size of the inputs for coin selection, the fee bumper will use the size of the inputs of the transaction being bumped. Because the sizes of signatures are not guaranteed, for external inputs, the fee bumper will verify the scripts with a special SignatureChecker which will compute the weight of all of the signatures in that input, and compute their weights if those signatures were maximally sized. This allows the fee bumper to obtain a max size estimate for each external input.

  Builds on #23201 as it relies on the ability to pass weights in to coin selection.

  Closes #23189

ACKs for top commit:
  ishaanam:
    reACK c3b099ace0
  t-bast:
    Re-ran my tests agains c3b099ace0, ACK

Tree-SHA512: 40016ec52d351430977579cfa2694c7e6764f42c9ce09d3a6f1753b767f86053f296d9de988248df033be6d725d67badbf2a5ef82c8ace23c61487729b7691e5
2022-08-22 10:12:19 +01:00
MacroFake
e5a83141fa
Merge bitcoin/bitcoin#25883: doc: Security config warning
3a71da0b72 Security config warning (Robert Spigler)

Pull request description:

  https://github.com/bitcoin/bitcoin/issues/23412

  Warning about modifying unknown config changes

ACKs for top commit:
  jarolrod:
    ACK 3a71da0b72
  1440000bytes:
    ACK 3a71da0b72

Tree-SHA512: 01963f7de76b9aa623dfeb1e3d4f0a223dfc5a948f54688b60f895a3e1ab14398090fbd2116ff9fd4d90bf637e956e9cc484672053e195622253fd9895decae2
2022-08-22 11:07:48 +02:00
fanquake
0f35f4ddf4
Merge bitcoin/bitcoin#25786: refactor: Make adjusted time type safe
eeee5ada23 Make adjusted time type safe (MacroFake)
fa3be799fe Add time helpers (MacroFake)

Pull request description:

  This makes follow-ups easier to review. Also, it makes sense by itself.

ACKs for top commit:
  ryanofsky:
    Code review ACK eeee5ada23. Confirmed type changes and equivalent code changes only.

Tree-SHA512: 51bf1ae5428552177286113babdd49e82459d6c710a07b6e80a0a045d373cf51045ee010461aba98e0151d8d71b9b3b5f8f73e302d46ba4558e0b55201f99e9f
2022-08-22 10:00:46 +01:00
MacroFake
027b6729bc
Merge bitcoin/bitcoin#25888: refactor: use strprintf for creating unknown-service-flag string
706c8e0969 refactor: use `strprintf` for creating unknown-service-flag string (Sebastian Falbesoner)

Pull request description:

  No need to use a stringstream here. The trivial change can be verified by running the functional test `rpc_net.py`:
  c73c8d53fe/test/functional/rpc_net.py (L181-L184)
  As far as I could tell, this is the only instace left where we used `std::ostringstream` for the creation of simple strings (in `FormatSubVersion` using a stream makes sense since the number of placeholders is not constant).

ACKs for top commit:
  kristapsk:
    ACK 706c8e0969

Tree-SHA512: 069cea29aef03996ae16a0dc3ed87b1b2cf2ab0bf5987c225b10da12d0f4b62b7c3faf3a169c0b912eb2ad60c6ea0a09a622be7eaadad78cee0463ef4ffc0e19
2022-08-22 08:26:16 +02:00
w0xlt
57d1367fec test: remove unused norm_prv parameter 2022-08-21 18:26:11 -03:00
Sebastian Falbesoner
1b5bec78e9 init: avoid unsetting service bits from nLocalServices
Rather than setting the service bit `NODE_NETWORK` first and then unset
it, start out the bare minimum flags that every node serves and only add
`NODE_NETWORK` if we are running as a non-pruned node.
2022-08-20 22:36:27 +02:00
Sebastian Falbesoner
706c8e0969 refactor: use strprintf for creating unknown-service-flag string
No need to use a stringstream here.
2022-08-20 15:11:28 +02:00
Jon Atack
9580480570 Update debug logging section in the developer notes 2022-08-20 13:40:03 +02:00
Jon Atack
1abaa31aa3 Update -debug and -debugexclude help docs for severity level logging 2022-08-20 11:55:17 +02:00
Jon Atack
45f9282162 Create BCLog::Level::Trace log severity level
for verbose log messages for development or debugging only, as bitcoind may run
more slowly, that are more granular/frequent than the Debug log level, i.e. for
very high-frequency, low-level messages to be logged distinctly from
higher-level, less-frequent debug logging that could still be usable in production.

An example would be to log higher-level peer events (connection, disconnection,
misbehavior, eviction) as Debug, versus Trace for low-level, high-volume p2p
messages in the BCLog::NET category. This will enable the user to log only the
former without the latter, in order to focus on high-level peer management events.

With respect to the name, "trace" is suggested as the most granular level
in resources like the following:
- https://sematext.com/blog/logging-levels
- https://howtodoinjava.com/log4j2/logging-levels

Update the test framework and add test coverage.
2022-08-20 11:55:17 +02:00
klementtan
2a8712db4f Unit test coverage for -loglevel configuration option
Co-authored-by: "Jon Atack <jon@atack.com>"
2022-08-20 11:55:17 +02:00
klementtan
eb7bee5f84 Create -loglevel configuration option
- add a -loglevel=<level>|<category:level> config option to allow users
  to set a global -loglevel and category-specific log levels. LogPrintLevel
  messages with a higher severity level than -loglevel will not be printed
  in the debug log.

- for now, this config option is debug-only during the migration to
  severity-based logging

- update unit and functional tests

Co-authored-by: "Jon Atack <jon@atack.com>"
2022-08-20 11:53:37 +02:00
klementtan
98a1f9c687 Unit test coverage for log severity levels
Co-authored-by: "Jon Atack <jon@atack.com>"
2022-08-20 11:31:28 +02:00
klementtan
9c7507bf76 Create BCLog::Logger::LogLevelsString() helper function
Co-authored-by: "Jon Atack <jon@atack.com>"
2022-08-20 11:31:28 +02:00
klementtan
8fe3457dbb Update LogAcceptCategory() and unit tests with log severity levels
Co-authored-by: "Jon Atack <jon@atack.com>"
2022-08-20 11:30:51 +02:00
klementtan
c2797cfc60 Add BCLog::Logger::SetLogLevel()/SetCategoryLogLevel() for string inputs
and remove unnecessary param constness in LogPrintStr()

Co-authored-by: jonatack <jon@atack.com>
2022-08-20 11:30:50 +02:00
Jon Atack
f6c0cc0350 Add BCLog::Logger::m_category_log_levels data member and getter/setter
Co-authored-by: "klementtan <klementtan@gmail.com>"
2022-08-20 11:30:50 +02:00
Jon Atack
2978b387bf Add BCLog::Logger::m_log_level data member and getter/setter
Co-authored-by: "klementtan <klementtan@gmail.com>"
2022-08-20 11:30:35 +02:00
MacroFake
fa875349e2
Fix iwyu 2022-08-20 09:33:01 +02:00
MacroFake
faad673716
Fix issues when calling std::move(const&) 2022-08-20 09:32:53 +02:00
MacroFake
c73c8d53fe
Merge bitcoin/bitcoin#25878: tests: Use mocktime for wallet encryption timeout
02dea9a47f tests: Use mocktime for wallet encryption timeout (Andrew Chow)

Pull request description:

  The intermittent wallet_encryption.py failures are related to differences in time between python and std::chrono. We can avoid this entirely by using mocktime. This also allows us to test for the exact unlocking time rather than that it is greater than expected.

  Fixes #25482

ACKs for top commit:
  MarcoFalke:
    review ACK 02dea9a47f
  vasild:
    ACK 02dea9a47f

Tree-SHA512: 5a5489f5cd2569c824bf5b3d839be0c632ed27627c0eff65dda63c143a8d1174fe3252acba8102b4242a9ddf42d82bfe79babad68f1beeb83eb251386058e039
2022-08-20 08:50:19 +02:00
Robert Spigler
3a71da0b72
Security config warning
https://github.com/bitcoin/bitcoin/issues/23412

Warning about modifying unknown config changes
2022-08-19 23:18:13 -04:00
Andrew Chow
c3b099ace0 wallet, tests: Test bumpfee's max input weight calculation 2022-08-19 14:37:36 -04:00
Andrew Chow
116a620ce7 Make DUMMY_CHECKER availble outside of script/sign.cpp 2022-08-19 14:37:36 -04:00
Andrew Chow
ff638323d1 test, bumpfee: Check that psbtbumpfee can bump txs with external inputs 2022-08-19 14:37:36 -04:00
Andrew Chow
02dea9a47f tests: Use mocktime for wallet encryption timeout 2022-08-19 13:51:39 -04:00
MacroFake
faf8da3c8d
Remove Join() helper only used in tests
Also remove redundant return type that can be deduced by the compiler.
2022-08-19 19:44:16 +02:00
Andrew Chow
6b56873b41
Merge bitcoin/bitcoin#25784: Wallet: Document expectations for AddWalletFlags (now InitWalletFlags) correctly
0cb6d2aec6 Bugfix: Wallet: Document expectations for AddWalletFlags (now InitWalletFlags) correctly (Luke Dashjr)

Pull request description:

  Includes some slight refactoring (return type changed, current status checked)

ACKs for top commit:
  achow101:
    ACK 0cb6d2aec6
  w0xlt:
    ACK 0cb6d2aec6
  ryanofsky:
    Code review ACK 0cb6d2aec6. This is a clarifying change, and should prevent the InitWalletFlags method being called incorrectly. I left a comment suggestion, but feel free to ignore it.

Tree-SHA512: fa18e9471b5e89d35cbc01526e6d4dbe4eee8faa9646847248909af1751b33014a6f9a42fe70a1331c0d73adea79008b8fc3ae2b51a641eba3e36d5c631327f6
2022-08-19 12:12:27 -04:00
Andrew Chow
0f0508bc72
Merge bitcoin/bitcoin#25869: wallet: remove UNKNOWN type from OUTPUT_TYPES array
5b4fdbbff5 wallet: remove UNKNOWN type from OUTPUT_TYPES array (furszy)

Pull request description:

  Fixing https://github.com/bitcoin/bitcoin/pull/25734#discussion_r949502998 ->  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=50329

  The `OUTPUT_TYPES` array contain the known active output types only.
  And it's solely used to create/walk-through the active spkms.

  So, no need to add the `UNKNOWN` type here.

ACKs for top commit:
  achow101:
    ACK 5b4fdbbff5
  w0xlt:
    ACK 5b4fdbbff5
  LarryRuane:
    ACK 5b4fdbbff5

Tree-SHA512: dee2dc362a1b0c777555e5ee4d355a3351340591d0096f74e8c3a25f374cb2d9aef26145977ff4dd0f8cc940da9464eb5541eb2895bc19f8cbd6bb6d292ab9a9
2022-08-19 12:01:23 -04:00
Andrew Chow
1bc8106d4c bumpfee: be able to bump fee of a tx with external inputs
In some cases, notably psbtbumpfee, it is okay, and potentially desired,
to be able to bump the fee of a transaction which contains external
inputs.
2022-08-19 11:27:01 -04:00
Andrew Chow
31dd3dc9e5 bumpfee: Clear scriptSigs and scriptWitnesses before calculated max size
The max size calculation expects some inputs to have empty scriptSigs
and witnesses, so we need to clear these before doing that calculation.
2022-08-19 11:27:01 -04:00
Andrew Chow
a0c3afb898 bumpfee: extract weights of external inputs when bumping fee
When bumping the fee of a transaction containing external inputs,
determine the weights of those inputs. Because signatures can have a
variable size, the script is executed with a special SignatureChecker
which will compute the total weight of the signatures in the transaction
and the weight if they were all maximum size signatures. This allows us
to compute the maximum weight of the input for use during coin
selection.
2022-08-19 11:27:01 -04:00
Andrew Chow
612f1e44fe bumpfee: Calculate fee by looking up UTXOs
Instead of calculating the fee by using what is stored in the wallet,
calculate it by looking up the UTXOs.
2022-08-19 11:27:01 -04:00
MacroFake
9eaef10801
Merge bitcoin/bitcoin#25707: refactor: Make const references to avoid unnecessarily copying objects and enable two clang-tidy checks
ae7ae36d31 tidy: Enable two clang-tidy checks (Aurèle Oulès)
081b0e53e3 refactor: Make const refs vars where applicable (Aurèle Oulès)

Pull request description:

  I added const references to some variables to avoid unnecessarily copying objects.

  Also added two clang-tidy checks : [performance-for-range-copy](https://releases.llvm.org/11.1.0/tools/clang/tools/extra/docs/clang-tidy/checks/performance-for-range-copy.html) and [performance-unnecessary-copy-initialization](https://releases.llvm.org/12.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/performance-unnecessary-copy-initialization.html).

ACKs for top commit:
  vasild:
    ACK ae7ae36d31
  MarcoFalke:
    review ACK ae7ae36d31

Tree-SHA512: f6ac6b0cd0eee1e0c34d2f186484bc0f7ec6071451cccb33fa88a67d93d92b304e2fac378b88f087e94657745bca4e966dbc443759587400eb01b1f3061fde8c
2022-08-19 17:11:06 +02:00