-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[INDY-1928] Add freshness info into validator-info output #1058
[INDY-1928] Add freshness info into validator-info output #1058
Conversation
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
@@ -435,7 +435,7 @@ def register_ledger(self, ledger_id): | |||
if ledger_id not in self.requestQueues: | |||
self.requestQueues[ledger_id] = OrderedSet() | |||
self._freshness_checker.register_ledger(ledger_id=ledger_id, | |||
initial_time=self.get_current_time()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_current_time
is used in unit tests to mock the time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, we need to
- Create a new field
get_time_for_3pc_batch
which can be overridden in tests similar toget_current_time
and isnode.utc_epoch()
by default - Use
get_time_for_3pc_batch
when creating a PrePrepare, and when checking for freshness (self._freshness_checker.check_freshness(self.get_time_for_3pc_batch())
) - Update all freshness unit tests to patch
get_time_for_3pc_batch
instead ofget_current_time
.
plenum/server/validator_info_tool.py
Outdated
|
||
def _is_updated_time_acceptable(self, updated_time): | ||
current_time = self._node.utc_epoch() | ||
return current_time - updated_time <= 2 * self._node.config.STATE_FRESHNESS_UPDATE_INTERVAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make 2
a parameter in config as well (something like ACCEPTABLE_FRESHNESS_INTERVALS_COUNT)
@@ -127,6 +127,10 @@ def test_node_info_section(info, node): | |||
assert len(info['Node_info']['Catchup_status']['Last_txn_3PC_keys']) == 3 | |||
assert info['Node_info']['Catchup_status']['Ledger_statuses'] | |||
assert len(info['Node_info']['Catchup_status']['Ledger_statuses']) == 3 | |||
for idx, ls in info['Node_info']['Catchup_status']['Ledger_statuses'].items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that having information about freshness in 'Catchup_status' is a good idea. Maybe we should create a separate section for this? For example, Freshness_status
?
@@ -435,7 +435,7 @@ def register_ledger(self, ledger_id): | |||
if ledger_id not in self.requestQueues: | |||
self.requestQueues[ledger_id] = OrderedSet() | |||
self._freshness_checker.register_ledger(ledger_id=ledger_id, | |||
initial_time=self.get_current_time()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, we need to
- Create a new field
get_time_for_3pc_batch
which can be overridden in tests similar toget_current_time
and isnode.utc_epoch()
by default - Use
get_time_for_3pc_batch
when creating a PrePrepare, and when checking for freshness (self._freshness_checker.check_freshness(self.get_time_for_3pc_batch())
) - Update all freshness unit tests to patch
get_time_for_3pc_batch
instead ofget_current_time
.
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
@@ -435,7 +435,7 @@ def register_ledger(self, ledger_id): | |||
if ledger_id not in self.requestQueues: | |||
self.requestQueues[ledger_id] = OrderedSet() | |||
self._freshness_checker.register_ledger(ledger_id=ledger_id, | |||
initial_time=self.get_current_time()) | |||
initial_time=self.get_time_for_3pc_batch()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use get_time_for_3pc_batch
for PrePrepare creation
plenum/server/replica.py
Outdated
if self._freshness_checker: | ||
return self._freshness_checker.get_last_update_time() | ||
|
||
def get_time_for_3pc_batch(self)->int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a matter of taste, but I prefer to have this as a field in constructor that can be overridden. This makes the tests more clean from my opinion.
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
{
0: {'Last_updated_time': '2019-01-22 13:27:44+00:00', 'Has_write_consensus': True},
1: {'Last_updated_time': '2019-01-22 13:27:44+00:00', 'Has_write_consensus': True},
2: {'Last_updated_time': '2019-01-22 13:27:44+00:00', 'Has_write_consensus': True}}
}