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-2073] Dynamic validation for client requests taa acceptance data #1195

Merged

Conversation

andkononykhin
Copy link
Contributor

No description provided.

Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
@andkononykhin andkononykhin changed the title [INDY-2073] Dynamic validation for client taa acceptance data [WIP][ci skip] [INDY-2073] Dynamic validation for client requests taa acceptance data [WIP][ci skip] May 7, 2019
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>
…-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>
@andkononykhin andkononykhin changed the title [INDY-2073] Dynamic validation for client requests taa acceptance data [WIP][ci skip] [INDY-2073] Dynamic validation for client requests taa acceptance data [WIP] May 15, 2019
@andkononykhin
Copy link
Contributor Author

test this please

Signed-off-by: Andrey Kononykhin <andkononykhin@gmail.com>
)

self._node_leecher.register_ledger(ledger_id)

def ledger_info(self, lid: int) -> Optional[LedgerInfo]:
try:
return self.ledgerRegistry[lid]
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, updated

)
return

config_req_handler = self.ledger_to_req_handler.get(CONFIG_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 think it's better to use get_req_handler(ledger_id=CONFIG_LEDGER_ID)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed, updated

if taa_data is not None:
taa, taa_seq_no, taa_txn_time = taa_data

if not taa:
Copy link
Contributor

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.

Copy link
Contributor Author

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

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

return

# TODO not (None or empty) ???
taa_digest = config_req_handler.get_taa_digest() # TODO test that digest match taa
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

taa_aml = {}
# taa_aml = config_req_handler.get_taa_aml()
# if not taa_aml:
# raise TaaAmlNotSetError(
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

self.config.TXN_AUTHOR_AGREEMENT_ACCEPANCE_TIME_BEFORE_TAA
)
ts_higest = (
self.now +
Copy link
Contributor

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.

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, 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>
@@ -18,6 +22,14 @@ class NodeError(Exception):
pass


class PoolError(Exception):
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 need this Error?

Copy link
Contributor Author

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

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?

Copy link
Contributor Author

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>
@andkononykhin andkononykhin changed the title [INDY-2073] Dynamic validation for client requests taa acceptance data [WIP] [INDY-2073] Dynamic validation for client requests taa acceptance data May 17, 2019
if taa_data is not None:
(taa, taa_seq_no, taa_txn_time), taa_digest = taa_data

if taa is None:
Copy link
Contributor

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)


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 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(
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 where TAA is present, but with an empty test.

Copy link
Contributor

@ashcherbakov ashcherbakov left a 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:

  1. Please add a (unit) test where TAA is present, but with an empty test.
  2. Please add a (unit) test for checking that PrePrepare time is used for validation, not node's local time.
  3. Please make sure (a fix and a (unit) test) that no TAA must be present in a request if TAA is not set/disabled.
  4. integration tests with libindy

@ashcherbakov ashcherbakov merged commit 6ba94d3 into hyperledger:master May 17, 2019
@andkononykhin andkononykhin deleted the INDY-2073-request-taa-validation branch May 17, 2019 14:22
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