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

Anoncreds - Cred Def and Revocation Endorsement #2752

Merged
merged 4 commits into from
Feb 9, 2024

Conversation

jamshale
Copy link
Contributor

@jamshale jamshale commented Jan 31, 2024

  • Implements anoncreds endorsement of cred def's and revocation objects
  • enables the integration tests both manual and auto endorsement transactions

For the anoncreds transaction objects the previous implementation changed the structure of the objects. I really didn't like this so I changed it in the indy ledger module with if statements.

I changed the optional[dict] params in anoncreds to be an empty dict by default to avoid null checking in a lot of places.

Note: The only thing not completed for single tenant is publishing revocations. I want to do this in another task/PR. I created an integration test for anoncreds that stops just prior to publishing revocations.

@ianco
Copy link
Contributor

ianco commented Jan 31, 2024

FYI I've noticed some integration tests are now failing, for example:

AGENT_PORT_OVERRIDE=8030 ./run_bdd -t @RFC0586 -t @WalletType_Askar_AnonCreds

(Note that these aren't tagged as @GHA so they aren't included in the set of tests that runs on a PR. Possibly we should add this tag to these tests ... they haven't been included so far as the anoncreds/endorsement is still in progress)

@jamshale
Copy link
Contributor Author

@ianco Ya I had the integration tests working but then I did some refactoring and broke them somehow. Was going to try and look at why this happened today.

@jamshale
Copy link
Contributor Author

FYI I've noticed some integration tests are now failing, for example:

AGENT_PORT_OVERRIDE=8030 ./run_bdd -t @RFC0586 -t @WalletType_Askar_AnonCreds

(Note that these aren't tagged as @GHA so they aren't included in the set of tests that runs on a PR. Possibly we should add this tag to these tests ... they haven't been included so far as the anoncreds/endorsement is still in progress)

I know these had been working. I'll work on fixing them and then I will add them to run on a PR.

@jamshale jamshale force-pushed the main branch 2 times, most recently from 1e0af89 to 54d234e Compare February 1, 2024 18:38
@jamshale jamshale marked this pull request as ready for review February 1, 2024 18:50
@jamshale jamshale requested review from ianco and dbluhm February 7, 2024 17:28
@jamshale
Copy link
Contributor Author

jamshale commented Feb 7, 2024

Updated description. Ready for review. Integration tests should pass.

@jamshale
Copy link
Contributor Author

jamshale commented Feb 7, 2024

Hmm. Some integration tests are failing. I'll have to look into it.

@ianco
Copy link
Contributor

ianco commented Feb 7, 2024

Hmm. Some integration tests are failing. I'll have to look into it.

Looks like you're trying to issue the credential before the revocation registry is active. Try just running alice/faber with the --revocation flag (and anoncreds-askar wallet) and try to issue the credential manually.

@jamshale
Copy link
Contributor Author

jamshale commented Feb 7, 2024

Hmm. Some integration tests are failing. I'll have to look into it.

Looks like you're trying to issue the credential before the revocation registry is active. Try just running alice/faber with the --revocation flag (and anoncreds-askar wallet) and try to issue the credential manually.

I think I was focusing to much on the endorsement tests and might have broke creating the registry for non-endorsement. Good thing we have so many integration tests. Hopefully it's minor. Will ping you when it's fixed.

@jamshale
Copy link
Contributor Author

jamshale commented Feb 7, 2024

@ianco I did have a logic issue with the various configs/params. Tests are passing now.

@jamshale
Copy link
Contributor Author

jamshale commented Feb 8, 2024

One integration test is failing, even though it passed one time. I think it's taking too long to create the revocation registry. Going to try and fix it.

@ianco
Copy link
Contributor

ianco commented Feb 8, 2024

One integration test is failing, even though it passed one time. I think it's taking too long to create the revocation registry. Going to try and fix it.

It's possibly creating the revocation registry but not activating it:

      Traceback (most recent call last):
        File "/home/aries/.local/lib/python3.9/site-packages/behave/model.py", line 1329, in run
          match.run(runner.context)
        File "/home/aries/.local/lib/python3.9/site-packages/behave/matchers.py", line 98, in run
          self.func(context, *args, **kwargs)
        File "features/steps/0586-sign-transaction.py", line 421, in step_impl
          assert len(rev_regs["rev_reg_ids"]) >= 1
      AssertionError

(There should always be exactly one Active revocation registry per cred def, even though there may be more than one created)

@jamshale jamshale marked this pull request as draft February 9, 2024 15:58
@jamshale jamshale marked this pull request as ready for review February 9, 2024 17:34
Signed-off-by: jamshale <[email protected]>
Copy link

sonarqubecloud bot commented Feb 9, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link
Contributor

@ianco ianco left a comment

Choose a reason for hiding this comment

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

LGTM. I did a quick scan of the code and ran the demo. Looks like all the tests are passing. Good job!

@jamshale jamshale merged commit 232d755 into openwallet-foundation:main Feb 9, 2024
8 checks passed
@swcurran
Copy link
Contributor

swcurran commented Feb 9, 2024

W00t! Nicely done!

@@ -144,7 +144,7 @@ async def register_schema(
self,
profile: Profile,
schema: AnonCredsSchema,
options: Optional[dict] = None,
options: dict = {},
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, default empty dicts in args are 'dangerous' in python:
https://stackoverflow.com/questions/26320899/why-is-the-empty-dictionary-a-dangerous-default-value-in-python

Pylint warns about it, so ruff should probably pick up on this? @dbluhm (because you know about the ruff config)

Copy link
Contributor

Choose a reason for hiding this comment

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

Really good point. Looks like this would be covered by rule B006, which we don't currently have activated.

@jamshale it would be great to see a follow up PR to add checks for this rule and fix this argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll have another PR for the publish revocations and I'll do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had no idea python did that. Seems really odd a default function argument wouldn't be scoped to the function.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have personal experience with this foot-gun lol. Debugging without the context of the "static" evaluation of the default arguments was a nightmare. The Ruff check will be good to help prevent future headaches.

endorser_connection_id = fields.Str(
metadata={
"description": endorser_connection_id_description,
"required": False,
Copy link
Contributor

Choose a reason for hiding this comment

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

required is not a metadata field -- should be passed as required = False, metadata=...
I'll fix in my deprecation warnings PR (which had merge conflicts here)

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.

5 participants