Skip to content

Commit

Permalink
This hotfix adds fixes for rotation from kli and witness arg for logg…
Browse files Browse the repository at this point in the history
…ing (WebOfTrust#695)

* Update to `delegate confirm` and `rotate` kli commands to fix delegation approval of rotation from command line.

Signed-off-by: pfeairheller <[email protected]>

* Pull in changes from PR WebOfTrust#688 to hotfix to main.

Signed-off-by: pfeairheller <[email protected]>

---------

Signed-off-by: pfeairheller <[email protected]>
  • Loading branch information
pfeairheller authored Mar 1, 2024
1 parent 7afa432 commit 93dbd86
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 17 deletions.
16 changes: 14 additions & 2 deletions scripts/demo/basic/delegate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,24 @@ kli incept --name delegate --alias delegate --proxy proxy --file ${KERI_DEMO_SCR
pid=$!
PID_LIST+=" $pid"

# In other console run the following:
sleep 2
kli delegate confirm --name delegator --alias delegator -Y &
pid=$!
PID_LIST+=" $pid"

wait $PID_LIST

kli status --name delegate --alias delegate
kli status --name delegate --alias delegate

echo "Now rotating delegate..."
kli rotate --name delegate --alias delegate --proxy proxy &
pid=$!
PID_LIST="$pid"

sleep 2
echo "Checking for delegate rotate..."
kli delegate confirm --name delegator --alias delegator -Y &
pid=$!
PID_LIST+=" $pid"

wait $PID_LIST
6 changes: 6 additions & 0 deletions scripts/demo/test_scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ printf "\n************************************\n"
"${script_dir}/basic/demo-witness-async-script.sh"
isSuccess

printf "\n************************************\n"
printf "Running delegate.sh"
printf "\n************************************\n"
"${script_dir}/basic/delegate.sh"
isSuccess

printf "\n************************************\n"
printf "Running multisig.sh"
printf "\n************************************\n"
Expand Down
18 changes: 13 additions & 5 deletions src/keri/app/cli/commands/delegate/confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,21 @@ def confirmDo(self, tymth, tock=0.0):
print(f'\tDelegate {eserder.pre} {typ} Anchored at Seq. No. {hab.kever.sner.num}')

# wait for confirmation of fully commited event
wits = [werfer.qb64 for werfer in eserder.berfers]
self.witq.query(src=hab.pre, pre=eserder.pre, sn=eserder.sn, wits=wits)
if eserder.pre in self.hby.kevers:
self.witq.query(src=hab.pre, pre=eserder.pre, sn=eserder.sn)

while eserder.pre not in self.hby.kevers:
yield self.tock
while eserder.sn < self.hby.kevers[eserder.pre].sn:
yield self.tock

print(f"Delegate {eserder.pre} {typ} event committed.")
print(f"Delegate {eserder.pre} {typ} event committed.")
else: # It should be an inception event then...
wits = [werfer.qb64 for werfer in eserder.berfers]
self.witq.query(src=hab.pre, pre=eserder.pre, sn=eserder.sn, wits=wits)

while eserder.pre not in self.hby.kevers:
yield self.tock

print(f"Delegate {eserder.pre} {typ} event committed.")

self.remove(self.toRemove)
return True
Expand Down
13 changes: 9 additions & 4 deletions src/keri/app/cli/commands/rotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
default=None, type=int, required=False)
parser.add_argument("--receipt-endpoint", help="Attempt to connect to witness receipt endpoint for witness receipts.",
dest="endpoint", action='store_true')
parser.add_argument("--proxy", help="alias for delegation communication proxy", default="")

rotating.addRotationArgs(parser)


Expand Down Expand Up @@ -58,7 +60,7 @@ def rotate(args):
cuts=opts.witsCut, adds=opts.witsAdd,
isith=opts.isith, nsith=opts.nsith,
count=opts.ncount, toad=opts.toad,
data=opts.data)
data=opts.data, proxy=args.proxy)

doers = [rotDoer]

Expand Down Expand Up @@ -113,7 +115,7 @@ class RotateDoer(doing.DoDoer):
"""

def __init__(self, name, base, bran, alias, endpoint=False, isith=None, nsith=None, count=None,
toad=None, wits=None, cuts=None, adds=None, data: list = None):
toad=None, wits=None, cuts=None, adds=None, data: list = None, proxy=None):
"""
Returns DoDoer with all registered Doers needed to perform rotation.
Expand All @@ -126,6 +128,8 @@ def __init__(self, name, base, bran, alias, endpoint=False, isith=None, nsith=No
cuts is list of qb64 pre of witnesses to be removed from witness list
adds is list of qb64 pre of witnesses to be added to witness list
data is list of dicts of committed data such as seals
proxy is optional name of proxy Hab to use to send messages to delegator
"""

self.alias = alias
Expand All @@ -135,6 +139,7 @@ def __init__(self, name, base, bran, alias, endpoint=False, isith=None, nsith=No
self.toad = toad
self.data = data
self.endpoint = endpoint
self.proxy = proxy

self.wits = wits if wits is not None else []
self.cuts = cuts if cuts is not None else []
Expand All @@ -144,7 +149,7 @@ def __init__(self, name, base, bran, alias, endpoint=False, isith=None, nsith=No
self.hbyDoer = habbing.HaberyDoer(habery=self.hby) # setup doer
self.swain = delegating.Sealer(hby=self.hby)
self.postman = forwarding.Poster(hby=self.hby)
self.mbx = indirecting.MailboxDirector(hby=self.hby, topics=["/receipt"])
self.mbx = indirecting.MailboxDirector(hby=self.hby, topics=['/receipt', "/replay", "/reply"])
doers = [self.hbyDoer, self.mbx, self.swain, self.postman, doing.doify(self.rotateDo)]

super(RotateDoer, self).__init__(doers=doers)
Expand Down Expand Up @@ -183,7 +188,7 @@ def rotateDo(self, tymth, tock=0.0):
data=self.data)

if hab.kever.delegator:
self.swain.delegation(pre=hab.pre, sn=hab.kever.sn)
self.swain.delegation(pre=hab.pre, sn=hab.kever.sn, 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)):
yield self.tock
Expand Down
7 changes: 4 additions & 3 deletions src/keri/app/cli/commands/witness/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@
parser.add_argument("--keypath", action="store", required=False, default=None)
parser.add_argument("--certpath", action="store", required=False, default=None)
parser.add_argument("--cafilepath", action="store", required=False, default=None)
parser.add_argument("--loglevel", action="store", required=False, default="CRITICAL",
help="Set log level to DEBUG | INFO | WARNING | ERROR | CRITICAL. Default is CRITICAL")


def launch(args):
help.ogler.level = logging.CRITICAL
help.ogler.reopen(name=args.name, temp=True, clear=True)

help.ogler.level = logging.getLevelName(args.loglevel)
help.ogler.reopen(name=args.name, temp=True, clear=True) # need to configure for logging persistent file
logger = help.ogler.getLogger()

logger.info("\n******* Starting Witness for %s listening: http/%s, tcp/%s "
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 @@ -47,7 +47,7 @@ def __init__(self, hby, proxy=None, **kwa):
self.proxy = proxy

super(Sealer, self).__init__(doers=[self.witq, self.witDoer, self.postman, doing.doify(self.escrowDo)],
**kwa)
**kwa)

def delegation(self, pre, sn=None, proxy=None):
if pre not in self.hby.habs:
Expand All @@ -69,10 +69,10 @@ def delegation(self, pre, sn=None, proxy=None):
if isinstance(hab, GroupHab):
phab = hab.mhab
smids = hab.smids
elif hab.kever.sn > 0:
phab = hab
elif proxy is not None:
phab = proxy
elif hab.kever.sn > 0:
phab = hab
elif self.proxy is not None:
phab = self.proxy
else:
Expand Down

0 comments on commit 93dbd86

Please sign in to comment.