-
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-2073] Dynamic validation for client requests taa acceptance data #1195
[INDY-2073] Dynamic validation for client requests taa acceptance data #1195
Conversation
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
…-2073-request-taa-validation
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
…-2073-request-taa-validation
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
…-2073-request-taa-validation Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
test this please |
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
plenum/common/ledger_manager.py
Outdated
) | ||
|
||
self._node_leecher.register_ledger(ledger_id) | ||
|
||
def ledger_info(self, lid: int) -> Optional[LedgerInfo]: | ||
try: | ||
return self.ledgerRegistry[lid] |
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 don't we use self.ledgerRegistry,get(lid)
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.
thanks, updated
plenum/server/node.py
Outdated
) | ||
return | ||
|
||
config_req_handler = self.ledger_to_req_handler.get(CONFIG_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 think it's better to use get_req_handler(ledger_id=CONFIG_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.
agreed, updated
plenum/server/node.py
Outdated
if taa_data is not None: | ||
taa, taa_seq_no, taa_txn_time = taa_data | ||
|
||
if not taa: |
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.
In case of empty TAA, only the test is empty, but the version is not. So, not taa
check is not enough 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.
updated
# "Txn Author Agreement acceptance mechanism list is not defined" | ||
# ) # TODO test | ||
|
||
if not request.taaAcceptance: |
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 think it makes sense to do this check before 2 previous ones (AML check and TAA_digest check), right after we decide if we need a TAA. This can save some time going into states (for AML and digest)
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.
updated
plenum/server/node.py
Outdated
return | ||
|
||
# TODO not (None or empty) ??? | ||
taa_digest = config_req_handler.get_taa_digest() # TODO test that digest match taa |
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.
We've already get TAA data for the 'latest' key. When doing this, we've already got the digest as well (because we have 'latest' -> 'digest' and 'digest' -> 'data'). So, there is no need to go to the state again.
I think get_taa_data
needs to return the digest as well.
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.
done
plenum/server/node.py
Outdated
taa_aml = {} | ||
# taa_aml = config_req_handler.get_taa_aml() | ||
# if not taa_aml: | ||
# raise TaaAmlNotSetError( |
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 think we can raise a LogicError here, since there is a dynamic validation that TAA can be set only after there is non-empty AML present. So, according to this logic, TAA without an AML can not happen.
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.
updated
plenum/server/node.py
Outdated
self.config.TXN_AUTHOR_AGREEMENT_ACCEPANCE_TIME_BEFORE_TAA | ||
) | ||
ts_higest = ( | ||
self.now + |
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.
It looks like we need to use the time of the primary's PrePrepare this request is present in instead of the local node's 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.
yes, updated
…-2073-request-taa-validation Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
…-2073-request-taa-validation Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
…-2073-request-taa-validation Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
plenum/common/exceptions.py
Outdated
@@ -18,6 +22,14 @@ class NodeError(Exception): | |||
pass | |||
|
|||
|
|||
class PoolError(Exception): |
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 need this Error?
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.
Not so much
def get_taa_data(self, digest: Optional[str] = None, | ||
version: Optional[str] = None, | ||
isCommitted: bool = True) -> Optional[Dict]: | ||
isCommitted: bool = True) -> Tuple[Optional[Dict], Optional[str]]: | ||
data = None | ||
if digest is 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.
If digest is not None, then None
data will be returned. Is it intended?
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.
right, fixed
Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
if taa_data is not None: | ||
(taa, taa_seq_no, taa_txn_time), taa_digest = taa_data | ||
|
||
if taa is 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.
After a discussion with Andrey, we decided that no TAA must be present in a request if TAA is not set/disabled.
): | ||
validate_taa_acceptance(domain_req, pp_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.
Please add a test for checking that PrePrepare time is used for validation, not node's local time.
|
||
|
||
@pytest.mark.taa_acceptance_missed | ||
def test_taa_acceptance_missed_during_disabled_taa( |
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 where TAA is present, but with an empty test.
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.
Approving, but please make sure that we do the following in the next PR:
- Please add a (unit) test where TAA is present, but with an empty test.
- Please add a (unit) test for checking that PrePrepare time is used for validation, not node's local time.
- Please make sure (a fix and a (unit) test) that no TAA must be present in a request if TAA is not set/disabled.
- integration tests with libindy
No description provided.