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

⬆️ Upgrade ACA-Py version to 0.12.1 #758

Merged
merged 47 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
ca94965
:art: set default project version to 0.12.0
ff137 Apr 11, 2024
dcdbc2e
:arrow_up: Use 0.12.0 ACA-Py base image
ff137 Apr 11, 2024
582007d
:construction: test 0.12.0 redis plugin
ff137 Apr 11, 2024
8f44910
:construction: test 0.12.0 groups plugin
ff137 Apr 11, 2024
a6d3a34
:construction: test 0.12 cloudcontroller
ff137 Apr 23, 2024
218a073
:art: update to new method operation id
ff137 Apr 23, 2024
a4383f5
:art: update models
ff137 Apr 23, 2024
c30aa3b
:construction: test on nightly aca-py build
ff137 Apr 23, 2024
f4aad47
:white_check_mark: fix required fields in models
ff137 Apr 23, 2024
f1f9c3f
:construction: Test fix on ff137:fix/find_oob_target
ff137 Apr 23, 2024
deeaf7d
:construction: Use aries-acapy-plugins@v1-2024-04-23
ff137 Apr 23, 2024
7c8a2b4
:arrow_up: use latest 0.12.1rc0 image
ff137 Apr 25, 2024
8d323ea
:rewind: revert testing with forked aca-py
ff137 Apr 25, 2024
c09d273
:arrow_up: Use acapy-wallet-groups-plugin with 0.12.1rc0
ff137 Apr 25, 2024
9d627af
:arrow_up: use latest acapy-wallet-groups-plugin
ff137 Apr 25, 2024
399957a
:arrow_up: use latest cloudcontroller
ff137 Apr 25, 2024
36ce1c3
:rewind: Revert git install
ff137 Apr 25, 2024
8b95c63
:arrow_up: Upgrade to 0.12.1
ff137 May 9, 2024
ed5269f
:art: deduplicate project version
ff137 May 9, 2024
b3afe0c
:arrow_up: Use latest redis-events plugin for 0.12.1
ff137 May 10, 2024
444c9ec
✨ publishing pending revocations should wait and assert transaction h…
ff137 May 21, 2024
a0d4771
:art:
ff137 May 23, 2024
7293ade
:art: optionally return the transaction id for a publish revocations …
ff137 May 23, 2024
e2c1f61
:art: only wait if transaction id returned
ff137 May 23, 2024
2f896c7
:construction: test with forked acapy
ff137 May 23, 2024
9ad4218
:art: publish-revocations only needs to be called once
ff137 May 23, 2024
d2cf7c7
:sparkles: the beginnings of asserting that auto_publish revocation r…
ff137 May 23, 2024
77b2cf1
:white_check_mark: use empty non_revoked request to check if cred is …
ff137 May 23, 2024
5074159
:art: modify `non_revoked` requests to be empty
ff137 May 23, 2024
a046e27
:construction_worker: use default docker image again
ff137 May 23, 2024
4e4dc4b
:bug: wait for 2 registries again
ff137 May 23, 2024
cd07538
:art:
ff137 May 23, 2024
cbdf307
Merge branch 'development' into upgrade/acapy-0.12
ff137 Jun 5, 2024
1478961
:bug: non_revoked must be specified to avoid bug in acapy (hyperledge…
ff137 Jun 5, 2024
2830378
:construction: test with acapy nightly build
ff137 Jun 5, 2024
dd4f88d
:construction: fix test and leave todo
ff137 Jun 5, 2024
91aa9e4
Merge branch 'development' into upgrade/acapy-0.12
ff137 Jun 11, 2024
eb6506e
Update aries-acapy-plugins tag
ff137 Jun 11, 2024
f66bb04
Update acapy-wallet-groups-plugin tag
ff137 Jun 11, 2024
5776362
:arrow_up: use latest acapy image
ff137 Jun 11, 2024
792bf7e
:arrow_up: use acapy-wallet-groups-plugin tagged release
ff137 Jun 11, 2024
8292ac7
add sleep to work around acapy issue
ff137 Jun 11, 2024
eccfb45
:sparkles: `assert_both_webhooks_received`: use asyncio.gather to sim…
ff137 Jun 11, 2024
78a8548
:art: remove unneeded look_back
ff137 Jun 11, 2024
6d0f491
:art:
ff137 Jun 11, 2024
bbf51ce
:art: fix
ff137 Jun 11, 2024
b009825
:rewind: revert from nightly build back to 0.12.1 release
ff137 Jun 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
from app.routes.wallet import sd_jws as wallet_sd_jws
from app.services.event_handling.websocket_manager import WebsocketManager
from app.util.extract_validation_error import extract_validation_error_msg
from shared.constants import PROJECT_VERSION
from shared.exceptions import CloudApiValueError
from shared.log_config import get_logger

OPENAPI_NAME = os.getenv("OPENAPI_NAME", "OpenAPI")
PROJECT_VERSION = os.getenv("PROJECT_VERSION", "0.11.0")
ROLE = os.getenv("ROLE", "*")
ROOT_PATH = os.getenv("ROOT_PATH", "")

Expand Down
2 changes: 1 addition & 1 deletion app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
aiohttp~=3.9.2
aries-cloudcontroller==0.11.0.post5
aries-cloudcontroller==0.12.1
base58~=2.1.1
fastapi~=0.111.0
fastapi_websocket_pubsub~=0.3.8
Expand Down
26 changes: 25 additions & 1 deletion app/routes/issuer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
Dismissed Show dismissed Hide dismissed
from typing import List, Optional
from uuid import UUID

Expand Down Expand Up @@ -26,6 +27,7 @@
issuer_from_protocol_version,
)
from app.util.did import did_from_credential_definition_id, qualified_did_sov
from app.util.retry_method import coroutine_with_retry_until_value
from shared.log_config import get_logger
from shared.models.credential_exchange import (
CredentialExchange,
Expand Down Expand Up @@ -661,11 +663,33 @@ async def publish_revocations(

async with client_from_auth(auth) as aries_controller:
bound_logger.debug("Publishing revocations")
await revocation_registry.publish_pending_revocations(
endorser_transaction_id = await revocation_registry.publish_pending_revocations(
controller=aries_controller,
revocation_registry_credential_map=publish_request.revocation_registry_credential_map,
)

if endorser_transaction_id:
bound_logger.debug(
"Wait for publish complete on transaction id: {}",
endorser_transaction_id,
)
try:
# Wait for transaction to be acknowledged and written to the ledger
await coroutine_with_retry_until_value(
coroutine_func=aries_controller.endorse_transaction.get_transaction,
args=(endorser_transaction_id,),
field_name="state",
expected_value="transaction_acked",
logger=bound_logger,
max_attempts=10,
retry_delay=2,
)
except asyncio.TimeoutError as e:
raise CloudApiException(
"Timeout waiting for endorser to accept the revocations request.",
504,
) from e

bound_logger.info("Successfully published revocations.")


Expand Down
4 changes: 2 additions & 2 deletions app/routes/wallet/jws.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def sign_jws(
async with client_from_auth(auth) as aries_controller:
jws = await handle_acapy_call(
logger=bound_logger,
acapy_call=aries_controller.wallet.wallet_jwt_sign_post,
acapy_call=aries_controller.wallet.sign_jwt,
body=sign_request,
)

Expand Down Expand Up @@ -90,7 +90,7 @@ async def verify_jws(
async with client_from_auth(auth) as aries_controller:
verify_result = await handle_acapy_call(
logger=bound_logger,
acapy_call=aries_controller.wallet.wallet_jwt_verify_post,
acapy_call=aries_controller.wallet.verify_jwt,
body=verify_request,
)

Expand Down
4 changes: 2 additions & 2 deletions app/routes/wallet/sd_jws.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async def sign_sd_jws(
async with client_from_auth(auth) as aries_controller:
sd_jws = await handle_acapy_call(
logger=bound_logger,
acapy_call=aries_controller.wallet.wallet_sd_jwt_sign_post,
acapy_call=aries_controller.wallet.sign_sd_jwt,
body=sign_request,
)

Expand Down Expand Up @@ -92,7 +92,7 @@ async def verify_sd_jws(
async with client_from_auth(auth) as aries_controller:
verify_result = await handle_acapy_call(
logger=bound_logger,
acapy_call=aries_controller.wallet.wallet_sd_jwt_verify_post,
acapy_call=aries_controller.wallet.verify_sd_jwt,
body=verify_request,
)

Expand Down
2 changes: 1 addition & 1 deletion app/services/issuer/acapy_issuer_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async def create_offer(
)
record = await handle_acapy_call(
logger=bound_logger,
acapy_call=controller.issue_credential_v2_0.issue_credential20_create_offer_post,
acapy_call=controller.issue_credential_v2_0.create_offer,
body=request_body,
)

Expand Down
60 changes: 52 additions & 8 deletions app/services/revocation_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
)
from app.models.issuer import ClearPendingRevocationsResult
from app.util.credentials import strip_protocol_prefix
from app.util.retry_method import coroutine_with_retry
from shared.log_config import get_logger

logger = get_logger(__name__)
Expand Down Expand Up @@ -112,12 +113,43 @@ async def revoke_credential(
f"Failed to revoke credential: {e.detail}", e.status_code
) from e

if auto_publish_to_ledger:
bound_logger.debug("Wait for publish complete")

revoked = False
max_tries = 5
retry_delay = 1
n_try = 0
while not revoked and n_try < max_tries:
n_try += 1
# Safely fetch revocation record and check if change reflected
record = await coroutine_with_retry(
coroutine_func=controller.revocation.get_revocation_status,
args=(strip_protocol_prefix(credential_exchange_id),),
logger=bound_logger,
max_attempts=5,
retry_delay=0.5,
)
# Todo: this record state can be "revoked" before it's been endorsed
if record.result:
revoked = record.result.state == "revoked"

if not revoked and n_try < max_tries:
bound_logger.debug("Not yet revoked, waiting ...")
await asyncio.sleep(retry_delay)

if not revoked:
raise CloudApiException(
"Could not assert that revocation was published within timeout. "
"Please check the revocation record state and retry if not revoked."
)

bound_logger.info("Successfully revoked credential.")


async def publish_pending_revocations(
controller: AcaPyClient, revocation_registry_credential_map: Dict[str, List[str]]
) -> None:
) -> Optional[str]:
"""
Publish pending revocations

Expand All @@ -130,18 +162,16 @@ async def publish_pending_revocations(
Exception: When the pending revocations could not be published

Returns:
result (None): Successful execution returns None.
result (str): Successful execution returns the endorser transaction id.
"""
bound_logger = logger.bind(body=revocation_registry_credential_map)

bound_logger.info("Validating revocation registry ids")
await validate_rev_reg_ids(
controller=controller,
revocation_registry_credential_map=revocation_registry_credential_map,
)

try:
await handle_acapy_call(
result = await handle_acapy_call(
logger=bound_logger,
acapy_call=controller.revocation.publish_revocations,
body=PublishRevocations(rrid2crid=revocation_registry_credential_map),
Expand All @@ -151,7 +181,19 @@ async def publish_pending_revocations(
f"Failed to publish pending revocations: {e.detail}", e.status_code
) from e

bound_logger.info("Successfully published pending revocations.")
if not result.txn or not result.txn.transaction_id:
bound_logger.warning(
"Published pending revocations but received no endorser transaction id. Got result: {}",
result,
)
return

endorse_transaction_id = result.txn.transaction_id
bound_logger.info(
"Successfully published pending revocations. Endorser transaction id: {}.",
endorse_transaction_id,
)
return endorse_transaction_id


async def clear_pending_revocations(
Expand Down Expand Up @@ -339,12 +381,13 @@ async def validate_rev_reg_ids(

"""
bound_logger = logger.bind(body=revocation_registry_credential_map)
bound_logger.info("Validating revocation registry ids")
rev_reg_id_list = list(revocation_registry_credential_map.keys())

if not rev_reg_id_list:
return

bound_logger.info("Validating revocation registry ids")

for rev_reg_id in rev_reg_id_list:
try:
rev_reg_result = await handle_acapy_call(
Expand Down Expand Up @@ -437,7 +480,8 @@ async def wait_for_active_registry(
active_registries = []
sleep_duration = 0 # First sleep should be 0

while len(active_registries) < 1: # We need one of the two registries to be ready
# we want both active registries ready before trying to publish revocations to it
while len(active_registries) < 2:
await asyncio.sleep(sleep_duration)
active_registries = await get_created_active_registries(controller, cred_def_id)
sleep_duration = 0.5 # Following sleeps should wait 0.5s before retry
Expand Down
Loading
Loading