Test Details Overview

Fix race in online_reps.vote_observed_once (#5196)

* Add shared flag and counter test helpers

A test's observer on a node component can still run after the test
body returns, because node threads keep running until `system` stops
the node. An observer that captured a local by reference then writes
to a dead stack slot. online_reps.vote_observed_once did this, and the
Linux ASAN job reported a stack-use-after-scope when the vote cache
thread delivered the test's vote during teardown.

`nano::test::shared_flag` and `nano::test::shared_counter` keep their
value on the heap and share it between copies, so an observer can
capture a copy whatever the declaration order. The test's flag now
uses it.

* Give the vote cache processor its own config

The vote cache processor read its only setting, `max_triggered`, from
`vote_processor_config` and could not be turned off. It now has
`vote_cache_processor_config` holding `max_triggered` and an `enable`
switch, which `start` honours the way `vote_processor` honours its
own. Neither field is written to the config file: elections rely on
the processor for votes that arrived before they started.

A peering-only node turns it off along with the vote processor. It
runs no elections, so the only change there is one idle thread fewer.

* Keep vote cache deliveries out of online_reps.vote_observed_once

Each election the test starts queues a vote cache lookup. When the
cache thread runs such a lookup only after the test's vote got cached,
it routes the vote a second time. The elections are still active, so
`vote_matched` fires again and the representative is observed again.
If that happens before the test's assertions, `rep_update` is 1
instead of 0.

The test checks what a single call to the router observes, so it
turns the processor off.

__________

Type: commit

Hash: 079ab7c7bbfbcd551219f101dd417b8e95535ddd

Created: yesterday

__________

gr0v1ty/nano-node:079ab7c7bbfbcd551219f101dd417b8e95535ddd

Test Results

Test Case Status Duration Median Deviation Log Graph
5n4pr_conf_10k_bintree PASS 110 s -4.0 s - Show
5n4pr_conf_10k_change PASS 137 s -7.0 s - Show
5n4pr_conf_change_dependant PASS 121 s 7.0 s - -
5n4pr_conf_change_independant PASS 141 s 24.5 s - -
5n4pr_conf_send_dependant PASS 123 s 7.5 s - -
5n4pr_conf_send_independant PASS 115 s -1.0 s - -
5n4pr_rocks_10k_bintree PASS 131 s 13.0 s - -
5n4pr_rocks_10k_change PASS 241 s 76.0 s - -