Commit Graph

4 Commits

Author SHA1 Message Date
Alexander Block
3a1aeb000e Multiple fixes/refactorings for ChainLocks (#2765)
* Print which DKG type aborted

* Don't directly call EnforceBestChainLock and instead schedule the call

Calling EnforceBestChainLock might result in switching chains, which in
turn might end up calling signals, so we get into a recursive call chain.

Better to call EnforceBestChainLock from the scheduler.

* Regularly call EnforceBestChainLock and reset error flags on locked chain

* Don't invalidate blocks from CChainLocksHandler::TrySignChainTip

As the name of this method implies, it's trying to sign something and not
enforce/invalidate chains. Invalidating blocks is the job of
EnforceBestChainLock.

* Only call ActivateBestChain when tip != best CL tip

* Fix unprotected access of bestChainLockBlockIndex and bail out if its null

* Fix ChainLocks tests after changes in enforcement handling

* Only invoke NotifyChainLock signal from EnforceBestChainLock

This ensures that NotifyChainLock is not prematurely called before the
block is fully connected.

* Use a mutex to ensure that only one thread executes ActivateBestChain

It might happen that 2 threads enter ActivateBestChain at the same time
start processing block by block, while randomly switching between threads
so that sometimes one thread processed the block and then another one
processes it. A mutex protects ActivateBestChain now against this race.

* Rename local copy of bestChainLockBlockIndex to currentBestChainLockBlockIndex

* Don't call ActivateBestChain when best CL is part of the main chain
2019-03-13 16:00:54 +03:00
Alexander Block
d2573c43b6 Only return from wait_for_chainlock when the block is actually processed (#2728)
getblock also returns blocks which are not processed yet or in the middle
of processing.
2019-02-27 20:42:06 +03:00
Alexander Block
54f576ea7c
Fix LLMQ related test failures on Travis (#2666)
* Use fast_dip3_enforcement instead of fast_dip3_activation

DashTestFramework was refactored before ChainLocks got merged, causing tests
to fail now.

* Move updating of DKG debug status into WaitForNextPhase

Otherwise callers of the RPCs might believe that the next phase has already
started and start producing more blocks, which would then cancel the
current session if it happens faster than the phase handler thread can
progress to the next phase.
2019-01-30 14:05:22 +01:00
Alexander Block
886299a400 Implement llmq-chainlocks.py integration tests 2019-01-28 12:24:15 +01:00