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

Clean up logic for acceptance of delegation. Prelim testing of superseding logic. Detailed doc string on delegated acceptance #640

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 src/keri/app/cli/commands/delegate/confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def confirmDo(self, tymth, tock=0.0):
elif ilk in (coring.Ilks.drt,):
typ = "rotation"
dkever = self.hby.kevers[eserder.pre]
delpre = dkever.delegator
delpre = dkever.delpre

else:
continue
Expand Down
4 changes: 2 additions & 2 deletions src/keri/app/cli/commands/delegate/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def requestDo(self, tymth, tock=0.0):

(seqner, saider) = esc[0]
evt = hab.makeOwnEvent(sn=seqner.sn)
delpre = hab.kever.delegator # get the delegator identifier
delpre = hab.kever.delpre # get the delegator identifier

if isinstance(hab, GroupHab):
phab = hab.mhab
Expand All @@ -99,7 +99,7 @@ def requestDo(self, tymth, tock=0.0):
srdr = serdering.SerderKERI(raw=evt) # coring.Serder(raw=evt)
del evt[:srdr.size]
self.postman.send(src=phab.pre, dest=delpre, topic="delegate", serder=srdr, attachment=evt)
self.postman.send(src=phab.pre, dest=hab.kever.delegator, topic="delegate", serder=exn, attachment=atc)
self.postman.send(src=phab.pre, dest=hab.kever.delpre, topic="delegate", serder=exn, attachment=atc)

while True:
while self.postman.cues:
Expand Down
4 changes: 2 additions & 2 deletions src/keri/app/cli/commands/incept.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def inceptDo(self, tymth, tock=0.0):
receiptor = agenting.Receiptor(hby=self.hby)
self.extend([witDoer, receiptor])

if hab.kever.delegator:
if hab.kever.delpre:
self.swain.delegation(pre=hab.pre, sn=0, proxy=self.hby.habByName(self.proxy))
print("Waiting for delegation approval...")
while not self.swain.complete(hab.kever.prefixer, coring.Seqner(sn=hab.kever.sn)):
Expand All @@ -183,7 +183,7 @@ def inceptDo(self, tymth, tock=0.0):
while not witDoer.cues:
_ = yield self.tock

if hab.kever.delegator:
if hab.kever.delpre:
yield from self.postman.sendEvent(hab=hab, fn=hab.kever.sn)

print(f'Prefix {hab.pre}')
Expand Down
2 changes: 1 addition & 1 deletion src/keri/app/cli/commands/multisig/continue.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def recover(self, tymth, tock=0.0, **opts):
(seqner, saider) = esc[0]
src = hab.mhab.pre if isinstance(hab, GroupHab) else hab.pre
anchor = dict(i=hab.pre, s=seqner.snh, d=saider.qb64)
self.witq.query(src=src, pre=hab.kever.delegator, anchor=anchor)
self.witq.query(src=src, pre=hab.kever.delpre, anchor=anchor)

print(f"Checking mailboxes for any events to process")
while self.hby.db.cgms.get(keys=(hab.pre, seqner.qb64)) is None:
Expand Down
2 changes: 1 addition & 1 deletion src/keri/app/cli/commands/multisig/incept.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def inceptDo(self, tymth, tock=0.0):

yield self.tock

if ghab.kever.delegator:
if ghab.kever.delpre:
yield from self.postman.sendEvent(hab=ghab, fn=ghab.kever.sn)

print()
Expand Down
2 changes: 1 addition & 1 deletion src/keri/app/cli/commands/multisig/rotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def rotateDo(self, tymth, tock=0.0, **opts):

yield self.tock

if ghab.kever.delegator:
if ghab.kever.delpre:
yield from self.postman.sendEvent(hab=ghab, fn=ghab.kever.sn)

print()
Expand Down
4 changes: 2 additions & 2 deletions src/keri/app/cli/commands/rotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def rotateDo(self, tymth, tock=0.0):
cuts=list(self.cuts), adds=list(self.adds),
data=self.data)

if hab.kever.delegator:
if hab.kever.delpre:
self.swain.delegation(pre=hab.pre, sn=hab.kever.sn)
print("Waiting for delegation approval...")
while not self.swain.complete(hab.kever.prefixer, coring.Seqner(sn=hab.kever.sn)):
Expand All @@ -206,7 +206,7 @@ def rotateDo(self, tymth, tock=0.0):

self.remove([witDoer])

if hab.kever.delegator:
if hab.kever.delpre:
yield from self.postman.sendEvent(hab=hab, fn=hab.kever.sn)

print(f'Prefix {hab.pre}')
Expand Down
4 changes: 2 additions & 2 deletions src/keri/app/cli/common/displaying.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def printIdentifier(hby, pre, label="Identifier"):
print("Seq No:\t{}".format(kever.sner.num))
if kever.delegated:
print("Delegated Identifier")
sys.stdout.write(f" Delegator: {kever.delegator} ")
sys.stdout.write(f" Delegator: {kever.delpre} ")
if seal:
print(f"{terming.Colors.OKGREEN}{terming.Symbols.CHECKMARK} Anchored{terming.Colors.ENDC}")
else:
Expand Down Expand Up @@ -93,7 +93,7 @@ def printExternal(hby, pre, label="Identifier"):
print("Seq No:\t{}".format(kever.sner.num))
if kever.delegated:
print("Delegated Identifier")
sys.stdout.write(f" Delegator: {kever.delegator} ")
sys.stdout.write(f" Delegator: {kever.delpre} ")
if anchor:
print(f"{terming.Colors.OKGREEN}{terming.Symbols.CHECKMARK} Anchored{terming.Colors.ENDC}")
else:
Expand Down
6 changes: 3 additions & 3 deletions src/keri/app/delegating.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def delegation(self, pre, sn=None, proxy=None):

# load the hab of the delegated identifier to anchor
hab = self.hby.habs[pre]
delpre = hab.kever.delegator # get the delegator identifier
delpre = hab.kever.delpre # get the delegator identifier
if delpre not in hab.kevers:
raise kering.ValidationError(f"delegator {delpre} not found, unable to process delegation")

Expand All @@ -81,7 +81,7 @@ def delegation(self, pre, sn=None, proxy=None):
# Send exn message for notification purposes
exn, atc = delegateRequestExn(phab, delpre=delpre, evt=bytes(evt), aids=smids)

self.postman.send(hab=phab, dest=hab.kever.delegator, topic="delegate", serder=exn, attachment=atc)
self.postman.send(hab=phab, dest=hab.kever.delpre, topic="delegate", serder=exn, attachment=atc)

srdr = serdering.SerderKERI(raw=evt)
del evt[:srdr.size]
Expand Down Expand Up @@ -151,7 +151,7 @@ def processUnanchoredEscrow(self):
"""
for (pre, said), serder in self.hby.db.dune.getItemIter(): # group partial witness escrow
kever = self.hby.kevers[pre]
dkever = self.hby.kevers[kever.delegator]
dkever = self.hby.kevers[kever.delpre]

seal = dict(i=serder.pre, s=serder.snh, d=serder.said)
if dserder := self.hby.db.findAnchoringSealEvent(dkever.prefixer.qb64, seal=seal):
Expand Down
2 changes: 1 addition & 1 deletion src/keri/app/forwarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def sendEvent(self, hab, fn=0):
del icp[:ser.size]

sender = hab.mhab.pre if isinstance(hab, GroupHab) else hab.pre
self.send(src=sender, dest=hab.kever.delegator, topic="delegate", serder=ser, attachment=icp)
self.send(src=sender, dest=hab.kever.delpre, topic="delegate", serder=ser, attachment=icp)
while True:
if self.cues:
cue = self.cues.popleft()
Expand Down
6 changes: 3 additions & 3 deletions src/keri/app/grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ def processPartialSignedEscrow(self):
else:
anchor = dict(i=pre, s=seqner.snh, d=saider.qb64)
if self.proxy:
self.witq.query(hab=self.proxy, pre=kever.delegator, anchor=anchor)
self.witq.query(hab=self.proxy, pre=kever.delpre, anchor=anchor)
else:
self.witq.query(src=ghab.mhab.pre, pre=kever.delegator, anchor=anchor)
self.witq.query(src=ghab.mhab.pre, pre=kever.delpre, anchor=anchor)

print("Waiting for delegation approval...")
self.hby.db.gdee.add(keys=(pre,), val=(seqner, saider))
Expand Down Expand Up @@ -175,7 +175,7 @@ def processDelegateEscrow(self):
self.hby.db.cgms.put(keys=(pre, seqner.qb64), val=saider)

else: # Not witnesser, we need to look for the anchor and then wait for receipts
if serder := self.hby.db.findAnchoringSealEvent(kever.delegator, seal=anchor):
if serder := self.hby.db.findAnchoringSealEvent(kever.delpre, seal=anchor):
aseq = coring.Seqner(sn=serder.sn)
couple = aseq.qb64b + serder.saidb
dgkey = dbing.dgKey(pre, saider.qb64b)
Expand Down
8 changes: 5 additions & 3 deletions src/keri/app/habbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ def rotate(self, *, verfers=None, digers=None, isith=None, nsith=None, toad=None
if not kever.ntholder.satisfy(indices):
raise kering.ValidationError("invalid rotation, new key set unable to satisfy prior next signing threshold")

if kever.delegator is not None: # delegator only shows up in delcept
if kever.delpre is not None: # delegator only shows up in delcept
serder = eventing.deltate(pre=kever.prefixer.qb64,
keys=keys,
dig=kever.serder.said,
Expand Down Expand Up @@ -1493,8 +1493,10 @@ def witness(self, serder):
indexed receipt signatures if key state of serder.pre shows that own pre
is a current witness of event in serder

Before calling this must check that serder being witnessed has been
accepted as valid event into controller's KEL
ToDo XXXX add parameter to force check that serder as been accepted
as valid. Otherwise must assume that before calling this that serder
being witnessed has been accepted as valid event into this hab
controller's KEL

"""
if self.kever.prefixer.transferable: # not non-transferable prefix
Expand Down
Loading
Loading