aboutsummaryrefslogtreecommitdiff
path: root/src/validationinterface.h
AgeCommit message (Collapse)Author
2024-07-25[refactor] change ActiveTipChange to use CBlockIndex ref instead of ptrglozow
2024-07-16add ValidationInterface::ActiveTipChangeglozow
This is a synchronous callback notifying clients of all tip changes. It allows clients to respond to a new block immediately after it is connected. The synchronicity is important for things like m_recent_rejects, in which a transaction's validity can change (rejected vs accepted) when this event is processed. For example, the transaction might have a timelock condition that has just been met. This is distinct from something like m_recent_confirmed_transactions, in which the validation outcome is the same (valid vs already-have), so it does not need to be reset immediately.
2024-02-16kernel: Remove dependency on CSchedulerTheCharlatan
By defining a virtual interface class for the scheduler client, users of the kernel can now define their own event consuming infrastructure, without having to spawn threads or rely on the scheduler design. Removing CScheduler also allows removing the thread and exception modules from the kernel library.
2024-02-15scripted-diff: Rename MainSignals to ValidationSignalsTheCharlatan
-BEGIN VERIFY SCRIPT- s() { git grep -l "$1" src | xargs sed -i "s/$1/$2/g"; } s 'CMainSignals' 'ValidationSignals' s 'MainSignalsImpl' 'ValidationSignalsImpl' -END VERIFY SCRIPT-
2024-02-15[refactor] Make MainSignals RAII styledTheCharlatan
2024-02-15refactor: De-globalize g_signalsTheCharlatan
2024-02-15[refactor] Prepare for g_signals de-globalizationTheCharlatan
To this end move some functions into the CMainSignals class.
2024-01-02doc: fix typo and update incorrect commentismaelsadeeq
2023-11-22CValidationInterface: modify the parameter of `TransactionAddedToMempool`ismaelsadeeq
Create a new struct `NewMempoolTransactionInfo` that will be used as the new parameter of `TransactionAddedToMempool` callback.
2023-11-22CValidationInterface, mempool: add new callback to `CValidationInterface`ismaelsadeeq
This commit adds a new callback `MempoolTransactionsRemovedForBlock` which notify its listeners of the transactions that are removed from the mempool because a new block is connected, along with the block height the transactions were removed. The transactions are in `RemovedMempoolTransactionInfo` format. `CTransactionRef`, base fee, virtual size, and height which the transaction was added to the mempool are all members of the struct called `RemovedMempoolTransactionInfo`. A struct `NewMempoolTransactionInfo`, which has fields similar to `RemovedMempoolTransactionInfo`, will be added in a later commit, create a struct `TransactionInfo` with all similar fields. They can both have a member with type `TransactionInfo`.
2023-09-30validation: pass ChainstateRole for validationinterface callsJames O'Beirne
This allows consumers to decide how to handle events from background or assumedvalid chainstates.
2023-09-30validation: only call UpdatedBlockTip for active chainstateJames O'Beirne
This notification isn't needed for background chainstates. `kernel::Notifications::blockTip` are also skipped.
2023-01-05refactor: add kernel/cs_main.*fanquake
Co-authored-by: Anthony Towns <aj@erisian.com.au>
2022-12-24scripted-diff: Bump copyright headersHennadii Stepanov
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT- Commits of previous years: - 2021: f47dda2c58b5d8d623e0e7ff4e74bc352dfa83d7 - 2020: fa0074e2d82928016a43ca408717154a1c70a4db - 2019: aaaaad6ac95b402fe18d019d67897ced6b316ee0
2022-05-09scripted-diff: Rename MainSignalsInstance() class to MainSignalsImpl()Jon Atack
``` -BEGIN VERIFY SCRIPT- s() { git grep -l "$1" src test doc | xargs sed -i "s/$1/$2/g"; } s 'MainSignalsInstance' 'MainSignalsImpl' -END VERIFY SCRIPT-
2022-05-09refactor: remove unused forward declarations in validationinterface.hJon Atack
2022-05-09refactor: make MainSignalsInstance() a classJon Atack
and use Doxygen documentation for it, per our developer notes. Context: MainSignalsInstance was created in 3a19fed9db5 and originally was a struct collection of boost::signals methods moved to validationinterface.cpp, in order to no longer need to include boost/signals in validationinterface.h. MainSignalsInstance then evolved in d6815a23131 to remove boost/signals2 and became class-like. [C.8: Use class rather than struct if any member is non-public](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-class) [C.2: Use class if the class has an invariant; use struct if the data members can vary independently](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c2-use-class-if-the-class-has-an-invariant-use-struct-if-the-data-members-can-vary-independently) A class also has the advantage of default private access, as opposed to public for a struct.
2022-02-25Add coinstatsindex_unclean_shutdown testRyan Ofsky
2020-09-22Add 'sequence' zmq publisher to track all block (dis)connects, mempool deltasGregory Sanders
Using the zmq notifications to avoid excessive mempool polling can be difficult given the current notifications available. It announces all transactions being added to mempool or included in blocks, but announces no evictions and gives no indication if the transaction is in the mempool or a block. Block notifications for zmq are also substandard, in that it only announces block tips, while all block transactions are still announced. This commit adds a unified stream which can be used to closely track mempool: 1) getrawmempool to fill out mempool knowledge 2) if txhash is announced, add or remove from set based on add/remove flag 3) if blockhash is announced, get block txn list, remove from those transactions local view of mempool 4) if we drop a sequence number, go to (1) The mempool sequence number starts at the value 1, and increments each time a transaction enters the mempool, or is evicted from the mempool for any reason, including block inclusion. The mempool sequence number is published via ZMQ for any transaction-related notification. These features allow for ZMQ/RPC consumer to track mempool state in a more exacting way, without unnecesarily polling getrawmempool. See interface_zmq.py::test_mempool_sync for example usage.
2020-05-22trivial: Suggested cleanups to surrounding codeRussell Yanofsky
https://github.com/bitcoin/bitcoin/pull/18982#pullrequestreview-416974841
2020-05-15wallet: Minimal fix to restore conflicted transaction notificationsRussell Yanofsky
This fix is a based on the fix by Antoine Riard <ariard@student.42.fr> in https://github.com/bitcoin/bitcoin/pull/18600. Unlike that PR, which implements some new behavior, this just restores previous wallet notification and status behavior for transactions removed from the mempool because they conflict with transactions in a block. The behavior was accidentally changed in two `CWallet::BlockConnected` updates: a31be09bfd77eed497a8e251d31358e16e2f2eb1 and 7e89994133725125dddbfa8d45484e3b9ed51c6e from https://github.com/bitcoin/bitcoin/pull/16624, causing issue https://github.com/bitcoin/bitcoin/issues/18325. The change here could be improved and replaced with a more comprehensive cleanup, so it includes a detailed comment explaining future considerations. Fixes #18325 Co-authored-by: Antoine Riard <ariard@student.42.fr>
2020-05-13validationinterface: Rework documentation, Rename pwalletIn to callbacksMarcoFalke
2020-04-04refactor: drop boost::signals2 in validationinterfaceRussell Yanofsky
Stop using boost::signals2 internally in validationinterface. Replace with std::list and Add/Remove/Clear/Iterate helper functions. Motivation for change is to reduce dependencies and avoid issues happening with boost versions before 1.59: https://github.com/bitcoin/bitcoin/issues/18517 https://github.com/bitcoin/bitcoin/pull/18471
2020-03-27Fix wallet unload race conditionRussell Yanofsky
Currently it's possible for ReleaseWallet to delete the CWallet pointer while it is processing BlockConnected, etc chain notifications. To fix this, unregister from notifications earlier in UnloadWallet instead of ReleaseWallet, and use a new RegisterSharedValidationInterface function to prevent the CValidationInterface shared_ptr from being deleted until the last notification is actually finished.
2020-03-11[validation interface] Remove vtxConflicted from BlockConnectedJohn Newbery
The wallet now uses TransactionRemovedFromMempool to be notified about conflicted wallet, and no other clients use vtxConflicted.
2020-03-11[wallet] Notify conflicted transactions in TransactionRemovedFromMempoolJohn Newbery
The only CValidationInterface client that cares about transactions that are removed from the mempool because of CONFLICT is the wallet. Start using the TransactionRemovedFromMempool method to notify about conflicted transactions instead of using the vtxConflicted vector in BlockConnected.
2020-01-15scripted-diff: Bump copyright of files changed in 2020MarcoFalke
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
2020-01-15scripted-diff: Replace CCriticalSection with RecursiveMutexMarcoFalke
-BEGIN VERIFY SCRIPT- # Delete outdated alias for RecursiveMutex sed -i -e '/CCriticalSection/d' ./src/sync.h # Replace use of outdated alias with RecursiveMutex sed -i -e 's/CCriticalSection/RecursiveMutex/g' $(git grep -l CCriticalSection) -END VERIFY SCRIPT-
2019-12-30scripted-diff: Bump copyright of files changed in 2019MarcoFalke
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
2019-11-21Fire TransactionRemovedFromMempool from mempool251
This commit fires TransactionRemovedFromMempool callbacks from the mempool and cleans up a bunch of code.
2019-11-05Pass block height in Chain::BlockConnected/Chain::BlockDisconnectedAntoine Riard
To do so we update CValidationInterface::BlockDisconnect to take a CBlockIndex pointing to the block being disconnected. This new parameter will be use in the following commit to establish wallet height.
2019-10-29[validation] Add CValidationState subclassesJohn Newbery
Split CValidationState into TxValidationState and BlockValidationState to store validation results for transactions and blocks respectively.
2019-06-25Remove extra CBlockIndex declarationRJ Rybarczyk
2019-04-10[cleanup] Remove unused CReserveKeyJohn Newbery
2019-04-09[wallet] Schedule tx rebroadcasts in walletJohn Newbery
Removes the now-unused Broadcast/ResendWalletTransactions interface from validationinterface. The wallet_resendwallettransactions.py needs a sleep added at the start to make sure that the rebroadcast scheduler is warmed up before the next block is mined.
2019-04-09[wallet] Keep track of the best block time in the walletJohn Newbery
Move nTimeBestReceived (which is only used for wallet rebroadcasts) into the wallet.
2018-08-26Add compile time checking for all cs_main runtime locking assertionspracticalswift
2018-08-08Merge #13780: 0.17: Pre-branch maintenanceWladimir J. van der Laan
3fc20632a3ad30809356a58d2cf0ea4a4ad4cec3 qt: Set BLOCK_CHAIN_SIZE = 220 (DrahtBot) 2b6a2f4a28792f2fe9dc1be843b1ff1ecae35e8a Regenerate manpages (DrahtBot) eb7daf4d600eeb631427c018a984a77a34aca66e Update copyright headers to 2018 (DrahtBot) Pull request description: Some trivial maintenance to avoid having to do it again after the 0.17 branch off. (The scripts to do this are in `./contrib/`) Tree-SHA512: 16b2af45e0351b1c691c5311d48025dc6828079e98c2aa2e600dc5910ee8aa01858ca6c356538150dc46fe14c8819ed8ec8e4ec9a0f682b9950dd41bc50518fa
2018-07-31Merge #13247: Add tests to SingleThreadedSchedulerClient() and document the ↵MarcoFalke
memory model cbeaa91dbb Update ValidationInterface() documentation to explicitly specify threading and memory model (Jesse Cohen) b296b425a7 Update documentation for SingleThreadedSchedulerClient() to specify the memory model (Jesse Cohen) 9994d01d8b Add Unit Test for SingleThreadedSchedulerClient (Jesse Cohen) Pull request description: As discussed in #13023 I've split this test out into a separate pr This test (and documentation update) makes explicit the guarantee (previously undefined, but implied by the 'SingleThreaded' in `SingleThreadedSchedulerClient()`) - that callbacks pushed to the `SingleThreadedSchedulerClient()` obey the single threaded model for memory and execution - specifically, the callbacks are executed fully and in order, and even in cases where a subsequent callback is executed by a different thread, sequential consistency of memory for all threads executing these callbacks is maintained. Maintaining memory consistency should make the api more developer friendly - especially for users of the validationinterface. To the extent that there are performance implications from this decision, these are not currently present in practice because all use of this scheduler happens on a single thread currently, furthermore the lock should guarantee consistency across callback executions even when callbacks are executed by multiple threads (as the test does). Tree-SHA512: 5d95a7682c402e5ad76b05bc9dfbca99ca64105f62ab9e78f6fc0f6ea8c5277aa399fbb94298e35cc677b0c2181ff17259584bb7ae230e38aa68b85ecbc22856
2018-07-30Update ValidationInterface() documentation to explicitly specify threading ↵Jesse Cohen
and memory model
2018-07-27Update copyright headers to 2018DrahtBot
2018-07-09Remove useless mapRequest tracking that just effects Qt display.Matt Corallo
I thought we had removed this a long time ago, TBH, its really confusing feedback to users that we display whether a tx was broadcast to immediate neighbor nodes, given that has little indication of whether the tx propagated very far.
2018-05-16Merge #13023: Fix some concurrency issues in ActivateBestChain()Wladimir J. van der Laan
dd435ad Add unit tests for signals generated by ProcessNewBlock() (Jesse Cohen) a3ae8e6 Fix concurrency-related bugs in ActivateBestChain (Jesse Cohen) ecc3c4a Do not unlock cs_main in ABC unless we've actually made progress. (Matt Corallo) Pull request description: Originally this PR was just to add tests around concurrency in block validation - those tests seem to have uncovered another bug in ActivateBestChain - this now fixes that bug and adds tests. ActivateBestChain (invoked after a new block is validated) proceeds in steps - acquiring and releasing cs_main while incrementally disconnecting and connecting blocks to sync to the most work chain known (FindMostWorkChain()). Every time cs_main is released the result of FindMostWorkChain() can change - but currently that value is cached across acquisitions of cs_main and only refreshed when an invalid chain is explored. It needs to be refreshed every time cs_main is reacquired. The test added in https://github.com/bitcoin/bitcoin/pull/13023/commits/6094ce73045fe0b4654ff94327c2059512af88fb will occasionally fail without the commit fixing this issue https://github.com/bitcoin/bitcoin/pull/13023/commits/26bfdbaddbb9f13864deb7241c6d513f22c5ab62 Original description below -- After a bug discovered where UpdatedBlockTip() notifications could be triggered out of order (#12978), these unit tests check certain invariants about these signals. The scheduler test asserts that a SingleThreadedSchedulerClient processes callbacks fully and sequentially. The block validation test generates a random chain and calls ProcessNewBlock from multiple threads at random and in parallel. ValidationInterface callbacks verify that the ordering of BlockConnected BlockDisconnected and UpdatedBlockTip events occur as expected. Tree-SHA512: 4102423a03d2ea28580c7a70add8a6bdb22ef9e33b107c3aadef80d5af02644cdfaae516c44933924717599c81701e0b96fbf9cf38696e9e41372401a5ee1f3c
2018-05-12Do not unlock cs_main in ABC unless we've actually made progress.Matt Corallo
Technically, some internal datastructures may be in an inconsistent state if we do this, though there are no known bugs there. Still, for future safety, its much better to only unlock cs_main if we've made progress (not just tried a reorg which may make progress).
2018-04-27Simplify semantics of ChainStateFlushed callbackMatt Corallo
Previously, ChainStateFlushed would fire either if a full flush completed (which can happen due to memory limits, forced flush, or on its own DATABASE_WRITE_INTERVAL timer) *or* on a ChainStateFlushed-specific DATABASE_WRITE_INTERVAL timer. This is both less clear for clients (as there are no guarantees about a flush having actually happened prior to the call), and reults in extra flushes not clearly intended by the code. We drop the second case, providing a strong guarantee without removing the periodit timer-based flushing.
2018-04-27scripted-diff: Rename SetBestChain callback ChainStateFlushedMatt Corallo
This much more accurately captures the meaning of the callback. -BEGIN VERIFY SCRIPT- sed -i 's/SetBestChain/ChainStateFlushed/g' src/validationinterface.h src/validationinterface.cpp src/wallet/wallet.h src/wallet/wallet.cpp src/validation.cpp src/index/txindex.h src/index/txindex.cpp -END VERIFY SCRIPT-
2018-03-14Polish interfaces around PeerLogicValidationVasil Dimov
* Make PeerLogicValidation final to prevent deriving from it [1] * Prevent deletions of NetEventsInterface and CValidationInterface objects via a base class pointer [1] silences the following compiler warning (from Clang 7.0.0): /usr/include/c++/v1/memory:2285:5: error: delete called on non-final 'PeerLogicValidation' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor] delete __ptr; ^ /usr/include/c++/v1/memory:2598:7: note: in instantiation of member function 'std::__1::default_delete<PeerLogicValidation>::operator()' requested here __ptr_.second()(__tmp); ^ init.cpp:201:15: note: in instantiation of member function 'std::__1::unique_ptr<PeerLogicValidation, std::__1::default_delete<PeerLogicValidation> >::reset' requested here peerLogic.reset(); ^
2018-01-03Increment MIT Licence copyright header year on files modified in 2017Akira Takizawa
2017-12-26Add helper to wait for validation interface queue to catch upMatt Corallo
2017-12-26Add an interface to get the queue depth out of CValidationInterfaceMatt Corallo