Page MenuHomePhabricator

[avalanche] replace banscore int with disconnect bool in registerVotes
ClosedPublic

Authored by PiRK on Tue, Apr 29, 10:19.

Details

Summary

The banscore was always 0 or 100 (which causes disconnection), so we can simplify the logic by using a boolean without changing behavior.

Test Plan

ninja all check-all

Event Timeline

PiRK requested review of this revision.Tue, Apr 29, 10:19
PiRK added inline comments.
src/avalanche/processor.cpp
586 ↗(On Diff #53744)

oops

Failed tests logs:

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

------- Stdout: -------
2025-04-29T10:29:32.981000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250429_102508_26041/p2p_timeouts_259
2025-04-29T10:31:33.610000Z TestFramework.utils (ERROR): wait_until() failed. Predicate: ''''
        def test_function():
            if check_connected:
                assert self.is_connected
            return test_function_in()
'''
2025-04-29T10:31:33.611000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 152, in main
    self._run_test_internal()
  File "/work/test/functional/test_framework/test_framework.py", line 142, in _run_test_internal
    self.run_test()
  File "/work/test/functional/p2p_timeouts.py", line 94, in run_test
    no_version_node.wait_for_disconnect()
  File "/work/test/functional/test_framework/p2p.py", line 599, in wait_for_disconnect
    self.wait_until(test_function, timeout=timeout, check_connected=False)
  File "/work/test/functional/test_framework/p2p.py", line 582, in wait_until
    wait_until_helper(
  File "/work/test/functional/test_framework/util.py", line 309, in wait_until_helper
    raise AssertionError(
AssertionError: Predicate ''''
        def test_function():
            if check_connected:
                assert self.is_connected
            return test_function_in()
''' not true after 120.0 seconds
2025-04-29T10:31:33.662000Z TestFramework (INFO): Stopping nodes
2025-04-29T10:31:33.764000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250429_102508_26041/p2p_timeouts_259
2025-04-29T10:31:33.764000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250429_102508_26041/p2p_timeouts_259/test_framework.log
2025-04-29T10:31:33.764000Z TestFramework (ERROR): 
2025-04-29T10:31:33.764000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_🏃_20250429_102508_26041/p2p_timeouts_259' to consolidate all logs
2025-04-29T10:31:33.765000Z TestFramework (ERROR): 
2025-04-29T10:31:33.765000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2025-04-29T10:31:33.765000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2025-04-29T10:31:33.765000Z TestFramework (ERROR):

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

rebase to clean CI. The test failure was for the previous diff version

Fabien requested changes to this revision.Tue, Apr 29, 13:52
Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/net_processing.cpp
6732

I actually disagree with you on this one, and I think setting it to false by default bool disconnect{false} makes it more readable, it documents that the registerVotes() function is expected to turn it true upon misbehavior.

This revision now requires changes to proceed.Tue, Apr 29, 13:52
PiRK edited the summary of this revision. (Show Details)

initialize disconnect when declaring it. Just don't overwrite false with false

Fabien requested changes to this revision.Tue, Apr 29, 15:31

You still want to set it to false in the function, so it is never left untouched. It's just defensive programming to initialize to false at the callsite.

This revision now requires changes to proceed.Tue, Apr 29, 15:31

set it also to false in registerVotes

This revision is now accepted and ready to land.Tue, Apr 29, 16:16