-
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-1200] Each next 3PC batch have a timestamp not less than the previous one #646
[INDY-1200] Each next 3PC batch have a timestamp not less than the previous one #646
Conversation
lampkin-diet
commented
Apr 24, 2018
- 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
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
…evious one Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
test this please |
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
plenum/common/ledger_manager.py
Outdated
req_handler = node.get_req_handler(ledgerId) | ||
# Assume, that state updating was called before | ||
# state | ||
if req_handler and ledgerId == DOMAIN_LEDGER_ID: |
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.
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()...
plenum/server/ledger_req_handler.py
Outdated
self.state = state | ||
self.ledger = ledger | ||
self.tsRevoc_store = tsRevoc_store |
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.
Why is it called tsRevoc_store
? This looks like just a ts_store
plenum/server/replica.py
Outdated
|
||
def _get_last_timestamp_from_state(self, ledger_id): | ||
last_timestamp = None | ||
if ledger_id == DOMAIN_LEDGER_ID: |
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 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']) |
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 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) |
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.
Should we wait for data equality here?
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.
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 |
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.
Do we have a test where tm < last_accepted_pre_prepare_time, so we choose last_accepted_pre_prepare_time instead?
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.
Yes, in plenum/test/replica/test_get_last_timestamp_from_state.py :: test_choose_ts_from_state
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.
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): |
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 add a test to test_kv_storages
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.
already added into storage/test/test_ts_store.py
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>
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
…dger Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
…accepted Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
test this please |
plenum/server/node.py
Outdated
@@ -175,6 +176,8 @@ def __init__(self, | |||
|
|||
self.primaryStorage = storage or self.getPrimaryStorage() | |||
|
|||
self.stateTsDbStorage = None |
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 mention that this is stateTsStore for domain ledger
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
…evious one (hyperledger#646) * [INDY-1200] Move tsRevocStore from indy-node and support while catchup Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com> * [INDY-1200] Add get_last_key into storages Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com> * [INDY-1200] Each next 3PC batch have a timestamp not less than the previous one Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com> * [INDY-1200] flake8 fixes Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com> * [INDY-1200] add close for stateTsDbStorage Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com> * [INDY-1200] Syntax fix Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com> * [INDY-1200] Rename tsRevoc_store to ts_store Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com> * [INDY-1200] More readable changes Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com> * [INDY-1200] Refactor tests Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com> * [INDY-1200] Fix error Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com> * [INDY-1200] Move ts_store catchuping into postTxnFromCatchupAddedToLedger Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com> * [INDY-1200] tm now calculated from last accepted pptime if tm < last_accepted Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com> * [INDY-1200] Add comment for stateTsDbStorage Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>