-
Notifications
You must be signed in to change notification settings - Fork 516
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
DRAFT: please_ack support PoC for the 0453-issue-credential-v2 protocol #2546
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -515,8 +515,15 @@ async def issue_credential( | |
credentials_attach=[attach for (_, attach) in issue_formats], | ||
) | ||
|
||
cred_ex_record.state = V20CredExRecord.STATE_ISSUED | ||
cred_ex_record.cred_issue = cred_issue_message | ||
|
||
if self._profile.settings.get("debug.cred_issue_ack_required"): | ||
# request the holder to answer with an ack message | ||
cred_ex_record.state = V20CredExRecord.STATE_ISSUED | ||
cred_issue_message.assign_please_ack(["OUTCOME"]) | ||
else: | ||
cred_ex_record.state = V20CredExRecord.STATE_DONE | ||
|
||
async with self._profile.session() as session: | ||
# FIXME - re-fetch record to check state, apply transactional update | ||
await cred_ex_record.save(session, reason="v2.0 issue credential") | ||
|
@@ -550,6 +557,11 @@ async def receive_credential( | |
role=V20CredExRecord.ROLE_HOLDER, | ||
) | ||
|
||
please_ack = cred_issue_message._please_ack | ||
|
||
if please_ack is not None and 'OUTCOME' in please_ack.on: | ||
cred_ex_record.ack_required = True | ||
|
||
cred_request_message = cred_ex_record.cred_request | ||
req_formats = [ | ||
V20CredFormat.Format.get(fmt.format) | ||
|
@@ -667,6 +679,36 @@ async def send_cred_ack( | |
|
||
return cred_ex_record, cred_ack_message | ||
|
||
|
||
async def transit_to_done( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this "DONE" in the context of the entire protocol, or just in the context of the current message for which a "please-ack" OUTCOME was requested? Or to put another way -- does each
In other words -- only send Acks where there is not already a message going back to the other party at the same time. What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello @swcurran. Thank you for your questions.
It sounds we can ignore the 'please_ack' when an agent is going to send response immediately. But first of all, it is only possible for 'RECEIPT', not for 'OUTCOME' (we discussed it here ). At the other hand, I think this behavior (sending explicit 'ack' message or not depending on some conditions) has to be defined in the 'please_ack' RFC. My proposal is to continue implementation of support for 'OUTCOME'. And maybe to start discussion (in background with community) about possible behavior for agents who received 'RECEIPT' (is it ok to ignore in some cases or not? If yes, in what cases exactly? etc). Does it sound reasonable in your opinion? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my comment on the Markdown file PR that I just posted. I’ve changed my mind about sending ACKs only sometimes — I think that does not make sense and is too hard to implement. My new thinking is that the use of |
||
self, | ||
cred_ex_record: V20CredExRecord, | ||
): | ||
"""Transition of the protocol instance to STATE_DONE | ||
|
||
Delete cred ex record if set to auto-remove. | ||
|
||
Returns: | ||
cred ex record | ||
""" | ||
|
||
# FIXME - most of the code are copy-pasted from the send_cred_ack() | ||
cred_ex_record.state = V20CredExRecord.STATE_DONE | ||
try: | ||
async with self._profile.session() as session: | ||
await cred_ex_record.save(session, reason="store credential v2.0") | ||
|
||
if cred_ex_record.auto_remove: | ||
await self.delete_cred_ex_record(cred_ex_record.cred_ex_id) | ||
|
||
except StorageError: | ||
LOGGER.exception( | ||
"Error transition to done" | ||
) | ||
|
||
return cred_ex_record | ||
|
||
|
||
async def receive_credential_ack( | ||
self, cred_ack_message: V20CredAck, connection_id: Optional[str] | ||
) -> V20CredExRecord: | ||
|
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.
This raises another question -- how to define configuration settings for when to request ACKs? For example, is there a way with ArgParser to add a parameter type
--ack-request-protocol <protocol>
that can be defined multiple times? I don't know if that is even possible...Likewise, should the Admin API be extended for supported protocols to add a
add-please-ack
on certain endpoints? That would mean that the controller would be responsible for using please ack when necessary/desirable.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 will check it