mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
Merge #13023: Fix some concurrency issues in ActivateBestChain()
dd435adAdd unit tests for signals generated by ProcessNewBlock() (Jesse Cohen)a3ae8e6Fix concurrency-related bugs in ActivateBestChain (Jesse Cohen)ecc3c4aDo 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 in6094ce7304will occasionally fail without the commit fixing this issue26bfdbaddbOriginal 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
This commit is contained in:
@@ -61,7 +61,11 @@ protected:
|
||||
*/
|
||||
~CValidationInterface() = default;
|
||||
/**
|
||||
* Notifies listeners of updated block chain tip
|
||||
* Notifies listeners when the block chain tip advances.
|
||||
*
|
||||
* When multiple blocks are connected at once, UpdatedBlockTip will be called on the final tip
|
||||
* but may not be called on every intermediate tip. If the latter behavior is desired,
|
||||
* subscribe to BlockConnected() instead.
|
||||
*
|
||||
* Called on a background thread.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user