HomePhabricator

[avalanche] Don't hold cs_main when adding a block to reconcile

Description

[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

Details

Provenance
FabienAuthored on Jan 16 2023, 16:40
FabienPushed on Jan 17 2023, 19:31
Reviewer
Restricted Project
Differential Revision
D12983: [avalanche] Don't hold cs_main when adding a block to reconcile
Parents
rABCd67474db0eea: [avalanche] Create a generic vote map that can have any kind of item being…
Branches
Unknown
Tags
Unknown