aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
AgeCommit message (Collapse)Author
2021-02-18Merge #19809: log: Prefix log messages with function name and source code ā†µWladimir J. van der Laan
location if -logsourcelocations is set b4511e2e2ed1a6077ae6826a9ee6b7a311293d08 log: Prefix log messages with function name if -logsourcelocations is set (practicalswift) Pull request description: Prefix log messages with function name if `-logfunctionnames` is set. Yes, exactly like `-logthreadnames` but for function names instead of thread names :) This is a small developer ergonomics improvement: I've found this to be a cheap/simple way to correlate log output and originating function. For me it beats the ordinary cycle of 1.) try to figure out a regexp matching the static part of the dynamic log message, 2.) `git grep -E 'Using .* MiB out of .* requested for signature cache'`, 3.) `mcedit filename.cpp` (`openemacs filename.cpp` works too!) and 4.) search for log message and scroll up to find the function name :) Without any logging parameters: ``` $ src/bitcoind -regtest 2020-08-25T03:29:04Z Using RdRand as an additional entropy source 2020-08-25T03:29:04Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements 2020-08-25T03:29:04Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements 2020-08-25T03:29:04Z Loaded best chain: hashBestChain=0fff88f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e22ff height=0 date=2011-02-02T23:16:42Z progress=1.000000 2020-08-25T03:29:04Z block tree size = 1 2020-08-25T03:29:04Z nBestHeight = 0 2020-08-25T03:29:04Z Imported mempool transactions from disk: 0 succeeded, 0 failed, 0 expired, 0 already there, 0 waiting for initial broadcast 2020-08-25T03:29:04Z 0 addresses found from DNS seeds ``` With `-logthreadnames` and `-logfunctionnames`: ``` $ src/bitcoind -regtest -logthreadnames -logfunctionnames 2020-08-25T03:29:04Z [init] [ReportHardwareRand] Using RdRand as an additional entropy source 2020-08-25T03:29:04Z [init] [InitSignatureCache] Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements 2020-08-25T03:29:04Z [init] [InitScriptExecutionCache] Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements 2020-08-25T03:29:04Z [init] [LoadChainTip] Loaded best chain: hashBestChain=0fff88f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e22ff height=0 date=2011-02-02T23:16:42Z progress=1.000000 2020-08-25T03:29:04Z [init] [AppInitMain] block tree size = 1 2020-08-25T03:29:04Z [init] [AppInitMain] nBestHeight = 0 2020-08-25T03:29:04Z [loadblk] [LoadMempool] Imported mempool transactions from disk: 0 succeeded, 0 failed, 0 expired, 0 already there, 0 waiting for initial broadcast 2020-08-25T03:29:04Z [dnsseed] [ThreadDNSAddressSeed] 0 addresses found from DNS seeds ``` ACKs for top commit: laanwj: Code review ACK b4511e2e2ed1a6077ae6826a9ee6b7a311293d08 MarcoFalke: review ACK b4511e2e2ed1a6077ae6826a9ee6b7a311293d08 šŸŒƒ Tree-SHA512: d100f5364630c323f31d275259864c597f7725e462d5f4bdedcc7033ea616d7fc0d16ef1b2af557e692f4deea73c6773ccfc681589e7bf6ba970b9ec169040c7
2021-02-18Merge #15946: Allow maintaining the blockfilterindex when using pruneJonas Schnelli
84716b134e9afca2fba7731de4af1f22fa1b1518 Add "index/blockfilterindex -> validation -> index/blockfilterindex" to expected circular dependencies (Jonas Schnelli) ab3a0a2fb915d8b8384c30a8b38b4b5cc35236fd Add functional test for blockfilterindex in prune-mode (Jonas Schnelli) c286a22f7b63a8bd336d5d7606c339053ee0054b Add debug startup parameter -fastprune for more effective pruning tests (Jonas Schnelli) 5e112269c311a559bfded814d3c3c438349a1986 Avoid pruning below the blockfilterindex sync height (Jonas Schnelli) 00d57ff76854938ead800767fb673a8af46eac8e Avoid accessing nullpointer in BaseIndex::GetSummary() (Jonas Schnelli) 6abe9f5b11cd4a5ecb6caca8443fe2950a417842 Allow blockfilter in conjunction with prune (Jonas Schnelli) Pull request description: Maintaining the blockfilterindexes in prune mode is possible and may lead to efficient p2p based rescans of wallets (restore backups, import/sweep keys) beyond the prune height (rescans not part of that PR). This PR allows running the blockfilterindex(es) in conjunction with pruning. * Bitcoind/Qt will shutdown during startup when missing block data has been detected ([re]enable `-blockfilterindex` when we already have pruned) * manual block pruning is disabled during blockfilterindex sync * auto-pruning is delayed during blockfilterindex sync ToDos: * [x] Functional tests ACKs for top commit: fjahr: Code review ACK 84716b1 ryanofsky: Code review ACK 84716b134e9afca2fba7731de4af1f22fa1b1518. Only changes since last review were suggested new FindFilesToPrune argument and test. benthecarman: tACK 84716b134e9afca2fba7731de4af1f22fa1b1518 Tree-SHA512: 91d832c6c562c463f7ec7655c08956385413a99a896640b9737bda0183607fac530435d03d87c3c0e70c61ccdfe73fe8f3639bc7d26d33ca7e60925ebb97d77a
2021-02-17time: add runtime sanity checkCory Fields
std::chrono::system_clock.time_since_epoch and time_t(0) are not guaranteed to use the Unix epoch timestamp, but in practice they almost certainly will. Any differing behavior will be assumed to be an error, unless certain platforms prove to consistently deviate, at which point we'll cope with it by adding offsets. Do a quick runtime check to verify that time_t(0) == std::chrono::system_clock's epoch time == unix epoch. Co-authored-by: Anthony Towns <aj@erisian.com.au>
2021-02-16Add debug startup parameter -fastprune for more effective pruning testsJonas Schnelli
2021-02-15Merge #20965: net, rpc: return NET_UNROUTABLE as not_publicly_routable, ā†µMarcoFalke
automate helps 96635e61777add29b6a34d47767a63f43b2919af init: use GetNetworkNames() in -onlynet help (Jon Atack) 0dbde700a6e9894a8ead20f2eebd0ff6554ef2d9 rpc: use GetNetworkNames() in getnetworkinfo and getpeerinfo helps (Jon Atack) 1c3af37881adbbc37fb9924bcf69c403fcae1ae7 net: create GetNetworkNames() (Jon Atack) b45eae4d5332f1da71ba9ec983fe7818fa4d32e9 net: update NET_UNROUTABLE to not_publicly_routable in GetNetworkName() (Jon Atack) Pull request description: per the IRC discussion today at http://www.erisian.com.au/bitcoin-core-dev/log-2021-01-19.html#l-87 - return a more helpful string name for `Network::NET_UNROUTABLE`: "not_publicly_routable" instead of "unroutable" - update the RPC getpeerinfo "network" help, and automate it and the getnetworkinfo "network#name" and the -onlynet help doc generation ACKs for top commit: theStack: re-ACK 96635e61777add29b6a34d47767a63f43b2919af šŸŒ³ MarcoFalke: review ACK 96635e61777add29b6a34d47767a63f43b2919af šŸ— Tree-SHA512: 511a7d987126b48a7a090739aa7c4964b6186a3ff8f5f7eec9233dd816c6b7a6dc91b3ea6b824aa68f218a8a3ebdc6ffd214e9a88af38f2bf23f3257c4284c3a
2021-02-11[p2p] No delay in adding fixed seeds if -dnsseed=0 and peers.dat is empty. ā†µDhruv Mehta
Add -fixedseeds arg.
2021-02-11Allow blockfilter in conjunction with pruneJonas Schnelli
2021-02-05Merge #21077: doc: clarify -timeout and -peertimeout config optionsMarcoFalke
eecb7ab105a4a59d09cd55b124c5ad563846fe11 [doc] clarify -peertimeout and -timeout descriptions (gzhao408) Pull request description: The debug-only option `-peertimeout` is used to delay `InactivityCheck()`, whereas the `-timeout` option specifies socket timeouts (`nConnectTimeout`). The current descriptions are a bit misleading and hard to tell apart. I think it would save dev/review time to update them šŸ¤· ACKs for top commit: MarcoFalke: ACK eecb7ab105a4a59d09cd55b124c5ad563846fe11 nice doc fixup jnewbery: ACK eecb7ab105a4a59d09cd55b124c5ad563846fe11 Tree-SHA512: 71d2e6c31664b9f7f0b053ecf3be21c6c55472553fa7478d8526ba3be8d54979bceafca63d87b8b2488c11f409c332ac795da613ff8101546b18d9cd8bcceb50
2021-02-04[doc] clarify -peertimeout and -timeout descriptionsgzhao408
2021-02-03Merge #21060: doc: More precise -debug and -debugexclude docfanquake
572fd0f7382bd0e6c7acc27dc354fae8489ab0a0 doc: More precise -debug and -debugexclude doc (wodry) Pull request description: I wondered how one could enable debug logging with `-debug=<category>` for multiple categories. Found out solution is to specify that option multiple times for each wanted category. This PR documents this behavior and uses the same wording for the same behavior of `-debugexclude=<category>` to make that also clear and stringent. ACKs for top commit: laanwj: ACK 572fd0f7382bd0e6c7acc27dc354fae8489ab0a0 MarcoFalke: ACK 572fd0f7382bd0e6c7acc27dc354fae8489ab0a0 theStack: ACK 572fd0f7382bd0e6c7acc27dc354fae8489ab0a0 Tree-SHA512: 8d93db37602fd5ff4247e7c11478e55b99c0e3d47eaa2bb901937805d8f2a466b3a198b713b760981c5411576b74c52e2909c46c6d3f2e0e04215fd521b65cf7
2021-02-02Merge #19509: Per-Peer Message CaptureMarcoFalke
bff7c66e67aa2f18ef70139338643656a54444fe Add documentation to contrib folder (Troy Giorshev) 381f77be858d7417209b6de0b7cd23cb7eb99261 Add Message Capture Test (Troy Giorshev) e4f378a505922c0f544b4cfbfdb169e884e02be9 Add capture parser (Troy Giorshev) 4d1a582549bc982d55e24585b0ba06f92f21e9da Call CaptureMessage at appropriate locations (Troy Giorshev) f2a77ff97bec09dd5fcc043d8659d8ec5dfb87c2 Add CaptureMessage (Troy Giorshev) dbf779d5deb04f55c6e8493ce4e12ed4628638f3 Clean PushMessage and ProcessMessages (Troy Giorshev) Pull request description: This PR introduces per-peer message capture into Bitcoin Core. šŸ““ ## Purpose The purpose and scope of this feature is intentionally limited. It answers a question anyone new to Bitcoin's P2P protocol has had: "Can I see what messages my node is sending and receiving?". ## Functionality When a new debug-only command line argument `capturemessages` is set, any message that the node receives or sends is captured. The capture occurs in the MessageHandler thread. When receiving a message, it is captured as soon as the MessageHandler thread takes the message off of the vProcessMsg queue. When sending, the message is captured just before the message is pushed onto the vSendMsg queue. The message capture is as minimal as possible to reduce the performance impact on the node. Messages are captured to a new `message_capture` folder in the datadir. Each node has their own subfolder named with their IP address and port. Inside, received and sent messages are captured into two binary files, msgs_recv.dat and msgs_sent.dat, like so: ``` message_capture/203.0.113.7:56072/msgs_recv.dat message_capture/203.0.113.7:56072/msgs_sent.dat ``` Because the messages are raw binary dumps, included in this PR is a Python parsing tool to convert the binary files into human-readable JSON. This script has been placed on its own and out of the way in the new `contrib/message-capture` folder. Its usage is simple and easily discovered by the autogenerated `-h` option. ## Future Maintenance I sympathize greatly with anyone who says "the best code is no code". The future maintenance of this feature will be minimal. The logic to deserialize the payload of the p2p messages exists in our testing framework. As long as our testing framework works, so will this tool. Additionally, I hope that the simplicity of this tool will mean that it gets used frequently, so that problems will be discovered and solved when they are small. ## FAQ "Why not just use Wireshark" Yes, Wireshark has the ability to filter and decode Bitcoin messages. However, the purpose of the message capture added in this PR is to assist with debugging, primarily for new developers looking to improve their knowledge of the Bitcoin Protocol. This drives the design in a different direction than Wireshark, in two different ways. First, this tool must be convenient and simple to use. Using an external tool, like Wireshark, requires setup and interpretation of the results. To a new user who doesn't necessarily know what to expect, this is unnecessary difficulty. This tool, on the other hand, "just works". Turn on the command line flag, run your node, run the script, read the JSON. Second, because this tool is being used for debugging, we want it to be as close to the true behavior of the node as possible. A lot can happen in the SocketHandler thread that would be missed by Wireshark. Additionally, if we are to use Wireshark, we are at the mercy of whoever it maintaining the protocol in Wireshark, both as to it being accurate and recent. As can be seen by the **many** previous attempts to include Bitcoin in Wireshark (google "bitcoin dissector") this is easier said than done. Lastly, I truly believe that this tool will be used significantly more by being included in the codebase. It's just that much more discoverable. ACKs for top commit: MarcoFalke: re-ACK bff7c66e67aa2f18ef70139338643656a54444fe only some minor changes: šŸ‘š jnewbery: utACK bff7c66e67aa2f18ef70139338643656a54444fe theStack: re-ACK bff7c66e67aa2f18ef70139338643656a54444fe Tree-SHA512: e59e3160422269221f70f98720b47842775781c247c064071d546c24fa7a35a0e5534e8baa4b4591a750d7eb16de6b4ecf54cbee6d193b261f4f104e28c15f47
2021-02-02init: use GetNetworkNames() in -onlynet helpJon Atack
2021-02-01doc: More precise -debug and -debugexclude docwodry
I wondered how one could enable debug logging with `-debug=<category>` for multiple categories. Found out solution is to specify that option multiple times for each wanted category. This PR documents this behavior and uses the same wording for the same behavior of `-debugexclude=<category>` to make that also clear and stringent.
2021-02-01Merge #21016: refactor: remove boost::thread_group usageWladimir J. van der Laan
dc8be12510c2fd5a809d9a82d2c14b464b5e5a3f refactor: remove boost::thread_group usage (fanquake) Pull request description: Post #18710, there isn't much left using `boost::thread_group`, so should just be able to replace it with the standard library. This also removes the last use of `boost::thread_interrupted`. After this change, last piece of Boost Thread we'd be using is `boost::shared_mutex`. See the commentary [here](https://github.com/bitcoin/bitcoin/issues/16684#issuecomment-726214696) as to why it may be non-trivial to swap that for `std::shared_mutex` in the near future. Closes #17307 ACKs for top commit: laanwj: Code review re-ACK dc8be12510c2fd5a809d9a82d2c14b464b5e5a3f MarcoFalke: review ACK dc8be12510c2fd5a809d9a82d2c14b464b5e5a3f šŸ” jonatack: Non-expert code review ACK dc8be12510c2fd5a809d9a82d2c14b464b5e5a3f, also checked range-diff since last review and that local debug build is clean with gcc 10.2.1-6 on Debian Tree-SHA512: 5510e2d760cce824234207dc86b1551ca8f21cbf3a2ce753c0254a0d03ffd83c94e449aec202fb7bd76e6fc64df783a6b70a736b0add9ece3734bb9c8ce8fc2f
2021-02-01Merge #20749: [Bundle 1/n] Prune g_chainman usage related to ::LookupBlockIndexWladimir J. van der Laan
67c9a83df19c6e2a2edb32336879204e7770b4a7 style-only: Remove redundant sentence in ActivateBestChain comment (Carl Dong) b8e95658d5909f93dfc7d1e6532661db8919e5b7 style-only: Make TestBlockValidity signature readable (Carl Dong) 0cdad753903640ff4240b715dec9d62f68e51407 validation: Use accessible chainstate in ChainstateManager::ProcessNewBlock (Carl Dong) ea4fed90219be17160136313c68c06d84176af08 validation: Use existing chainstate in ChainstateManager::ProcessNewBlockHeaders (Carl Dong) e0dc3057277c9576ddbfb8541599db0149e08bb6 validation: Move LoadExternalBlockFile to CChainState (Carl Dong) 5f8cd7b3a527999512161956db4d718688cb956f validation: Remove global ::ActivateBestChain (Carl Dong) 2a696472a1423e877bfa83f016f66c7e45be7369 validation: Pass in chainstate to ::NotifyHeaderTip (Carl Dong) 9c300cc8b3ce3d82874982fbf3087e48a6ac0ef2 validation: Pass in chainstate to TestBlockValidity (Carl Dong) 0e17c833cda67cdba5338bd7409061772b6d5edb validation: Make CChainState.m_blockman public (Carl Dong) d363d06bf7d6c3736140672ba8a7f82f4d6fb6ab validation: Pass in blockman to ContextualCheckBlockHeader (Carl Dong) f11d11600ddb0ddff6538250ae2a35df6112c3db validation: Move GetLastCheckpoint to BlockManager (Carl Dong) e4b95eefbc700ebc915bec312f77477ce3e87a7e validation: Move GetSpendHeight to BlockManager (Carl Dong) b026e318c39f59a06e29f1b25c7f577e01b25ccb validation: Move FindForkInGlobalIndex to BlockManager (Carl Dong) 3664a150ac7547c9336b571557af223d9e31aac9 validation: Remove global LookupBlockIndex (Carl Dong) eae54e6e60d7ed05b29d8345c0bb055397149ce8 scripted-diff: Use BlockManager::LookupBlockIndex (Carl Dong) 15d20f40e1321b24963b40c12958c7d30ad112ec validation: Move LookupBlockIndex to BlockManager (Carl Dong) f92dc6557a153b390a1ae1d0808ff7ed5d02c66e validation: Guard the active_chainstate with cs_main (Carl Dong) Pull request description: Overall PR: #20158 (tree-wide: De-globalize ChainstateManager) Note to reviewers: 1. This bundle may _apparently_ introduce usage of `g_chainman` or `::Chain(state|)Active()` globals, but these are resolved later on in the overall PR. [Commits of overall PR](https://github.com/bitcoin/bitcoin/pull/20158/commits) 2. There may be seemingly obvious local references to `ChainstateManager` or other validation objects which are not being used in callers of the current function in question, this is done intentionally to **_keep each commit centered around one function/method_** to ease review and to make the overall change systematic. We don't assume anything about our callers. Rest assured that once we are considering that particular caller in later commits, we will use the obvious local references. [Commits of overall PR](https://github.com/bitcoin/bitcoin/pull/20158/commits) 3. When changing a function/method that has many callers (e.g. `LookupBlockIndex` with 55 callers), it is sometimes easier (and less error-prone) to use a scripted-diff. When doing so, there will be 3 commits in sequence so that every commit compiles like so: 1. Add `new_function`, make `old_function` a wrapper of `new_function`, divert all calls to `old_function` to `new_function` **in the local module only** 2. Scripted-diff to divert all calls to `old_function` to `new_function` **in the rest of the codebase** 3. Remove `old_function` ACKs for top commit: jnewbery: utACK 67c9a83df19c6e2a2edb32336879204e7770b4a7 laanwj: re-ACK 67c9a83df19c6e2a2edb32336879204e7770b4a7 ryanofsky: Code review ACK 67c9a83df19c6e2a2edb32336879204e7770b4a7. Changes since last review: Tree-SHA512: 8744aba2dd57a40cd2fedca809b0fe24d771bc60da1bffde89601999384aa0df428057a86644a3f72fbeedbc8b04db6c4fd264ea0db2e73c279e5acc6d056cbf
2021-01-29refactor: remove boost::thread_group usagefanquake
2021-01-28validation: Move LoadExternalBlockFile to CChainStateCarl Dong
[META] This commit should be followed up by removing the comments and assertions meant only to show that the change is correct. LoadExternalBlockFile mainly acts on CChainState.
2021-01-28scripted-diff: Use BlockManager::LookupBlockIndexCarl Dong
[META] In a previous commit, we moved ::LookupBlockIndex to become a member function of BlockManager. This commit is split out from that one since it can be expressed nicely as a scripted-diff. -BEGIN VERIFY SCRIPT- find_regex='LookupBlockIndex' \ && git grep -l -E "$find_regex" -- src \ | grep -v '^src/validation\.\(cpp\|h\)$' \ | xargs sed -i -E "s@${find_regex}@g_chainman.m_blockman.LookupBlockIndex@g" -END VERIFY SCRIPT-
2021-01-25doc: update -onlynet help in src/init.cppJon Atack
2021-01-25Merge #18710: Add local thread pool to CCheckQueueWladimir J. van der Laan
bb6fcc75d1ec94b733d1477c816351c50be5faf9 refactor: Drop boost::thread stuff in CCheckQueue (Hennadii Stepanov) 6784ac471bb32b6bb8e2de60986f123eb4990706 bench: Use CCheckQueue local thread pool (Hennadii Stepanov) dba30695fc42f45828db008e7e5b81cb2b5d8551 test: Use CCheckQueue local thread pool (Hennadii Stepanov) 01511776acb0c7ec216dc9c8112531067763f1cb Add local thread pool to CCheckQueue (Hennadii Stepanov) 0ef938685b5c079a6f5a98daf0e3865d718d817b refactor: Use member initializers in CCheckQueue (Hennadii Stepanov) Pull request description: This PR: - gets rid of `boost::thread_group` in the `CCheckQueue` class - allows thread safety annotation usage in the `CCheckQueue` class - is alternative to #14464 (https://github.com/bitcoin/bitcoin/pull/18710#issuecomment-616618525, https://github.com/bitcoin/bitcoin/pull/18710#issuecomment-617291612) Also, with this PR (I hope) it could be easier to resurrect a bunch of brilliant ideas from #9938. Related: #17307 ACKs for top commit: laanwj: Code review ACK bb6fcc75d1ec94b733d1477c816351c50be5faf9 LarryRuane: ACK bb6fcc75d1ec94b733d1477c816351c50be5faf9 jonatack: Code review ACK bb6fcc75d1ec94b733d1477c816351c50be5faf9 and verified rebase to master builds cleanly with unit/functional tests green Tree-SHA512: fddeb720d5a391b48bb4c6fa58ed34ccc3f57862fdb8e641745c021841c8340e35c5126338271446cbd98f40bd5484f27926aa6c3e76fa478ba1efafe72e73c1
2021-01-23Call CaptureMessage at appropriate locationsTroy Giorshev
These calls are toggled by a debug-only "capturemessages" flag. Default disabled.
2021-01-23Add CaptureMessageTroy Giorshev
This commit adds the CaptureMessage function. This will later be called when any message is sent or received. The capture directory is fixed, in a new folder "message_capture" in the datadir. Peers will then have their own subfolders, named with their IP address and port, replacing colons with underscores to keep compatibility with Windows. Inside, received and sent messages will be captured into two binary files, msgs_recv.dat and msgs_sent.dat. e.g. message_capture/203.0.113.7_56072/msgs_recv.dat message_capture/203.0.113.7_56072/msgs_sent.dat The format has been designed as to result in a minimal performance impact. A parsing script is added in a later commit.
2021-01-15log: Prefix log messages with function name if -logsourcelocations is setpracticalswift
2021-01-09net_processing: split PeerManager into interface and implementation classesAnthony Towns
2021-01-07net: Add -natpmp command line optionHennadii Stepanov
2021-01-07net: Add flags for port mapping protocolsHennadii Stepanov
2021-01-07refactor: Move port mapping code to its own moduleHennadii Stepanov
This commit does not change behavior.
2021-01-02refactor: Remove nMyStartingHeight from CNode/ConnmanMarcoFalke
2020-12-22[net processing] Remove dropmessagestestJohn Newbery
-dropmessagestest is a command line option that causes 1 in n received messages to be dropped. The Bitcoin P2P protocol is stateful and in general cannot handle messages being dropped. Dropped version/verack/ping/pong messages will cause the connection to time out and be torn down. Other dropped messages may also cause the peer to believe that the peer has stalled and tear down the connection. It seems difficult to uncover any actual issues with -dropmessagestest, and any coverage that could be generated would probably be easier to trigger with fuzz testing.
2020-12-17Merge #20668: doc: warn that incoming conns are unlikely when not using ā†µWladimir J. van der Laan
default ports 010eed3ce03cf4fc622a48f40fc4d589383f7a44 doc: warn that incoming conns are unlikely when not using default ports (Adam Jonas) Pull request description: Closes #5150. This was mostly copied from #5285 by sulks, who has since quit GitHub. The issue has remained open for 6 years, but the extra explanation still seems useful. ACKs for top commit: laanwj: re-ACK 010eed3ce03cf4fc622a48f40fc4d589383f7a44 Tree-SHA512: d240fb06bba41ad8898ced59356c10adefc09f3abb33e277f8e2c5980b40678f2d237f286b476451bb29d2b94032a7dee2ada3b2efe004ed1c2509e70b48e40f
2020-12-16Merge #20605: init: Signal-safe instant shutdownWladimir J. van der Laan
cd03513dc2fcccaa142e9632a28b38efd0056436 init: Signal-safe instant shutdown (Wladimir J. van der Laan) Pull request description: Replace the 200ms polling loop with a faster and more efficient waiting operation. This should speed up short RPC tests. This change has been tried a few times before, but abandoned every time because solutions used a condition variable which is not safe for use in signals, as they need to be reentrant. On UNIX-ish OSes, use a safe way: a pipe. When shutdown is requested write a dummy byte to the pipe. Waiting for shutdown is a matter of a blocking read from the pipe. On Windows, there are no signals so using a condition variable is safe. This only affects bitcoind. The GUI is unaffected by this change, and keeps polling as before in `BitcoinGUI::detectShutdown()`. It might be possible to listen to a pipe there, too, but I'm not sure, and it's complicated by the GUI-node abstraction. ACKs for top commit: jonatack: ACK cd03513dc2fcccaa142e9632a28b38efd0056436 tested on Debian 5.9.11-1 (2020-11-27) x86_64 GNU/Linux Tree-SHA512: ed2f532f69fec4855c17bf7b8f3d0eb96e78ee2a3c13d374dd2c6add06e3ad6a190da8ed8f9d7a76532cf998222d67f57e35b206aec29675e96437448ae7e13c
2020-12-16doc: warn that incoming conns are unlikely when not using default portsAdam Jonas
2020-12-15init: Signal-safe instant shutdownWladimir J. van der Laan
Replace the 200ms polling loop with a faster and more efficient waiting operation. This was tried a few times before, but given up every time because solutions use a condition variable which is not safe for use in signals as they need to be reentrant. On UNIX-ish OSes, use a safe way: a pipe. When shutdown is requested write a dummy byte to the pipe. Waiting for shutdown is a matter of a blocking read from the pipe. On Windows, there are no signals so using a condition variable is safe.
2020-12-13init: set nMaxOutboundLimit connection option directlyfanquake
DEFAULT_MAX_UPLOAD_TARGET is a compile time constant.
2020-12-13net: remove nMaxOutboundTimeframe from connection optionsfanquake
It's not actually possible to change this value, so remove the indirection of it being a conn option. DEFAULT_MAX_UPLOAD_TIMEFRAME is a compile time constant.
2020-12-10Simplify and clarify extra outbound peer countingSuhas Daftuar
2020-12-09Remove g_relay_txesJohn Newbery
Also remove vestigial commend in init.cpp
2020-12-09[net processing] Add m_ignores_incoming_txs to PeerManager and use internallyJohn Newbery
2020-12-09[init] Use MakeUnique<> to construct peermanJohn Newbery
2020-12-07Merge #18766: Disable fee estimation in blocksonly mode (by removing the fee ā†µMarcoFalke
estimates global) 4e28753f60613ecd35cdef87bef5f99c302c3fbd feestimator: encapsulate estimation file logic (Antoine Poinsot) e8ea6ad9c16997bdc7e22a20eca16e234290b7ff init: don't create a CBlockPolicyEstimator if we don't relay transactions (Antoine Poinsot) 86ff2cf202bfb9d9b50800b8ffe3fead3f77f5fa Remove the remaining fee estimation globals (Antoine Poinsot) 03bfeee957ab7e3b6aece82b9561774648094f54 interface: remove unused estimateSmartFee method from node (Antoine Poinsot) Pull request description: If the `blocksonly` mode is turned on after running with transaction relay enabled for a while, the fee estimation will serve outdated data to both the internal wallet and to external applications that might be feerate-sensitive and make use of `estimatesmartfee` (for example a Lightning Network node). This has already caused issues (for example https://github.com/bitcoin/bitcoin/issues/16840 (C-lightning), or https://github.com/lightningnetwork/lnd/issues/2562 (LND)) and it seems prudent to fail rather than to give inaccurate values. This fixes #16840, and closes #16890 which tried to fix the symptoms (RPC) but not the cause as mentioned by sdaftuar : > If this is a substantial problem, then I would think we should take action to protect our own wallet users as well (rather than hide the results of what our fee estimation would do!). ACKs for top commit: MarcoFalke: re-ACK 4e28753f60 šŸ‘‹ jnewbery: utACK 4e28753f60613ecd35cdef87bef5f99c302c3fbd Tree-SHA512: c869cf03b86d8194002970bbc84662dae76874967949b9be0d9a4511a1eabcb1627c38aca3154da9dcece1a4c49ec02bd4f9fcca2ec310986e07904559e63ba8
2020-12-06Don't make "in" parameters look like "out"/"in-out" parameters: pass by ref ā†µpracticalswift
to const instead of ref to non-const
2020-12-03feestimator: encapsulate estimation file logicAntoine Poinsot
This moves the fee_estimates file management to the CBlockPolicyEstimator Flush() method. Co-authored-by: John Newbery <john@johnnewbery.com> Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-12-03init: don't create a CBlockPolicyEstimator if we don't relay transactionsAntoine Poinsot
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-12-03Remove the remaining fee estimation globalsAntoine Poinsot
This moves the CBlockPolicyEstimator to the NodeContext, which get rids of two globals and allows us to conditionally create the CBlockPolicyEstimator (and to remove a circular dep). Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-12-01Merge #20222: refactor: CTxMempool constructor clean upMarcoFalke
f15e780b9e57554c723bc02aa41150ecf3e3a8c9 refactor: Clean up CTxMemPool initializer list (Elle Mouton) e3310692d0e9720e960b9785274ce1f0b58b4cd7 refactor: Make CTxMemPool::m_check_ratio a const and a constructor argument (Elle Mouton) 9d4b4b2c2c49774523de740d6492ee5b1ee15e74 refactor: Avoid double to int cast for nCheckFrequency (Elle Mouton) Pull request description: This PR cleans up the CTxMemPool interface by including the ratio used to determine when a mempool sanity check should run in the constructor of CTxMempool instead of using nCheckFrequency which required a cast from a double to a uint32_t. Since nCheckFrequency (now called m_check_ratio) is set in the constructor and only every read from there after, it can be turned into a const and no longer needs to be guarded by the 'cs' lock. Since nCheckFrequency/m_check_ratio no longer needs to lock the 'cs' mutux, mutex lock line in the "CTxMempool::check" function can be moved below where the m_check_ratio variable is checked. Since the variable is 0 by default (meaning that "CTxMempool::check" will most likely not run its logic) this saves us from unnecessarily grabbing the lock. ACKs for top commit: jnewbery: utACK f15e780b9e57554c723bc02aa41150ecf3e3a8c9 MarcoFalke: ACK f15e780b9e57554c723bc02aa41150ecf3e3a8c9 šŸ‘˜ glozow: utACK https://github.com/bitcoin/bitcoin/pull/20222/commits/f15e780b9e57554c723bc02aa41150ecf3e3a8c9 theStack: Code Review ACK f15e780b9e57554c723bc02aa41150ecf3e3a8c9 Tree-SHA512: d83f3b5311ca128847b621e5e999c7e1bf0f4e6261d4cc090fb13e229a0f7eecd66ad997f654f50a838baf708d1515740aa3bffc244909a001d01fd5ae398b68
2020-11-26scripted-diff: Use [[nodiscard]] (C++17) instead of NODISCARDpracticalswift
-BEGIN VERIFY SCRIPT- sed -i "s/NODISCARD/[[nodiscard]]/g" $(git grep -l "NODISCARD" ":(exclude)src/bench/nanobench.h" ":(exclude)src/attributes.h") -END VERIFY SCRIPT-
2020-11-19Merge #20024: init: Fix incorrect warning "Reducing -maxconnections from N ā†µWladimir J. van der Laan
to N-1, because of system limitations" ea93bbeb26948c0ddba39b589bd166eaecf446c8 init: Fix incorrect warning "Reducing -maxconnections from N to N-1, because of system limitations" (practicalswift) Pull request description: Fix incorrect warning `Reducing -maxconnections from N to N-1, because of system limitations`. Before this patch (only the first warning is correct): ``` $ src/bitcoind -maxconnections=10000000 | grep Warning 2020-09-26T01:23:45Z Warning: Reducing -maxconnections from 10000000 to 1048417, because of system limitations. $ src/bitcoind -maxconnections=1000000 | grep Warning 2020-09-26T01:23:45Z Warning: Reducing -maxconnections from 1000000 to 999999, because of system limitations. $Ā src/bitcoind -maxconnections=100000 | grep Warning 2020-09-26T01:23:45Z Warning: Reducing -maxconnections from 100000 to 99999, because of system limitations. $ src/bitcoind -maxconnections=10000 | grep Warning 2020-09-26T01:23:45Z Warning: Reducing -maxconnections from 10000 to 9999, because of system limitations. $ src/bitcoind -maxconnections=1000 | grep Warning 2020-09-26T01:23:45Z Warning: Reducing -maxconnections from 1000 to 999, because of system limitations. $ src/bitcoind -maxconnections=100 | grep Warning [no warning] ``` After this patch (no incorrect warnings): ``` $ src/bitcoind -maxconnections=10000000 | grep Warning 2020-09-26T01:23:45Z Warning: Reducing -maxconnections from 10000000 to 1048417, because of system limitations. $ src/bitcoind -maxconnections=1000000 | grep Warning [no warning] $Ā src/bitcoind -maxconnections=100000 | grep Warning [no warning] $ src/bitcoind -maxconnections=10000 | grep Warning [no warning] $ src/bitcoind -maxconnections=1000 | grep Warning [no warning] $ src/bitcoind -maxconnections=100 | grep Warning [no warning] ``` ACKs for top commit: n-thumann: tACK https://github.com/bitcoin/bitcoin/pull/20024/commits/ea93bbeb26948c0ddba39b589bd166eaecf446c8, Ran on other systems running Debian 10.5 (4.19.0-8-amd64) and Debian bullseye/sid (5.3.0-1-amd64) and was able to reproduce the issue exactly as you described above on both of them. After applying your patch the issue is fixed :v: laanwj: Code review ACK ea93bbeb26948c0ddba39b589bd166eaecf446c8 theStack: tACK ea93bbeb26948c0ddba39b589bd166eaecf446c8 Tree-SHA512: 9b0939a1a51fdf991d11024a5d20b4f39cab1a80320b799a1d24d0250aa059666bcb1ae6dd79c941c2f2686f07f59fc0f6618b5746aa8ca6011fdd202828a930
2020-11-12Remove references to CreateWalletFromFilefanquake
CWallet::CreateWalletFromFile() was removed in 8b5e7297c02f3100a9cb27bfe206e3fc617ec173 but these references remain.
2020-10-23refactor: Make CTxMemPool::m_check_ratio a const and a constructor argumentElle Mouton
Since m_check_ratio is only set once and since the CTxMemPool object is no longer a global variable, m_check_ratio can be passed into the constructor of CTxMemPool. Since it is only read from after initialization, m_check_ratio can also be made a const and hence no longer needs to be guarded by the cs mutex.
2020-10-23refactor: Avoid double to int cast for nCheckFrequencyElle Mouton
Use a ratio instead of a frequency that requires a double to int cast for determining how often a mempool sanity check should run.