-
Notifications
You must be signed in to change notification settings - Fork 529
Fix: Use correct profile context for ledger signing during revocation setup (#3624) #3649
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
base: main
Are you sure you want to change the base?
Conversation
You've done a ton of investigation and debugging -- thank you! I'd like to understand more of what's going on here. Passing a profile to a ledger method is a bit odd; Ledger instances are obtained through the injection context where a provider is bound on profile creation: acapy/acapy_agent/askar/profile.py Lines 139 to 156 in 8a83571
The ledger should only ever interact with this profile that it's instantiated with. Passing different profiles to a method is working against the patterns and assumptions baked into ACA-Py so I think we need to find another solution. |
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.
PS: sign commits with DCO, can be done with git rebase -i HEAD~7
and reword commits
36d99f8
to
76146aa
Compare
@dbluhm , thanks for the feedback and the reference to the intended injection pattern. I completely agree that, ideally, the BaseLedger instance obtained via injection should inherently have the correct profile context it was created with, and we shouldn't need to pass the profile around explicitly to its methods. However, the extensive debugging undertaken for this issue (partially documented in the issue comments and detailed in related discussions) revealed a breakdown in this pattern specifically within the asynchronous revocation setup flow following credential definition creation with endorsement enabled. Here's a summary of the findings that led to the current solution: Correct Initial Context: The process starts correctly. The initial API request, the event handler (on_rev_reg_def), and the subsequent service calls (AnonCredsRevocation, AnonCredsRegistry, LegacyIndyRegistry._revoc_reg_entry_with_fix) all demonstrably operate with the correct tenant profile context. The Problem Point: get_ledger_for_identifier: The critical failure point occurred when retrieving the ledger instance within profile prior to here is the correct tenant profileacapy/acapy_agent/anoncreds/default/legacy_indy/registry.py Lines 806 to 815 in 80d797c
From this point, 'ledger.profile' referenced the admin profileDetailed logging confirmed that while The underlying cause appears to be that the Failure Mechanism: Consequently, when _revoc_reg_entry_with_fix called methods on the returned ledger object (specifically ledger.send_revoc_reg_entry which internally calls ledger._submit), those methods use self.profile (the incorrect admin profile) for wallet operations like signing. This resulted in the WalletNotFoundError because the tenant's signing key wasn't found in the admin wallet. The Chosen Fix (Explicit Profile Passing): Given that the calling code (like _revoc_reg_entry_with_fix) did have the correct tenant profile object available, the most direct way to fix the immediate signing failure was to explicitly pass this correct profile down to the ledger methods (send_revoc_reg_entry, _submit, etc.). These methods were modified to prioritize the passed profile parameter over their potentially incorrect self.profile for wallet/TAA operations. This effectively bypasses the incorrectly profiled ledger instance returned by the manager for those specific sensitive operations. While this approach deviates from the ideal injection pattern, it directly addresses the identified failure mode where the ledger instance provided by the current infrastructure lacked the necessary tenant context. Fixing the root cause within the MultiIndyVDRLedgerManager or the DI scoping for ledger instances would be a more fundamental solution but likely involves a larger refactor. This PR aims to restore the critical revocation functionality using the available correct profile context. Happy to discuss alternative approaches or contribute to a deeper refactor if preferred. |
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.
Good work and test coverage 👍
abcfb8e
to
88a1e9a
Compare
Looks like the rebase was out of sync. Try |
I think this is ok for now. Thanks for figuring it out. Maybe we can just add some notes where the profile is added as a parameter that this was done because of an injection issue. We should create an issue for looking into fixing the root of the injection problem. |
I'm not able to reproduce; @jamshale I recommend holding off on merging until we know what's going on. My minimal example may not be perfectly capturing the issue we're seeking to fix here. Would really like to be able to see this in an isolated environment though; the fact that it works (according to my understanding of the setup as captured in the example) gives me pause. |
Can this be merged now pending a preferred resolution? |
So this is a temporary fix for the I'm not opposed to allowing this for now when the root of the problem gets looked into. That's not an area I have looked at, so I'm not sure of the difficulty in finding a solution. |
Yes it is specific to the multi-ledger configuration scenario. Also are you referring to inline comments? Or does this pr + issue suffice? |
I was thinking some in code comments. We definitely want to make it clear to avoid this pattern and the PR and issues are easier to miss than having it recorded in the code. |
I see there's an effort going on to help find the root cause of that issue. Let's hold off on this for now. |
Signed-off-by: Yuki I <[email protected]>
Signed-off-by: Yuki I <[email protected]>
Signed-off-by: Yuki I <[email protected]>
openwallet-foundation#3649 workaround Signed-off-by: Yuki I <[email protected]>
|
Solution:
Testing:
Considerations:
Resolves #3624