Page MenuHomePhabricator

net: dedup and RAII-fy the creation of a copy of CConnman::vNodes
ClosedPublic

Authored by PiRK on Mon, Nov 11, 18:55.

Details

Summary

The following pattern was duplicated in CConnman:

cpp
lock
create a copy of vNodes, add a reference to each one
unlock
... use the copy ...
lock
release each node from the copy
unlock

Put that code in a RAII helper that reduces it to:

cpp
create snapshot "snap"
... use the copy ...
// release happens when "snap" goes out of scope

This is a partial backport of core#21943
https://github.com/bitcoin/bitcoin/pull/21943/commits/75e8bf55f5a014faada7712a9640dc35e8c86f15

Test Plan

ninja all check-all

Event Timeline

PiRK requested review of this revision.Mon, Nov 11, 18:55

Failed tests logs:

====== Bitcoin ABC functional tests: interface_rest.py ======

------- Stdout: -------
2024-11-11T19:07:58.968000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20241111_190213/interface_rest_74
2024-11-11T19:08:00.291000Z TestFramework (INFO): Mine blocks and send Bitcoin Cash to node 1
2024-11-11T19:08:05.706000Z TestFramework (INFO): Test the /tx URI
2024-11-11T19:08:05.707000Z TestFramework (INFO): Query an unspent TXO using the /getutxos URI
2024-11-11T19:08:05.716000Z TestFramework (INFO): Query a spent TXO using the /getutxos URI
2024-11-11T19:08:05.717000Z TestFramework (INFO): Query two TXOs using the /getutxos URI
2024-11-11T19:08:05.717000Z TestFramework (INFO): Query the TXOs using the /getutxos URI with a binary response
2024-11-11T19:08:05.718000Z TestFramework (INFO): Test the /getutxos URI with and without /checkmempool
2024-11-11T19:08:06.835000Z TestFramework (INFO): Test the /block, /blockhashbyheight and /headers URIs
2024-11-11T19:08:06.866000Z TestFramework (INFO): Test tx inclusion in the /mempool and /block URIs
2024-11-11T19:09:07.342000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 147, in main
    self._run_test_internal()
  File "/work/test/functional/test_framework/test_framework.py", line 137, in _run_test_internal
    self.run_test()
  File "/work/test/functional/interface_rest.py", line 397, in run_test
    self.sync_all()
  File "/work/test/functional/test_framework/test_framework.py", line 820, in sync_all
    self.sync_mempools(nodes)
  File "/work/test/functional/test_framework/test_framework.py", line 792, in sync_mempools
    raise AssertionError(f"Mempool sync timed out after {timeout}s:{pool_str}")
AssertionError: Mempool sync timed out after 60s:
  {'fd77151a8ea4ba8b0ebea9c4eff5343642f4735bf81d7e38b36e39444e2cd5ce', '5c7ef2841444e56c73a93b4f8fc012115cfadd6c16e1dfc06372b6f09cae2386', 'aad6ef777f0216e93847176304e0ea30c36846008a30daf7de3a7973fe459e1a'}
  set()
2024-11-11T19:09:07.394000Z TestFramework (INFO): Stopping nodes
2024-11-11T19:09:07.696000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20241111_190213/interface_rest_74
2024-11-11T19:09:07.696000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20241111_190213/interface_rest_74/test_framework.log
2024-11-11T19:09:07.696000Z TestFramework (ERROR): 
2024-11-11T19:09:07.696000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20241111_190213/interface_rest_74' to consolidate all logs
2024-11-11T19:09:07.696000Z TestFramework (ERROR): 
2024-11-11T19:09:07.696000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2024-11-11T19:09:07.696000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2024-11-11T19:09:07.696000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: interface_rest.py

PiRK planned changes to this revision.Mon, Nov 11, 19:21

functional test failure to be investigated

I'm not able to reproduce the failure in 100 runs of the test , but I noticed that the test duration variability is wild, with values ranging from 6s to 41s.
I will backport 27114 to hopefully speed this up.

This revision is now accepted and ready to land.Tue, Nov 12, 18:21