Skip to content
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

Merged
merged 9 commits into from
Jan 23, 2019

Conversation

lampkin-diet
Copy link

@lampkin-diet lampkin-diet commented Jan 21, 2019

  • move last_updated in Freshness to timestamp
  • Freshness_status in Node_info section will looks like:
    {
    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}}
    }

Andrew Nikitin added 3 commits January 18, 2019 20:08
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())
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we need to

  1. Create a new field get_time_for_3pc_batch which can be overridden in tests similar to get_current_time and is node.utc_epoch() by default
  2. 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()))
  3. Update all freshness unit tests to patch get_time_for_3pc_batch instead of get_current_time.


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
Copy link
Contributor

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():
Copy link
Contributor

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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we need to

  1. Create a new field get_time_for_3pc_batch which can be overridden in tests similar to get_current_time and is node.utc_epoch() by default
  2. 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()))
  3. Update all freshness unit tests to patch get_time_for_3pc_batch instead of get_current_time.

Andrew Nikitin added 3 commits January 22, 2019 16:10
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())
Copy link
Contributor

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

if self._freshness_checker:
return self._freshness_checker.get_last_update_time()

def get_time_for_3pc_batch(self)->int:
Copy link
Contributor

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.

Andrew Nikitin added 3 commits January 23, 2019 10:00
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>
@ashcherbakov ashcherbakov merged commit 4c4fd9e into hyperledger:master Jan 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants