@@ -1208,19 +1208,33 @@ async def revoke_pending_credentials(
12081208 Tuple with the update revocation list, list of cred rev ids not revoked
12091209
12101210 """
1211+ LOGGER .info (
1212+ "Starting revocation process for registry %s with "
1213+ "additional_crids=%s, limit_crids=%s" ,
1214+ revoc_reg_id ,
1215+ additional_crids ,
1216+ limit_crids ,
1217+ )
12111218 updated_list = None
12121219 failed_crids = set ()
12131220 max_attempt = 5
12141221 attempt = 0
12151222
12161223 while True :
12171224 attempt += 1
1225+ LOGGER .debug ("Revocation attempt %d/%d" , attempt , max_attempt )
12181226 if attempt >= max_attempt :
1227+ LOGGER .error (
1228+ "Max attempts (%d) reached while trying to update registry %s" ,
1229+ max_attempt ,
1230+ revoc_reg_id ,
1231+ )
12191232 raise AnonCredsRevocationError (
12201233 "Repeated conflict attempting to update registry"
12211234 )
12221235 try :
12231236 async with self .profile .session () as session :
1237+ LOGGER .debug ("Fetching revocation registry data for %s" , revoc_reg_id )
12241238 rev_reg_def_entry = await session .handle .fetch (
12251239 CATEGORY_REV_REG_DEF , revoc_reg_id
12261240 )
@@ -1231,6 +1245,11 @@ async def revoke_pending_credentials(
12311245 CATEGORY_REV_REG_DEF_PRIVATE , revoc_reg_id
12321246 )
12331247 except AskarError as err :
1248+ LOGGER .error (
1249+ "Failed to retrieve revocation registry data for %s: %s" ,
1250+ revoc_reg_id ,
1251+ str (err ),
1252+ )
12341253 raise AnonCredsRevocationError (
12351254 "Error retrieving revocation registry"
12361255 ) from err
@@ -1240,41 +1259,53 @@ async def revoke_pending_credentials(
12401259 or not rev_list_entry
12411260 or not rev_reg_def_private_entry
12421261 ):
1262+ missing_data = []
1263+ if not rev_reg_def_entry :
1264+ missing_data .append ("revocation registry definition" )
1265+ if not rev_list_entry :
1266+ missing_data .append ("revocation list" )
1267+ if not rev_reg_def_private_entry :
1268+ missing_data .append ("revocation registry private definition" )
1269+ LOGGER .error (
1270+ "Missing required revocation registry data for %s: %s" ,
1271+ revoc_reg_id ,
1272+ ", " .join (missing_data ),
1273+ )
12431274 raise AnonCredsRevocationError (
1244- (
1245- "Missing required revocation registry data: "
1246- "revocation registry definition"
1247- if not rev_reg_def_entry
1248- else ""
1249- ),
1250- "revocation list" if not rev_list_entry else "" ,
1251- (
1252- "revocation registry private definition"
1253- if not rev_reg_def_private_entry
1254- else ""
1255- ),
1275+ f"Missing required revocation registry data: { ' ' .join (missing_data )} "
12561276 )
12571277
12581278 try :
12591279 async with self .profile .session () as session :
1280+ cred_def_id = rev_reg_def_entry .value_json ["credDefId" ]
1281+ LOGGER .debug ("Fetching credential definition %s" , cred_def_id )
12601282 cred_def_entry = await session .handle .fetch (
1261- CATEGORY_CRED_DEF , rev_reg_def_entry . value_json [ "credDefId" ]
1283+ CATEGORY_CRED_DEF , cred_def_id
12621284 )
12631285 except AskarError as err :
1286+ LOGGER .error (
1287+ "Failed to retrieve credential definition %s: %s" ,
1288+ cred_def_id ,
1289+ str (err ),
1290+ )
12641291 raise AnonCredsRevocationError (
1265- f"Error retrieving cred def { rev_reg_def_entry . value_json [ 'credDefId' ] } " # noqa: E501
1292+ f"Error retrieving cred def { cred_def_id } "
12661293 ) from err
12671294
12681295 try :
12691296 # TODO This is a little rough; stored tails location will have public uri
12701297 # but library needs local tails location
1298+ LOGGER .debug ("Deserializing revocation registry data" )
12711299 rev_reg_def = RevRegDef .deserialize (rev_reg_def_entry .value_json )
12721300 rev_reg_def .value .tails_location = self .get_local_tails_path (rev_reg_def )
12731301 cred_def = CredDef .deserialize (cred_def_entry .value_json )
12741302 rev_reg_def_private = RevocationRegistryDefinitionPrivate .load (
12751303 rev_reg_def_private_entry .value_json
12761304 )
12771305 except AnoncredsError as err :
1306+ LOGGER .error (
1307+ "Failed to load revocation registry definition: %s" , str (err )
1308+ )
12781309 raise AnonCredsRevocationError (
12791310 "Error loading revocation registry definition"
12801311 ) from err
@@ -1286,21 +1317,29 @@ async def revoke_pending_credentials(
12861317 cred_revoc_ids = (rev_info ["pending" ] or []) + (additional_crids or [])
12871318 rev_list = RevList .deserialize (rev_info ["rev_list" ])
12881319
1320+ LOGGER .info (
1321+ "Processing %d credential revocation IDs for registry %s" ,
1322+ len (cred_revoc_ids ),
1323+ revoc_reg_id ,
1324+ )
1325+
12891326 for rev_id in cred_revoc_ids :
12901327 if rev_id < 1 or rev_id > max_cred_num :
12911328 LOGGER .error (
12921329 "Skipping requested credential revocation "
1293- "on rev reg id %s, cred rev id=%s not in range" ,
1330+ "on rev reg id %s, cred rev id=%s not in range (1-%d) " ,
12941331 revoc_reg_id ,
12951332 rev_id ,
1333+ max_cred_num ,
12961334 )
12971335 failed_crids .add (rev_id )
12981336 elif rev_id >= rev_info ["next_index" ]:
12991337 LOGGER .warning (
13001338 "Skipping requested credential revocation "
1301- "on rev reg id %s, cred rev id=%s not yet issued" ,
1339+ "on rev reg id %s, cred rev id=%s not yet issued (next_index=%d) " ,
13021340 revoc_reg_id ,
13031341 rev_id ,
1342+ rev_info ["next_index" ],
13041343 )
13051344 failed_crids .add (rev_id )
13061345 elif rev_list .revocation_list [rev_id ] == 1 :
@@ -1315,15 +1354,26 @@ async def revoke_pending_credentials(
13151354 rev_crids .add (rev_id )
13161355
13171356 if not rev_crids :
1357+ LOGGER .info (
1358+ "No valid credentials to revoke for registry %s" , revoc_reg_id
1359+ )
13181360 break
13191361
1320- if limit_crids is None :
1362+ if limit_crids is None or limit_crids == [] :
13211363 skipped_crids = set ()
13221364 else :
13231365 skipped_crids = rev_crids - set (limit_crids )
13241366 rev_crids = rev_crids - skipped_crids
13251367
1368+ LOGGER .info (
1369+ "Revoking %d credentials, skipping %d credentials for registry %s" ,
1370+ len (rev_crids ),
1371+ len (skipped_crids ),
1372+ revoc_reg_id ,
1373+ )
1374+
13261375 try :
1376+ LOGGER .debug ("Updating revocation list with new revocations" )
13271377 updated_list = await asyncio .get_event_loop ().run_in_executor (
13281378 None ,
13291379 lambda : rev_list .to_native ().update (
@@ -1336,25 +1386,31 @@ async def revoke_pending_credentials(
13361386 ),
13371387 )
13381388 except AnoncredsError as err :
1389+ LOGGER .error ("Failed to update revocation registry: %s" , str (err ))
13391390 raise AnonCredsRevocationError (
13401391 "Error updating revocation registry"
13411392 ) from err
13421393
13431394 try :
13441395 async with self .profile .transaction () as txn :
1396+ LOGGER .debug ("Saving updated revocation list" )
13451397 rev_info_upd = await txn .handle .fetch (
13461398 CATEGORY_REV_LIST , revoc_reg_id , for_update = True
13471399 )
13481400 if not rev_info_upd :
13491401 LOGGER .warning (
1350- f"Revocation registry missing, skipping update: { revoc_reg_id } " # noqa: E501
1402+ "Revocation registry %s missing during update, skipping" ,
1403+ revoc_reg_id ,
13511404 )
13521405 updated_list = None
13531406 break
13541407 tags = rev_info_upd .tags
13551408 rev_info_upd = rev_info_upd .value_json
13561409 if rev_info_upd != rev_info :
1357- # handle concurrent update to the registry by retrying
1410+ LOGGER .debug (
1411+ "Concurrent update detected for registry %s, retrying" ,
1412+ revoc_reg_id ,
1413+ )
13581414 continue
13591415 rev_info_upd ["rev_list" ] = updated_list .to_dict ()
13601416 rev_info_upd ["pending" ] = (
@@ -1368,18 +1424,30 @@ async def revoke_pending_credentials(
13681424 tags = tags ,
13691425 )
13701426 await txn .commit ()
1427+ LOGGER .info (
1428+ "Successfully updated revocation list for registry %s" ,
1429+ revoc_reg_id ,
1430+ )
13711431 except AskarError as err :
1432+ LOGGER .error ("Failed to save revocation registry: %s" , str (err ))
13721433 raise AnonCredsRevocationError (
13731434 "Error saving revocation registry"
13741435 ) from err
13751436 break
13761437
1377- return RevokeResult (
1438+ result = RevokeResult (
13781439 prev = rev_list ,
13791440 curr = RevList .from_native (updated_list ) if updated_list else None ,
13801441 revoked = list (rev_crids ),
13811442 failed = [str (rev_id ) for rev_id in sorted (failed_crids )],
13821443 )
1444+ LOGGER .info (
1445+ "Completed revocation process for registry %s: %d revoked, %d failed" ,
1446+ revoc_reg_id ,
1447+ len (result .revoked ),
1448+ len (result .failed ),
1449+ )
1450+ return result
13831451
13841452 async def mark_pending_revocations (self , rev_reg_def_id : str , * crids : int ):
13851453 """Cred rev ids stored to publish later."""
0 commit comments