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

Feat/submit #271

Merged
merged 55 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
9a5e2dc
improved design and logic per review comments, still need to track th…
2byrds Jun 3, 2024
9348519
delegator endpoint processes dip as a long running processes. tests pass
2byrds Jun 3, 2024
042d551
small fixes to op checks
2byrds Jun 3, 2024
f589fab
small fixes on checking dip success
2byrds Jun 3, 2024
78cf663
remove unnecessary loop for interact operation
2byrds Jun 3, 2024
f9ab9a1
point to keri main for now, will use 1.2.0-dev5 when it's available
2byrds Jun 3, 2024
2c6ce5f
refactored degator end to delegating.py and corresponding tests and u…
2byrds Jun 4, 2024
f4de29d
consolidate to optype of 'delegation' and clean up tests
2byrds Jun 4, 2024
414744f
improve naming to be consistent with credentialing, and tested with s…
2byrds Jun 4, 2024
c900b85
fixes and tests rotation. also tested with signify-ts integration tes…
2byrds Jun 7, 2024
48046fd
fixed group end smids/rmids
2byrds Jun 12, 2024
6475a17
fix smid list in multisig request on_post
2byrds Jun 12, 2024
4a12a94
fix for intermittent smid/rmid dict or str
2byrds Jun 13, 2024
f41c79f
moving approval into longrunning operation, need to make approveDeleg…
2byrds Jun 13, 2024
903dfff
merged latest
2byrds Jun 13, 2024
32fc74f
successful delegated multisig integration testing with Signify-ts
2byrds Jun 13, 2024
54de5a7
set to tagged keripy 1.2.0.dev6
2byrds Jun 14, 2024
fcaf2fb
removed duplicate comment and simplified keria.dockerfile to leverage…
2byrds Jun 14, 2024
b274643
Started development on Submitter
2byrds Jun 17, 2024
8fe2ed3
continued unit testing submiter
2byrds Jun 18, 2024
2151ff6
Submitter only processes witnessed identifiers
2byrds Jun 18, 2024
99594af
added submit endpoint need to confirm wigs in long running operation
2byrds Jun 18, 2024
8f336ce
updated identifier endpoint testing to include submit operation
2byrds Jun 19, 2024
a2a8bbe
need to have operation based on cue instead of db
2byrds Jun 21, 2024
66b3e23
Remove any smids/rmids state dict test problems
2byrds Jun 21, 2024
59e7041
Removed unnecessary annotation
2byrds Jun 21, 2024
d3b3ee8
fix multisig join after original creation see https://github.com/WebO…
2byrds Jun 21, 2024
76d9a54
cleanup docker image entrypoint and instructions
2byrds Jun 22, 2024
baea95e
merged latest from fixes
2byrds Jun 22, 2024
ddcd055
submitter doers and cues decide completion of long running operation
2byrds Jun 22, 2024
b5ac15d
prepping makefile for release, will change org soon
2byrds Jun 22, 2024
d19836d
re-submit witness testing improvements
2byrds Jul 1, 2024
4cb96c1
tidy submit tests
2byrds Jul 1, 2024
50c0f28
updated to latest keripy dev tag 1.2.0.dev8
2byrds Jul 1, 2024
7eddaa3
Merge branch 'main' into feat/submit_id
2byrds Jul 5, 2024
60169d7
use image keri:1.2.0-dev8
2byrds Jul 5, 2024
8eb99ec
improve submit error message
2byrds Jul 5, 2024
38fb89c
added manual witness receipts to submit unit test
2byrds Jul 10, 2024
0892de7
simplify the witness receipts testing. Need to scrub the witness and …
2byrds Jul 10, 2024
0fd1530
server witness processing improved but still need to finish processin…
2byrds Jul 14, 2024
0ce3c00
witness receipts accounted for and submit operation completes
2byrds Jul 15, 2024
f020d76
merged latest
2byrds Jul 16, 2024
f795ab0
removed prototyped testing
2byrds Jul 16, 2024
8f2bbad
bump keria version
2byrds Jul 18, 2024
9070af8
small adjustments based on PR self-review
2byrds Jul 18, 2024
aa0df10
fix rotate test path
2byrds Jul 18, 2024
165baeb
update keria version
2byrds Jul 18, 2024
3f2ab9d
merged latest
2byrds Aug 12, 2024
f07da43
remove formatting from diff of agenting.py
2byrds Aug 12, 2024
c73b264
update formatting for better diff
2byrds Aug 12, 2024
21e0cef
update formatting for better diff
2byrds Aug 12, 2024
4ca9520
update formatting for better diff
2byrds Aug 12, 2024
1205f0b
update formatting for better diff
2byrds Aug 12, 2024
dac2135
revert keripy api change
2byrds Aug 13, 2024
5b32db9
set dev keri version
2byrds Aug 13, 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 setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
python_requires='>=3.12.2',
install_requires=[
'hio>=0.6.14',
'keri>=1.2.0.dev11',
'keri==1.2.0.dev11',
'mnemonic>=0.21',
'multicommand>=1.0.0',
'falcon>=3.1.3',
Expand Down
48 changes: 47 additions & 1 deletion src/keria/app/agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,13 @@ def __init__(self, hby, rgy, agentHab, agency, caid, **opts):
self.exchanges = decking.Deck()
self.grants = decking.Deck()
self.admits = decking.Deck()
self.submits = decking.Deck()
2byrds marked this conversation as resolved.
Show resolved Hide resolved

receiptor = agenting.Receiptor(hby=hby)
self.witq = agenting.WitnessInquisitor(hby=self.hby)
self.witPub = agenting.WitnessPublisher(hby=self.hby)
self.witDoer = agenting.WitnessReceiptor(hby=self.hby)
self.witSubmitDoer = agenting.WitnessReceiptor(hby=self.hby, force=True)

self.rep = storing.Respondant(hby=hby, cues=self.cues, mbx=Mailboxer(name=self.hby.name, temp=self.hby.temp))

Expand Down Expand Up @@ -341,8 +343,9 @@ def __init__(self, hby, rgy, agentHab, agency, caid, **opts):
self.exc = exchanging.Exchanger(hby=hby, handlers=handlers)
grouping.loadHandlers(exc=self.exc, mux=self.mux)
protocoling.loadHandlers(hby=self.hby, exc=self.exc, notifier=self.notifier)
self.submitter = Submitter(hby=hby, submits=self.submits, witRec=self.witSubmitDoer)
self.monitor = longrunning.Monitor(hby=hby, swain=self.swain, counselor=self.counselor, temp=hby.temp,
registrar=self.registrar, credentialer=self.credentialer, exchanger=self.exc)
registrar=self.registrar, credentialer=self.credentialer, submitter=self.submitter, exchanger=self.exc)

self.rvy = routing.Revery(db=hby.db, cues=self.cues)
self.kvy = eventing.Kevery(db=hby.db,
Expand Down Expand Up @@ -386,6 +389,7 @@ def __init__(self, hby, rgy, agentHab, agency, caid, **opts):
SeekerDoer(seeker=self.seeker, cues=self.verifier.cues, tock=self.tocks.get("seeker", 0.0)),
ExchangeCueDoer(seeker=self.exnseeker, cues=self.exc.cues, queries=self.queries,
tock=self.tocks.get("exchangecue", 0.0)),
self.submitter,
2byrds marked this conversation as resolved.
Show resolved Hide resolved
])

super(Agent, self).__init__(doers=doers, always=True, **opts)
Expand Down Expand Up @@ -1232,3 +1236,45 @@ def on_post(req, rep):
rep.status = falcon.HTTP_202
rep.content_type = "application/json"
rep.data = op.to_json().encode("utf-8")

class Submitter(doing.DoDoer):
def __init__(self, hby, submits, witRec):
"""
Process to re-submit the last event from the KEL to the witnesses for receipts and to propogate it to each witness
"""
self.hby = hby
self.submits = submits
self.witRec = witRec

super(Submitter, self).__init__(always=True)

def recur(self, tyme, deeds=None):
"""Processes submit reqests submitting any on the cue"""
if self.submits:
msg = self.submits.popleft()
alias = msg["alias"]
hab = self.hby.habByName(name=alias)
sn = hab.kever.sn
if hab and hab.kever.wits:
auths = {}
if hasattr(msg, "code"):
code = msg["code"]
if code:
for wit in hab.kever.wits:
auths[wit] = f"{code}#{helping.nowIso8601()}"
witDoer = self.witRec
witDoer.force = True
self.extend([witDoer])
print("Re-submit waiting for witness receipts...")
witDoer.msgs.append(dict(pre=hab.pre, sn=sn))

else:
for doer in self.doers:
if doer.cues:
cue = doer.cues.popleft()

if len(doer.cues) == 0:
print("Re-submit received all witness receipts for", cue["pre"])
self.doers.remove(doer)

return super(Submitter, self).recur(tyme, deeds)
26 changes: 25 additions & 1 deletion src/keria/app/aiding.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def loadEnds(app, agency, authn):
aidEnd = IdentifierResourceEnd()
app.add_route("/identifiers/{name}", aidEnd)
app.add_route("/identifiers/{name}/events", aidEnd)
app.add_route("/identifiers/{name}/submit", aidEnd)
2byrds marked this conversation as resolved.
Show resolved Hide resolved

aidOOBIsEnd = IdentifierOOBICollectionEnd()
app.add_route("/identifiers/{name}/oobis", aidOOBIsEnd)
Expand Down Expand Up @@ -756,7 +757,7 @@ def on_post(self, req, rep, name):

---
summary: Process identifier events.
description: This endpoint handles the 'rot' or 'ixn' events of an identifier based on the provided request.
description: This endpoint handles the 'rot' or 'ixn' events of an identifier, or the request to resubmit the KEL, based on the provided request.
tags:
- Identifier
parameters:
Expand All @@ -778,11 +779,16 @@ def on_post(self, req, rep, name):
ixn:
type: object
description: The interaction event details.
submit:
type: object
description: The request to resubmit event details to witnesses.
oneOf:
- required:
- rot
- required:
- ixn
- required:
- submit
responses:
200:
description: Successfully processed the identifier's event.
Expand All @@ -798,6 +804,8 @@ def on_post(self, req, rep, name):
op = self.rotate(agent, name, body)
elif body.get("ixn") is not None:
op = self.interact(agent, name, body)
elif body.get("submit") is not None:
2byrds marked this conversation as resolved.
Show resolved Hide resolved
op = self.submit_id(agent, name, body)
else:
raise falcon.HTTPBadRequest(
title="invalid request",
Expand Down Expand Up @@ -956,7 +964,23 @@ def interact(agent, name, body):
metadata=dict(response=serder.ked),
)
return op


@staticmethod
def submit_id(agent, name, body):
2byrds marked this conversation as resolved.
Show resolved Hide resolved
hab = agent.hby.habByName(name)
if hab is None:
raise falcon.HTTPNotFound(title=f"No AID {name} found")

code = body.get("code")

if hab.kever.wits:
agent.submits.append(dict(alias=name,code=code))
op = agent.monitor.submit(hab.kever.prefixer.qb64, longrunning.OpTypes.submit,
metadata=dict(alias=name,sn=hab.kever.sn))
return op

raise falcon.HTTPBadRequest(title=f"invalid identifier submitted, {name} has no witnesses")

def info(hab, rm, full=False):
data = dict(
Expand Down
1 change: 1 addition & 0 deletions src/keria/app/grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def on_post(req, rep, name):
" signing member list must contain a local identifier'")

hab = agent.hby.joinSignifyGroupHab(gid, name=name, mhab=mhab, smids=smids, rmids=rmids)

try:
hab.make(serder=serder, sigers=sigers)
except (ValueError) as e:
Expand Down
27 changes: 24 additions & 3 deletions src/keria/core/longrunning.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
from keria.app import delegating

# long running operation types
Typeage = namedtuple("Tierage", 'oobi witness delegation group query registry credential endrole challenge exchange '
Typeage = namedtuple("Tierage", 'oobi witness delegation group query registry credential endrole challenge exchange submit '
'done')

OpTypes = Typeage(oobi="oobi", witness='witness', delegation='delegation', group='group', query='query',
registry='registry', credential='credential', endrole='endrole', challenge='challenge',
exchange='exchange', done='done')
exchange='exchange', submit='submit', done='done')


@dataclass_json
Expand Down Expand Up @@ -94,7 +94,7 @@ class Monitor:

"""

def __init__(self, hby, swain, counselor=None, registrar=None, exchanger=None, credentialer=None, opr=None,
def __init__(self, hby, swain, counselor=None, registrar=None, exchanger=None, credentialer=None, submitter=None, opr=None,
temp=False):
""" Create long running operation monitor

Expand All @@ -110,6 +110,7 @@ def __init__(self, hby, swain, counselor=None, registrar=None, exchanger=None, c
self.registrar = registrar
self.exchanger = exchanger
self.credentialer = credentialer
self.submitter = submitter
2byrds marked this conversation as resolved.
Show resolved Hide resolved
self.opr = opr if opr is not None else Operator(name=hby.name, temp=temp)

def submit(self, oid, typ, metadata=None):
Expand Down Expand Up @@ -412,6 +413,26 @@ def status(self, op):
else:
operation.done = False

elif op.type in (OpTypes.submit,):
2byrds marked this conversation as resolved.
Show resolved Hide resolved
kever = self.hby.kevers[op.oid]
if kever and len(self.submitter.submits) == 0 and len(self.submitter.doers) == 0:
operation.done = True
operation.response = asdict(kever.state())
else:
start = helping.fromIso8601(op.start)
dtnow = helping.nowUTC()
if (dtnow - start) > datetime.timedelta(
seconds=eventing.Kevery.TimeoutPWE
):
operation.done = True
operation.error = Status(
code=408, # Using HTTP error codes here for lack of a better alternative
message=f"long running {op.type} for {op.oid} operation timed out before "
f"receiving sufficient witness receipts",
)
else:
operation.done = False

elif op.type in (OpTypes.done, ):
operation.done = True
operation.response = op.metadata["response"]
Expand Down
24 changes: 22 additions & 2 deletions src/keria/testing/testing_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def createRotate(aid, salt, signers, pidx, ridx, kidx, wits, toad):
salter = core.Salter(raw=salt)
creator = keeping.SaltyCreator(salt=salter.qb64, stem="signify:aid", tier=coring.Tiers.low)
encrypter = core.Encrypter(verkey=signers[0].verfer.qb64)
sxlt = encrypter.encrypt(salter.qb64).qb64
sxlt = encrypter.encrypt(ser=salter.qb64).qb64

rsigners = creator.create(pidx=pidx, ridx=ridx, tier=coring.Tiers.low, temp=False, count=1)
rnsigners = creator.create(pidx=pidx, ridx=ridx+1, tier=coring.Tiers.low, temp=False, count=1)
Expand Down Expand Up @@ -468,7 +468,7 @@ def createAid(client, name, salt, wits=None, toad="0", delpre=None):

salter = core.Salter(raw=salt)
encrypter = core.Encrypter(verkey=signers[0].verfer.qb64)
sxlt = encrypter.encrypt(salter.qb64).qb64
sxlt = encrypter.encrypt(ser=salter.qb64).qb64

sigers = [signer.sign(ser=serder.raw, index=0).qb64 for signer in signers]

Expand Down Expand Up @@ -599,6 +599,26 @@ def mockNowIso8601():
def mockRandomNonce():
return "A9XfpxIl1LcIkMhUSCCC8fgvkuX8gG9xK3SM-S8a8Y_U"

@staticmethod
def witnessMsg(hab, msg, sn, witHabs):
2byrds marked this conversation as resolved.
Show resolved Hide resolved
rctMsgs = []
for i, witHab in enumerate(witHabs):
kvy = witHab.kvy
witHab.psr.parse(ims=bytearray(msg), kvy=kvy, local=True)
# accepted event with cam sigs since own witness
assert kvy.kevers[hab.pre].sn == sn
assert len(kvy.cues) >= 1 # at least queued receipt cue
# better to find receipt cue in cues exactly
rctMsg = witHab.processCues(kvy.cues) # process cue returns rct msg
assert len(rctMsg) > len(msg)
rctMsgs.append(rctMsg)

for rMsg in rctMsgs: # process rct msgs from all witnesses
hab.psr.parse(ims=bytearray(rMsg), kvy=hab.kvy, local=True)
for whab in witHabs:
assert whab.pre in hab.kvy.kevers

return rctMsgs

class Issuer:
LE = "ENTAoj2oNBFpaniRswwPcca9W1ElEeH2V7ahw68HV4G5"
Expand Down
Loading
Loading