Commit Graph

25188 Commits

Author SHA1 Message Date
Samuel Dobson
f5642281cc
Merge #20282: wallet: change upgradewallet return type to be an object
2ead31fb1b17c9b183a4b81f0ae4f48e5cf67d64 [wallet] Return object from upgradewallet RPC (Sishir Giri)

Pull request description:

  Change the return type of upgradewallet to be an object for future extensibility.

  Also return any error string returned from the `UpgradeWallet()` function.

ACKs for top commit:
  MarcoFalke:
    ACK 2ead31fb1b17c9b183a4b81f0ae4f48e5cf67d64
  meshcollider:
    Tested ACK 2ead31fb1b17c9b183a4b81f0ae4f48e5cf67d64

Tree-SHA512: bcc7432d2f35093ec2463ea19e894fa885b698c0e8d8e4bd2f979bd4d722cbfed53ec589d6280968917893c64649dc9e40800b8d854273b0f9a1380f51afbdb1
2024-03-07 02:06:28 +07:00
pasta
32d9e38157
Merge #5898: chore: bump cppcheck to 2.13 version
df554f396b test: add multiple suppression for cppcheck to make it finally quiet (Konstantin Akimov)
e2ac86b8f7 refactor: drop dependency of CJ to fee_estimator (Konstantin Akimov)
e7e355ba8b refactor: make SetNull in CJ classes virtual to prevent warning from compiler (Konstantin Akimov)
6bc14a35e5 chore: bump cpp check 2.10 to 2.13 (Konstantin Akimov)
b4ed65e15e refactor: add multiple missing `const` (Konstantin Akimov)
add99ea862 refactor: add more consts everywhere as required by cppcheck 2.13.0 (Konstantin Akimov)
61a6c407fe fix: re-order asserts in creditpool (Konstantin Akimov)
28f7ecc11f test: tidy up and reorder warnings in lint-cppcheck-dash (Konstantin Akimov)
3abeab16d3 refactor: replace multiple C-style casts to reinterpret_cast (Konstantin Akimov)
f36bb1f085 style: add semicolumn that the end to ENTER/LEAVE CRITICAL SECTION (Konstantin Akimov)
c23c25d00b test: supress any_of suggestions in cppcheck-dash (Konstantin Akimov)
7daa9bea9a refactor: use std::any_of (Konstantin Akimov)
3f1cb8d13d test: add suppression for state.Invalid() which is widely used by cppcheck is unhappy (Konstantin Akimov)

Pull request description:

  ## Issue being fixed or feature implemented
  https://github.com/dashpay/dash-issues/issues/67

  See also https://github.com/dashpay/dash/pull/5880 for prior work.
  There's too many false alarm warnings with new kubuntu 23.10 (cppcheck 2.11)

  ## What was done?
  Bump cppcheck to version 2.13 and fix related warnings or suppressing them if they are false-alarm.

  ## How Has This Been Tested?
  Run `test/lint/lint-cppcheck-dash.sh` and see no output.

  ## Breaking Changes
  N/A

  ## Checklist:
  - [x] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone

Top commit has no ACKs.

Tree-SHA512: 352a36958102ee687a2f065691a5113f90a014816683335b11291a556ad09c7f8797c6ced98f0851f39f597c26493f2d5a2bf54c4e833a37d35487384b7102db
2024-03-06 12:07:33 -06:00
pasta
e84e3d9c85
Merge #5902: backport: merge bitcoin#27985, #27993, #28008, #28267, #28374, #28100 (p2p primitives)
b60c493265 merge bitcoin#28100: more Span<std::byte> modernization & follow-ups (Kittywhiskers Van Gogh)
c2aa01cf1d merge bitcoin#28374: python cryptography required for BIP 324 functional tests (Kittywhiskers Van Gogh)
7c5edf772a merge bitcoin#28267: BIP324 ciphersuite follow-up (Kittywhiskers Van Gogh)
1b1924e3d5 merge bitcoin#28008: BIP324 ciphersuite (Kittywhiskers Van Gogh)
ff542199bc merge bitcoin#27993: Make poly1305 support incremental computation + modernize (Kittywhiskers Van Gogh)
d7482eb8a6 merge bitcoin#27985: Add support for RFC8439 variant of ChaCha20 (Kittywhiskers Van Gogh)

Pull request description:

  ## Additional Information

  * Dependent on https://github.com/dashpay/dash/pull/5900

  * Dependent on https://github.com/dashpay/dash/pull/5901

  * Without modifications, tests introduced in [bitcoin#28008](https://github.com/bitcoin/bitcoin/pull/28008) will fail due to salt comprising of a fixed string (`bitcoin_v2_shared_secret`) and network bytes ([source](1c7582ead6/src/bip324.cpp (L39-L40))). Bitcoin uses [`{0xf9, 0xbe, 0xb4, 0xd9}`](1c7582ead6/src/kernel/chainparams.cpp (L114-L117)) for mainnet while Dash uses [`{0xbf, 0x0c, 0x6b, 0xbd}`](37f43e4e56/src/chainparams.cpp (L238-L241)).
    * The replacement parameters are generated by:
      * Cloning https://github.com/bitcoin/bips (as of this writing, at b3701faef2)
      * Editing `bip-0324/reference.py`
        * Changing `NETWORK_MAGIC` to Dash's network magic
      * Running `gen_test_vectors.py` to get a new `packet_encoding_test_vectors.csv`
      * Using [this python script](1c7582ead6/src/test/bip324_tests.cpp (L174-L196)) mentioned in a comment in `src/test/bip324_tests.cpp`, generate the values that will be used to replace the ones in `bip324_tests.cpp` (it will print to `stdout` so it's recommended to pipe it to a file)
      * Paste the new values over the old ones

  ## Breaking Changes

  None. Changes are restricted to BIP324 cryptosuite, tests and associated logic.

  ## Checklist:
    _Go over all the following points, and put an `x` in all the boxes that apply._
  - [x] I have performed a self-review of my own code
  - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)**
  - [x] I have added or updated relevant unit/integration/functional/e2e tests **(note: N/A)**
  - [x] I have made corresponding changes to the documentation **(note: N/A)**
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

Top commit has no ACKs.

Tree-SHA512: bb056de8588026adae63e78d56878274ff3934a439e2eae81606fa9c0a37dab432a129315bb9c1b754400b5c883bf460eea3a0c857a3be0816c8fbf55c479843
2024-03-06 12:00:55 -06:00
Kittywhiskers Van Gogh
b60c493265
merge bitcoin#28100: more Span<std::byte> modernization & follow-ups 2024-03-05 21:43:22 +00:00
Kittywhiskers Van Gogh
c2aa01cf1d
merge bitcoin#28374: python cryptography required for BIP 324 functional tests 2024-03-05 21:43:22 +00:00
Kittywhiskers Van Gogh
7c5edf772a
merge bitcoin#28267: BIP324 ciphersuite follow-up 2024-03-05 21:43:22 +00:00
Kittywhiskers Van Gogh
1b1924e3d5
merge bitcoin#28008: BIP324 ciphersuite 2024-03-05 21:43:21 +00:00
Kittywhiskers Van Gogh
ff542199bc
merge bitcoin#27993: Make poly1305 support incremental computation + modernize 2024-03-05 21:42:49 +00:00
Kittywhiskers Van Gogh
d7482eb8a6
merge bitcoin#27985: Add support for RFC8439 variant of ChaCha20 2024-03-05 21:42:49 +00:00
Konstantin Akimov
df554f396b
test: add multiple suppression for cppcheck to make it finally quiet 2024-03-06 03:31:50 +07:00
Konstantin Akimov
e2ac86b8f7
refactor: drop dependency of CJ to fee_estimator
Coinjoin should not know about CBlockFeeEstimator
2024-03-06 03:31:50 +07:00
Konstantin Akimov
e7e355ba8b
refactor: make SetNull in CJ classes virtual to prevent warning from compiler 2024-03-06 03:31:49 +07:00
Konstantin Akimov
6bc14a35e5
chore: bump cpp check 2.10 to 2.13 2024-03-06 03:31:49 +07:00
Konstantin Akimov
b4ed65e15e
refactor: add multiple missing const 2024-03-06 03:31:48 +07:00
Konstantin Akimov
add99ea862
refactor: add more consts everywhere as required by cppcheck 2.13.0 2024-03-06 03:31:48 +07:00
Konstantin Akimov
61a6c407fe
fix: re-order asserts in creditpool 2024-03-06 03:31:47 +07:00
Konstantin Akimov
28f7ecc11f
test: tidy up and reorder warnings in lint-cppcheck-dash 2024-03-06 03:31:47 +07:00
Konstantin Akimov
3abeab16d3
refactor: replace multiple C-style casts to reinterpret_cast 2024-03-06 03:31:46 +07:00
Konstantin Akimov
f36bb1f085
style: add semicolumn that the end to ENTER/LEAVE CRITICAL SECTION
It is not required but it looks alien without it
2024-03-06 03:31:46 +07:00
Konstantin Akimov
c23c25d00b
test: supress any_of suggestions in cppcheck-dash
even it maybe useful lint message for some particular case, sometimes it asks
to make an refactoring that will be over-complex.

For example, it asks to refactor external loop to std::any_of:
```
for (const auto& inner_entry : vecEntries) {
    if (ranges::any_of(inner_entry.vecTxDSIn,
                    [&txin](const auto& txdsin){
                            return txdsin.prevout == txin.prevout;
                    })) {
        LogPrint(BCLog::COINJOIN, "CCoinJoinServer::%s -- ERROR: already have this txin in entries\n", __func__);
        nMessageIDRet = ERR_ALREADY_HAVE;
        // Two peers sent the same input? Can't really say who is the malicious one here,
        // could be that someone is picking someone else's inputs randomly trying to force
        // collateral consumption. Do not punish.
        return false;
    }
}
```
That's possible to refactor, but that's unreasonable complexity to have an
lambda inside an lambda... That's unreasonable.
Some other suggestion are also non-trivial.

One more suppression for any_of in llmq/commitment which is false-alarm:

There's used index but linter doesn't see it:
```
for (const auto i : irange::range(members.size(), size_t(llmq_params.size))) {
    if (validMembers[i]) {
        LogPrintfFinalCommitment("q[%s] invalid validMembers bitset. bit %d should not be set\n", quorumHash.ToString(), i);
        return false;
    }
    if (signers[i]) {
        LogPrintfFinalCommitment("q[%s] invalid signers bitset. bit %d should not be set\n", quorumHash.ToString(), i);
        return false;
    }
}
```
2024-03-06 03:31:46 +07:00
Konstantin Akimov
7daa9bea9a
refactor: use std::any_of 2024-03-06 03:31:45 +07:00
Konstantin Akimov
3f1cb8d13d
test: add suppression for state.Invalid() which is widely used by cppcheck is unhappy 2024-03-06 03:31:43 +07:00
pasta
27736114a1
Merge #5924: refactor: subsume CGovernanceTriggerManager into CGovernanceManager
a1636d429a refactor: subsume CGovernanceTriggerManager into CGovernanceManager (Kittywhiskers Van Gogh)

Pull request description:

  ## Issue being fixed or feature implemented
  Having a dedicated manager to manipulate one variable, that relies almost exclusively on another manager doesn't make much sense. Rather than converting it into a unique_ptr, creating an alias and deglob'ing it, it's much easier to subsume it into its dependent manager.

  ## What was done?
  See commit

  ## How Has This Been Tested?
  Built locally; kudos @kwvg. Good idea!

  ## Breaking Changes
  None

  ## Checklist:
    _Go over all the following points, and put an `x` in all the boxes that apply._
  - [x] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

Top commit has no ACKs.

Tree-SHA512: 782aa7861e55675c77cd4ce3ebf5fdf8cfc953e535c6c3d5e98373a89611a86f14cdba0757df153b936ddb77b711472ec78c5b1a64fe596c85e6efcd49dec8fa
2024-03-05 13:16:14 -06:00
Kittywhiskers Van Gogh
a1636d429a
refactor: subsume CGovernanceTriggerManager into CGovernanceManager
Having a dedicated manager to manipulate one variable, that relies
almost exclusively on another manager doesn't make much sense. Rather
than converting it into a unique_ptr, creating an alias and deglob'ing
it, it's much easier to subsume it into its dependent manager.
2024-03-05 13:15:59 -06:00
pasta
8459820478
Merge #5854: refactor: move HD code from CWallet to LegacyScriptPubKeyMan
b5f4411d11 fix: extra logs to distinct WriteHDChain for encrypted/raw batches (Konstantin Akimov)
e8f84afd3e refactor: move BIP39 related code to wallet (Konstantin Akimov)
fa6519f320 refactor: move hdchain to wallet/ because it belongs there (Konstantin Akimov)
392b51b197 refactor: obsolete hdCryptedChain from ScriptPubKeyMan (Konstantin Akimov)
a0389e181f refactor: rename EncryptHDChain to EncryptAndSetHDChain (Konstantin Akimov)
b2143f9346 refactor: re-order public and private methods in scriptpubkeyman (Konstantin Akimov)
a219748f5e refactor: make SetHDChain private in ScriptPubKeyManager (Konstantin Akimov)
f418b9ac62 refactor: move Encrypt chain call inside ScriptPubKeyMan::Encrypt (Konstantin Akimov)
c3754d5183 refactor: move DecryptHDChain from public to private (Konstantin Akimov)
e08b64a1bb refactor: unify SetHDChainSingle and SetCryptedHDChainSingle (Konstantin Akimov)
59a998843b refactor: unify ScriptPubKeyMan's SetHDChain nad SetHDCryptedChain (Konstantin Akimov)
a180d73e5c refactor: unify WalletBatch's WriteHDChain and WriteCryptedHDChain (Konstantin Akimov)
9c8e4584ae refactor: unify SetHDChain and SetCryptedHDChain helpers (Konstantin Akimov)
7b72726b3e refactor: SetCryptedHDChain moved to scriptpubkeyman (Konstantin Akimov)
6993d112f3 feat: extra check failure case CWallet::GenerateNewHDChainEncrypted (Konstantin Akimov)

Pull request description:

  ## Issue being fixed or feature implemented
  During backport bitcoin#17261 significant part of HD chain has been forgotten in CWallet due to our own implementation.

  This PR do not change behaviour of HD wallets, it's just refactoring.

  ## What was done?
  This PR refactor HD wallets implementation:
   - key related stuff is moved from CWallet to LegacyScriptPubKeyMan (to follow-up bitcoin#17261)
   - refactored duplicated code between hdChain and hdCryptedChain
   - modules hdchain and bip39 related moved to wallet/ module

  ## How Has This Been Tested?
  Run unit/functional tests

  ## Breaking Changes
  N/A

  ## Checklist:
  - [x] I have performed a self-review of my own code
  - [x] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone

Top commit has no ACKs.

Tree-SHA512: 763ea6dd9af902dfc4dd99896c1cb16a75e3c0322e806e37ff05bc9229923057c544732ebf9fca705da870568643370867d3f81a46cab1e9d229b2949016c484
2024-03-05 13:10:56 -06:00
pasta
2441489c1a
Merge #5919: backport: bitcoin#18937, #19390, #19473, #19478, #19489, #19596, #19657, #19727, #19816, partial #18638
4e46e6101c Merge #19478: Remove CTxMempool::mapLinks data structure member (MarcoFalke)
be5662a785 Merge #19596: Deduplicate parent txid loop of requested transactions and missing parents of orphan transactions (Wladimir J. van der Laan)
9c3ecd167e Merge #19473: net: Add -networkactive option (MarcoFalke)
0593c1ffcb Merge #19390: doc/REST-interface: Remove stale info (fanquake)
8368bd795e Merge #19816: test: Rename wait until helper to wait_until_helper (fanquake)
063c9b744d Merge #19727: test: Remove unused classes from p2p_leak.py (fanquake)
941b39d9a9 Merge #18937: refactor: s/command/msg_type/ in CNetMsgMaker and CSerializedNetMsg (MarcoFalke)
a89bd562fd Merge #19657: test: Wait until is_connected in add_p2p_connection (Wladimir J. van der Laan)
a11743f009 Merge #19489: test: Fail wait_until early if connection is lost (MarcoFalke)
ad3f424b4d partial Merge #18638: net: Use mockable time for ping/pong, add tests (MarcoFalke)

Pull request description:

  ## Issue being fixed or feature implemented
  Just regular backports from bitcoin v21

  ## What was done?
   - partial bitcoin/bitcoin#18638
   - bitcoin/bitcoin#19489
   - bitcoin/bitcoin#19657
   - bitcoin/bitcoin#18937
   - bitcoin/bitcoin#19727
   - bitcoin/bitcoin#19816
   - bitcoin/bitcoin#19390
   - bitcoin/bitcoin#19473
   - bitcoin/bitcoin#19596
   - bitcoin/bitcoin#19478

  ## How Has This Been Tested?
  Run unit/functional tests

  ## Breaking Changes
  N/A

  ## Checklist:
  - [x] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone

Top commit has no ACKs.

Tree-SHA512: a656c7f8b39b0220250268e15e2c1d08272cb0253df555559f21ee142ce9ec9d4807ab3aafb0167c4ed79cc3ca73dc9c5aefd279b75b5901e1cc592f4df74bb0
2024-03-05 13:09:22 -06:00
Konstantin Akimov
b5f4411d11
fix: extra logs to distinct WriteHDChain for encrypted/raw batches 2024-03-06 02:04:25 +07:00
Konstantin Akimov
e8f84afd3e
refactor: move BIP39 related code to wallet 2024-03-06 02:04:25 +07:00
Konstantin Akimov
fa6519f320
refactor: move hdchain to wallet/ because it belongs there 2024-03-06 02:04:25 +07:00
Konstantin Akimov
392b51b197
refactor: obsolete hdCryptedChain from ScriptPubKeyMan 2024-03-06 02:04:24 +07:00
Konstantin Akimov
a0389e181f
refactor: rename EncryptHDChain to EncryptAndSetHDChain 2024-03-06 02:04:24 +07:00
Konstantin Akimov
b2143f9346
refactor: re-order public and private methods in scriptpubkeyman 2024-03-06 02:04:24 +07:00
Konstantin Akimov
a219748f5e
refactor: make SetHDChain private in ScriptPubKeyManager 2024-03-06 02:04:23 +07:00
Konstantin Akimov
f418b9ac62
refactor: move Encrypt chain call inside ScriptPubKeyMan::Encrypt 2024-03-06 02:04:23 +07:00
Konstantin Akimov
c3754d5183
refactor: move DecryptHDChain from public to private 2024-03-06 02:04:23 +07:00
Konstantin Akimov
e08b64a1bb
refactor: unify SetHDChainSingle and SetCryptedHDChainSingle 2024-03-06 02:04:22 +07:00
Konstantin Akimov
59a998843b
refactor: unify ScriptPubKeyMan's SetHDChain nad SetHDCryptedChain 2024-03-06 02:04:22 +07:00
Konstantin Akimov
a180d73e5c
refactor: unify WalletBatch's WriteHDChain and WriteCryptedHDChain 2024-03-06 02:04:21 +07:00
Konstantin Akimov
9c8e4584ae
refactor: unify SetHDChain and SetCryptedHDChain helpers 2024-03-06 02:04:21 +07:00
Konstantin Akimov
7b72726b3e
refactor: SetCryptedHDChain moved to scriptpubkeyman 2024-03-06 02:04:21 +07:00
Konstantin Akimov
6993d112f3
feat: extra check failure case CWallet::GenerateNewHDChainEncrypted
To unify code with GenerateNewHDChain
2024-03-06 02:04:20 +07:00
MarcoFalke
4e46e6101c
Merge #19478: Remove CTxMempool::mapLinks data structure member
296be8f58e02b39a58f017c52294aceed22c3ffd Get rid of unused functions CTxMemPool::GetMemPoolChildren, CTxMemPool::GetMemPoolParents (Jeremy Rubin)
46d955d196043cc297834baeebce31ff778dff80 Remove mapLinks in favor of entry inlined structs with iterator type erasure (Jeremy Rubin)

Pull request description:

  Currently we have a peculiar data structure in the mempool called maplinks. Maplinks job is to track the in-pool children and parents of each transaction. This PR can be primarily understood and reviewed as a simple refactoring to remove this extra data structure, although it comes with a nice memory and performance improvement for free.

  Maplinks is particularly peculiar because removing it is not as simple as just moving it's inner structure to the owning CTxMempoolEntry. Because TxLinks (the class storing the setEntries for parents and children) store txiters to each entry in the mempool corresponding to the parent or child, it means that the TxLinks type is "aware" of the boost multiindex (mapTx) it's coming from, which is in turn, aware of the entry type stored in mapTx. Thus we used maplinks to store this entry associated data we in an entirely separate data structure just to avoid a circular type reference caused by storing a txiter inside a CTxMempoolEntry.

  It turns out, we can kill this circular reference by making use of iterator_to multiindex function and std::reference_wrapper. This allows us to get rid of the maplinks data structure and move the ownership of the parents/child sets to the entries themselves.

  The benefit of this good all around, for any of the reasons given below the change would be acceptable, and it doesn't make the code harder to reason about or worse in any respect (as far as I can tell, there's no tradeoff).

  ### Simpler ownership model
  No longer having to consistency check that mapLinks did have records for our CTxMempoolEntry, impossible to have a mapLinks entry outlive or incorrectly die before a CTxMempoolEntry.

  ### Memory Usage
  We get rid of a O(Transactions) sized map in the mempool, which is a long lived data structure.

  ### Performance
  If you have a CTxMemPoolEntry, you immediately know the address of it's children/parents, rather than having to do a O(log(Transactions)) lookup via maplinks (which we do very often). We do it in *so many* places that a true benchmark has to look at a full running node, but it is easy enough to show an improvement in this case.

  The ComplexMemPool shows a good coherence check that we see the expected result of it being 12.5% faster / 1.14x faster.
  ```
  Before:
  # Benchmark, evals, iterations, total, min, max, median
  ComplexMemPool, 5, 1, 1.40462, 0.277222, 0.285339, 0.279793

  After:
  # Benchmark, evals, iterations, total, min, max, median
  ComplexMemPool, 5, 1, 1.22586, 0.243831, 0.247076, 0.244596
  ```
  The ComplexMemPool benchmark only checks doing addUnchecked and TrimToSize for 800 transactions. While this bench does a good job of hammering the relevant types of function, it doesn't test everything.

  Subbing in 5000 transactions shows a that the advantage isn't completely wiped out by other asymptotic factors (this isn't the only bottleneck in growing the mempool), but it's only a bit proportionally slower (10.8%, 1.12x), which adds evidence that this will be a good change for performance minded users.

  ```
  # Benchmark, evals, iterations, total, min, max, median
  ComplexMemPool, 5, 1, 59.1321, 11.5919, 12.235, 11.7068

  # Benchmark, evals, iterations, total, min, max, median
  ComplexMemPool, 5, 1, 52.1307, 10.2641, 10.5206, 10.4306
  ```
  I don't think it's possible to come up with an example of where a maplinks based design would have better performance, but it's something for reviewers to consider.

  # Discussion
  ## Why maplinks in the first place?

  I spoke with the author of mapLinks (sdaftuar) a while back, and my recollection from our conversation was that it was implemented because he did not know how to resolve the circular dependency at the time, and there was no other reason for making it a separate map.

  ## Is iterator_to weird?

  iterator_to is expressly for this purpose, see https://www.boost.org/doc/libs/1_51_0/libs/multi_index/doc/tutorial/indices.html#iterator_to

  >  iterator_to provides a way to retrieve an iterator to an element from a pointer to the element, thus making iterators and pointers interchangeable for the purposes of element pointing (not so for traversal) in many situations. This notwithstanding, it is not the aim of iterator_to to promote the usage of pointers as substitutes for real iterators: the latter are specifically designed for handling the elements of a container, and not only benefit from the iterator orientation of container interfaces, but are also capable of exposing many more programming bugs than raw pointers, both at compile and run time. iterator_to is thus meant to be used in scenarios where access via iterators is not suitable or desireable:
  >
  >     - Interoperability with preexisting APIs based on pointers or references.
  >     - Publication of pointer-based interfaces (for instance, when designing a C-compatible library).
  >     - The exposure of pointers in place of iterators can act as a type erasure barrier effectively decoupling the user of the code from the implementation detail of which particular container is being used. Similar techniques, like the famous Pimpl idiom, are used in large projects to reduce dependencies and build times.
  >     - Self-referencing contexts where an element acts upon its owner container and no iterator to itself is available.

  In other words, iterator_to is the perfect tool for the job by the last reason given. Under the hood it should just be a simple pointer cast and have no major runtime overhead (depending on if the function call is inlined).

  Edit by laanwj: removed at sign from the description

ACKs for top commit:
  jonatack:
    re-ACK 296be8f per `git range-diff ab338a19 3ba1665 296be8f`, sanity check gcc 10.2 debug build is clean.
  hebasto:
    re-ACK 296be8f58e02b39a58f017c52294aceed22c3ffd, only rebased since my [previous](https://github.com/bitcoin/bitcoin/pull/19478#pullrequestreview-482400727) review (verified with `git range-diff`).

Tree-SHA512: f5c30a4936fcde6ae32a02823c303b3568a747c2681d11f87df88a149f984a6d3b4c81f391859afbeb68864ef7f6a3d8779f74a58e3de701b3d51f78e498682e
2024-03-06 02:00:40 +07:00
Wladimir J. van der Laan
be5662a785
Merge #19596: Deduplicate parent txid loop of requested transactions and missing parents of orphan transactions
4c0731f9c50b0556f8a57b912c8f295c7a9ea89c Deduplicate missing parents of orphan transactions (Suhas Daftuar)
81961762439fb72fc2ef168164689ddc29d7ef94 Rewrite parent txid loop of requested transactions (Suhas Daftuar)

Pull request description:

  I noticed a couple of places recently where we loop over all inputs of a transaction in order to do some processing on the txids we find in those inputs.  There may be thousands of inputs in a transaction, and the same txid may appear many times.  In a couple of places in particular, we loop over those txids and add them to a rolling bloom filter; doing that multiple times for the same txid wastes entries in that filter.

  This PR fixes that in two places relating to transaction relay: one on the server side, where we look for parent transactions of a tx that we are delivering to a peer to ensure that getdata requests for those parents will succeed; and the other on the client side, where when we process an orphan tx we want to loop over the parent txids and ensure that all are eventually requested from the peer who provided the orphan.

  This addresses a couple of [related](https://github.com/bitcoin/bitcoin/pull/19109#discussion_r455197217) [comments](https://github.com/bitcoin/bitcoin/pull/19109#discussion_r456820373) left in #19109.

ACKs for top commit:
  laanwj:
    Code review ACK 4c0731f9c50b0556f8a57b912c8f295c7a9ea89c
  jonatack:
    ACK 4c0731f9c50b0556f8a57b912c8f295c7a9ea89c
  ajtowns:
    ACK 4c0731f9c50b0556f8a57b912c8f295c7a9ea89c

Tree-SHA512: 8af9df7f56c6e54b5915519d7d5465e081473ceb1bcc89bbebf83e78722cf51ff58145e588cf57126bce17071a8053273f4bcef0ad8166bec83ba14352e40f5d
2024-03-06 02:00:40 +07:00
MarcoFalke
9c3ecd167e
Merge #19473: net: Add -networkactive option
2aac093a3d60e446b85eebdf170ea6bed77bec92 test: Add test coverage for -networkactive option (Hennadii Stepanov)
3c58129b1293742a49aa196cb210ff345a7339e6 net: Log network activity status change unconditionally (Hennadii Stepanov)
62fe6aa87e4cdd8b06207abc1387c68d7bfc04c1 net: Add -networkactive option (Hennadii Stepanov)

Pull request description:

  Some Bitcoin Core activity is completely local (offline), e.g., reindexing.

  The `setnetworkactive` RPC command is already present. This PR adds the corresponding command-line argument / config option, and allows to start the client with disabled p2p network by providing `-networkactive=0` or `-nonetworkactive`.

  This was done while reviewing #16981.

ACKs for top commit:
  MarcoFalke:
    re-ACK 2aac093a3d60e446b85eebdf170ea6bed77bec92 🏠
  LarryRuane:
    ACK 2aac093a3d60e446b85eebdf170ea6bed77bec92

Tree-SHA512: 446d791b46d7b556d7694df7b1f88cd4fbc09301fe4eaf036b45cb8166ed806156353cc03788a07b633d5887d5eee30a7c02a2d4307141c8ccc75e0a88145636
2024-03-06 02:00:39 +07:00
fanquake
0593c1ffcb
Merge #19390: doc/REST-interface: Remove stale info
fd9c213c6e42cedd8a03c2f721ff46790cded76b doc/REST-interface: Remove stale info (Luke Dashjr)

Pull request description:

  Clean merge to 0.19+

ACKs for top commit:
  fanquake:
    ACK fd9c213c6e42cedd8a03c2f721ff46790cded76b
  MarcoFalke:
    ACK fd9c213c6e42cedd8a03c2f721ff46790cded76b

Tree-SHA512: ac3ffaa72226380ed8b8ab505518d0dc4350bfcc4625dfd27a2350fbb972a8d2bb4255307926eb331c49232023bcb283a659f0d87e4ecbf654982341242f7d36
2024-03-06 02:00:39 +07:00
fanquake
8368bd795e
Merge #19816: test: Rename wait until helper to wait_until_helper
fa1cd9e1ddc6918c3d600d36eadea71eebb242b6 test: Remove unused lock arg from BitcoinTestFramework.wait_until (MarcoFalke)
fad2794e93b4f5976e81793a4a63aa03a2c8c686 test: Rename wait until helper to wait_until_helper (MarcoFalke)
facb41bf1d1b7ee552c627f9829b4494b817ce28 test: Remove unused p2p_lock in VersionBitsWarningTest (MarcoFalke)

Pull request description:

  This avoids confusion with the `wait_until` member functions, which should be preferred because they take the appropriate locks and scale the timeout appropriately on their own.

ACKs for top commit:
  laanwj:
    Code review ACK fa1cd9e1ddc6918c3d600d36eadea71eebb242b6
  hebasto:
    ACK fa1cd9e1ddc6918c3d600d36eadea71eebb242b6, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: 319d400085606a4c738e314824037f72998e6657d8622b363726842aba968744f23c56d27275dfe506b8cbbb6e97fc39ca1d325db05d4d67df0e8b35f2244d5c
2024-03-06 02:00:39 +07:00
fanquake
063c9b744d
Merge #19727: test: Remove unused classes from p2p_leak.py
ed5cd12869e0691a785199d2d977ce5879095180 test: Distinguish between nodes(bitcoind) and peers(mininodes) in p2p_leak.py (Dhruv Mehta)
f6f082b9343522bc8005f23937ac6ecf56548c98 test: remove `CNodeNoVersionIdle` from p2p_leak.py (Dhruv Mehta)
45cf55ccac94689e48dd0648ed2401918a778024 test: remove `CNodeNoVersionMisbehavior` from p2p_leak.py (Dhruv Mehta)

Pull request description:

  - Removes `CNodeNoVersionMisbehavior` per recommendation at https://github.com/bitcoin/bitcoin/pull/19657#issuecomment-669926458
  - Removes `CNodeNoVersionIdle` because it is similarly unnecessary
  - As someone new to the codebase, I found it easier to understand it if `no_version_disconnect_node` tries to overwhelm the peer with any message that is not version/verack.
  - Per recommendation at https://github.com/bitcoin/bitcoin/pull/19727#pullrequestreview-468093555, made a clear distinction between nodes(bitcoind) and peers(mininode interface implementations)

ACKs for top commit:
  jnewbery:
    tested ACK ed5cd12869e0691a785199d2d977ce5879095180
  amitiuttarwar:
    utACK ed5cd12869

Tree-SHA512: 310a24c91fd837e7f65177edb55fe6142fb3559fae7867c5cdd9c9a23b1a02202b935ca9a82633fa7649f3de2fa221f6da906a7b5e499fc20f7254085033757d
2024-03-06 02:00:38 +07:00
MarcoFalke
941b39d9a9
Merge #18937: refactor: s/command/msg_type/ in CNetMsgMaker and CSerializedNetMsg
51e9393c1f6c9eaac554f821f5327f63bd09c8cf refactor: s/command/msg_type/ in CNetMsgMaker and CSerializedNetMsg (Sebastian Falbesoner)

Pull request description:

  Follow-up PR for #18533 -- another small step towards getting rid of the confusing "command" terminology. Also see PR #18610 which tackled the functional tests.

ACKs for top commit:
  MarcoFalke:
    ACK 51e9393c1f6c9eaac554f821f5327f63bd09c8cf

Tree-SHA512: bb6f05a7be6823d5c4eab1d05b31fee944e700946827ad9425d59a3957fd879776c88c606319cbe9832d9451b275baedf913b71429ea3e01e4e82bf2d419e819
2024-03-06 02:00:38 +07:00
Wladimir J. van der Laan
a89bd562fd
Merge #19657: test: Wait until is_connected in add_p2p_connection
fa4dfd215f62e88d668311701735c332c264fa2a test: Wait until is_connected in add_p2p_connection (MarcoFalke)

Pull request description:

  Moving the wait_until from the individual test scripts to the test framework simplifies two tests

ACKs for top commit:
  jnewbery:
    Code review ACK fa4dfd215f62e88d668311701735c332c264fa2a
  theStack:
    ACK fa4dfd215f 

Tree-SHA512: 36eda7eb323614a4c4f9215f1d7b40b9f9c4036d1c08eb701ea705f3e2986fdabd2fc558965a6aadabeed861034aeaeef3c00f968ca17ed7a27e42e506cda87d
2024-03-06 02:00:38 +07:00
MarcoFalke
a11743f009
Merge #19489: test: Fail wait_until early if connection is lost
faa9a74c9e99eb43ba0d27fa906767ee88011aeb test: Fail wait_until early if connection is lost (MarcoFalke)

Pull request description:

  Calling `minonode.wait_until` needs a connection to make progress (e.g. waiting for an inv), unless the mininode waits for the initial connection or for a disconnection. So for test development and failure debugging, fail early in all `wait_until`, unless opted out.

ACKs for top commit:
  jnewbery:
    Code review ACK faa9a74c9e99eb43ba0d27fa906767ee88011aeb.

Tree-SHA512: 4be850b96e23b87bc2ff42c028a5045d6f5cdbc9482ce6a6ba01cc5eb26710dab9e2ed547c363aac4bd5825151ee9996fb797261420b631bceeddbfa698d1dec
2024-03-06 02:00:37 +07:00