GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Commit a050110d authored by juga  's avatar juga

fix: relaylist: Stop measuring relays not in the consenus

as this might cause many circuit errors.
They're already added to the generator.
Also adapt the number in test_init_relays.

Closes: #40037.

Happy solstice! :)
parent 713d4004
Pipeline #2081 failed with stage
in 43 minutes and 3 seconds
...@@ -14,7 +14,7 @@ from ..globals import ( ...@@ -14,7 +14,7 @@ from ..globals import (
MAX_RECENT_PRIORITY_LIST_COUNT, MAX_RECENT_PRIORITY_LIST_COUNT,
MEASUREMENTS_PERIOD MEASUREMENTS_PERIOD
) )
from ..util import timestamp, timestamps from ..util import timestamps
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -250,12 +250,6 @@ class Relay: ...@@ -250,12 +250,6 @@ class Relay:
def relay_recent_priority_list_count(self): def relay_recent_priority_list_count(self):
return len(self.relay_recent_priority_list) return len(self.relay_recent_priority_list)
def is_old(self):
"""Whether the last consensus seen for this relay is older than the
measurement period.
"""
return timestamp.is_old(self.last_consensus_timestamp)
# XXX: tech-debt: replace `_desc` attr by a a `dequee` of the last # XXX: tech-debt: replace `_desc` attr by a a `dequee` of the last
# descriptors seen for this relay and the timestamp. # descriptors seen for this relay and the timestamp.
def update_server_descriptor(self, server_descriptor): def update_server_descriptor(self, server_descriptor):
...@@ -417,11 +411,10 @@ class RelayList: ...@@ -417,11 +411,10 @@ class RelayList:
# already added to the new list. # already added to the new list.
new_relays_dict.pop(fp) new_relays_dict.pop(fp)
# If the relay is not in the current consensus but is not "old" # In #30727, the relay that is not in the current conensus but is
# yet, add it to the new list of relays too, though its timestamp, # not "old", was added to the new list of relays too.
# router status and descriptor can't be updated. # In #40037 we think it should not be measured, as it might cause
elif not r.is_old(): # many circuit errors. It's already added to the generator.
new_relays.append(r)
# Otherwise, don't add it to the new list of relays. # Otherwise, don't add it to the new list of relays.
# For debugging, count the old relays that will be discarded. # For debugging, count the old relays that will be discarded.
else: else:
......
...@@ -51,7 +51,7 @@ def test_init_relays( ...@@ -51,7 +51,7 @@ def test_init_relays(
assert 6505 == 6433 + len(added_fps) assert 6505 == 6433 + len(added_fps)
# The calculated min bw for the second hop # The calculated min bw for the second hop
assert 2120000 == relay_list._exit_min_bw assert 2120000 == relay_list._exit_min_bw
assert 200000 == relay_list._non_exit_min_bw assert 210000 == relay_list._non_exit_min_bw
# Five days later plus 1 second. # Five days later plus 1 second.
# The first consensus timestamp will get removed. # The first consensus timestamp will get removed.
...@@ -69,10 +69,10 @@ def test_init_relays( ...@@ -69,10 +69,10 @@ def test_init_relays(
removed_fps = fps.difference(fps_5days_later) removed_fps = fps.difference(fps_5days_later)
# The number of relays will be the number of relays in the cosensus plus # The number of relays will be the number of relays in the cosensus plus
# the added ones minus the removed ones. # the added ones minus the removed ones.
assert 6925 == 6505 + len(added_fps) - len(removed_fps) assert 6596 == 6505 + len(added_fps) - len(removed_fps)
# The calculated min bw for the second hop # The calculated min bw for the second hop
assert 2790000 == relay_list._exit_min_bw assert 2800000 == relay_list._exit_min_bw
assert 110000 == relay_list._non_exit_min_bw assert 150000 == relay_list._non_exit_min_bw
def test_increment_recent_measurement_attempt(args, conf, controller): def test_increment_recent_measurement_attempt(args, conf, controller):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment