aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2024-03-29Merge bitcoin/bitcoin#29724: 29242 Diagram check followupsAva Chow
ee1b9b231a0a7e89b77cbf8ea54e0534f0970dd0 CalculateFeerateDiagramsForRBF: update misleading description of old diagram contents (Greg Sanders) a9d42b9aa579f54922ffd17fdeb61e704539b92c CompareFeerateDiagram: short-circuit comparison when detected as incomparable (Greg Sanders) cebcced65e8fdbd54893d4852d5ed6b85a8b0c45 remove erroneous CompareFeerateDiagram comment about slope (Greg Sanders) a0376e106182075634e50c14da00e84b4069b985 unit test: clarify unstated assumption for calc_feerate_diagram_rbf chunking (Greg Sanders) 890cb015f3b99c4f2f57a1bbc69e5cf2045c2739 s/effected/affected/ (Greg Sanders) d9391ec0952920bdbb10d3f6e9e706e85f717ec0 CalculateFeerateDiagramsForRBF: remove size tie-breaking from chunking conflicts (Greg Sanders) b684d82d7e093889a8dc7678c6d6605ca4cd9fa4 fuzz: Add more invariant checks for package_rbf (Greg Sanders) 2a3ada8b2181b45165608947c7c42b341d0a54dd fuzz: finer grained ImprovesFeerateDiagram check on error result (Greg Sanders) c377ae9ba08150c467e8b6cfaac7865f4d31457c unit test: improve ImprovesFeerateDiagram coverage with one less vb case (Greg Sanders) d2bf923eb19f6330bad673b71faadec582780aa1 unit test: make calc_feerate_diagram_rbf less brittle (Greg Sanders) defe023f6ec49dd64c6e03880cee0e9299b45762 fuzz: add PrioritiseTransaction coverage in diagram checks (Greg Sanders) 216d5ff1627be6562312b5afb477078ed8495999 unit test: add coverage showing priority affects diagram check results (Greg Sanders) a80d80936a8de487569d00755d0fbcd058a94823 unit test: add CheckConflictTopology case for not the only child (Greg Sanders) 69bd18ca80007584be4089b3f42650d351854bb3 unit test: check tx4 conflict error message (Greg Sanders) c0c37f07eb0fb4027faa04e5457f8421264e8ad5 unit test: have CompareFeerateDiagram tested with diagrams both ways (Greg Sanders) b62e2c0fa5f6010ff1fc60c59418d0796b83c5de ImprovesFeerateDiagram: Spelling fix and removal of unused diagram vectors (Greg Sanders) bb424029459af691c4d07988f3d76afeaee21644 doc: fix comment about non-existing CompareFeeFrac (Greg Sanders) Pull request description: Follow-ups to https://github.com/bitcoin/bitcoin/pull/29242 ACKs for top commit: glozow: ACK ee1b9b231a0a7e89b77cbf8ea54e0534f0970dd0, reviewed the changes and package_rbf fuzzer seems to run fine murchandamus: crACK ee1b9b231a0a7e89b77cbf8ea54e0534f0970dd0 ismaelsadeeq: Code review ACK ee1b9b231a0a7e89b77cbf8ea54e0534f0970dd0 willcl-ark: ACK ee1b9b231a0a7e89b77cbf8ea54e0534f0970dd0 Tree-SHA512: 8399fe12064fb49b0e4c73258968b57be1d9c2e35701b2d3b0bb67e2e4052e44216358238f92508e4697d0fb6176518d5b885474054d3deda242f669e99262a7
2024-03-29Merge bitcoin/bitcoin#29130: wallet: Add `createwalletdescriptor` and ↵Ryan Ofsky
`gethdkeys` RPCs for adding new automatically generated descriptors 746b6d88395607abbd3c13bbdcdd4ca83e9bc9e4 test: Add test for createwalletdescriptor (Ava Chow) 2402b6306215a9ee8d5f4068ea81f4e7f324adeb wallet: Test upgrade of pre-taproot wallet to have tr() descriptors (Ava Chow) 460ae1bf67c0051033c1802d44787d173abb9248 wallet, rpc: Add createwalletdescriptor RPC (Ava Chow) 8e1a475062e62321e58a0624385cc3fa0885aa12 wallet: Be able to retrieve single key from descriptors (Ava Chow) 85b1fb19dd3a3f3c68da1c5e60a6eb911e1119a6 wallet: Add GetActiveHDPubKeys to retrieve xpubs from active descriptors (Ava Chow) 73926f2d31b61ff78d5f0c8f9b5e3130fb1f9620 wallet, descspkm: Refactor wallet descriptor generation to standalone func (Andrew Chow) 54e74f46ea10e479be682750c1279165f29bb2f4 wallet: Refactor function for single DescSPKM setup (Andrew Chow) 3b09d0eb7f2c1d6ebdab73d18db28e5bf7d74f18 tests: Test for gethdkeys (Ava Chow) 5febe28c9e131fb93fac9c35f80c42759654f150 wallet, rpc: Add gethdkeys RPC (Ava Chow) 66632e5c24c1b59afef1e89b562fbd0117ab6ef5 wallet: Add IsActiveScriptPubKeyMan (Ava Chow) fa6a259985b61235ebc21eae2a76014cc9437d5f desc spkm: Add functions to retrieve specific private keys (Ava Chow) fe67841464cc0f970a1c233caba92cb78e9c78dc descriptor: Be able to get the pubkeys involved in a descriptor (Ava Chow) ef6745879d87cdb6f1061337867a689167e965a1 key: Add constructor for CExtKey that takes CExtPubKey and CKey (Ava Chow) Pull request description: This PR adds a `createwalletdescriptor` RPC which allows users to add new automatically generated descriptors to their wallet, e.g. to upgrade a 0.21.x wallet to contain a taproot descriptor. This RPC takes 3 arguments: the output type to create a descriptor for, whether the descriptor will be internal or external, and the HD key to use if the user wishes to use a specific key. The HD key is an optional parameter. If it is not specified, the wallet will use the key shared by the active descriptors, if they are all single key. For most users in the expected upgrade scenario, this should be sufficient. In more advanced cases, the user must specify the HD key to use. Currently, specified HD keys must already exist in the wallet. To make it easier for the user to know, `gethdkeys` is also added to list out the HD keys in use by all of the descriptors in the wallet. This will include all HD keys, whether we have the private key, for it, which descriptors use it and their activeness, and optionally the extended private key. In this way, users with more complex wallets will be still be able to get HD keys from their wallet for use in other scenarios, and if they want to use `createwalletdescriptor`, they can easily get the keys that they can specify to it. See also https://github.com/bitcoin/bitcoin/pull/26728#issuecomment-1866961865 ACKs for top commit: Sjors: re-utACK 746b6d88395607abbd3c13bbdcdd4ca83e9bc9e4 furszy: ACK 746b6d8 ryanofsky: Code review ACK 746b6d88395607abbd3c13bbdcdd4ca83e9bc9e4, and this looks ready to merge. There were various suggested changes since last review where main change seems to be switching `gethdkeys` output to use normalized descriptors (removing hardened path components). Tree-SHA512: f2849101e6fbf1f59cb031eaaaee97af5b1ae92aaab54c5716940d210f08ab4fc952df2725b636596cd5747b8f5beb1a7a533425bc10d09da02659473516fbda
2024-03-28Merge bitcoin/bitcoin#29402: mempool: Log added for dumping mempool ↵glozow
transactions to disk 4d5b55735bcf82847d748d24da5dbdbd1de8ef41 log: renamed disk to file so wording was more accurate (kevkevin) b9f04be870c948f071216fba8402a2c5395a336b mempool: Log added for dumping mempool transactions to disk (kevkevin) Pull request description: Sometimes when shutting off bitcoind it can take a while to dump the mempool transaction onto the disk so this change adds additional logging to the `DumpMempool` method in `kernel/mempool_persist.cpp` Motivated by https://github.com/bitcoin/bitcoin/pull/29227 this change - adds a single new line for the amount of transactions being dumped and the amount of memory being dumped to file This is in response to https://github.com/bitcoin/bitcoin/pull/29227#issuecomment-1893375082 The logs will now look like this ``` 2024-02-09T23:41:52Z DumpAnchors: Flush 2 outbound block-relay-only peer addresses to anchors.dat completed (0.02s) 2024-02-09T23:41:52Z scheduler thread exit 2024-02-09T23:41:52Z Writing 29 mempool transactions to file... 2024-02-09T23:41:52Z Writing 0 unbroadcast transactions to file. 2024-02-09T23:41:52Z Dumped mempool: 0.000s to copy, 0.022s to dump, 0.015 MB dumped to file 2024-02-09T23:41:52Z Flushed fee estimates to fee_estimates.dat. 2024-02-09T23:41:53Z Shutdown: done ``` ACKs for top commit: maflcko: cr-ACK 4d5b55735bcf82847d748d24da5dbdbd1de8ef41 glozow: reACK 4d5b557 Tree-SHA512: 049191e140d00c1ea57debe0138f1c9eb0f9bb0ef8138e2568e6d89e64f45a5d5853ce3b9cc0b28566aab97555b47ddfb0f9199fc8cea6b81e53f50592d5ae6a
2024-03-27Merge bitcoin/bitcoin#27307: wallet: track mempool conflicts with wallet ↵Ryan Ofsky
transactions 5952292133d6cc889f51ae771f2e0557311e1efe wallet, rpc: show mempool conflicts in `gettransaction` result (ishaanam) 54e07ee22ff16fc68583ade0d2b8ffffc81d444a wallet: track mempool conflicts (ishaanam) d64922b5903e5ffc8d2ce0e6761f99f173b60800 wallet refactor: use CWalletTx member functions to determine tx state (ishaanam) ffe5ff1fb622a8da11b66289e1b778e45e449811 scripted-diff: wallet: s/TxStateConflicted/TxStateBlockConflicted (ishaanam) 180973a94180f9849bf7cb0dab7c9177a942efb8 test: Add tests for wallet mempool conflicts (ishaanam) Pull request description: The `mempool_conflicts` variable is added to `CWalletTx`, it is a set of txids of txs in the mempool conflicting with the wallet tx or a wallet tx's parent. This PR only changes how mempool-conflicted txs are dealt with in memory. `IsSpent` now returns false for an output being spent by a mempool conflicted transaction where it previously returned true. A txid is added to `mempool_conflicts` during `transactionAddedToMempool`. A txid is removed from `mempool_conflicts` during `transactionRemovedFromMempool`. This PR also adds a `mempoolconflicts` field to the `gettransaction` wallet RPC result. Builds on #27145 Second attempt at #18600 ACKs for top commit: achow101: ACK 5952292133d6cc889f51ae771f2e0557311e1efe ryanofsky: Code review ACK 5952292133d6cc889f51ae771f2e0557311e1efe. Just small suggested changes since last review furszy: ACK 59522921 Tree-SHA512: 615779606723dbb6c2e302681d8e58ae2052ffee52d721ee0389746ddbbcf4b4c4afacf01ddf42b6405bc6f883520524186a955bf6b628fe9b3ae54cffc56a29
2024-03-27log: renamed disk to file so wording was more accuratekevkevin
2024-03-27mempool: Log added for dumping mempool transactions to diskkevkevin
2024-03-26CalculateFeerateDiagramsForRBF: update misleading description of old diagram ↵Greg Sanders
contents
2024-03-26CompareFeerateDiagram: short-circuit comparison when detected as incomparableGreg Sanders
2024-03-26remove erroneous CompareFeerateDiagram comment about slopeGreg Sanders
2024-03-26unit test: clarify unstated assumption for calc_feerate_diagram_rbf chunkingGreg Sanders
2024-03-26s/effected/affected/Greg Sanders
2024-03-26CalculateFeerateDiagramsForRBF: remove size tie-breaking from chunking conflictsGreg Sanders
2024-03-26fuzz: Add more invariant checks for package_rbfGreg Sanders
2024-03-26fuzz: finer grained ImprovesFeerateDiagram check on error resultGreg Sanders
2024-03-26unit test: improve ImprovesFeerateDiagram coverage with one less vb caseGreg Sanders
2024-03-26unit test: make calc_feerate_diagram_rbf less brittleGreg Sanders
2024-03-26fuzz: add PrioritiseTransaction coverage in diagram checksGreg Sanders
2024-03-26unit test: add coverage showing priority affects diagram check resultsGreg Sanders
2024-03-26unit test: add CheckConflictTopology case for not the only childGreg Sanders
2024-03-26unit test: check tx4 conflict error messageGreg Sanders
2024-03-26unit test: have CompareFeerateDiagram tested with diagrams both waysGreg Sanders
2024-03-26ImprovesFeerateDiagram: Spelling fix and removal of unused diagram vectorsGreg Sanders
2024-03-26doc: fix comment about non-existing CompareFeeFracGreg Sanders
2024-03-26Merge bitcoin/bitcoin#29722: 28950 followupsglozow
7b29119d79efbc8c4148f350cc86531fde8b7251 use const ref for client_maxfeerate (Greg Sanders) f10fd07320da302e8d038213c85e2b16e77d5dc2 scripted-diff: Rename max_sane_feerate to client_maxfeerate (Greg Sanders) Pull request description: Follow-ups to https://github.com/bitcoin/bitcoin/pull/28950 ACKs for top commit: glozow: utACK 7b29119d79efbc8c4148f350cc86531fde8b7251 stickies-v: ACK 7b29119d79efbc8c4148f350cc86531fde8b7251 Tree-SHA512: b9e13509c6e9d7c08aa9d4e759f9707004c1c7b8f3e521fe2ec0037160b87c7fb02528966b9f26eaca6291621df9300e84b5aec66dbc2e97d13bf2f3cd7f979c
2024-03-26Merge bitcoin/bitcoin#29242: Mempool util: Add RBF diagram checks for single ↵glozow
chunks against clusters of size 2 72959867784098137a50c34f86deca8235eef4f8 Unit tests for CalculateFeerateDiagramsForRBF (Greg Sanders) b767e6bd47cb0fb8f7aea3fb10c597e59a35bf74 test: unit test for ImprovesFeerateDiagram (Greg Sanders) 7e89b659e1ddd0c04fa2bddba9706b5d1a1daec3 Add fuzz test for FeeFrac (Greg Sanders) 4d6528a3d6bf3821c216c68f99170e2faab5d63c fuzz: fuzz diagram creation and comparison (Greg Sanders) e9c5aeb11d641b8cae373452339760809625021d test: Add tests for CompareFeerateDiagram and CheckConflictTopology (Greg Sanders) 588a98dccc5dbb6e331f28d83a4a10a13d70eb31 fuzz: Add fuzz target for ImprovesFeerateDiagram (Greg Sanders) 2079b80854e2595f6f696e7c13a56c7f2a7da9f4 Implement ImprovesFeerateDiagram (Greg Sanders) 66d966dcfaad3638f84654e710f403cb0a0a2ac7 Add FeeFrac unit tests (Greg Sanders) ce8e22542ed0b4fa5794d3203207146418d59473 Add FeeFrac utils (Greg Sanders) Pull request description: This is a smaller piece of https://github.com/bitcoin/bitcoin/pull/28984 broken off for easier review. Up to date explanation of diagram checks are here: https://delvingbitcoin.org/t/mempool-incentive-compatibility/553 This infrastructure has two near term applications prior to cluster mempool: 1) Limited Package RBF(https://github.com/bitcoin/bitcoin/pull/28984): We want to allow package RBF only when we know it improves the mempool. This narrowly scoped functionality allows use with v3-like topologies, and will be expanded at some point post-cluster mempool when diagram checks can be done efficiently against bounded cluster sizes. 2) Replacement for single tx RBF(in a cluster size of up to two) against conflicts of up to cluster size two. `ImprovesFeerateDiagram` interface will have to change for this use-case, which is a future direction to solve certain pins and improve mempool incentive compatibility: https://delvingbitcoin.org/t/ephemeral-anchors-and-mev/383#diagram-checks-fix-this-3 And longer-term, this would be the proposed way we would compute incentive compatibility for all conflicts, post-cluster mempool. ACKs for top commit: sipa: utACK 72959867784098137a50c34f86deca8235eef4f8 glozow: code review ACK 72959867784098137a50c34f86deca8235eef4f8 murchandamus: utACK 72959867784098137a50c34f86deca8235eef4f8 ismaelsadeeq: Re-ACK https://github.com/bitcoin/bitcoin/commit/72959867784098137a50c34f86deca8235eef4f8 willcl-ark: crACK 72959867784098137a50c34f86deca8235eef4f8 sdaftuar: ACK 72959867784098137a50c34f86deca8235eef4f8 Tree-SHA512: 79593e5a087801c06f06cc8b73aa3e7b96ab938d3b90f5d229c4e4bfca887a77b447605c49aa5eb7ddcead85706c534ac5eb6146ae2396af678f4beaaa5bea8e
2024-03-25use const ref for client_maxfeerateGreg Sanders
2024-03-25scripted-diff: Rename max_sane_feerate to client_maxfeerateGreg Sanders
-BEGIN VERIFY SCRIPT- git grep -l 'max_sane_feerate' | xargs sed -i 's/max_sane_feerate/client_maxfeerate/g' -END VERIFY SCRIPT-
2024-03-23init: clarify -test error0xb10c
See https://github.com/bitcoin/bitcoin/pull/29007#discussion_r1469388717
2024-03-23addrman: drop /*deterministic=*/ comment0xb10c
Just having deterministic is enough. See https://github.com/bitcoin/bitcoin/pull/29007#discussion_r1488241966
2024-03-22Merge bitcoin/bitcoin#29672: validation: Make translations of fatal errors ↵Ava Chow
consistent 824f47294a309ba8e58ba8d1da0af15d8d828f43 node: Use log levels in noui_ThreadSafeMessageBox (TheCharlatan) ddc7872c08b7ddf9b1e83abdb97c21303f4a9172 node: Make translations of fatal errors consistent (TheCharlatan) Pull request description: The extra `bilingual_str` argument of the fatal error notifications and `node::AbortNode()` is often unused and when used usually contains the same string as the message argument. It also seems to be confusing, since it is not consistently used for errors requiring user action. For example some assumeutxo fatal errors require the user to do something, but are not translated. So simplify the fatal error and abort node interfaces by only passing a translated string. This slightly changes the fatal errors displayed to the user. ACKs for top commit: stickies-v: re-ACK 824f47294a309ba8e58ba8d1da0af15d8d828f43 maflcko: ACK 824f47294a309ba8e58ba8d1da0af15d8d828f43 🔎 achow101: ACK 824f47294a309ba8e58ba8d1da0af15d8d828f43 hebasto: re-ACK 824f47294a309ba8e58ba8d1da0af15d8d828f43. Tree-SHA512: 2868ee7b045fe7f3ac582ce5039141b398480b7627734976201dafaaef7544b8461635a7292fee4a7f32ff1bfc26f9bd4d0c292dca424ba42fb7fc4483d7ce8d
2024-03-22Merge bitcoin/bitcoin#28998: rpc: "addpeeraddress tried" return error on failureAva Chow
99954f914f031c80aa53daa367fc049c4c55bdf3 test: fix test to ensure hidden RPC is present in detailed help (stratospher) 0d01f6f0c6e53c9765f84e0616ab46b83923a6ad test: remove unused mocktime in test_addpeeraddress (0xb10c) 6205466512d4b94d1e507a77ab2151425790d29f rpc: "addpeeraddress tried" return error on failure (0xb10c) Pull request description: When trying to add an address to the IP address manager tried table, it's first added to the new table and then moved to the tried table. Previously, adding a conflicting address to the address manager's tried table with test-only `addpeeraddress tried=true` RPC would return `{ "success": true }`. However, the address would not be added to the tried table, but would remain in the new table. This caused, e.g., issue #28964. This is fixed by new returning `{ "success": false, "error": "..." }` for failed tried table additions. Since the address remaining in the new table can't be removed (the address manager interface does not support removing addresses at the moment and adding this seems to be a bigger effort), an error message is returned. This indicates to a user why the RPC failed and allows accounting for the extra address in the new table. This is done in the functional test for the `getrawaddrman` RPC. Fixes #28964 ACKs for top commit: achow101: ACK 99954f914f031c80aa53daa367fc049c4c55bdf3 stratospher: reACK 99954f9. 🚀 brunoerg: utACK 99954f914f031c80aa53daa367fc049c4c55bdf3 Tree-SHA512: 2f1299410c0582ebc2071271ba789a8abed905f9a510821f77afbcf2a555ec31397578ea55cbcd162fb828be27afedd3246c7b13ad8883f2f745bb8e04364a76
2024-03-22Merge bitcoin/bitcoin#29647: Avoid divide-by-zero in header sync logs when ↵Ava Chow
NodeClock is behind fa4d98b3c8e63f20c6f366fc9382039ba52614a4 Avoid divide-by-zero in header sync logs when NodeClock is behind (MarcoFalke) fa58550317c633c411009c1cc8fb692e3baf97e8 refactor: Modernize header sync logs (MarcoFalke) Pull request description: The log may be confusing, when the NodeClock is behind the current header tip. Fix it, by assuming the NodeClock is never behind the current header tip. ACKs for top commit: sipa: utACK fa4d98b3c8e63f20c6f366fc9382039ba52614a4 sr-gi: tACK [fa4d98b](https://github.com/bitcoin/bitcoin/pull/29647/commits/fa4d98b3c8e63f20c6f366fc9382039ba52614a4) achow101: ACK fa4d98b3c8e63f20c6f366fc9382039ba52614a4 tdb3: ACK fa4d98b3c8e63f20c6f366fc9382039ba52614a4 Tree-SHA512: 3c5aee4030af387695918c5238012c972ebf850b52e956b5f74590cd7fd4eff0b3e593d411e3eb2a0bb12294af8dc6fbe320f90e4c261399b65a404ff3c3cbd9
2024-03-21node: Use log levels in noui_ThreadSafeMessageBoxTheCharlatan
2024-03-21node: Make translations of fatal errors consistentTheCharlatan
The extra `bilingual_str` argument of the fatal error notifications and `node::AbortNode()` is often unused and when used usually contains the same string as the message argument. It also seems to be confusing, since it is not consistently used for errors requiring user action. For example some assumeutxo fatal errors require the user to do something, but are not translated. So simplify the fatal error and abort node interfaces by only passing a translated string. This slightly changes the fatal errors displayed to the user. Also de-duplicate the abort error log since it is repeated in noui.cpp.
2024-03-20Merge bitcoin/bitcoin#29671: index: avoid "failed to commit" errors on ↵Ava Chow
initialization f65b0f6401091e4a4ca4c9f4db1cf388f0336bad index: Move last_locator_write_time and logging to end of threadsync loop (Fabian Jahr) Pull request description: In the index sync thread, when initializing an index for the first time, stop callng BaseIndex::Commit when m_best_block_index is null, to avoid a spurious "failed to commit" error from that function. This error started happening in commit https://github.com/bitcoin/bitcoin/commit/7878f97bf15b6e7c9b47d1c0d96419b97e1bdcbd from https://github.com/bitcoin/bitcoin/pull/25494 and was reported by pstratem in https://github.com/bitcoin/bitcoin/pull/26903 with an alternate fix. ACKs for top commit: achow101: ACK f65b0f6401091e4a4ca4c9f4db1cf388f0336bad ryanofsky: Code review ACK f65b0f6401091e4a4ca4c9f4db1cf388f0336bad. Just moved log "Syncing" log line since last commit to avoid having to call now() twice. furszy: ACK f65b0f6401091e4a4ca4c9f4db1cf388f0336bad TheCharlatan: ACK f65b0f6401091e4a4ca4c9f4db1cf388f0336bad Tree-SHA512: afa8f05786318d36346d167ff53ea0b3bc8abdb0ad04465d199dc3eb91e9f837369e24fcb7e24b5757b02d698ec504e61da6ac365eaf006c874fc07a424a7e20
2024-03-20wallet, rpc: Add createwalletdescriptor RPCAva Chow
2024-03-20wallet: Be able to retrieve single key from descriptorsAva Chow
Adds CWallet::GetKey which retrieves a single key from the descriptors stored in the wallet.
2024-03-20wallet: Add GetActiveHDPubKeys to retrieve xpubs from active descriptorsAva Chow
2024-03-20wallet, descspkm: Refactor wallet descriptor generation to standalone funcAndrew Chow
2024-03-20wallet: Refactor function for single DescSPKM setupAndrew Chow
We will need access to a function that sets up a singular DescriptorSPKM, so refactor this out of the multiple DescriptorSPKM setup function.
2024-03-20wallet, rpc: Add gethdkeys RPCAva Chow
gethdkeys retrieves all HD keys stored in the wallet's descriptors.
2024-03-20wallet, rpc: show mempool conflicts in `gettransaction` resultishaanam
2024-03-20wallet: track mempool conflictsishaanam
Behavior changes are: - if a tx has a mempool conflict, the wallet will not attempt to rebroadcast it - if a txo is spent by a mempool-conflicted tx, that txo is no longer considered spent
2024-03-20Merge bitcoin/bitcoin#29370: assumeutxo: Get rid of faked nTx and nChainTx ↵Ava Chow
values 9d9a7458a2570f7db56ab626b22010591089c312 assumeutxo: Remove BLOCK_ASSUMED_VALID flag (Ryan Ofsky) ef174e9ed21c08f38e5d4b537b6decfd1f646db9 test: assumeutxo snapshot block CheckBlockIndex crash test (Ryan Ofsky) 0391458d767b842a7925785a7053400c0e1cb55a test: assumeutxo stale block CheckBlockIndex crash test (Ryan Ofsky) ef29c8b662309a438121a83f27fd7bdd1779700c assumeutxo: Get rid of faked nTx and nChainTx values (Ryan Ofsky) 9b97d5bbf980d657a277c85d113c2ae3e870e0ec doc: Improve comments describing setBlockIndexCandidates checks (Ryan Ofsky) 0fd915ee6bef63bb360ccc5c039a3c11676c38e3 validation: Check GuessVerificationProgress is not called with disconnected block (Ryan Ofsky) 63e8fc912c21a2f5b47e8eab10fb13c604afed85 ci: add getchaintxstats ubsan suppressions (Ryan Ofsky) f252e687ec94b6ccafb5bc44b7df3daeb473fdea assumeutxo test: Add RPC test for fake nTx and nChainTx values (Ryan Ofsky) Pull request description: The `PopulateAndValidateSnapshot` function introduced in f6e2da5fb7c6406c37612c838c998078ea8d2252 from #19806 has been setting fake `nTx` and `nChainTx` values that can show up in RPC results (https://github.com/bitcoin/bitcoin/issues/29328) and make `CBlockIndex` state hard to reason about, because it is difficult to know whether the values are real or fake. Revert to previous behavior of setting `nTx` and `nChainTx` to 0 when the values are unknown, instead of faking them. Also drop no-longer needed `BLOCK_ASSUMED_VALID` flag. Dropping the faked values also fixes assert failures in the `CheckBlockIndex` `(pindex->nChainTx == pindex->nTx + prev_chain_tx)` check that could happen previously if forked or out-of-order blocks before the snapshot got submitted while the snapshot was being validated. The PR includes two commits adding tests for these failures and describing them in detail. Compatibility note: This change could cause new `-checkblockindex` failures if a snapshot was loaded by a previous version of Bitcoin Core and not fully validated, because fake `nTx` values will have been saved to the block index. It would be pretty easy to avoid these failures by adding some compatibility code to `LoadBlockIndex` and changing `nTx` values from 1 to 0 when they are fake (when `(pindex->nStatus & BLOCK_VALID_MASK) < BLOCK_VALID_TRANSACTIONS`), but a little simpler not to worry about being compatible in this case. ACKs for top commit: Sjors: re-ACK 9d9a7458a2570f7db56ab626b22010591089c312 achow101: ACK 9d9a7458a2570f7db56ab626b22010591089c312 mzumsande: Tested ACK 9d9a7458a2570f7db56ab626b22010591089c312 maflcko: ACK 9d9a7458a2570f7db56ab626b22010591089c312 🎯 Tree-SHA512: b1e1e2731ec36be30d5f5914042517219378fc31486674030c29d9c7488ed83fb60ba7095600f469dc32f0d8ba79c49ff7706303006507654e1762f26ee416e0
2024-03-20Merge bitcoin/bitcoin#27039: blockstorage: do not flush block to disk if it ↵Ava Chow
is already there dfcef536d0e6c40e98dce35ae7af6e3e4a2595cd blockstorage: do not flush block to disk if it is already there (Matthew Zipkin) Pull request description: Closes https://github.com/bitcoin/bitcoin/issues/2039 When reindexing from flat-file block storage there is no need to write anything back to disk, since the block data is already there. This PR skips flushing to disk those blocks that already have a known position in the datastore. Skipping this means that users can write-protect the `blk` files on disk which may be useful for security or even safely sharing that data between multiple bitcoind instances. `FindBlockPos()` may also flush the undo data file, but again this is skipped if the corresponding block position is known, like during the initial stage of a reindex when block data is being indexed. Once the block index is complete the validation mechanism will call `ConnectBlock()` which will save undo data at that time. The call stack looks like this: ``` init() ThreadImport() <-- process fReindex flag LoadExternalBlockFile() AcceptBlock() SaveBlockToDisk() FindBlockPos() FlushBlockFile() <-- unnecessary if block is already on disk ``` A larger refactor of this part of the code was started by mzumsande here: https://github.com/mzumsande/bitcoin/tree/202207_refactor_findblockpos including this fix, reviewers can let me know if the changes should be combined. ACKs for top commit: sipa: utACK dfcef536d0e6c40e98dce35ae7af6e3e4a2595cd mzumsande: re-ACK dfcef536d0e6c40e98dce35ae7af6e3e4a2595cd achow101: ACK dfcef536d0e6c40e98dce35ae7af6e3e4a2595cd furszy: Rebase diff ACK dfcef53. Tree-SHA512: 385c5ac1288b325135398d0ddd3ab788fa98cc0ca19bd2474c74039f2ce70d5088c1d1c9d4dd10aefcbd4c757767ec5805d07ba8cee9289a66f96e6f9eaa5279
2024-03-20Merge bitcoin/bitcoin#28955: index: block filters sync, reduce disk read ↵Ava Chow
operations by caching last header 99afb9d15a08d2f46739f4d2b66c63dbabd7a44e refactor: init, simplify index shutdown code (furszy) 0faafb57f8298547949cbc0044ee9e925ed887ba index: decrease ThreadSync cs_main contention (furszy) f1469eb45469672046c5793b44863f606736c853 index: cache last block filter header (furszy) a6756ecdb2f1ac960433412807aa377d1ee80d05 index: blockfilter, decouple header lookup into its own function (furszy) 331f044e3b49223cedd16803d123c0da9d91d6a2 index: blockfilter, decouple Write into its own function (furszy) bcbd7eb8d40fbbd0e58c61acef087d65f2047036 bench: basic block filter index initial sync (furszy) Pull request description: Work decoupled from #26966 per request. The aim is to remove an unnecessary disk read operation that currently takes place with every new arriving block (or scanned block during background sync). Instead of reading the last filter header from disk merely to access its hash for constructing the next filter, this work caches it, occupying just 32 more bytes in memory. Also, reduces `cs_main` lock contention during the index initial sync process. And, simplifies the indexes initialization and shutdown procedure. Testing Note: To compare the changes, added a pretty basic benchmark in the second commit. Alternatively, could also test the changes by timing the block filter sync from scratch on any network; start the node with `-blockfilterindex` and monitor the logs until the syncing process finish. Local Benchmark Results: *Master (c252a0fc0f4dc7d262b971a5e7ff01508159193b): | ns/op | op/s | err% | total | benchmark |--------------------:|--------------------:|--------:|----------:|:---------- | 132,042,516.60 | 7.57 | 0.3% | 7.79 | `BlockFilterIndexSync` *PR (43a212cfdac6c64e82b601c664443d022f191520): | ns/op | op/s | err% | total | benchmark |--------------------:|--------------------:|--------:|----------:|:---------- | 126,915,841.60 | 7.88 | 0.6% | 7.51 | `BlockFilterIndexSync` ACKs for top commit: Sjors: re-ACK 99afb9d15a08d2f46739f4d2b66c63dbabd7a44e achow101: ACK 99afb9d15a08d2f46739f4d2b66c63dbabd7a44e TheCharlatan: Re-ACK 99afb9d15a08d2f46739f4d2b66c63dbabd7a44e andrewtoth: ACK 99afb9d15a08d2f46739f4d2b66c63dbabd7a44e Tree-SHA512: 927daadd68f4ee1ca781a89519539b895f5185a76ebaf525fbc246ea8dcf40d44a82def00ac34b188640802844b312270067f1b33e65a2479e06be9169c616de
2024-03-19index: Move last_locator_write_time and logging to end of threadsync loopFabian Jahr
This avoids having commit print a needless error message during init. Co-authored-by: furszy <mfurszy@protonmail.com>
2024-03-19Merge bitcoin/bitcoin#29192: Weaken serfloat testsfanquake
6e873df3478f3ab8f67d1b9339c7e990ae90e95b serfloat: improve/simplify tests (Pieter Wuille) b45f1f56582fb3a0d17db5014ac57f1fb40a3611 serfloat: do not test encode(bits)=bits anymore (Pieter Wuille) Pull request description: Closes #28941. Our current tests for serfloat verify two distinct properties: 1. Whether they roundtrip `double`->`uint64_t`->`double` (excluding NaN values) on all systems. 2. Whether on systems with a typical floating point unit that encoding matches the hardware representation, as before v22.0, we would dump the hardware representation directly to disk and we wanted to retain compatibility with that. #28941 seems to show that the second property doesn't always hold, but just for "subnormal" numbers (below $2^{-1021}$). Since we don't care about encoding these numbers, we could exclude such subnormal numbers from the hardware-identical representation test, but this PR goes further and just drops the second property entirely, as I don't think we care about edge-case compatibility with pre-v22.0 code for fee_estimates.dat (the only place it is used). ACKs for top commit: glozow: ACK 6e873df3478f3ab8f67d1b9339c7e990ae90e95b fanquake: ACK 6e873df3478f3ab8f67d1b9339c7e990ae90e95b - It's not as much of a priority, but I think we could still backport this. Tree-SHA512: e18ceee0753a7ee7e999fdfa10b014dc5bb67b6ef79522a0f8c76b889adcfa785772fc26ed7559bcb5a09a9938e243bb54eedd9549bc59080a2c8090155e2267
2024-03-19rpc: "addpeeraddress tried" return error on failure0xb10c
When trying to add an address to the IP address manager tried table, it's first added to the new table and then moved to the tried table. Previously, adding a conflicting address to the address manager's tried table with test-only `addpeeraddress tried=true` RPC would return `{ "success": true }`. However, the address would not be added to the tried table, but would remain in the new table. This caused, e.g., issue 28964. This is fixed by returning `{ "success": false, "error": "failed-adding-to-tried" }` for failed tried table additions. Since the address remaining in the new table can't be removed (the address manager interface does not support removing addresses at the moment and adding this seems to be a bigger effort), an error message is returned. This indicates to a user why the RPC failed and allows accounting for the extra address in the new table. Also: To check the number of addresses in each addrman table, the addrman checks were re-run and the log output of this check was asserted. Ideally, logs shouldn't be used as an interface in automated tests. To avoid asserting the logs, use the getaddrmaninfo and getrawaddrman RPCs (which weren't implemented when the test was added). Removing the "getnodeaddress" calls would also remove the addrman checks from the test, which could reduce the test coverage. To avoid this, these are kept.
2024-03-19Merge bitcoin/bitcoin#29667: fuzz: actually test garbage >64b in p2p ↵fanquake
transport test 626f8e398e219b84907ccaad036f69177d39284c fuzz: actually test garbage >64b in p2p transport test (Pieter Wuille) Pull request description: This fixes an oversight from #28196: in the `p2p_transport_bidirectional_v2` fuzz test, when the desired garbage length is over 64 bytes, the code would actually use garbage length 0. Fix this. ACKs for top commit: instagibbs: ACK https://github.com/bitcoin/bitcoin/pull/29667/commits/626f8e398e219b84907ccaad036f69177d39284c brunoerg: crACK 626f8e398e219b84907ccaad036f69177d39284c Tree-SHA512: f6346367adb10464b6c9d20aef43625531d2a4d8110887ad03214b8c1907b83560f2dd5b5415e2180a40b4cd276d51881b32b60c740471b5c6bb218aa19848d8