Repository navigation
fix(anoncreds-upgrade): tag cred defs with their own schema and fix Schema.create argument order - #4301
Conversation
1a97d5e to
717d33f
Compare
upgrade_all_records_with_transaction passed the schema from the last loop iteration to every cred def upgrade, so cred defs issued under an earlier schema were rewritten with the wrong schema name, version and issuer. Look up the schema by the cred def's schema_id instead, and fail the upgrade explicitly if the schema record is missing. Signed-off-by: KutluhanETH <kutluhaneth46@users.noreply.github.com>
get_schema_upgrade_object called Schema.create(issuer_id-less positional args) as (schema_id, name, issuer_did, attrs), but the signature is (name, version, issuer_id, attr_names). Upgraded schemas therefore had the schema id as their name and the schema name as their version, and the cred defs built from them carried the same swapped schema_name and schema_version tags, so filtering by schema_name returned nothing. Pass the stored schema_name and schema_version instead. Signed-off-by: KutluhanETH <kutluhaneth46@users.noreply.github.com>
Signed-off-by: KutluhanETH <kutluhaneth46@users.noreply.github.com>
717d33f to
7ea781e
Compare
Signed-off-by: KutluhanETH <kutluhaneth46@users.noreply.github.com>
|
|
Hi, I pushed an empty commit (c009e4d) to re-trigger the BDD Integration Tests after the earlier run failed on a ledger upload timeout in The re-run did not come back green. It now fails in two revocation scenarios from the same feature ( Everything else on the head is green (lint, unit tests, PostgreSQL integration, CodeQL, SonarCloud, DCO). Could a maintainer re-run the BDD job or check whether these scenarios are known flakes? I can also adjust the PR if something specific should change. Thank you! |
jamshale
left a comment
There was a problem hiding this comment.
I'm hoping this isn't a huge issue because we've already upgraded wallets in production. I don't think this lookup should cause major issues. Thanks for finding and fixing it.



Part of #4175
Summary
While reproducing #4175 against the public BCovrin test ledger (askar to askar-anoncreds issuer upgrade), I found two bugs in
acapy_agent/wallet/anoncreds_upgrade.pythat corrupt the migrated schema and credential definition records. Both are fixed here.upgrade_all_records_with_transaction: every credential definition was tagged with the schema of the last loop iteration, because the loop reusedschema_upgrade_obj.schemainstead of looking up the schema by the cred def'sschema_id. Schemas are now indexed by id and each cred def gets its own schema.get_schema_upgrade_object:Schema.createreceived(schema_id, schema_name, ...)while its signature is(name, version, issuer_id, attr_names), so the schema id ended up innameand the schema name inversion. The arguments are now passed in the correct order.Testing
askar-anoncredswallet.test_upgrade_cred_defs_use_their_own_schemaandtest_schema_upgrade_object_keeps_schema_name_and_version.acapy_agent/wallet/tests/test_anoncreds_upgrade.py: all tests pass.pytest acapy_agentrun: passes.ruff checkandruff format --checkpass on both changed files.Notes
This PR does not claim to fix the credential-loss part of #4175. In my holder-side repro (issuer and holder on askar, upgrade to
askar-anoncreds), the credential stayed visible on/credentialsafter the restart, with both sqlite and postgres storage. Thekanon-anoncredsholder path showed an empty/credentialsresult, but in this codebase there is no basekanonwallet type, and the restart opens a separate store (dbstore/sqlite_dbstore.db) that the upgrade does not populate. I have not changed that path here.