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-2262: Implementing NodeRegHandler #1397

Merged
merged 16 commits into from
Nov 8, 2019

Conversation

ashcherbakov
Copy link
Contributor

Implemented Items 1, 2 and 4 from INDY-2262 PoA:

  • Implement NodeRegHandler to store uncommitted and committed node regs, as well as nod regs for previous view
  • Store nodeReg in audit ledger
  • Added missing tests to be run by CI
  • some random fixes and improvements

Signed-off-by: ashcherbakov <alexander.sherbakov@dsr-corporation.com>
Signed-off-by: ashcherbakov <alexander.sherbakov@dsr-corporation.com>
Signed-off-by: ashcherbakov <alexander.sherbakov@dsr-corporation.com>
Signed-off-by: ashcherbakov <alexander.sherbakov@dsr-corporation.com>
Signed-off-by: ashcherbakov <alexander.sherbakov@dsr-corporation.com>
Signed-off-by: ashcherbakov <alexander.sherbakov@dsr-corporation.com>
Signed-off-by: ashcherbakov <alexander.sherbakov@dsr-corporation.com>
Signed-off-by: ashcherbakov <alexander.sherbakov@dsr-corporation.com>
Signed-off-by: ashcherbakov <alexander.sherbakov@dsr-corporation.com>
Signed-off-by: ashcherbakov <alexander.sherbakov@dsr-corporation.com>
Signed-off-by: ashcherbakov <alexander.sherbakov@dsr-corporation.com>
Signed-off-by: ashcherbakov <alexander.sherbakov@dsr-corporation.com>
Signed-off-by: ashcherbakov <alexander.sherbakov@dsr-corporation.com>
Signed-off-by: ashcherbakov <alexander.sherbakov@dsr-corporation.com>
Signed-off-by: ashcherbakov <alexander.sherbakov@dsr-corporation.com>
@lgtm-com
Copy link

lgtm-com bot commented Nov 7, 2019

This pull request introduces 2 alerts and fixes 1 when merging 8371cad into 2043fa6 - view on LGTM.com

new alerts:

  • 1 for Conflicting attributes in base classes
  • 1 for Comparison of identical values

fixed alerts:

  • 1 for NotImplemented is not an Exception

@lgtm-com
Copy link

lgtm-com bot commented Nov 8, 2019

This pull request introduces 1 alert and fixes 1 when merging 22e7b4a into 2043fa6 - view on LGTM.com

new alerts:

  • 1 for Conflicting attributes in base classes

fixed alerts:

  • 1 for NotImplemented is not an Exception

@lgtm-com
Copy link

lgtm-com bot commented Nov 8, 2019

This pull request introduces 1 alert and fixes 1 when merging b28a8a9 into 2043fa6 - view on LGTM.com

new alerts:

  • 1 for Conflicting attributes in base classes

fixed alerts:

  • 1 for NotImplemented is not an Exception

Copy link
Member

@skhoroshavin skhoroshavin left a comment

Choose a reason for hiding this comment

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

This looks good overall. Things I would consider changing in future PRs are:

  • intention behind on_catchup_finished hook looks sensible, however name is a bit misleading IMHO. I'd consider naming it like initialize, reset or sync_from_ledgers (or maybe there is better name)
  • we implement same encoding algorithm for different fields in audit ledger again and again, probably it's time to move it into separate set of helper functions?
  • now that node reg is stored in audit ledger - can we remove primaries from audit ledger?

txn[AUDIT_TXN_NODE_REG] = current_node_reg

# 3. Previous primaries field is delta
elif isinstance(last_audit_node_reg, int) and last_audit_node_reg < self.ledger.uncommitted_size:
Copy link
Member

Choose a reason for hiding this comment

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

Probably it makes sense to move check last_audit_node_reg < self.ledger.uncommitted_size inside this brach and throw LogicError if it doesn't hold


if node_name not in self.uncommitted_node_reg and VALIDATOR in services:
# new node added or old one promoted
self.uncommitted_node_reg.append(node_name)
Copy link
Member

Choose a reason for hiding this comment

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

It seems like this code relies on uncommitted_node_reg always being initialized. Is it always the case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. It's called every time a NODE txn is being applied.

@skhoroshavin skhoroshavin merged commit 29adcb0 into hyperledger:master Nov 8, 2019
@ashcherbakov
Copy link
Contributor Author

Thanks for review!

* intention behind `on_catchup_finished` hook looks sensible, however name is a bit misleading IMHO. I'd consider naming it like `initialize`, `reset` or `sync_from_ledgers` (or maybe there is better name)

I agree that the current name is not perfect. However, I believe that our general name convention in BatchHandlers is a callback on some system events (on batch created, on batch reverted, etc.), so on catchup finished looks fine, and it makes clear that this is not an abstract initialization, but the one that needs to be done after catchup is finished.

* we implement same encoding algorithm for different fields in audit ledger again and again, probably it's time to move it into separate set of helper functions?

Fully agree, And there is a TODO comment for this (as well as for other improvements I would like to have). The PR is huge even without these changes, so I suggest to do it in one of the next PRs.

* now that node reg is stored in audit ledger - can we remove primaries from audit ledger?

In theory yes, but I'm not sure that we must do it.
We should defenetly remove FuturePrimariesBatch Handler (this will be done in the next PR)
As for removing Priomaries, I'm not so sure because:

  • This is the only easy way to jump to the previous view in audit ledger (and we do use this in NodeRegHandler)
  • We may have another algorithm for primaries selection besides round robin
  • It's quite cheap to store them as we use deltas

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