Commit graph

1894 commits

Author SHA1 Message Date
MacroFake
fa97a528d6
Fix UB/data-race in RPCNotifyBlockChange
ActiveTip() is *not* thread-safe, as the required ::cs_main lock will be
released as ActiveChainstate() returns.

ActiveTip() is an alias for ActiveChainstate().m_chain.Tip(), so m_chain
may be involved in a data-race (UB).
2022-08-16 17:25:49 +02:00
Carl Dong
41c5201a90 validationcaches: Add and use ValidationCacheSizes
Also:

- Make DEFAULT_MAX_SIG_CACHE_SIZE into constexpr
  DEFAULT_MAX_SIG_CACHE_BYTES to utilize the compile-time integer
  arithmetic overflow checking available to constexpr.
- Fix comment (MiB instead of MB) for DEFAULT_MAX_SIG_CACHE_BYTES.
- Pass in max_size_bytes parameter to InitS*Cache(), modify log line to
  no longer allude to maxsigcachesize being split evenly between the two
  validation caches.
- Fix possible integer truncation and add a comment.

[META] I've kept the integer types as int64_t in order to not introduce
       unintended behaviour changes, in the next commit we will make
       them size_t.
2022-08-03 12:03:27 -04:00
Carl Dong
08dbc6ef72 cuckoocache: Return approximate memory size
Returning the approximate total size eliminates the need for
InitS*Cache() to do nElems*sizeof(uint256). The cuckoocache has a better
idea of this information.
2022-08-03 12:02:31 -04:00
MacroFake
ddddd6913b
sort after scripted-diff 2022-08-02 15:31:05 +02:00
MacroFake
fac812ca83
scripted-diff: Move mempool_args to src/node
It is part of the node library. Also, it won't be moved to the kernel
lib, as it will be pruned of ArgsManager.

-BEGIN VERIFY SCRIPT-
 # Move module
 git mv src/mempool_args.cpp src/node/
 git mv src/mempool_args.h   src/node/
 # Replacements
 sed -i 's:mempool_args\.h:node/mempool_args.h:g'     $(git grep -l mempool_args)
 sed -i 's:mempool_args\.cpp:node/mempool_args.cpp:g' $(git grep -l mempool_args)
 sed -i 's:MEMPOOL_ARGS_H:NODE_MEMPOOL_ARGS_H:g'      $(git grep -l MEMPOOL_ARGS_H)
-END VERIFY SCRIPT-
2022-08-02 15:31:01 +02:00
MacroFake
66664384a6
Remove ::g_max_datacarrier_bytes global 2022-08-02 15:29:16 +02:00
MacroFake
fa2a6b8516
Combine datacarrier globals into one 2022-08-02 15:28:10 +02:00
MacroFake
fa2f6c1a61
Remove ::fIsBareMultisigStd global 2022-08-02 15:27:19 +02:00
MacroFake
fadc14e4f5
Remove ::dustRelayFee 2022-08-02 15:26:49 +02:00
MacroFake
fa9cba7afb
Remove ::incrementalRelayFee and ::minRelayTxFee globals 2022-08-02 15:23:36 +02:00
MacroFake
fa148602e6
Remove ::fRequireStandard global 2022-08-02 15:23:24 +02:00
MacroFake
fa468bdfb6
Return optional error from ApplyArgsManOptions
Also pass in a (for now unused) reference to the params.

Both changes are needed for the next commit.
2022-08-02 15:21:50 +02:00
Ryan Ofsky
6db6552377 refactor: Reduce number of SanityChecks return values 2022-07-19 16:54:52 -04:00
Russell Yanofsky
b3e7de7ee6 refactor: Reduce number of LoadChainstate return values 2022-07-19 15:54:52 -05:00
Russell Yanofsky
3b91d4b994 refactor: Reduce number of LoadChainstate parameters 2022-07-19 15:54:52 -05:00
fanquake
92c8e1849d
Merge bitcoin/bitcoin#25494: indexes: Stop using node internal types
7878f97bf1 indexes, refactor: Remove CChainState use in index CommitInternal method (Ryan Ofsky)
ee3a079fab indexes, refactor: Remove CBlockIndex* uses in index Rewind methods (Ryan Ofsky)
dc971be083 indexes, refactor: Remove CBlockIndex* uses in index WriteBlock methods (Ryan Ofsky)
bef4e405f3 indexes, refactor: Remove CBlockIndex* uses in index Init methods (Ryan Ofsky)
addb4f2af1 indexes, refactor: Remove CBlockIndex* uses in coinstatsindex LookUpOne function (Ryan Ofsky)
33b4d48cfc indexes, refactor: Pass Chain interface instead of CChainState class to indexes (Ryan Ofsky)
a0b5b4ae5a interfaces, refactor: Add more block information to block connected notifications (Ryan Ofsky)

Pull request description:

  Start transitioning index code away from using internal node types like `CBlockIndex` and `CChain` so index code is less coupled to node code and index code will later be able to stop locking cs_main and sync without having to deal with validationinterface race conditions, and so new indexes are easier to write and can run as plugins or separate processes.

  This PR contains the first 7 commits from https://github.com/bitcoin/bitcoin/pull/24230#issuecomment-1165625977 which have been split off for easier review. Previous review comments can be found in #24230

ACKs for top commit:
  MarcoFalke:
    ACK 7878f97bf1 though did not review the last commit 🤼
  mzumsande:
    Code Review ACK 7878f97bf1

Tree-SHA512: f84ac2eb6dca2c305566ddeb35ea14d0b71c00860c0fd752bbcf1a0188be833d8c2a6ac9d3ef6ab5b46fbd02d7a24cbb8f60cf12464cb8ba208e22287f709989
2022-07-19 21:42:48 +01:00
Ryan Ofsky
33b4d48cfc indexes, refactor: Pass Chain interface instead of CChainState class to indexes
Passing abstract Chain interface will let indexes run in separate
processes.

This commit does not change behavior in any way.
2022-07-18 13:39:55 -05:00
fanquake
d6787bc19b
refactor: remove unused using directives 2022-07-18 17:25:03 +01:00
glozow
821f5c824f
Merge bitcoin/bitcoin#25487: [kernel 3b/n] Decouple {Dump,Load}Mempool from ArgsManager
cb3e9a1e3f Move {Load,Dump}Mempool to kernel namespace (Carl Dong)
aa30676541 Move DEFAULT_PERSIST_MEMPOOL out of libbitcoinkernel (Carl Dong)
06b88ffb8a LoadMempool: Pass in load_path, stop using gArgs (Carl Dong)
b857ac60d9 test/fuzz: Invoke LoadMempool via CChainState (Carl Dong)
b3267258b0 Move FopenFn to fsbridge namespace (Carl Dong)
ae1e8e3756 mempool: Use NodeClock+friends for LoadMempool (Carl Dong)
f9e8e5719f mempool: Improve comments for [GS]etLoadTried (Carl Dong)
813962da0b scripted-diff: Rename m_is_loaded -> m_load_tried (Carl Dong)
413f4bb52b DumpMempool: Pass in dump_path, stop using gArgs (Carl Dong)
bd4407817e DumpMempool: Use std::chrono instead of weird int64_t arthmetics (Carl Dong)
c84390b741 test/mempool_persist: Test manual savemempool when -persistmempool=0 (Carl Dong)

Pull request description:

  This is part of the `libbitcoinkernel` project: #24303, https://github.com/bitcoin/bitcoin/projects/18

  -----

  This PR moves `{Dump,Load}Mempool` into its own `kernel/mempool_persist` module and introduces `ArgsManager` `node::` helpers in `node/mempool_persist_args`to remove the scattered calls to `GetBoolArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)`.

  More context can be gleaned from the commit messages.

  -----

  One thing I was reflecting on as I wrote this was that in the long run, I think we should probably invert the validation <-> mempool relationship. Instead of mempool not depending on validation, it might make more sense to have validation not depend on mempool. Not super urgent since `libbitcoinkernel` will include both validation and mempool, but perhaps something for the future.

ACKs for top commit:
  glozow:
    re ACK cb3e9a1e3f via `git range-diff 7ae032e...cb3e9a1`
  MarcoFalke:
    ACK cb3e9a1e3f 🔒
  ryanofsky:
    Code review ACK cb3e9a1e3f

Tree-SHA512: 979d7237c3abb5a1dd9b5ad3dbf3b954f906a6d8320ed7b923557f41a4472deccae3e8a6bca0018c8e7a3c4a93afecc502acd1e26756f2054f157f1c0edd939d
2022-07-18 16:09:27 +01:00
Carl Dong
cb3e9a1e3f Move {Load,Dump}Mempool to kernel namespace
Also:
1. Add the newly introduced kernel/mempool_persist.cpp to IWYU CI script
2. Add chrono mapping for iwyu
2022-07-15 12:26:20 -04:00
Carl Dong
aa30676541 Move DEFAULT_PERSIST_MEMPOOL out of libbitcoinkernel
It is no longer used by anything inside libbitcoinkernel, move it to
node/mempool_persist_args.h where it belongs.
2022-07-15 12:26:20 -04:00
Carl Dong
06b88ffb8a LoadMempool: Pass in load_path, stop using gArgs
Also:
1. Have CChainState::LoadMempool and ::ThreadImport take in paths and
   pass it through untouched to LoadMempool.
2. Make LoadMempool exit early if the load_path is empty.
3. Adjust the call to ::ThreadImport in ::AppInitMain to correctly pass
   in an empty path if mempool persistence is disabled.
2022-07-15 12:26:20 -04:00
Carl Dong
813962da0b scripted-diff: Rename m_is_loaded -> m_load_tried
m_is_loaded/IsLoaded() doesn't actually indicate whether or not the
mempool was successfully, loaded, but rather if a load has been
attempted and did not result in a catastrophic ShutdownRequested.

-BEGIN VERIFY SCRIPT-
find_regex="\bm_is_loaded\b" \
    && git grep -l -E "$find_regex" \
        | xargs sed -i -E "s@$find_regex@m_load_tried@g"

find_regex="\bIsLoaded\b" \
    && git grep -l -E "$find_regex" \
        | xargs sed -i -E "s@$find_regex@GetLoadTried@g"

find_regex="\bSetIsLoaded\b" \
    && git grep -l -E "$find_regex" \
        | xargs sed -i -E "s@$find_regex@SetLoadTried@g"
-END VERIFY SCRIPT-
2022-07-15 11:35:13 -04:00
Carl Dong
413f4bb52b DumpMempool: Pass in dump_path, stop using gArgs
Also introduce node::{ShouldPersistMempool,MempoolPath} helper functions
in node/mempool_persist_args.{h,cpp} which are used by non-kernel
DumpMempool callers to determine whether or not to automatically dump
the mempool and where to dump it to.
2022-07-15 11:30:50 -04:00
Carl Dong
ce8b0f971b Use designated initializers for ChainstateManager::Options
This wasn't available at the time when ChainstateManager::Options was
introduced but is helpful to be explicit and ensure correctness.
2022-07-14 08:35:23 -04:00
fanquake
c30b3e90f0
Merge bitcoin/bitcoin#25472: build: Increase MS Visual Studio minimum version
630c1711b4 refactor: Drop no longer needed `util/designator.h` (Hennadii Stepanov)
88ec5d40dc build: Increase MS Visual Studio minimum version (Hennadii Stepanov)
555f9dd5d3 rpc, refactor: Add `decodepsbt_outputs` (Hennadii Stepanov)
0c432cbbfa rpc, refactor: Add `decodepsbt_inputs` (Hennadii Stepanov)
01d95a3964 rpc, refactor: Add `getblock_prevout` (Hennadii Stepanov)

Pull request description:

  Visual Studio 2022 with `/std:c++20` supports [designated initializers](https://github.com/bitcoin/bitcoin/pull/24531).

ACKs for top commit:
  sipsorcery:
    reACK 630c1711b4.

Tree-SHA512: 5b8933940dd69061c6b077512168bebb6fea05d429b63ffbab191950798b4c825e8484b1a651db0ae13f97eae481097d3c16395659c0f3b9f847af2aaf44b65d
2022-07-13 16:18:44 +01:00
MacroFake
a7f3479ba3
Merge bitcoin/bitcoin#25353: Add a -mempoolfullrbf node setting
4c9666bd73 Mention `mempoolfullrbf` in policy/mempool-replacements.md (Antoine Riard)
aae66ab43d Update getmempoolinfo RPC with `mempoolfullrbf` (Antoine Riard)
3e27e31727 Introduce `mempoolfullrbf` node setting. (Antoine Riard)

Pull request description:

  This is ready for review.

  Recent discussions among LN devs have brought back on the surface concerns about the security of multi-party funded transactions against pinnings attacks and other mempool-based nuisances. The lack of full-rbf transaction-relay topology connected to miners open the way to cheap and naive DoS against multi-party funded transactions (e.g coinjoins, dual-funded channels, on-chain DLCs, ...) without solutions introducing an overhead cost or centralization vectors afaik . For more details, see [0].

  This PR implements a simple `fullrbf` setting, where the node always allows transaction replacement, ignoring BIP125 opt-in flag. The default value of the setting stays **false**, therefore opt-in replacement is still the default Bitcoin Core replacement policy. Contrary to a previous proposal of mine and listening to feedbacks collected since then [1], I think this new setting simply offers more flexibility in a node transaction-relay policy suiting one's application requirements, without arguing a change of the default behavior.

  I [posted](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2022-June/020557.html) on the ML to invite operators with a bitcoin application sensitive to full-rbf (e.g dual-funded LN channels service providers) or mempool researchers to join a bootstrapped full-rbf activated peers network for experimentation and learning. If people have strong opinions against the existence of such full-rbf transaction-relay network, I'm proposing to express them on the future thread.

  [0] https://lists.linuxfoundation.org/pipermail/lightning-dev/2021-May/003033.html
  [1] https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2021-June/019074.html

  Follow-up suggestions :
  - soft-enable opt-in RBF in the wallet : https://github.com/bitcoin/bitcoin/pull/25353#issuecomment-1154918789
  - p2p discovery and additional outbound connection to full-rbf peers : https://github.com/bitcoin/bitcoin/pull/25353#issuecomment-1156044401
  - match the code between RPC, wallet and mempool about disregard of inherited signaling : #22698

ACKs for top commit:
  instagibbs:
    reACK 4c9666bd73
  glozow:
    ACK 4c9666bd73, a few nits which are non-blocking.
  w0xlt:
    ACK 4c9666bd73

Tree-SHA512: 9e288bf22e06a9808804e58178444ef1830c3fdd42fd8a7cd7ffb101f8f586e08b000679be407d63ca76a56f7216227b368ff630c81f3fac3243db1a1202ab1c
2022-07-08 11:06:24 +02:00
Hennadii Stepanov
630c1711b4
refactor: Drop no longer needed util/designator.h 2022-07-07 20:01:01 +01:00
Antoine Riard
3e27e31727 Introduce mempoolfullrbf node setting.
This new node policy setting enables to accept replaced-by-fee
transaction without inspection of the replaceability signaling
as described in BIP125 "explicit signaling".

If turns on, the node mempool accepts transaction replacement
as described in `policy/mempool-replacements.md`.

The default setting value is `false`, implying opt-in RBF
is enforced.
2022-07-06 20:57:29 -04:00
/dev/fd0
748a10e896 rephrase error for invalid timeout 2022-06-30 14:16:04 +05:30
Carl Dong
d1684beabe fees: Pass in a filepath instead of referencing gArgs 2022-06-28 16:08:34 -04:00
Carl Dong
9a3d825c30 init: Remove redundant -*mempool*, -limit* queries
Now that MemPoolOptions has correctly-determined max_size and limits
members, perform sanity checks on that instead of re-determining the
options.
2022-06-28 15:53:45 -04:00
Carl Dong
716bb5fbd3 scripted-diff: Rename anc/desc size limit vars to indicate SI unit
Better to be explicit when it comes to sizes to avoid unintentional
bugs. We use MB and KB all over the place.

-BEGIN VERIFY SCRIPT-
find_regex="DEFAULT_(ANCESTOR|DESCENDANT)_SIZE_LIMIT" \
    && git grep -l -E "$find_regex" \
        | xargs sed -i -E "s@$find_regex@\0_KVB@g"
-END VERIFY SCRIPT-
2022-06-28 15:42:40 -04:00
Carl Dong
1ecc77321d scripted-diff: Rename DEFAULT_MEMPOOL_EXPIRY to indicate time unit
Better to be explicit when it comes to time to avoid unintentional bugs.

-BEGIN VERIFY SCRIPT-
find_regex="DEFAULT_MEMPOOL_EXPIRY" \
    && git grep -l -E "$find_regex" \
        | xargs sed -i -E "s@$find_regex@\0_HOURS@g"
-END VERIFY SCRIPT-
2022-06-28 15:42:40 -04:00
Carl Dong
51c7a41a5e init: Only determine maxmempool once
Now that MemPoolOptions has a correctly-determined max_size member, use
that instead of redetermining it to print the log line.
2022-06-28 15:39:31 -04:00
Carl Dong
f1941e8bfd pool: Add and use MemPoolOptions, ApplyArgsManOptions
Reviewers: Note that CTxMemPool now requires a non-defaulted
CTxMemPool::Options for its constructor. Meaning that there's no need to
worry about a stray CTxMemPool constructor somewhere defaulting to
something incorrect. All instances of CTxMemPool construction are
addressed here in this commit.

We set options for CTxMemPool and construct it in many different ways. A
good example can be seen in how we determine CTxMemPool's check_ratio in
AppInitMain(...).

1. We first set the default based on chainparams's
   DefaultConsistencyChecks()
2. Then, we apply the ArgsManager option on top of that default
3. Finally, we clamp the result of that between 0 and 1 Million

With this patch, most CTxMemPool construction are along the lines of:

    MemPoolOptions mempool_opts{...default overrides...};
    ApplyArgsManOptions(argsman, mempool_opts);
    ...hard overrides...
    CTxMemPool pool{mempool_opts};

This "compositional" style of building options means that we can omit
unnecessary/irrelevant steps wherever we want but also maintain full
customizability.

For example:

- For users of libbitcoinkernel, where we eventually want to remove
  ArgsManager, they simply won't call (or even know about)
  ApplyArgsManOptions.

- See src/init.cpp to see how the check_ratio CTxMemPool option works
  after this change.

A MemPoolOptionsForTest helper was also added and used by tests/fuzz
tests where a local CTxMemPool needed to be created.

The change in src/test/fuzz/tx_pool.cpp seemingly changes behaviour by
applying ArgsManager options on top of the CTxMemPool::Options defaults.
However, in future commits where we introduce flags like -maxmempool,
the call to ApplyArgsManOptions is actually what preserves the existing
behaviour. Previously, although it wasn't obvious, our CTxMemPool would
consult gArgs for flags like -maxmempool when it needed it, so it
already relied on ArgsManager information. This patchset just laid bare
the obfuscatory perils of globals.

[META] As this patchset progresses, we will move more and more
       CTxMemPool-relevant options into MemPoolOptions and add their
       ArgsMan-related logic to ApplyArgsManOptions.
2022-06-28 15:30:05 -04:00
Carl Dong
ccbaf546a6 scripted-diff: Rename DEFAULT_MAX_MEMPOOL_SIZE to indicate SI unit
Better to be explicit when it comes to sizes to avoid unintentional
bugs. We use MB and KB all over the place.

-BEGIN VERIFY SCRIPT-
find_regex="DEFAULT_MAX_MEMPOOL_SIZE" \
    && git grep -l -E "$find_regex" \
        | xargs sed -i -E "s@$find_regex@\0_MB@g"
-END VERIFY SCRIPT-
2022-06-22 18:18:56 -04:00
MacroFake
38c63e3683
Merge bitcoin/bitcoin#25338: scripted-diff: Avoid incompatibility with CMake AUTOUIC feature
018d70b587 scripted-diff: Avoid incompatibility with CMake AUTOUIC feature (Hennadii Stepanov)

Pull request description:

  Working on [migration](https://github.com/hebasto/bitcoin/pull/3) from Autotools to CMake build system, I found that our current code base needs to be adjusted.

  CMake [allows](https://cmake.org/cmake/help/latest/prop_tgt/AUTOUIC.html) to
  > handle the Qt `uic` code generator automatically

  When using this feature, statements like `#include "ui_<ui_base>.h"` are processed in a special way.

  The `node/ui_interface.h` unintentionally breaks this feature. Of course, it is possible to provide a list of source files to be excluded from `AUTOUIC`. But, unfortunately, this approach does not work for the `qt/sendcoinsdialog.cpp` source file, where there are both b71d37da2c/src/qt/sendcoinsdialog.cpp (L10) and b71d37da2c/src/qt/sendcoinsdialog.cpp (L24)

ACKs for top commit:
  MarcoFalke:
    cr ACK 018d70b587
  ryanofsky:
    Code review ACK 018d70b587
  furszy:
    Code review ACK 018d70b5

Tree-SHA512: 4fc83f2e5a82c8ab15c3c3d68f48b9863c47b96c0a66b6276b9b4dfc6063abffd73a16382acfe116553487b3ac697dbde2d9ada1b92010c5d8f8c6aa06f56428
2022-06-15 08:10:38 +02:00
laanwj
9e4fbebcc8
Merge bitcoin/bitcoin#25306: logging: add LogPrintfCategory to log unconditionally with category
ecff20db28 logging: use LogPrintfCategory rather than a manual category (Jon Atack)
eb8aab759f logging: add LogPrintfCategory to log unconditionally with category (Jon Atack)

Pull request description:

  These are the next two commits from #25203.

  - Add `LogPrintfCategory` to log unconditionally while prefixing the output with the passed category name. Add documentation and a unit test, and update the `lint-logs.py` and `lint-format-strings.py` scripts.

  - Replace the log messages that manually print a category, with `LogPrintfCategory`. In upcoming commits, it will likely be used in many other cases, such as to replace `LogPrintf` where it makes sense.

ACKs for top commit:
  klementtan:
    Code Review ACK ecff20db28
  laanwj:
    Code review ACK ecff20db28
  brunoerg:
    ACK ecff20db28

Tree-SHA512: ad3a82835254f7606efcd14b88f3d9072f1eb9b25db1321ed38ef6a4ec60efd555d78f5e19d93736f2f8500251d06f8beee9d694a153f24bf5cce3590a2a45a5
2022-06-14 11:46:32 +02:00
Hennadii Stepanov
018d70b587
scripted-diff: Avoid incompatibility with CMake AUTOUIC feature
-BEGIN VERIFY SCRIPT-
sed -i "s|node/ui_interface|node/interface_ui|g" $(git grep -l "node/ui_interface" ./src)
git mv src/node/ui_interface.cpp src/node/interface_ui.cpp
git mv src/node/ui_interface.h src/node/interface_ui.h
sed -i "s|BITCOIN_NODE_UI_INTERFACE_H|BITCOIN_NODE_INTERFACE_UI_H|g" src/node/interface_ui.h
-END VERIFY SCRIPT-
2022-06-14 10:38:51 +02:00
MacroFake
8f3ab9a1b1
Merge bitcoin/bitcoin#24931: Strengthen thread safety assertions
ce893c0497 doc: Update developer notes (Anthony Towns)
d2852917ee sync.h: Imply negative assertions when calling LOCK (Anthony Towns)
bba87c0553 scripted-diff: Convert global Mutexes to GlobalMutexes (Anthony Towns)
a559509a0b sync.h: Add GlobalMutex type (Anthony Towns)
be6aa72f9f qt/clientmodel: thread safety annotation for m_cached_tip_mutex (Anthony Towns)
f24bd45b37 net_processing: thread safety annotation for m_tx_relay_mutex (Anthony Towns)

Pull request description:

  This changes `LOCK(mutex)` for non-global, non-recursive mutexes to be annotated with the negative capability for the mutex it refers to, to prevent . clang applies negative capabilities recursively, so this helps avoid forgetting to annotate functions.

  This can't reasonably be used for globals, because clang would require every function to be annotated with `EXCLUSIVE_LOCKS_REQUIRED(!g_mutex)` for each global mutex; so this introduces a trivial `GlobalMutex` subclass of `Mutex`, and reduces the annotations for both `GlobalMutex`  to `LOCKS_EXCLUDED` which only catches trivial errors (eg (`LOCK(x); LOCK(x);`).

ACKs for top commit:
  MarcoFalke:
    review ACK ce893c0497 🐦
  hebasto:
    ACK ce893c0497

Tree-SHA512: 5c35e8c7677ce3d994a7e3774f4344adad496223a51b3a1d1d3b5f20684b2e1d5cff688eb3fbc8d33e1b9940dfa76e515f9434e21de6f3ce3c935e29a319f529
2022-06-10 16:42:53 +02:00
Jon Atack
ecff20db28 logging: use LogPrintfCategory rather than a manual category
Here we update only the log messages that manually print a category.

In upcoming commits, LogPrintCategory will likely be used in many
other cases, such as to replace `LogPrintf` where it makes sense.
2022-06-08 14:02:54 +02:00
Carl Dong
d87784ac87 kernel: SanityChecks: Return an error struct
This reduces libbitcoinkernel's coupling with ui_interface and
translation.
2022-06-02 12:22:46 -04:00
Carl Dong
265d6393bf Move init::SanityCheck to kernel::SanityCheck 2022-06-02 11:42:12 -04:00
Carl Dong
fed085a1a4 init: Initialize globals with kernel::Context's life
...instead of explicitly calling init::{Set,Unset}Globals.

Cool thing about this is that in both the testing and bitcoin-chainstate
codepaths, we no longer need to explicitly unset globals. The
kernel::Context goes out of scope and the globals are unset
"automatically".

Also construct kernel::Context outside of AppInitSanityChecks()
2022-06-02 11:40:03 -04:00
fanquake
cc61bc2e19
compat: remove glibcxx sanity checks
These checks were added in #4339, (see also #4081), to test
our back-compat stubs, however, those stubs no-longer exist (#22930),
meaning that these checks are now just testing some specific standard
library behaviour, without a particular rationale, or reason, compared
to any other standard library functions we use.

There has also been some discussion about the sanity checks in the
context of the libbitcoinkernel refactoring, see
https://github.com/bitcoin/bitcoin/pull/25065#discussion_r880668218.
Removing the checks removes the need to worry about atleast the glibcxx
checks.

Also remove the list of check from the doc in init.h, because it is
incomplete, and anyone who wants to know what checks are included can
look at the function.
2022-05-28 09:43:02 +01:00
MacroFake
2642dee136
Merge bitcoin/bitcoin#15936: interfaces: Expose settings.json methods to GUI
f9fdcec7e9 settings: Add resetSettings() method (Ryan Ofsky)
77fabffef4 init: Remove Shutdown() node.args reset (Ryan Ofsky)
0e55bc6e7f settings: Add update/getPersistent/isIgnored methods (Ryan Ofsky)

Pull request description:

  Add `interfaces::Node` `updateSetting`, `forceSetting`, `resetSettings`, `isSettingIgnored`, and `getPersistentSetting` methods so GUI is able to manipulate `settings.json` file and use and modify node settings.

  (Originally this PR also contained GUI changes to unify bitcoin-qt and bitcoind persistent settings and call these methods, but the GUI commits have been dropped from this PR and moved to bitcoin-core/gui/pull/602)

ACKs for top commit:
  vasild:
    ACK f9fdcec7e9
  hebasto:
    re-ACK f9fdcec7e9, only a function renamed since my recent [review](https://github.com/bitcoin/bitcoin/pull/15936#pullrequestreview-979324357).

Tree-SHA512: 4cac853ee29be96d2ff38404165b9dfb7c622b2a9c99a15979596f3484ffde0da3d9c9c372677dff5119ca7cffa6383d81037fd9889a29cc9285882a8dc0c268
2022-05-26 17:05:10 +02:00
Ben Woosley
71a8dbe5da
refactor: Remove defunct attributes.h includes
Since the removal of NODISCARD in 81d5af42f4,
the only attributes def is LIFETIMEBOUND, and it's included in many more
places that it is used.

This removes all includes which do not have an associated use of LIFETIMEBOUND,
and adds it to the following files, due to their use of the same:
* src/validationinterface.h
* src/script/standard.h
2022-05-21 13:54:33 -05:00
Carl Dong
04c31c1295 Add ChainstateManager::m_adjusted_time_callback
This decouples validation.cpp from netaddress.cpp (transitively,
timedata.cpp, and asmap.cpp).

This is important for libbitcoinkernel as:

- There is no reason for the consensus engine to be coupled with
  netaddress, timedata, and asmap
- Users of libbitcoinkernel can now easily supply their own
  std::function that provides the adjusted time.

See the src/Makefile.am changes for some satisfying removals.
2022-05-20 11:57:51 -04:00
Carl Dong
dbe45c34f8 Add ChainstateManagerOpts, using as ::Options
[META] Although it seems like we don't need it for just one option,
       we're going to introduce another member to this struct *in the
       next commit*. In future patchsets for libbitcoinkernel decoupling
       it from ArgsManager, even more members will be added here.
2022-05-20 11:54:18 -04:00