[avalanche] Don't hold cs_main when adding a block to reconcile
Summary:
This has 2 benefits:
- It prevents a recursive lock of cs_main
- It will prevent a deadlock after we switched to a single vote records structure
Note that this also fixes a subtle bug as a side effect: before this patch the node could poll for a block before it gets added to the chain, leading to a spurious initial "no" vote.
As a consequence the avalanche voting functional test needs a slight adjustment, which also makes it more correct.
A unit test is added to exibit the bug, and demonstrates that it's fixed with this patch.
Test Plan:
With Clang and Debug:
ninja check-all ninja check-extended ./contrib/teamcity/build-configurations.py build-tsan
Reviewers: #bitcoin_abc, sdulfari
Reviewed By: #bitcoin_abc, sdulfari
Subscribers: sdulfari
Differential Revision: https://reviews.bitcoinabc.org/D12983