From fb4ca24443a2f49a456e2e375d036a17f8647b4f Mon Sep 17 00:00:00 2001 From: akurbatov Date: Mon, 17 Feb 2025 16:30:16 +0300 Subject: [PATCH 1/7] VC-390 --- src/keria/__main__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/keria/__main__.py b/src/keria/__main__.py index eb5e76ea..5d0dec29 100644 --- a/src/keria/__main__.py +++ b/src/keria/__main__.py @@ -12,6 +12,7 @@ from keria.app.cli.keria import main -if __name__ == "__main__": - main() +import cProfile +if __name__ == "__main__": + cProfile.run("main.run()", "/reports/profile_data.prof") From 72c1c9d837b1e9579553900af2971fea051fa8a0 Mon Sep 17 00:00:00 2001 From: akurbatov Date: Mon, 17 Feb 2025 16:52:06 +0300 Subject: [PATCH 2/7] VC-390 --- src/keria/__main__.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/keria/__main__.py b/src/keria/__main__.py index 5d0dec29..4473ff75 100644 --- a/src/keria/__main__.py +++ b/src/keria/__main__.py @@ -13,6 +13,23 @@ from keria.app.cli.keria import main import cProfile +import pstats +import threading +import time + +def profile_app(interval=10, output_file="/reports/profile.prof"): + profiler = cProfile.Profile() + profiler.enable() + + def save_report(): + while True: + time.sleep(interval) + profiler.dump_stats(output_file) + + # Start background thread to save profile periodically + threading.Thread(target=save_report, daemon=True).start() + return profiler if __name__ == "__main__": - cProfile.run("main.run()", "/reports/profile_data.prof") + profiler = profile_app() + main.run() From 28283fcb01281a92e7c4fecce501235f24bde420 Mon Sep 17 00:00:00 2001 From: akurbatov Date: Tue, 18 Feb 2025 10:39:14 +0300 Subject: [PATCH 3/7] VC-390 --- src/keria/__main__.py | 18 ------------------ src/keria/app/agenting.py | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/keria/__main__.py b/src/keria/__main__.py index 4473ff75..690692be 100644 --- a/src/keria/__main__.py +++ b/src/keria/__main__.py @@ -12,24 +12,6 @@ from keria.app.cli.keria import main -import cProfile -import pstats -import threading -import time - -def profile_app(interval=10, output_file="/reports/profile.prof"): - profiler = cProfile.Profile() - profiler.enable() - - def save_report(): - while True: - time.sleep(interval) - profiler.dump_stats(output_file) - - # Start background thread to save profile periodically - threading.Thread(target=save_report, daemon=True).start() - return profiler if __name__ == "__main__": - profiler = profile_app() main.run() diff --git a/src/keria/app/agenting.py b/src/keria/app/agenting.py index 1c00a36a..143f2aeb 100644 --- a/src/keria/app/agenting.py +++ b/src/keria/app/agenting.py @@ -46,11 +46,31 @@ from ..core.keeping import RemoteManager from ..db import basing +import cProfile +import pstats +import threading +import time + logger = ogler.getLogger() +def profile_app(interval=10, output_file="reports/profile.prof"): + profiler = cProfile.Profile() + profiler.enable() + + def save_report(): + while True: + print(f"Profiling report saved to {output_file}") + time.sleep(interval) + profiler.dump_stats(output_file) + + # Start background thread to save profile periodically + threading.Thread(target=save_report, daemon=True).start() + return profiler def setup(name, bran, adminPort, bootPort, base='', httpPort=None, configFile=None, configDir=None, keypath=None, certpath=None, cafilepath=None): + print("Start setup") + profiler = profile_app() """ Set up an ahab in Signify mode """ agency = Agency(name=name, base=base, bran=bran, configFile=configFile, configDir=configDir) From ba76266b63d84565f35d8486a639ab71be422b50 Mon Sep 17 00:00:00 2001 From: akurbatov Date: Tue, 18 Feb 2025 10:46:08 +0300 Subject: [PATCH 4/7] VC-390 --- src/keria/app/agenting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/keria/app/agenting.py b/src/keria/app/agenting.py index 143f2aeb..fe688b4b 100644 --- a/src/keria/app/agenting.py +++ b/src/keria/app/agenting.py @@ -53,7 +53,7 @@ logger = ogler.getLogger() -def profile_app(interval=10, output_file="reports/profile.prof"): +def profile_app(interval=10, output_file="/reports/profile.prof"): profiler = cProfile.Profile() profiler.enable() From 88708992ac5d05c9e2cc67ab023b40c7cbdf50d0 Mon Sep 17 00:00:00 2001 From: akurbatov Date: Tue, 18 Feb 2025 12:02:15 +0300 Subject: [PATCH 5/7] VC-390 --- src/keria/app/agenting.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/keria/app/agenting.py b/src/keria/app/agenting.py index fe688b4b..32d71d28 100644 --- a/src/keria/app/agenting.py +++ b/src/keria/app/agenting.py @@ -53,7 +53,8 @@ logger = ogler.getLogger() -def profile_app(interval=10, output_file="/reports/profile.prof"): + +def profile_app(interval=10, output_file=os.getenv("PROFILER_REPORT_FILE", "/home/origin/data/reports/profile.prof")): profiler = cProfile.Profile() profiler.enable() @@ -69,8 +70,12 @@ def save_report(): def setup(name, bran, adminPort, bootPort, base='', httpPort=None, configFile=None, configDir=None, keypath=None, certpath=None, cafilepath=None): - print("Start setup") - profiler = profile_app() + + if os.getenv("PROFILING_ENABLED", "false").lower() in ("true", "1"): + print("Start profiling") + profiler = profile_app() + else: + print("Profiling disabled") """ Set up an ahab in Signify mode """ agency = Agency(name=name, base=base, bran=bran, configFile=configFile, configDir=configDir) From 2c8c2270140aad198c7ce955e2c61f00855add36 Mon Sep 17 00:00:00 2001 From: akurbatov Date: Tue, 18 Feb 2025 14:19:10 +0300 Subject: [PATCH 6/7] VC-390 --- src/keria/app/agenting.py | 18 +++++++++++++++++- src/keria/app/cli/commands/start.py | 8 +++++++- src/keria/app/credentialing.py | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/keria/app/agenting.py b/src/keria/app/agenting.py index 32d71d28..d629731e 100644 --- a/src/keria/app/agenting.py +++ b/src/keria/app/agenting.py @@ -68,7 +68,7 @@ def save_report(): threading.Thread(target=save_report, daemon=True).start() return profiler -def setup(name, bran, adminPort, bootPort, base='', httpPort=None, configFile=None, configDir=None, +def setup(name, bran, adminPort, bootPort, credentialsPort, base='', httpPort=None, configFile=None, configDir=None, keypath=None, certpath=None, cafilepath=None): if os.getenv("PROFILING_ENABLED", "false").lower() in ("true", "1"): @@ -143,6 +143,22 @@ def setup(name, bran, adminPort, bootPort, base='', httpPort=None, configFile=No specEnd.addRoutes(happ) happ.add_route("/spec.yaml", specEnd) + if os.getenv("SEPARATE_CREDENTIAL_CONTROLLER", "false").lower() in ("true", "1"): + print(f"Separate credential controller enabled on port {credentialsPort}") + # credentials + capp = falcon.App(middleware=falcon.CORSMiddleware( + allow_origins='*', allow_credentials='*', + expose_headers=['cesr-attachment', 'cesr-date', 'content-type', 'signature', 'signature-input', + 'signify-resource', 'signify-timestamp'])) + credentialing.loadCredentialsQuery(capp) + credentialsServer = createHttpServer(credentialsPort, capp, keypath, certpath, cafilepath) + credentialsDoer = http.ServerDoer(server=credentialsServer) + doers.append(credentialsDoer) + else: + print("Separate credential controller disabled") + credentialing.loadCredentialsQuery(app) + + print("The Agency is loaded and waiting for requests...") return doers diff --git a/src/keria/app/cli/commands/start.py b/src/keria/app/cli/commands/start.py index 9a9dc2dd..c44d9034 100644 --- a/src/keria/app/cli/commands/start.py +++ b/src/keria/app/cli/commands/start.py @@ -36,6 +36,10 @@ default=3903, help="Boot port number the Boot HTTP server listens on. This port needs to be secured." " Default is 3903.") +parser.add_argument('-C', '--credentials', + action='store', + default=3904, + help="Port for credentials operations. Default is 3904.") parser.add_argument('-n', '--name', action='store', default="keria", @@ -83,6 +87,7 @@ def launch(args): admin=int(args.admin), http=int(args.http), boot=int(args.boot), + credentials=int(args.credentials), configFile=args.configFile, configDir=args.configDir, keypath=args.keypath, @@ -93,7 +98,7 @@ def launch(args): ".******", args.name, args.admin, args.http) -def runAgent(name="ahab", base="", bran="", admin=3901, http=3902, boot=3903, configFile=None, +def runAgent(name="ahab", base="", bran="", admin=3901, http=3902, boot=3903, credentials=3904, configFile=None, configDir=None, keypath=None, certpath=None, cafilepath=None, expire=0.0): """ Setup and run a KERIA Agency @@ -104,6 +109,7 @@ def runAgent(name="ahab", base="", bran="", admin=3901, http=3902, boot=3903, co adminPort=admin, httpPort=http, bootPort=boot, + credentialsPort=credentials, configFile=configFile, configDir=configDir, keypath=keypath, diff --git a/src/keria/app/credentialing.py b/src/keria/app/credentialing.py index 70185c9a..02b83ec9 100644 --- a/src/keria/app/credentialing.py +++ b/src/keria/app/credentialing.py @@ -40,10 +40,10 @@ def loadEnds(app, identifierResource): credentialResourceDelEnd = CredentialResourceDeleteEnd(identifierResource) app.add_route("/identifiers/{name}/credentials/{said}", credentialResourceDelEnd) +def loadCredentialsQuery(app): queryCollectionEnd = CredentialQueryCollectionEnd() app.add_route("/credentials/query", queryCollectionEnd) - class RegistryCollectionEnd: """ ReST API for admin of credential issuance and revocation registries From 2bc684b6cafea4c943b8ed01667e5cbfdeca8d8a Mon Sep 17 00:00:00 2001 From: akurbatov Date: Wed, 19 Feb 2025 14:46:05 +0300 Subject: [PATCH 7/7] VC-390 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d7ce4c9c..12a180a2 100644 --- a/setup.py +++ b/setup.py @@ -76,7 +76,7 @@ python_requires='>=3.10.4', install_requires=[ 'hio>=0.6.10', - 'keri @ git+https://git@github.com/provenant-dev/keripy.git@v1.1.6-pr9', + 'keri @ git+https://git@github.com/provenant-dev/keripy.git@VC-390', 'mnemonic>=0.21', 'multicommand>=1.0.0', 'falcon>=3.1.3',