Skip to content

Commit cc630b9

Browse files
committed
fix: revocation-list storing and retrieving
1 parent 88b8cc0 commit cc630b9

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

aries_cloudagent/anoncreds/default/did_besu/registry.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
from web3.middleware import geth_poa_middleware
1313
from web3.types import TxReceipt
1414

15+
from ....anoncreds.events import RevListFinishedEvent
1516
from ....cache.base import BaseCache
1617
from ....config.injection_context import InjectionContext
18+
from ....core.event_bus import EventBus
1719
from ....core.profile import Profile
1820
from ....ledger.base import BaseLedger
1921
from ....ledger.error import (
@@ -258,8 +260,8 @@ async def send_transaction_tx(self, call_function) -> TxReceipt:
258260

259261
if tx_receipt["status"] == 0:
260262
LOGGER.debug("Receipt of the reverted transaction: %s", tx_receipt)
261-
raise AnonCredsRegistrationError(f"Transaction reverted: %s", send_tx)
262-
263+
raise AnonCredsRegistrationError("Transaction reverted: %s", send_tx)
264+
263265
return tx_receipt
264266

265267
async def register_revocation(
@@ -629,7 +631,9 @@ async def register_revocation_registry_definition(
629631
try:
630632
contract.functions.resolveRevocation(rev_reg_def_id).call()
631633
except ContractCustomError as e:
632-
raise AnonCredsRegistrationError("Error searching for newly created revocation") from e
634+
raise AnonCredsRegistrationError(
635+
"Error searching for newly created revocation"
636+
) from e
633637

634638
seq_no = self.REVOCATION_ADDRESS
635639
except LedgerError as err:
@@ -673,7 +677,7 @@ async def _get_or_fetch_rev_reg_def_max_cred_num(
673677

674678
def _indexes_to_bit_array(self, indexes: List[int], size: int) -> List[int]:
675679
"""Turn a sequence of indexes into a full state bit array."""
676-
return [1 if index in indexes else 0 for index in range(1, size + 1)]
680+
return [1 if index in indexes else 0 for index in range(0, size + 1)]
677681

678682
async def _get_ledger(self, profile: Profile, rev_reg_def_id: str):
679683
async with profile.session() as session:
@@ -864,20 +868,33 @@ async def update_revocation_list(
864868
options: Optional[dict] = None,
865869
) -> RevListResult:
866870
"""Update a revocation list."""
871+
delta, _ = await self.get_revocation_registry_delta(
872+
profile, curr_list.rev_reg_def_id, 0
873+
)
874+
delta_list = delta["value"]["revoked"] if delta["value"].get("revoked") else []
867875
newly_revoked_indices = list(revoked)
876+
full_revoked_list = newly_revoked_indices + delta_list
868877
rev_reg_entry = {
869878
"ver": "1.0",
870879
"value": {
871880
"accum": curr_list.current_accumulator,
872881
"prevAccum": prev_list.current_accumulator,
873-
"revoked": newly_revoked_indices,
882+
"revoked": full_revoked_list,
874883
},
875884
}
876885

877886
await self._revoc_reg_entry_with_fix(
878887
profile, curr_list, rev_reg_def.type, rev_reg_entry
879888
)
880889

890+
event_bus = profile.inject(EventBus)
891+
await event_bus.notify(
892+
profile,
893+
RevListFinishedEvent.with_payload(
894+
curr_list.rev_reg_def_id, newly_revoked_indices
895+
),
896+
)
897+
881898
return RevListResult(
882899
job_id=None,
883900
revocation_list_state=RevListState(

0 commit comments

Comments
 (0)