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-1200] Each next 3PC batch have a timestamp not less than the previous one #646

Merged
merged 14 commits into from
Apr 27, 2018

Conversation

lampkin-diet
Copy link

  • Move tsRevocStore from indy-node
  • Set into this store now in "commit" action and in catchup procedure for all txn
  • Add "get_last_key" into storages
  • Each next 3PC batch have a timestamp not less than the previous one

@dsurnin
Copy link
Contributor

dsurnin commented Apr 25, 2018

test this please

Andrew Nikitin added 2 commits April 25, 2018 11:54
Signed-off-by: Andrew Nikitin <[email protected]>
req_handler = node.get_req_handler(ledgerId)
# Assume, that state updating was called before
# state
if req_handler and ledgerId == DOMAIN_LEDGER_ID:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we do it here and not from postTxnFromCatchupAddedToLedger? Shouldn't it be called automatically when we update the state?
Looks like we also call it from ledger_req_handler's commit()...

self.state = state
self.ledger = ledger
self.tsRevoc_store = tsRevoc_store
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it called tsRevoc_store? This looks like just a ts_store


def _get_last_timestamp_from_state(self, ledger_id):
last_timestamp = None
if ledger_id == DOMAIN_LEDGER_ID:
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like too deep if-else hierarchy (more than 2).
I think the following pattern is more readable:

if not condition1:
    return
do_something()
if not condition2:
    return
....

Not so critical for this particular method since it's not so big.

for reply in sdk_replies:
key = req_handler.prepare_buy_key(reply[1]['result']['identifier'],
reply[1]['result']['reqId'])
root_hash = req_handler.tsRevoc_store.get_equal_or_prev(reply[1]['result']['txnTime'])
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add assert root_hash

sdk_wallet_steward,
1)[0][1]
reconnect_node_and_ensure_connected(looper, txnPoolNodeSet, node_to_disconnect)
ts_from_state = node_to_disconnect.master_replica._get_last_timestamp_from_state(DOMAIN_LEDGER_ID)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we wait for data equality here?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, it would be added

req_handler = primary_node.getDomainReqHandler()
req_handler.tsRevoc_store.set(excpected_ts,
req_handler.state.headHash)
primary_node.master_replica.last_accepted_pre_prepare_time = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have a test where tm < last_accepted_pre_prepare_time, so we choose last_accepted_pre_prepare_time instead?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, in plenum/test/replica/test_get_last_timestamp_from_state.py :: test_choose_ts_from_state

Copy link
Contributor

Choose a reason for hiding this comment

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

But we set last_accepted_pre_prepare_time to None here, so it's taken from the state.

@@ -40,3 +40,12 @@ def get_equal_or_prev(self, key):
except StopIteration:
value = None
return value

def get_last_key(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a test to test_kv_storages

Copy link
Author

Choose a reason for hiding this comment

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

already added into storage/test/test_ts_store.py

@lampkin-diet
Copy link
Author

test this please

@@ -175,6 +176,8 @@ def __init__(self,

self.primaryStorage = storage or self.getPrimaryStorage()

self.stateTsDbStorage = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Please mention that this is stateTsStore for domain ledger

@lampkin-diet lampkin-diet changed the title Public/indy 1200 [INDY-1200] Each next 3PC batch have a timestamp not less than the previous one Apr 26, 2018
@ashcherbakov ashcherbakov merged commit 29c3c2a into hyperledger:master Apr 27, 2018
lovesh pushed a commit to evernym/indy-plenum that referenced this pull request May 3, 2018
…evious one (hyperledger#646)

* [INDY-1200] Move tsRevocStore from indy-node and support while catchup

Signed-off-by: Andrew Nikitin <[email protected]>

* [INDY-1200] Add get_last_key into storages

Signed-off-by: Andrew Nikitin <[email protected]>

* [INDY-1200] Each next 3PC batch have a timestamp not less than the previous one

Signed-off-by: Andrew Nikitin <[email protected]>

* [INDY-1200] flake8 fixes

Signed-off-by: Andrew Nikitin <[email protected]>

* [INDY-1200] add close for stateTsDbStorage

Signed-off-by: Andrew Nikitin <[email protected]>

* [INDY-1200] Syntax fix

Signed-off-by: Andrew Nikitin <[email protected]>

* [INDY-1200] Rename tsRevoc_store to ts_store

Signed-off-by: Andrew Nikitin <[email protected]>

* [INDY-1200] More readable changes

Signed-off-by: Andrew Nikitin <[email protected]>

* [INDY-1200] Refactor tests

Signed-off-by: Andrew Nikitin <[email protected]>

* [INDY-1200] Fix error

Signed-off-by: Andrew Nikitin <[email protected]>

* [INDY-1200] Move ts_store catchuping into postTxnFromCatchupAddedToLedger

Signed-off-by: Andrew Nikitin <[email protected]>

* [INDY-1200] tm now calculated from last accepted pptime if tm < last_accepted

Signed-off-by: Andrew Nikitin <[email protected]>

* [INDY-1200] Add comment for stateTsDbStorage

Signed-off-by: Andrew Nikitin <[email protected]>
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.

3 participants