aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
AgeCommit message (Collapse)Author
2021-09-22Fix (inverse) meaning of -persistmempoolMarcoFalke
2021-09-16Merge bitcoin/bitcoin#22626: Remove txindex migration codeW. J. van der Laan
fa20f815a9cb438c5ab61e97a453612ddd8b21b5 Remove txindex migration code (MarcoFalke) fae878603345854527c211ebb7d1967f12c8bb9d doc: Fix validation typo (MarcoFalke) fab89006d656261770503e54fdd01ac9167bdd49 Add missing includes and forward declarations, remove unused ones (MarcoFalke) Pull request description: No supported version of Bitcoin Core used the legacy txindex, so all relevant nodes can be assumed to have upgraded. Thus, there is no need to keep this code any longer. As a temporary courtesy, provide a one-time warning on how to free the disk space used by the legacy txindex. Fixes #22615 ACKs for top commit: laanwj: Code review ACK fa20f815a9cb438c5ab61e97a453612ddd8b21b5 hebasto: ACK fa20f815a9cb438c5ab61e97a453612ddd8b21b5, tested on Linux Mint 20.2 (x86_64). Zero-1729: crACK fa20f815a9cb438c5ab61e97a453612ddd8b21b5 theStack: Approach ACK fa20f815a9cb438c5ab61e97a453612ddd8b21b5 Tree-SHA512: 68aa32d064d1e3932e6e382816a4b5de417bd7e82861fea1ee50660e8c397f4efeb88ae4ed54a8ad1952c3563eb0b8449d7ccf883c353cc4d4dc7e15c53d78e8
2021-09-10Merge bitcoin/bitcoin#22675: RBF move 2/3: extract RBF logic into policy/rbffanquake
32748da0f47f7aa9fba78dfb29aa426b14f15624 whitespace fixups after move and scripted-diff (glozow) fa47622e8dc66bec9ea690aec3f0999108d76dc9 scripted-diff: rename variables in policy/rbf (glozow) ac761f0a23c9c469fa00885edf3d5c9ae7c6a2b3 MOVEONLY: fee checks (Rules 3 and 4) to policy/rbf (glozow) 9c2f9f89846264b503d5573341bb78cf609cbc5e MOVEONLY: check that fees > direct conflicts to policy/rbf (glozow) 3f033f01a6b0f7772ae1b21044903b8f4249ad08 MOVEONLY: check for disjoint conflicts and ancestors to policy/rbf (glozow) 7b60c02b7d5e2ab12288393d2258873ebb26d811 MOVEONLY: BIP125 Rule 2 to policy/rbf (glozow) f8ad2a57c61d1e817e2445226688e03080fc8688 Make GetEntriesForConflicts return std::optional (glozow) Pull request description: This PR does not change behavior. It extracts the BIP125 logic into helper functions (and puts them in the policy/rbf* files). This enables three things - I think each one individually is pretty good: - Implementation of package RBF (see #22290). I want it to be as close to BIP125 as possible so that it doesn't become a distinct fee-bumping mechanism. Doing these move-only commits first means the diff is mostly mechanical to review, and I just need to create a function that mirrors the single transaction validation. - We will be able to isolate and test our RBF logic alone. Recently, there have been some discussions on discrepancies between our code and BIP125, as well as proposals for improving it. Generally, I think making this code more modular and de-bloating validation.cpp is probably a good idea. - Witness Replacement (replacing same-txid-different-wtxid when the witness is significantly smaller and therefore higher feerate) in a BIP125-similar way. Hopefully it can just be implemented with calls to the rbf functions (i.e. `PaysForRBF`) and an edit to the relevant mempool entries. ACKs for top commit: mjdietzx: ACK 32748da0f47f7aa9fba78dfb29aa426b14f15624 theStack: Code-review ACK 32748da0f47f7aa9fba78dfb29aa426b14f15624 📐 MarcoFalke: review ACK 32748da0f47f7aa9fba78dfb29aa426b14f15624 🦇 Tree-SHA512: d89985c8b4b42b54861018deb89468e04968c85a3fb1113bbcb2eb2609577bc4fd9bf254593b5bd0e7ab059a0fa8192d1a903b00f77e6f120c7a80488ffcbfc0
2021-09-07Enable clang-tidy bugprone-argument-comment and fix violationsMarcoFalke
2021-09-02MOVEONLY: fee checks (Rules 3 and 4) to policy/rbfglozow
2021-09-02MOVEONLY: check that fees > direct conflicts to policy/rbfglozow
2021-09-02MOVEONLY: check for disjoint conflicts and ancestors to policy/rbfglozow
This checks that a transaction isn't trying to replace something it supposedly depends on.
2021-09-02MOVEONLY: BIP125 Rule 2 to policy/rbfglozow
2021-09-02Make GetEntriesForConflicts return std::optionalglozow
Avoids reusing err_string.
2021-08-31Merge bitcoin/bitcoin#22796: RBF move (1/3): extract BIP125 Rule 5 into ↵fanquake
policy/rbf f293c68be0469894c988711559f5528020c0ff71 MOVEONLY: getting mempool conflicts to policy/rbf (glozow) 8d7179633552f58ca0d23305196dcb4249b6dce7 [validation] quit RBF logic earlier and separate loops (glozow) badb9b11a6f7e1e693cecc8cd5aae55a197d70e2 call SignalsOptInRBF instead of checking all inputs (glozow) e0df41d7d584b854c2914d4afe7b21e0af3fbf69 [validation] default conflicting fees and size to 0 (glozow) b001b9f6de7a039a468cf0f9645f3f0a430fa889 MOVEONLY: BIP125 max conflicts limit to policy/rbf.h (glozow) Pull request description: See #22675 for motivation, this is one chunk of it. It extracts some BIP125 logic into policy/rbf: - Defines a constant for specifying the maximum number of mempool entries we'd consider replacing by RBF - Calls the available `SignalsOptInRBF` function instead of manually iterating through inputs - Moves the logic for getting the list of conflicting mempool entries to a helper function - Also does a bit of preparation for future moves - moving declarations around, etc Also see #22677 for addressing the circular dependency. ACKs for top commit: jnewbery: Code review ACK f293c68be0469894c988711559f5528020c0ff71 theStack: Code-review ACK f293c68be0469894c988711559f5528020c0ff71 📔 ariard: ACK f293c68b Tree-SHA512: a60370994569cfc91d4b2ad5e94542d4855a48927ae8b174880216074e4fa50d4523dd4ee36efdd6edf2bf7adb87a8beff9c3aaaf6dd323b286b287233e63790
2021-08-29refactor: remove RecursiveMutex cs_nBlockSequenceIdSebastian Falbesoner
The RecursiveMutex cs_nBlockSequenceId is only used at one place in CChainState::ReceivedBlockTransactions() to atomically read-and-increment the nBlockSequenceId member. At this point, the cs_main lock is set, hence we can use a plain int for the member and mark it as guarded by cs_main.
2021-08-24MOVEONLY: getting mempool conflicts to policy/rbfglozow
2021-08-24[validation] quit RBF logic earlier and separate loopsglozow
No behavior change. While we're looking through the descendants and calculating how many transactions we might replace, quit early, as soon as we hit 100. Since we're failing faster, we can also separate the loops - yes, we loop through more times, but this helps us detangle the different BIP125 rules later.
2021-08-24call SignalsOptInRBF instead of checking all inputsglozow
2021-08-24[validation] default conflicting fees and size to 0glozow
This should have no effect in practice, since we only ever call PreChecks once per transaction.
2021-08-24MOVEONLY: BIP125 max conflicts limit to policy/rbf.hglozow
A circular dependency is added because policy now depends on txmempool and txmempool depends on validation. It is natural for [mempool] policy to rely on mempool; the problem is caused by txmempool depending on validation. #22677 will resolve this.
2021-08-20doc: Fix validation typoMarcoFalke
2021-08-06[policy] ancestor/descendant limits for packagesglozow
2021-07-28Merge bitcoin/bitcoin#22528: refactor: move GetTransaction to ↵MarcoFalke
node/transaction.cpp f685a13bef0418663015ea6d8f448f075510c0ec doc: GetTransaction()/getrawtransaction follow-ups to #22383 (John Newbery) abc57e1f0882a1a2bb20474648419979af6e383d refactor: move `GetTransaction(...)` to node/transaction.cpp (Sebastian Falbesoner) Pull request description: ~This PR is based on #22383, which should be reviewed first~ (merged by now). In [yesterday's PR review club session to PR 22383](https://bitcoincore.reviews/22383), the idea of moving the function `GetTransaction(...)` from src/validation.cpp to src/node/transaction.cpp came up. With this, the circular dependency "index/txindex -> validation -> index/txindex" is removed (see change in `lint-circular-dependencies.sh`). Thanks to jnewbery for suggesting and to sipa for providing historical background. Relevant IRC log: ``` 17:52 <jnewbery> Was anyone surprised that GetTransaction() is in validation.cpp? It seems to me that node/transaction.cpp would be a more appropriate place for it. 17:53 <raj_> jnewbery, +1 17:53 <stickies-v> agreed! 17:54 <glozow> jnewbery ya 17:54 <jnewbery> seems weird that validation would call into txindex. I wonder if we remove this function, then validation would no longer need to #include txindex 17:54 <sipa> GetTransaction predates node/transaction.cpp, and even the generic index framework itself :) 17:55 <sipa> (before 0.8, validation itself used the txindex) 17:55 <jnewbery> (and GetTransaction() seems like a natural sibling to BroadcastTransaction(), which is already in node/transaction.cpp) 17:55 <jnewbery> sipa: right, this is not meant as a criticism of course. Just wondering if we can organize things a bit more rationally now that we have better separation between things. 17:55 <sipa> jnewbery: sure, just providing background 17:56 <sipa> seems very reasonable to move it elsewhere now ``` The commit should be trivial to review with `--color-moved`. ACKs for top commit: jnewbery: Code review ACK f685a13bef0418663015ea6d8f448f075510c0ec rajarshimaitra: tACK https://github.com/bitcoin/bitcoin/pull/22528/commits/f685a13bef0418663015ea6d8f448f075510c0ec mjdietzx: crACK f685a13bef0418663015ea6d8f448f075510c0ec LarryRuane: Code review, test ACK f685a13bef0418663015ea6d8f448f075510c0ec Tree-SHA512: 0e844a6ecb1be04c638b55bc4478c2949549a4fcae01c984eee078de74d176fb19d508fc09360a62ad130677bfa7daf703b67870800e55942838d7313246248c
2021-07-27tracing: Tracepoint for connected blocks0xb10c
Can, for example, be used to benchmark block connections.
2021-07-22Merge bitcoin/bitcoin#22383: rpc: Prefer to use txindex if available for ↵MarcoFalke
GetTransaction 78f4c8b98eada337346ffb206339c3ebae4ff43b prefer to use txindex if available for GetTransaction (Jameson Lopp) Pull request description: Fixes #22382 Motivation: prevent excessive disk reads if txindex is enabled. Worth noting that this could be argued to be less of a bug and more of an issue of undefined behavior. If a user calls GetTransaction with the wrong block hash, what should happen? ACKs for top commit: jonatack: ACK 78f4c8b98eada337346ffb206339c3ebae4ff43b theStack: Code review ACK 78f4c8b98eada337346ffb206339c3ebae4ff43b LarryRuane: tACK 78f4c8b98eada337346ffb206339c3ebae4ff43b luke-jr: utACK 78f4c8b98eada337346ffb206339c3ebae4ff43b jnewbery: utACK 78f4c8b98eada337346ffb206339c3ebae4ff43b rajarshimaitra: Code review ACK https://github.com/bitcoin/bitcoin/commit/78f4c8b98eada337346ffb206339c3ebae4ff43b lsilva01: Code Review ACK and Tested ACK https://github.com/bitcoin/bitcoin/pull/22383/commits/78f4c8b98eada337346ffb206339c3ebae4ff43b on Ubuntu 20.04 Tree-SHA512: af7db5b98cb2ae4897b28476b2fa243bf7e6f850750d9347062fe8013c5720986d1a3c808f80098e5289bd84b085de03c81a44e584dc28982f721c223651bfe0
2021-07-22Merge bitcoin/bitcoin#21090: Default to NODE_WITNESS in nLocalServicesW. J. van der Laan
a806647d260132a00cd633160040625c7dd17803 [validation] Always include merkle root in coinbase commitment (Dhruv Mehta) 189128c220190a588500b8e74ee7ae47671b9558 [validation] Set witness script flag with p2sh for blocks (Dhruv Mehta) ac82b99db77ec843af82dcdf040dfdbc98c8ff26 [p2p] remove redundant NODE_WITNESS checks (Dhruv Mehta) 6f8b198b8256a6703a6f5e592dfa77fa024a7035 [p2p] remove unused segwitheight=-1 option (Dhruv Mehta) eba5b1cd6460c98e75d0422bd394e12af7f11e4c [test] remove or move tests using `-segwitheight=-1` (Dhruv Mehta) Pull request description: Builds on #21009 and makes progress on remaining items in #17862 Removing `RewindBlockIndex()` in #21009 allows the following: - removal of tests using `segwitheight=-1` in `p2p_segwit.py`. - move `test_upgrade_after_activation()` out of `p2p_segwit.py` reducing runtime - in turn, that allows us to drop support for `-segwitheight=-1`, which is only supported for that test. - that allows us to always set `NODE_WITNESS` in our local services. The only reason we don't do that is to support `-segwitheight=-1`. - that in turn allows us to drop all of the `GetLocalServices() & NODE_WITNESS` checks inside `net_processing.cpp`, since our local services would always include `NODE_WITNESS` ACKs for top commit: mzumsande: Code-Review ACK a806647d260132a00cd633160040625c7dd17803 laanwj: Code review ACK a806647d260132a00cd633160040625c7dd17803, nice cleanup jnewbery: utACK a806647d260132a00cd633160040625c7dd17803 theStack: ACK a806647d260132a00cd633160040625c7dd17803 Tree-SHA512: 73e1a69d1d7eca1f5c38558ec6672decd0b60b16c2ef6134df6f6af71bb159e6eea160f9bb5ab0eb6723c6632d29509811e29469d0d87abbe9b69a2890fbc73e
2021-07-22refactor: move `GetTransaction(...)` to node/transaction.cppSebastian Falbesoner
can be reviewed with --color-moved
2021-07-15Move pblocktree global to BlockManagerMarcoFalke
2021-07-15Move LoadBlockIndexDB to BlockManagerMarcoFalke
2021-07-15Merge bitcoin/bitcoin#22415: Make m_mempool optional in CChainStateMarcoFalke
ceb7b35a39145717e2d9d356fd382bd1f95d2a5a refactor: move UpdateTip into CChainState (James O'Beirne) 4abf0779d6594e97222279110c328b75b5f3db7b refactor: no mempool arg to GetCoinsCacheSizeState (James O'Beirne) 46e3efd1e4ae2f058ecfffdaee7e882c4305eb35 refactor: move UpdateMempoolForReorg into CChainState (James O'Beirne) 617661703ac29e0744f21de74501d033fdc53ff6 validation: make CChainState::m_mempool optional (James O'Beirne) Pull request description: Make `CChainState::m_mempool` optional by making it a pointer instead of a reference. This will allow a simplification to assumeutxo semantics (see https://github.com/bitcoin/bitcoin/pull/15606#pullrequestreview-692965905) and help facilitate the `-nomempool` option. ACKs for top commit: jnewbery: ACK ceb7b35a39145717e2d9d356fd382bd1f95d2a5a naumenkogs: ACK ceb7b35a39145717e2d9d356fd382bd1f95d2a5a ryanofsky: Code review ACK ceb7b35a39145717e2d9d356fd382bd1f95d2a5a (just minor style and test tweaks since last review) lsilva01: Code review ACK and tested on Signet ACK https://github.com/bitcoin/bitcoin/pull/22415/commits/ceb7b35a39145717e2d9d356fd382bd1f95d2a5a MarcoFalke: review ACK ceb7b35a39145717e2d9d356fd382bd1f95d2a5a 😌 Tree-SHA512: cc445ad33439d5918cacf80a6354eea8f3d33bb7719573ed5b970fad1a0dab410bcd70be44c862b8aba1b71263b82d79876688c553e339362653dfb3d8ec81e6
2021-07-13refactor: move UpdateTip into CChainStateJames O'Beirne
Makes sense and saves on arguments. Co-authored-by: John Newbery <john@johnnewbery.com>
2021-07-13refactor: no mempool arg to GetCoinsCacheSizeStateJames O'Beirne
Unnecessary argument since we can make use of this->m_mempool Co-authored-by: John Newbery <john@johnnewbery.com>
2021-07-13refactor: move UpdateMempoolForReorg into CChainStateJames O'Beirne
Allows fewer arguments and simplification of call sites. Co-authored-by: John Newbery <john@johnnewbery.com>
2021-07-13validation: make CChainState::m_mempool optionalJames O'Beirne
Since we now have multiple chainstate objects, only one of them is active at any given time. An active chainstate has a mempool, but there's no point to others having one. This change will simplify proposed assumeutxo semantics. See the discussion here: https://github.com/bitcoin/bitcoin/pull/15606#pullrequestreview-692965905 Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
2021-07-08[validation] distinguish same txid different wtxid in mempoolglozow
Changes behavior.
2021-07-07[validation] Always include merkle root in coinbase commitmentDhruv Mehta
2021-07-07[validation] Set witness script flag with p2sh for blocksDhruv Mehta
2021-07-03prefer to use txindex if available for GetTransactionJameson Lopp
Fixes #22382
2021-06-30[refactor] Move ComputeBlockVersion into VersionBitsCacheAnthony Towns
This also changes ComputeBlockVersion to take the versionbits cache mutex once, rather than once for each versionbits deployment.
2021-06-30[move-only] Move ComputeBlockVersion from validation to versionbitsAnthony Towns
2021-06-30[refactor] versionbits: make VersionBitsCache a full classAnthony Towns
Moves the VersionBits* functions to be methods of the cache class, and makes the cache and its lock private to the class.
2021-06-30scripted-diff: rename versionbitscacheAnthony Towns
-BEGIN VERIFY SCRIPT- sed -i -e 's/versionbitscache/g_versionbitscache/g' $(git grep -l versionbitscache) -END VERIFY SCRIPT-
2021-06-30[refactor] Add versionbits deployments to deploymentstatus.hAnthony Towns
Adds support for versionbits deployments to DeploymentEnabled, DeploymentActiveAfter and DeploymentActiveAt. Also moves versionbitscache from validation to deploymentstatus.
2021-06-29[refactor] Add deploymentstatus.hAnthony Towns
Provides DeploymentEnabled, DeploymentActiveAt, and DeploymentActiveAfter helpers for checking the status of buried deployments. Can be overloaded so the same syntax works for non-buried deployments, allowing future soft forks to be changed from signalled to buried deployments without having to touch the implementation code. Replaces IsWitnessEnabled and IsScriptWitnessEnabled.
2021-06-29versionbits: Use dedicated lock instead of cs_mainAnthony Towns
2021-06-29Merge bitcoin/bitcoin#21789: refactor: Remove ::Params() global from CChainStatefanquake
fa0d9211ef87a682573aaae932c0c440acbcb8a8 refactor: Remove chainparams arg from CChainState member functions (MarcoFalke) fa389471251f043ec25e7b01e59b37d3b921ce54 refactor: Remove ::Params() global from inside CChainState member functions (MarcoFalke) Pull request description: The `::Params()` global is verbose and confusing. Also it makes tests a bit harder to write because they'd have to mock a global. Fix all issues by simply using a member variable that points to the right params. (Can be reviewed with `--word-diff-regex=.`) ACKs for top commit: jnewbery: ACK fa0d9211ef87a682573aaae932c0c440acbcb8a8 kiminuo: utACK fa0d9211 theStack: ACK fa0d9211ef87a682573aaae932c0c440acbcb8a8 🍉 Tree-SHA512: 44676b19c9ed471ccb536331d3029bad192d7d50f394fd7b8527ec431452aeec8c4494164b9cf8e16e0123c4463b16be864366c6b599370032c17262625a0356
2021-06-28Merge bitcoin/bitcoin#22146: Reject invalid coin height and output index ↵MarcoFalke
when loading assumeutxo fa9ebedec3f982bb5bb459ea33d74c94d9b5cec4 Reject invalid coin height and output index when loading assumeutxo (MarcoFalke) Pull request description: It should be impossible to have a coin at a height higher than the height of the snapshot block, so reject those early to avoid integer wraparounds and hash collisions later on. Same for the outpoint index. Both issues were found by fuzzing: * The height issue by OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34793 * The outpoint issue by my fuzz server: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34793#c2 ACKs for top commit: practicalswift: cr ACK fa9ebedec3f982bb5bb459ea33d74c94d9b5cec4: patch looks correct jamesob: crACK https://github.com/bitcoin/bitcoin/pull/22146/commits/fa9ebedec3f982bb5bb459ea33d74c94d9b5cec4 theStack: Code review ACK fa9ebedec3f982bb5bb459ea33d74c94d9b5cec4 benthecarman: crACK fa9ebedec3f982bb5bb459ea33d74c94d9b5cec4 Tree-SHA512: dae7caee4b3862b23ebdf2acb7edec4baf75b0dbf1409b370b1a73aa6b632b317ebfac596dcbaf4edfb1301b513f45465ea75328962460f35e2af0d7e547c9ac
2021-06-13refactor: Remove chainparams arg from CChainState member functionsMarcoFalke
Passing this is confusing and redundant with the m_params member.
2021-06-13refactor: Remove ::Params() global from inside CChainState member functionsMarcoFalke
It is confusing and verbose to repeatedly access the global when a member variable can simply refer to it.
2021-06-13Merge bitcoin/bitcoin#22102: Remove `Warning:` from warning message printed ↵MarcoFalke
for unknown new rules 6d7e46ce23217da53ff52f535879c393c02fa2b2 Remove `Warning:` (Prayank) Pull request description: Reason: I noticed that `Warning` is printed 2 times in `-getinfo` while reviewing https://github.com/bitcoin/bitcoin/pull/21832#issuecomment-851004943 Same string is used for GUI, log and stderr. If we need to add `Warning:` in GUI or other place we can always prepend to this string. CLI: ``` Warnings: Unknown new rules activated (versionbit 28) ``` GUI: ![image](https://user-images.githubusercontent.com/13405205/120110401-e36ab180-c18a-11eb-8031-4d52287dc263.png) ACKs for top commit: MarcoFalke: review ACK 6d7e46ce23217da53ff52f535879c393c02fa2b2 Tree-SHA512: 25760cf6d850f6c2216d651fa46574d2d21a9d58f4577ecb58f9566ea8cd07bfcd6679bb8a1f53575e441b02d295306f492c0c99a48c909e60e5d977ec1861f6
2021-06-10validation: Farewell, global Chainstate!Carl Dong
2021-06-10scripted-diff: tree-wide: Remove all review-only assertionsCarl Dong
-BEGIN VERIFY SCRIPT- find_regex='((assert|CHECK_NONFATAL)\(std::addressof|TODO: REVIEW-ONLY)' \ && git grep -l -E "$find_regex" -- . \ | xargs sed -i -E "/${find_regex}/d" -END VERIFY SCRIPT-
2021-06-10Merge bitcoin/bitcoin#22084: package testmempoolaccept followupsfanquake
ee862d6efb4c3c01e55f0d5d7a82cce75323cf40 MOVEONLY: context-free package policies (glozow) 5cac95cd15da04b83afa1d31a43be9f5b30a1827 disallow_mempool_conflicts -> allow_bip125_replacement and check earlier (glozow) e8ecc621be6afd3252c0f8147e42c3b4918f7f46 [refactor] comment/naming improvements (glozow) 7d91442461776e2ef240d7885f768b624de341a7 [rpc] reserve space in txns (glozow) 6c5f19d9c4d267c54f4dbc4f9d65370ff1e0625b [package] static_assert max package size >= max tx size (glozow) Pull request description: various followups from #20833 ACKs for top commit: jnewbery: utACK ee862d6efb4c3c01e55f0d5d7a82cce75323cf40 ariard: Code Review ACK ee862d6 Tree-SHA512: 96ecb41f7bbced84d4253070f5274b7267607bfe4033e2bb0d2f55ec778cc41e811130b6321131e0418b5835894e510a4be8a0f822bc9d68d9224418359ac837
2021-06-09Reject invalid coin height and output index when loading assumeutxoMarcoFalke