From f291e485f1ad4c54b7a1f50f117cd21391c52057 Mon Sep 17 00:00:00 2001 From: rasswanth-s <43314053+rasswanth-s@users.noreply.github.com> Date: Thu, 14 Mar 2024 12:28:06 +0530 Subject: [PATCH 1/8] bump veilid timeout to 60 seconds --- packages/grid/veilid/veilid-server.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/grid/veilid/veilid-server.conf b/packages/grid/veilid/veilid-server.conf index 8f668fafc08..3644a1ef643 100644 --- a/packages/grid/veilid/veilid-server.conf +++ b/packages/grid/veilid/veilid-server.conf @@ -6,4 +6,4 @@ client_api: core: network: rpc: - timeout_ms: 10000 + timeout_ms: 60000 From 60f376c235760d3a2602c9e7dac9152c4d48bb03 Mon Sep 17 00:00:00 2001 From: rasswanth-s <43314053+rasswanth-s@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:07:27 +0530 Subject: [PATCH 2/8] added new endpoints generate_vld_key and retrieve_vld_key --- packages/grid/veilid/server/main.py | 18 +++++----- packages/grid/veilid/server/veilid_core.py | 38 +++++++++++++++------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/packages/grid/veilid/server/main.py b/packages/grid/veilid/server/main.py index f28389414f8..6b50c1ff5ff 100644 --- a/packages/grid/veilid/server/main.py +++ b/packages/grid/veilid/server/main.py @@ -18,9 +18,9 @@ from .veilid_core import VeilidConnectionSingleton from .veilid_core import app_call from .veilid_core import app_message -from .veilid_core import generate_dht_key +from .veilid_core import generate_vld_key from .veilid_core import healthcheck -from .veilid_core import retrieve_dht_key +from .veilid_core import retrieve_vld_key # Logging Configuration log_level = os.getenv("APP_LOG_LEVEL", "INFO").upper() @@ -45,19 +45,19 @@ async def healthcheck_endpoint() -> ResponseModel: return ResponseModel(message="FAIL") -@app.post("/generate_dht_key", response_model=ResponseModel) -async def generate_dht_key_endpoint() -> ResponseModel: +@app.post("/generate_vld_key", response_model=ResponseModel) +async def generate_vld_key_endpoint() -> ResponseModel: try: - res = await generate_dht_key() + res = await generate_vld_key() return ResponseModel(message=res) except Exception as e: - raise HTTPException(status_code=500, detail=f"Failed to generate DHT key: {e}") + raise HTTPException(status_code=500, detail=f"Failed to generate VLD key: {e}") -@app.get("/retrieve_dht_key", response_model=ResponseModel) -async def retrieve_dht_key_endpoint() -> ResponseModel: +@app.get("/retrieve_vld_key", response_model=ResponseModel) +async def retrieve_vld_key_endpoint() -> ResponseModel: try: - res = await retrieve_dht_key() + res = await retrieve_vld_key() return ResponseModel(message=res) except Exception as e: raise HTTPException(status_code=500, detail=str(e)) diff --git a/packages/grid/veilid/server/veilid_core.py b/packages/grid/veilid/server/veilid_core.py index a611449bd6c..2cc967073bc 100644 --- a/packages/grid/veilid/server/veilid_core.py +++ b/packages/grid/veilid/server/veilid_core.py @@ -123,11 +123,15 @@ async def create_private_route( return (route_id, route_blob) -async def get_node_id(conn: _JsonVeilidAPI) -> str: - state = await conn.get_state() - config = state.config.config - node_id = config.network.routing_table.node_id[0] - return node_id +async def get_node_id() -> str: + logger.info("Getting Node ID") + async with await get_veilid_conn() as conn: + state = await conn.get_state() + config = state.config.config + node_id = config.network.routing_table.node_id[0] + if not node_id: + raise Exception("Node ID not found.Veilid might not be ready") + return node_id async def generate_dht_key() -> str: @@ -140,12 +144,8 @@ async def generate_dht_key() -> str: async with await get_routing_context(conn) as router: dht_record = await router.create_dht_record(veilid.DHTSchema.dflt(1)) - if USE_DIRECT_CONNECTION: - node_id = await get_node_id(conn) - await router.set_dht_value(dht_record.key, 0, node_id.encode()) - else: - _, route_blob = await create_private_route(conn) - await router.set_dht_value(dht_record.key, 0, route_blob) + _, route_blob = await create_private_route(conn) + await router.set_dht_value(dht_record.key, 0, route_blob) await router.close_dht_record(dht_record.key) @@ -168,6 +168,22 @@ async def retrieve_dht_key() -> str: return str(dht_key) +async def generate_vld_key() -> str: + if USE_DIRECT_CONNECTION: + await get_node_id() + else: + await generate_dht_key() + + return "Veilid Key generated successfully" + + +async def retrieve_vld_key() -> str: + if USE_DIRECT_CONNECTION: + return await get_node_id() + else: + return await retrieve_dht_key() + + async def get_dht_value( router: _JsonRoutingContext, dht_key: TypedKey, From 207574f6051a0e58f8db4f5dd0236d02c12bb750 Mon Sep 17 00:00:00 2001 From: rasswanth-s <43314053+rasswanth-s@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:26:21 +0530 Subject: [PATCH 3/8] shifted app message and app call to vld key --- .../Testing/Veilid/Alice-Python-Server.ipynb | 43 ++++++++++++------- .../Testing/Veilid/Bob-Python-Server.ipynb | 33 +++++++++----- packages/grid/veilid/server/main.py | 9 ++-- packages/grid/veilid/server/veilid_core.py | 26 +++++------ 4 files changed, 67 insertions(+), 44 deletions(-) diff --git a/notebooks/Testing/Veilid/Alice-Python-Server.ipynb b/notebooks/Testing/Veilid/Alice-Python-Server.ipynb index b398119c7f0..8564567beef 100644 --- a/notebooks/Testing/Veilid/Alice-Python-Server.ipynb +++ b/notebooks/Testing/Veilid/Alice-Python-Server.ipynb @@ -45,7 +45,7 @@ "metadata": {}, "outputs": [], "source": [ - "res = requests.post(f\"http://{host}:{port}/generate_dht_key\")" + "res = requests.post(f\"http://{host}:{port}/generate_vld_key\")" ] }, { @@ -65,7 +65,7 @@ "metadata": {}, "outputs": [], "source": [ - "res = requests.get(f\"http://{host}:{port}/retrieve_dht_key\")" + "res = requests.get(f\"http://{host}:{port}/retrieve_vld_key\")" ] }, { @@ -75,9 +75,9 @@ "metadata": {}, "outputs": [], "source": [ - "self_dht_key = res.json()[\"message\"]\n", + "self_vld_key = res.json()[\"message\"]\n", "print(\"=\" * 30)\n", - "print(self_dht_key)\n", + "print(self_vld_key)\n", "print(\"=\" * 30)" ] }, @@ -86,7 +86,18 @@ "id": "a8c70d99-6814-453d-80bf-d141c40ba24e", "metadata": {}, "source": [ - "### Send AppMessage using DHT Key to Self" + "### Send AppMessage using VLD Key to Self" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a7495805-817d-44d9-ad62-32407b42316c", + "metadata": {}, + "outputs": [], + "source": [ + "# Cannot send messages to self, due to local routing feature not\n", + "# available in direct routing" ] }, { @@ -96,8 +107,8 @@ "metadata": {}, "outputs": [], "source": [ - "json_data = {\"dht_key\": self_dht_key, \"message\": \"Hello to me again\"}\n", - "app_message = requests.post(f\"http://{host}:{port}/app_message\", json=json_data)" + "# json_data = {\"dht_key\": self_dht_key, \"message\": \"Hello to me again\"}\n", + "# app_message = requests.post(f\"http://{host}:{port}/app_message\", json=json_data)" ] }, { @@ -107,7 +118,7 @@ "metadata": {}, "outputs": [], "source": [ - "app_message.content" + "# app_message.content" ] }, { @@ -115,7 +126,7 @@ "id": "4d0d9e39-bf05-4ef3-b00a-2bb605f041ee", "metadata": {}, "source": [ - "### Send AppCall using DHT Key to Self" + "### Send AppCall using VLD Key to Self" ] }, { @@ -125,8 +136,8 @@ "metadata": {}, "outputs": [], "source": [ - "json_data = {\"dht_key\": self_dht_key, \"message\": \"Hello to app call\"}\n", - "app_call = requests.post(f\"http://{host}:{port}/app_call\", json=json_data)" + "# json_data = {\"dht_key\": self_dht_key, \"message\": \"Hello to app call\"}\n", + "# app_call = requests.post(f\"http://{host}:{port}/app_call\", json=json_data)" ] }, { @@ -136,7 +147,7 @@ "metadata": {}, "outputs": [], "source": [ - "app_call.json()" + "# app_call.json()" ] }, { @@ -144,7 +155,7 @@ "id": "fd824cca-2a7f-4ea9-9e67-1c06d1f8bec2", "metadata": {}, "source": [ - "### Send AppMessage using DHT Key to Peer" + "### Send AppMessage using VLD Key to Peer" ] }, { @@ -154,7 +165,7 @@ "metadata": {}, "outputs": [], "source": [ - "peer_dht_key = input(\"Enter Peer DHT Key\")" + "peer_vld_key = input(\"Enter Peer VLD Key\")" ] }, { @@ -164,7 +175,7 @@ "metadata": {}, "outputs": [], "source": [ - "json_data = {\"dht_key\": peer_dht_key, \"message\": \"How are you doing , Bob\"}\n", + "json_data = {\"vld_key\": peer_vld_key, \"message\": \"How are you doing , Bob\"}\n", "app_message = requests.post(f\"http://{host}:{port}/app_message\", json=json_data)" ] }, @@ -185,7 +196,7 @@ "source": [ "res = requests.get(\n", " f\"http://{host}:{port}/proxy\",\n", - " json={\"url\": \"https://www.google.com\", \"method\": \"GET\", \"dht_key\": self_dht_key},\n", + " json={\"url\": \"https://www.google.com\", \"method\": \"GET\", \"vld_key\": self_vld_key},\n", ")" ] }, diff --git a/notebooks/Testing/Veilid/Bob-Python-Server.ipynb b/notebooks/Testing/Veilid/Bob-Python-Server.ipynb index c0b92df4115..35deb460032 100644 --- a/notebooks/Testing/Veilid/Bob-Python-Server.ipynb +++ b/notebooks/Testing/Veilid/Bob-Python-Server.ipynb @@ -45,7 +45,7 @@ "metadata": {}, "outputs": [], "source": [ - "res = requests.post(f\"http://{host}:{port}/generate_dht_key\")" + "res = requests.post(f\"http://{host}:{port}/generate_vld_key\")" ] }, { @@ -65,7 +65,7 @@ "metadata": {}, "outputs": [], "source": [ - "res = requests.get(f\"http://{host}:{port}/retrieve_dht_key\")" + "res = requests.get(f\"http://{host}:{port}/retrieve_vld_key\")" ] }, { @@ -75,9 +75,9 @@ "metadata": {}, "outputs": [], "source": [ - "self_dht_key = res.json()[\"message\"]\n", + "self_vld_key = res.json()[\"message\"]\n", "print(\"=\" * 30)\n", - "print(self_dht_key)\n", + "print(self_vld_key)\n", "print(\"=\" * 30)" ] }, @@ -89,6 +89,17 @@ "### Send AppMessage using DHT Key to Self" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "3e810776-491d-4170-a9c5-bf7eaf2995bd", + "metadata": {}, + "outputs": [], + "source": [ + "# Cannot send messages to self, due to local routing feature not\n", + "# available in direct routing" + ] + }, { "cell_type": "code", "execution_count": null, @@ -96,8 +107,8 @@ "metadata": {}, "outputs": [], "source": [ - "json_data = {\"dht_key\": self_dht_key, \"message\": \"Hello to me\"}\n", - "app_message = requests.post(f\"http://{host}:{port}/app_message\", json=json_data)" + "# json_data = {\"dht_key\": self_dht_key, \"message\": \"Hello to me\"}\n", + "# app_message = requests.post(f\"http://{host}:{port}/app_message\", json=json_data)" ] }, { @@ -115,8 +126,8 @@ "metadata": {}, "outputs": [], "source": [ - "json_data = {\"dht_key\": self_dht_key, \"message\": \"Hello to app call\"}\n", - "app_call = requests.post(f\"http://{host}:{port}/app_call\", json=json_data)" + "# json_data = {\"dht_key\": self_dht_key, \"message\": \"Hello to app call\"}\n", + "# app_call = requests.post(f\"http://{host}:{port}/app_call\", json=json_data)" ] }, { @@ -126,7 +137,7 @@ "metadata": {}, "outputs": [], "source": [ - "app_call.json()" + "# app_call.json()" ] }, { @@ -144,7 +155,7 @@ "metadata": {}, "outputs": [], "source": [ - "peer_dht_key = input(\"Enter Peer DHT Key\")" + "peer_vld_key = input(\"Enter Peer VLD Key\")" ] }, { @@ -154,7 +165,7 @@ "metadata": {}, "outputs": [], "source": [ - "json_data = {\"dht_key\": peer_dht_key, \"message\": \"Hello Alice\"}\n", + "json_data = {\"vld_key\": peer_vld_key, \"message\": \"Hello Alice\"}\n", "app_message = requests.post(f\"http://{host}:{port}/app_message\", json=json_data)" ] }, diff --git a/packages/grid/veilid/server/main.py b/packages/grid/veilid/server/main.py index 6b50c1ff5ff..e826e148179 100644 --- a/packages/grid/veilid/server/main.py +++ b/packages/grid/veilid/server/main.py @@ -65,10 +65,11 @@ async def retrieve_vld_key_endpoint() -> ResponseModel: @app.post("/app_message", response_model=ResponseModel) async def app_message_endpoint( - request: Request, dht_key: Annotated[str, Body()], message: Annotated[bytes, Body()] + request: Request, vld_key: Annotated[str, Body()], message: Annotated[bytes, Body()] ) -> ResponseModel: try: - res = await app_message(dht_key=dht_key, message=message) + logger.info("Received app_message request") + res = await app_message(vld_key=vld_key, message=message) return ResponseModel(message=res) except Exception as e: raise HTTPException(status_code=500, detail=str(e)) @@ -76,10 +77,10 @@ async def app_message_endpoint( @app.post("/app_call") async def app_call_endpoint( - request: Request, dht_key: Annotated[str, Body()], message: Annotated[bytes, Body()] + request: Request, vld_key: Annotated[str, Body()], message: Annotated[bytes, Body()] ) -> Response: try: - res = await app_call(dht_key=dht_key, message=message) + res = await app_call(vld_key=vld_key, message=message) return Response(res, media_type="application/octet-stream") except Exception as e: raise HTTPException(status_code=500, detail=str(e)) diff --git a/packages/grid/veilid/server/veilid_core.py b/packages/grid/veilid/server/veilid_core.py index 2cc967073bc..dd15b8786b9 100644 --- a/packages/grid/veilid/server/veilid_core.py +++ b/packages/grid/veilid/server/veilid_core.py @@ -125,6 +125,7 @@ async def create_private_route( async def get_node_id() -> str: logger.info("Getting Node ID") + # TODO: Cache NODE ID Retrieval async with await get_veilid_conn() as conn: state = await conn.get_state() config = state.config.config @@ -209,44 +210,43 @@ async def get_dht_value( # TODO: change verbosity of logs to debug at appropriate places -async def get_route_from_dht_record( - dht_key: str, conn: _JsonVeilidAPI, router: _JsonRoutingContext +async def get_route_from_vld_key( + vld_key: str, conn: _JsonVeilidAPI, router: _JsonRoutingContext ) -> str | RouteId: - dht_key = veilid.TypedKey(dht_key) - logger.info(f"App Call to DHT Key: {dht_key}") - dht_value = await get_dht_value(router, dht_key, 0) - logger.info(f"DHT Value:{dht_value}") - if USE_DIRECT_CONNECTION: - route = dht_value.data.decode() - logger.info(f"Node ID: {route}") + route = vld_key + logger.info(f"Peer Node ID: {route}") else: + dht_key = veilid.TypedKey(vld_key) + dht_value = await get_dht_value(router, dht_key, 0) + logger.info(f"DHT Value:{dht_value}") route = await conn.import_remote_private_route(dht_value.data) logger.info(f"Private Route of Peer: {route} ") return route -async def app_message(dht_key: str, message: bytes) -> str: +async def app_message(vld_key: str, message: bytes) -> str: async with await get_veilid_conn() as conn: async with await get_routing_context(conn) as router: - route = await get_route_from_dht_record(dht_key, conn, router) + route = await get_route_from_vld_key(vld_key, conn, router) await router.app_message(route, message) return "Message sent successfully" -async def app_call(dht_key: str, message: bytes) -> bytes: +async def app_call(vld_key: str, message: bytes) -> bytes: async with await get_veilid_conn() as conn: async with await get_routing_context(conn) as router: - route = await get_route_from_dht_record(dht_key, conn, router) + route = await get_route_from_vld_key(vld_key, conn, router) result = await router.app_call(route, message) return result +# TODO: Modify healthcheck endpoint to check public internet ready async def healthcheck() -> bool: async with await get_veilid_conn() as conn: state = await conn.get_state() From d3b9e85de6e28d3f6323217f8a064b929644a3f6 Mon Sep 17 00:00:00 2001 From: rasswanth-s <43314053+rasswanth-s@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:27:43 +0530 Subject: [PATCH 4/8] shifted proxy endpoint to vld key --- packages/grid/veilid/server/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/grid/veilid/server/main.py b/packages/grid/veilid/server/main.py index e826e148179..9941c9f9864 100644 --- a/packages/grid/veilid/server/main.py +++ b/packages/grid/veilid/server/main.py @@ -93,11 +93,11 @@ async def proxy(request: Request) -> Response: request_data = await request.json() logger.info(f"Request URL: {request_data}") - dht_key = request_data.get("dht_key") - request_data.pop("dht_key") + vld_key = request_data.get("vld_key") + request_data.pop("vld_key") message = json.dumps(request_data).encode() - res = await app_call(dht_key=dht_key, message=message) + res = await app_call(vld_key=vld_key, message=message) decompressed_res = lzma.decompress(res) return Response(decompressed_res, media_type="application/octet-stream") From b4c02f3dbbed0a3de8da0d5ec3c7337f26f3109f Mon Sep 17 00:00:00 2001 From: rasswanth-s <43314053+rasswanth-s@users.noreply.github.com> Date: Thu, 14 Mar 2024 15:06:43 +0530 Subject: [PATCH 5/8] modularized the file structure of veilid --- packages/grid/veilid/server/main.py | 2 +- .../grid/veilid/server/veilid_callback.py | 44 +++++++++ .../grid/veilid/server/veilid_connection.py | 36 +++++++ .../server/veilid_connection_singleton.py | 35 +++++++ packages/grid/veilid/server/veilid_core.py | 94 +------------------ 5 files changed, 118 insertions(+), 93 deletions(-) create mode 100644 packages/grid/veilid/server/veilid_callback.py create mode 100644 packages/grid/veilid/server/veilid_connection.py create mode 100644 packages/grid/veilid/server/veilid_connection_singleton.py diff --git a/packages/grid/veilid/server/main.py b/packages/grid/veilid/server/main.py index 9941c9f9864..1bb6bb0cbd9 100644 --- a/packages/grid/veilid/server/main.py +++ b/packages/grid/veilid/server/main.py @@ -15,7 +15,7 @@ # relative from .models import ResponseModel -from .veilid_core import VeilidConnectionSingleton +from .veilid_connection_singleton import VeilidConnectionSingleton from .veilid_core import app_call from .veilid_core import app_message from .veilid_core import generate_vld_key diff --git a/packages/grid/veilid/server/veilid_callback.py b/packages/grid/veilid/server/veilid_callback.py new file mode 100644 index 00000000000..7c3b8e89040 --- /dev/null +++ b/packages/grid/veilid/server/veilid_callback.py @@ -0,0 +1,44 @@ +# stdlib +import base64 +import json +import lzma + +# third party +import httpx +from loguru import logger +import veilid +from veilid import VeilidUpdate + +# relative +from .veilid_connection import get_veilid_conn + + +async def main_callback(update: VeilidUpdate) -> None: + # TODO: Handle other types of network events like + # when our private route goes + if update.kind == veilid.VeilidUpdateKind.APP_MESSAGE: + logger.info(f"Received App Message: {update.detail.message}") + + elif update.kind == veilid.VeilidUpdateKind.APP_CALL: + logger.info(f"Received App Call: {update.detail.message}") + message: dict = json.loads(update.detail.message) + + async with httpx.AsyncClient() as client: + data = message.get("data", None) + # TODO: can we optimize this? + # We encode the data to base64,as while sending + # json expects valid utf-8 strings + if data: + message["data"] = base64.b64decode(data) + response = await client.request( + method=message.get("method"), + url=message.get("url"), + data=message.get("data", None), + params=message.get("params", None), + json=message.get("json", None), + ) + + async with await get_veilid_conn() as conn: + compressed_response = lzma.compress(response.content) + logger.info(f"Compression response size: {len(compressed_response)}") + await conn.app_call_reply(update.detail.call_id, compressed_response) diff --git a/packages/grid/veilid/server/veilid_connection.py b/packages/grid/veilid/server/veilid_connection.py new file mode 100644 index 00000000000..0e208893aea --- /dev/null +++ b/packages/grid/veilid/server/veilid_connection.py @@ -0,0 +1,36 @@ +# stdlib +from collections.abc import Callable + +# third party +import veilid +from veilid import VeilidUpdate +from veilid.json_api import _JsonRoutingContext +from veilid.json_api import _JsonVeilidAPI + +# relative +from .constants import HOST +from .constants import PORT +from .constants import USE_DIRECT_CONNECTION + + +async def noop_callback(update: VeilidUpdate) -> None: + pass + + +async def get_veilid_conn( + host: str = HOST, port: int = PORT, update_callback: Callable = noop_callback +) -> _JsonVeilidAPI: + return await veilid.json_api_connect( + host=host, port=port, update_callback=update_callback + ) + + +async def get_routing_context(conn: _JsonVeilidAPI) -> _JsonRoutingContext: + if USE_DIRECT_CONNECTION: + return await (await conn.new_routing_context()).with_safety( + veilid.SafetySelection.unsafe(veilid.Sequencing.ENSURE_ORDERED) + ) + else: + return await (await conn.new_routing_context()).with_sequencing( + veilid.Sequencing.ENSURE_ORDERED + ) diff --git a/packages/grid/veilid/server/veilid_connection_singleton.py b/packages/grid/veilid/server/veilid_connection_singleton.py new file mode 100644 index 00000000000..2fe78676be0 --- /dev/null +++ b/packages/grid/veilid/server/veilid_connection_singleton.py @@ -0,0 +1,35 @@ +# third party +from loguru import logger +from veilid.json_api import _JsonVeilidAPI + +# relative +from .veilid_callback import main_callback +from .veilid_connection import get_veilid_conn + + +class VeilidConnectionSingleton: + _instance = None + + def __new__(cls) -> "VeilidConnectionSingleton": + if cls._instance is None: + cls._instance = super().__new__(cls) + cls._instance._connection = None + return cls._instance + + def __init__(self) -> None: + self._connection: _JsonVeilidAPI | None = None + + @property + def connection(self) -> _JsonVeilidAPI | None: + return self._connection + + async def initialize_connection(self) -> None: + if self._connection is None: + self._connection = await get_veilid_conn(update_callback=main_callback) + logger.info("Connected to Veilid") + + async def release_connection(self) -> None: + if self._connection is not None: + await self._connection.release() + logger.info("Disconnected from Veilid") + self._connection = None diff --git a/packages/grid/veilid/server/veilid_core.py b/packages/grid/veilid/server/veilid_core.py index dd15b8786b9..5364a6c547b 100644 --- a/packages/grid/veilid/server/veilid_core.py +++ b/packages/grid/veilid/server/veilid_core.py @@ -1,11 +1,4 @@ -# stdlib -import base64 -from collections.abc import Callable -import json -import lzma - # third party -import httpx from loguru import logger import veilid from veilid import KeyPair @@ -13,102 +6,19 @@ from veilid import Stability from veilid import TypedKey from veilid import ValueData -from veilid import VeilidUpdate from veilid.json_api import _JsonRoutingContext from veilid.json_api import _JsonVeilidAPI from veilid.types import RouteId # relative -from .constants import HOST -from .constants import PORT from .constants import USE_DIRECT_CONNECTION +from .veilid_connection import get_routing_context +from .veilid_connection import get_veilid_conn from .veilid_db import load_dht_key from .veilid_db import store_dht_key from .veilid_db import store_dht_key_creds -async def main_callback(update: VeilidUpdate) -> None: - # TODO: Handle other types of network events like - # when our private route goes - if update.kind == veilid.VeilidUpdateKind.APP_MESSAGE: - logger.info(f"Received App Message: {update.detail.message}") - - elif update.kind == veilid.VeilidUpdateKind.APP_CALL: - logger.info(f"Received App Call: {update.detail.message}") - message: dict = json.loads(update.detail.message) - - async with httpx.AsyncClient() as client: - data = message.get("data", None) - # TODO: can we optimize this? - # We encode the data to base64,as while sending - # json expects valid utf-8 strings - if data: - message["data"] = base64.b64decode(data) - response = await client.request( - method=message.get("method"), - url=message.get("url"), - data=message.get("data", None), - params=message.get("params", None), - json=message.get("json", None), - ) - - async with await get_veilid_conn() as conn: - compressed_response = lzma.compress(response.content) - logger.info(f"Compression response size: {len(compressed_response)}") - await conn.app_call_reply(update.detail.call_id, compressed_response) - - -async def noop_callback(update: VeilidUpdate) -> None: - pass - - -async def get_veilid_conn( - host: str = HOST, port: int = PORT, update_callback: Callable = noop_callback -) -> _JsonVeilidAPI: - return await veilid.json_api_connect( - host=host, port=port, update_callback=update_callback - ) - - -async def get_routing_context(conn: _JsonVeilidAPI) -> _JsonRoutingContext: - if USE_DIRECT_CONNECTION: - return await (await conn.new_routing_context()).with_safety( - veilid.SafetySelection.unsafe(veilid.Sequencing.ENSURE_ORDERED) - ) - else: - return await (await conn.new_routing_context()).with_sequencing( - veilid.Sequencing.ENSURE_ORDERED - ) - - -class VeilidConnectionSingleton: - _instance = None - - def __new__(cls) -> "VeilidConnectionSingleton": - if cls._instance is None: - cls._instance = super().__new__(cls) - cls._instance._connection = None - return cls._instance - - def __init__(self) -> None: - self._connection: _JsonVeilidAPI | None = None - - @property - def connection(self) -> _JsonVeilidAPI | None: - return self._connection - - async def initialize_connection(self) -> None: - if self._connection is None: - self._connection = await get_veilid_conn(update_callback=main_callback) - logger.info("Connected to Veilid") - - async def release_connection(self) -> None: - if self._connection is not None: - await self._connection.release() - logger.info("Disconnected from Veilid") - self._connection = None - - async def create_private_route( conn: _JsonVeilidAPI, stability: Stability = veilid.Stability.RELIABLE, From e89602f27f994da270cc8be621a03dca752d5010 Mon Sep 17 00:00:00 2001 From: rasswanth-s <43314053+rasswanth-s@users.noreply.github.com> Date: Thu, 14 Mar 2024 15:43:52 +0530 Subject: [PATCH 6/8] added dispatch mechasim for callback function --- .../grid/veilid/server/veilid_callback.py | 58 +++++++++++-------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/packages/grid/veilid/server/veilid_callback.py b/packages/grid/veilid/server/veilid_callback.py index 7c3b8e89040..0df6d26a809 100644 --- a/packages/grid/veilid/server/veilid_callback.py +++ b/packages/grid/veilid/server/veilid_callback.py @@ -13,32 +13,40 @@ from .veilid_connection import get_veilid_conn +async def handle_app_message(update: VeilidUpdate) -> None: + logger.info(f"Received App Message: {update.detail.message}") + + +async def handle_app_call(update: VeilidUpdate) -> None: + logger.info(f"Received App Call: {update.detail.message}") + message: dict = json.loads(update.detail.message) + + async with httpx.AsyncClient() as client: + data = message.get("data", None) + # TODO: can we optimize this? + # We encode the data to base64,as while sending + # json expects valid utf-8 strings + if data: + message["data"] = base64.b64decode(data) + response = await client.request( + method=message.get("method"), + url=message.get("url"), + data=message.get("data", None), + params=message.get("params", None), + json=message.get("json", None), + ) + + async with await get_veilid_conn() as conn: + compressed_response = lzma.compress(response.content) + logger.info(f"Compression response size: {len(compressed_response)}") + await conn.app_call_reply(update.detail.call_id, compressed_response) + + +# TODO: Handle other types of network events like +# when our private route goes async def main_callback(update: VeilidUpdate) -> None: - # TODO: Handle other types of network events like - # when our private route goes if update.kind == veilid.VeilidUpdateKind.APP_MESSAGE: - logger.info(f"Received App Message: {update.detail.message}") + await handle_app_message(update) elif update.kind == veilid.VeilidUpdateKind.APP_CALL: - logger.info(f"Received App Call: {update.detail.message}") - message: dict = json.loads(update.detail.message) - - async with httpx.AsyncClient() as client: - data = message.get("data", None) - # TODO: can we optimize this? - # We encode the data to base64,as while sending - # json expects valid utf-8 strings - if data: - message["data"] = base64.b64decode(data) - response = await client.request( - method=message.get("method"), - url=message.get("url"), - data=message.get("data", None), - params=message.get("params", None), - json=message.get("json", None), - ) - - async with await get_veilid_conn() as conn: - compressed_response = lzma.compress(response.content) - logger.info(f"Compression response size: {len(compressed_response)}") - await conn.app_call_reply(update.detail.call_id, compressed_response) + await handle_app_call(update) From d9f2ae1b713380bb6f2178a80a601055c2b62a71 Mon Sep 17 00:00:00 2001 From: rasswanth-s <43314053+rasswanth-s@users.noreply.github.com> Date: Thu, 14 Mar 2024 16:10:48 +0530 Subject: [PATCH 7/8] replaced dht_key with vld_key --- packages/syft/src/syft/client/client.py | 30 +++++++++---------- .../syft/service/network/network_service.py | 8 ++--- .../src/syft/service/network/node_peer.py | 2 +- .../syft/src/syft/service/network/routes.py | 2 +- .../syft/service/veilid/veilid_endpoints.py | 4 +-- .../src/syft/service/veilid/veilid_service.py | 28 ++++++++--------- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/packages/syft/src/syft/client/client.py b/packages/syft/src/syft/client/client.py index ce96e350fd5..6270dc86734 100644 --- a/packages/syft/src/syft/client/client.py +++ b/packages/syft/src/syft/client/client.py @@ -331,7 +331,7 @@ def get_client_type(self) -> type[SyftClient]: @serializable( - attrs=["proxy_target_uid", "dht_key", "vld_forward_proxy", "vld_reverse_proxy"] + attrs=["proxy_target_uid", "vld_key", "vld_forward_proxy", "vld_reverse_proxy"] ) class VeilidConnection(NodeConnection): __canonical_name__ = "VeilidConnection" @@ -339,7 +339,7 @@ class VeilidConnection(NodeConnection): vld_forward_proxy: GridURL = Field(default=GridURL.from_url(VEILID_SERVICE_URL)) vld_reverse_proxy: GridURL = Field(default=GridURL.from_url(VEILID_SYFT_PROXY_URL)) - dht_key: str + vld_key: str proxy_target_uid: UID | None = None routes: type[Routes] = Field(default=Routes) session_cache: Session | None = None @@ -363,7 +363,7 @@ def with_proxy(self, proxy_target_uid: UID) -> Self: raise NotImplementedError("VeilidConnection does not support with_proxy") def get_cache_key(self) -> str: - return str(self.dht_key) + return str(self.vld_key) # def to_blob_route(self, path: str, **kwargs) -> GridURL: # _path = self.routes.ROUTE_BLOB_STORE.value + path @@ -387,7 +387,7 @@ def _make_get(self, path: str, params: dict | None = None) -> bytes: json_data = { "url": str(rev_proxy_url), "method": "GET", - "dht_key": self.dht_key, + "vld_key": self.vld_key, "params": params, } response = self.session.get(str(forward_proxy_url), json=json_data) @@ -410,7 +410,7 @@ def _make_post( json_data = { "url": str(rev_proxy_url), "method": "POST", - "dht_key": self.dht_key, + "vld_key": self.vld_key, "json": json, "data": data, } @@ -483,7 +483,7 @@ def make_call(self, signed_call: SignedSyftAPICall) -> Any: json_data = { "url": str(rev_proxy_url), "method": "POST", - "dht_key": self.dht_key, + "vld_key": self.vld_key, "data": msg_base64, } response = requests.post( # nosec @@ -504,7 +504,7 @@ def __repr__(self) -> str: def __str__(self) -> str: res = f"{type(self).__name__}:" - res += f"\n DHT Key: {self.dht_key}" + res += f"\n DHT Key: {self.vld_key}" res += f"\n Forward Proxy: {self.vld_forward_proxy}" res += f"\n Reverse Proxy: {self.vld_reverse_proxy}" return res @@ -512,7 +512,7 @@ def __str__(self) -> str: def __hash__(self) -> int: return ( hash(self.proxy_target_uid) - + hash(self.dht_key) + + hash(self.vld_key) + hash(self.vld_forward_proxy) + hash(self.vld_reverse_proxy) ) @@ -1157,15 +1157,15 @@ def connect( port: int | None = None, vld_forward_proxy: str | GridURL | None = None, vld_reverse_proxy: str | GridURL | None = None, - dht_key: str | None = None, + vld_key: str | None = None, ) -> SyftClient: if node: connection = PythonConnection(node=node) - elif dht_key and vld_forward_proxy and vld_reverse_proxy: + elif vld_key and vld_forward_proxy and vld_reverse_proxy: connection = VeilidConnection( vld_forward_proxy=vld_forward_proxy, vld_reverse_proxy=vld_reverse_proxy, - dht_key=dht_key, + vld_key=vld_key, ) else: url = GridURL.from_url(url) @@ -1211,7 +1211,7 @@ def login_as_guest( # Veilid Connection vld_forward_proxy: str | GridURL | None = None, vld_reverse_proxy: str | GridURL | None = None, - dht_key: str | None = None, + vld_key: str | None = None, verbose: bool = True, ) -> SyftClient: _client = connect( @@ -1220,7 +1220,7 @@ def login_as_guest( port=port, vld_forward_proxy=vld_forward_proxy, vld_reverse_proxy=vld_reverse_proxy, - dht_key=dht_key, + vld_key=vld_key, ) if isinstance(_client, SyftError): @@ -1246,7 +1246,7 @@ def login( # Veilid Connection vld_forward_proxy: str | GridURL | None = None, vld_reverse_proxy: str | GridURL | None = None, - dht_key: str | None = None, + vld_key: str | None = None, password: str | None = None, cache: bool = True, ) -> SyftClient: @@ -1256,7 +1256,7 @@ def login( port=port, vld_forward_proxy=vld_forward_proxy, vld_reverse_proxy=vld_reverse_proxy, - dht_key=dht_key, + vld_key=vld_key, ) if isinstance(_client, SyftError): diff --git a/packages/syft/src/syft/service/network/network_service.py b/packages/syft/src/syft/service/network/network_service.py index 9cb0daa97ff..768f1f49631 100644 --- a/packages/syft/src/syft/service/network/network_service.py +++ b/packages/syft/src/syft/service/network/network_service.py @@ -523,16 +523,16 @@ def node_route_to_http_connection( @transform_method(VeilidNodeRoute, VeilidConnection) def node_route_to_veilid_connection( - obj: Any, context: TransformContext | None = None + obj: VeilidNodeRoute, context: TransformContext | None = None ) -> list[Callable]: - return VeilidConnection(dht_key=obj.dht_key, proxy_target_uid=obj.proxy_target_uid) + return VeilidConnection(vld_key=obj.vld_key, proxy_target_uid=obj.proxy_target_uid) @transform_method(VeilidConnection, VeilidNodeRoute) def veilid_connection_to_node_route( - obj: Any, context: TransformContext | None = None + obj: VeilidConnection, context: TransformContext | None = None ) -> list[Callable]: - return VeilidNodeRoute(dht_key=obj.dht_key, proxy_target_uid=obj.proxy_target_uid) + return VeilidNodeRoute(vld_key=obj.vld_key, proxy_target_uid=obj.proxy_target_uid) @transform(NodeMetadataV3, NodePeer) diff --git a/packages/syft/src/syft/service/network/node_peer.py b/packages/syft/src/syft/service/network/node_peer.py index bd7dedce97d..0f4a8a0b448 100644 --- a/packages/syft/src/syft/service/network/node_peer.py +++ b/packages/syft/src/syft/service/network/node_peer.py @@ -103,7 +103,7 @@ def existed_route(self, route: NodeRoute) -> tuple[bool, int | None]: elif isinstance(route, VeilidNodeRoute): for i, r in enumerate(self.node_routes): if ( - route.dht_key == r.dht_key + route.vld_key == r.vld_key and route.proxy_target_uid == r.proxy_target_uid ): return (True, i) diff --git a/packages/syft/src/syft/service/network/routes.py b/packages/syft/src/syft/service/network/routes.py index c9d27f78e6e..cbf26531f33 100644 --- a/packages/syft/src/syft/service/network/routes.py +++ b/packages/syft/src/syft/service/network/routes.py @@ -97,7 +97,7 @@ class VeilidNodeRoute(SyftObject, NodeRoute): __canonical_name__ = "VeilidNodeRoute" __version__ = SYFT_OBJECT_VERSION_1 - dht_key: str + vld_key: str proxy_target_uid: UID | None = None priority: int = 1 diff --git a/packages/syft/src/syft/service/veilid/veilid_endpoints.py b/packages/syft/src/syft/service/veilid/veilid_endpoints.py index 08b67585f74..0e37226dd27 100644 --- a/packages/syft/src/syft/service/veilid/veilid_endpoints.py +++ b/packages/syft/src/syft/service/veilid/veilid_endpoints.py @@ -3,6 +3,6 @@ # TODO: Remove this once when we remove reverse proxy in Veilid Connection VEILID_SYFT_PROXY_URL = "http://proxy:80" HEALTHCHECK_ENDPOINT = "/healthcheck" -GEN_DHT_KEY_ENDPOINT = "/generate_dht_key" -RET_DHT_KEY_ENDPOINT = "/retrieve_dht_key" +GEN_VLD_KEY_ENDPOINT = "/generate_vld_key" +RET_VLD_KEY_ENDPOINT = "/retrieve_vld_key" VEILID_PROXY_PATH = "/proxy" diff --git a/packages/syft/src/syft/service/veilid/veilid_service.py b/packages/syft/src/syft/service/veilid/veilid_service.py index 612f5415244..3fbcd064291 100644 --- a/packages/syft/src/syft/service/veilid/veilid_service.py +++ b/packages/syft/src/syft/service/veilid/veilid_service.py @@ -15,9 +15,9 @@ from ..service import AbstractService from ..service import service_method from ..user.user_roles import DATA_OWNER_ROLE_LEVEL -from .veilid_endpoints import GEN_DHT_KEY_ENDPOINT +from .veilid_endpoints import GEN_VLD_KEY_ENDPOINT from .veilid_endpoints import HEALTHCHECK_ENDPOINT -from .veilid_endpoints import RET_DHT_KEY_ENDPOINT +from .veilid_endpoints import RET_VLD_KEY_ENDPOINT from .veilid_endpoints import VEILID_SERVICE_URL @@ -49,33 +49,33 @@ def is_veilid_service_healthy(self) -> bool: return res == "OK" @service_method( - path="veilid.generate_dht_key", - name="generate_dht_key", + path="veilid.generate_vld_key", + name="generate_vld_key", roles=DATA_OWNER_ROLE_LEVEL, ) - def generate_dht_key(self, context: AuthedServiceContext) -> str | SyftError: + def generate_vld_key(self, context: AuthedServiceContext) -> str | SyftError: if not self.is_veilid_service_healthy(): return SyftError( message="Veilid service is not healthy. Please try again later." ) return self.perform_request( method=requests.post, - endpoint=GEN_DHT_KEY_ENDPOINT, + endpoint=GEN_VLD_KEY_ENDPOINT, ) @service_method( - path="veilid.retrieve_dht_key", - name="retrieve_dht_key", + path="veilid.retrieve_vld_key", + name="retrieve_vld_key", roles=DATA_OWNER_ROLE_LEVEL, ) - def retrieve_dht_key(self, context: AuthedServiceContext) -> str | SyftError: + def retrieve_vld_key(self, context: AuthedServiceContext) -> str | SyftError: if not self.is_veilid_service_healthy(): return SyftError( message="Veilid service is not healthy. Please try again later." ) return self.perform_request( method=requests.get, - endpoint=RET_DHT_KEY_ENDPOINT, + endpoint=RET_VLD_KEY_ENDPOINT, raw=True, ) @@ -86,7 +86,7 @@ def retrieve_dht_key(self, context: AuthedServiceContext) -> str | SyftError: def get_veilid_route( self, context: AuthedServiceContext ) -> VeilidNodeRoute | SyftError: - dht_key = self.retrieve_dht_key(context) - if isinstance(dht_key, SyftError): - return dht_key - return VeilidNodeRoute(dht_key=dht_key) + vld_key = self.retrieve_vld_key(context) + if isinstance(vld_key, SyftError): + return vld_key + return VeilidNodeRoute(vld_key=vld_key) From 68f05d5f87d09721148f933dfb350b8aef972dcd Mon Sep 17 00:00:00 2001 From: rasswanth-s <43314053+rasswanth-s@users.noreply.github.com> Date: Thu, 14 Mar 2024 16:51:40 +0530 Subject: [PATCH 8/8] updated veilid tests and notebook with new vld_key --- .../Veilid/Veilid-Gateway-Testing.ipynb | 12 +++---- .../src/syft/protocol/protocol_version.json | 34 +++++++++---------- .../integration/veilid/gateway_veilid_test.py | 8 ++--- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/notebooks/Testing/Veilid/Veilid-Gateway-Testing.ipynb b/notebooks/Testing/Veilid/Veilid-Gateway-Testing.ipynb index 16f5e7abe41..0e3754724cd 100644 --- a/notebooks/Testing/Veilid/Veilid-Gateway-Testing.ipynb +++ b/notebooks/Testing/Veilid/Veilid-Gateway-Testing.ipynb @@ -38,7 +38,7 @@ "metadata": {}, "outputs": [], "source": [ - "domain_client.api.services.veilid.generate_dht_key()" + "domain_client.api.services.veilid.generate_vld_key()" ] }, { @@ -48,7 +48,7 @@ "metadata": {}, "outputs": [], "source": [ - "gateway_client.api.services.veilid.generate_dht_key()" + "gateway_client.api.services.veilid.generate_vld_key()" ] }, { @@ -69,7 +69,7 @@ "metadata": {}, "outputs": [], "source": [ - "gateway_route.dht_key" + "gateway_route.vld_key" ] }, { @@ -79,7 +79,7 @@ "metadata": {}, "outputs": [], "source": [ - "domain_route.dht_key" + "domain_route.vld_key" ] }, { @@ -99,7 +99,7 @@ "metadata": {}, "outputs": [], "source": [ - "domain_client.peers[0].node_routes[0].dht_key" + "domain_client.peers[0].node_routes[0].vld_key" ] }, { @@ -109,7 +109,7 @@ "metadata": {}, "outputs": [], "source": [ - "gateway_client.api.services.network.get_all_peers()[0].node_routes[0].dht_key" + "gateway_client.api.services.network.get_all_peers()[0].node_routes[0].vld_key" ] }, { diff --git a/packages/syft/src/syft/protocol/protocol_version.json b/packages/syft/src/syft/protocol/protocol_version.json index ab4aecf4586..54450c79fe1 100644 --- a/packages/syft/src/syft/protocol/protocol_version.json +++ b/packages/syft/src/syft/protocol/protocol_version.json @@ -23,7 +23,7 @@ }, "3": { "version": 3, - "hash": "18785a4cce6f25f1900b82f30acb2298b4afeab92bd00d0be358cfbf5a93d97e", + "hash": "37bb8f0f87b1da2525da8f6873e6257dff4a732f2dba293b62931ad0b85ef9e2", "action": "add" } }, @@ -40,7 +40,7 @@ }, "3": { "version": 3, - "hash": "4fd4c5b29e395b7a1af3b820166e69af7f267b6e3234fb8329bd0d74adc6e828", + "hash": "7c55461e3c6ba36ff999c64eb1b97a65b5a1f27193a973b1355ee2675f14c313", "action": "add" } }, @@ -52,7 +52,7 @@ }, "2": { "version": 2, - "hash": "1b04f527fdabaf329786b6bb38209f6ca82d622fe691d33c47ed1addccaaac02", + "hash": "1ab941c7669572a41067a17e0e3f2d9c7056f7a4df8f899e87ae2358d9113b02", "action": "add" } }, @@ -148,7 +148,7 @@ }, "3": { "version": 3, - "hash": "5922c1253370861185c53161ad31e488319f46ea5faee2d1802ca94657c428dc", + "hash": "709dc84a946267444a3f9968acf4a5e9807d6aa5143626c3fb635c9282108cc1", "action": "add" } }, @@ -165,7 +165,7 @@ }, "3": { "version": 3, - "hash": "dbb72f43add3141d13a76e18a2a0903a6937966632f0def452ca264f3f70d81b", + "hash": "5e84c9905a1816d51c0dfb1eedbfb4d831095ca6c89956c6fe200c2a193cbb8f", "action": "add" } }, @@ -182,7 +182,7 @@ }, "3": { "version": 3, - "hash": "cf831130f66f9addf8f68a8c9df0b67775e53322c8a32e8babc7f21631845608", + "hash": "bf936c1923ceee4def4cded06d41766998ea472322b0738bade7b85298e469da", "action": "add" } }, @@ -199,7 +199,7 @@ }, "3": { "version": 3, - "hash": "78334b746e5230ac156e47960e91ce449543d1a77a62d9b8be141882e4b549aa", + "hash": "daf3629fb7d26f41f96cd7f9200d7327a4b74d800b3e02afa75454d11bd47d78", "action": "add" } }, @@ -216,7 +216,7 @@ }, "3": { "version": 3, - "hash": "0007e86c39ede0f5756ba348083f809c5b6e3bb3a0a9ed6b94570d808467041f", + "hash": "4747a220d1587e99e6ac076496a2aa7217e2700205ac80fc24fe4768a313da78", "action": "add" } }, @@ -300,7 +300,7 @@ }, "2": { "version": 2, - "hash": "9eaed0a784525dea0018d95de74d70ed212f20f6ead2b50c66e59467c42bbe68", + "hash": "b35897295822f061fbc70522ca8967cd2be53a5c01b19e24c587cd7b0c4aa3e8", "action": "add" } }, @@ -574,7 +574,7 @@ }, "4": { "version": 4, - "hash": "077987cfc94d617f746f27fb468210330c328bad06eee09a89226759e5745a5f", + "hash": "c37bc1c6303c467050ce4f8faa088a2f66ef1781437ffe34f15aadf5477ac25b", "action": "add" } }, @@ -608,7 +608,7 @@ }, "3": { "version": 3, - "hash": "8a8e721a4ca8aa9107403368851acbe59f8d7bdc1eeff0ff101a44e325a058ff", + "hash": "4159d6ea45bc82577828bc19d668196422ff29bb8cc298b84623e6f4f476aaf3", "action": "add" } }, @@ -630,7 +630,7 @@ }, "4": { "version": 4, - "hash": "9b0dd1a64d64b1e824746e93aae0ca14863d2430aea2e2a758945edbfcb79bc9", + "hash": "dae431b87cadacfd30613519b5dd25d2e4ff59d2a971e21a31d56901103b9420", "action": "add" } }, @@ -1225,7 +1225,7 @@ }, "2": { "version": 2, - "hash": "747c87b947346fb0fc0466a912e2dc743ee082ef6254079176349d6b63748c32", + "hash": "93c75b45b9b74c69243cc2f2ef2d661e11eef5c23ecf71692ffdbd467d11efe6", "action": "add" } }, @@ -1513,7 +1513,7 @@ }, "2": { "version": 2, - "hash": "ac452023b98534eb13cb99a86fa7e379c08316353fc0837d1b788e0050e13ab9", + "hash": "24b7c302f9821afe073534d4ed02c377bd4f7cb691f66ca92b94c38c92dc78c2", "action": "add" } }, @@ -1525,7 +1525,7 @@ }, "2": { "version": 2, - "hash": "c9fdefdc622131c3676243aafadc30b7e67ee155793791bf1000bf742c1a251a", + "hash": "6d2e2f64c00dcda74a2545c77abbcf1630c56c26014987038feab174d15bd9d7", "action": "add" } }, @@ -1652,14 +1652,14 @@ "VeilidConnection": { "1": { "version": 1, - "hash": "29f803cec69b9ca6118e7c004867e82de6297f138b267ebd3df9ed35d5c944e4", + "hash": "c5ed1cfa9b7b146dbce7f1057f6e81e89715b5addfd4d4c4d53c415e450373a5", "action": "add" } }, "VeilidNodeRoute": { "1": { "version": 1, - "hash": "0ecd536def6b99475f4478acefb0226886336934206529647ee3e4667e211514", + "hash": "4797413e3144fce7bccc290db64f1750e8c09f75d5e1aba6e19d29f921a21074", "action": "add" } }, diff --git a/tests/integration/veilid/gateway_veilid_test.py b/tests/integration/veilid/gateway_veilid_test.py index 984389dca22..6d96f20fb24 100644 --- a/tests/integration/veilid/gateway_veilid_test.py +++ b/tests/integration/veilid/gateway_veilid_test.py @@ -35,9 +35,9 @@ def test_domain_connect_to_gateway_veilid(domain_1_port, gateway_port): remove_existing_peers(gateway_client) # Generate DHT Record - gateway_dht_res = gateway_client.api.services.veilid.generate_dht_key() + gateway_dht_res = gateway_client.api.services.veilid.generate_vld_key() assert isinstance(gateway_dht_res, SyftSuccess), gateway_dht_res - domain_dht_res = domain_client.api.services.veilid.generate_dht_key() + domain_dht_res = domain_client.api.services.veilid.generate_vld_key() assert isinstance(domain_dht_res, SyftSuccess), domain_dht_res # Retrieve DHT Record @@ -62,14 +62,14 @@ def test_domain_connect_to_gateway_veilid(domain_1_port, gateway_port): assert domain_peer.node_type == NodeType.GATEWAY assert isinstance(domain_peer, NodePeer) assert isinstance(domain_peer.node_routes[0], VeilidNodeRoute) - assert domain_peer.node_routes[0].dht_key == gateway_veilid_route.dht_key + assert domain_peer.node_routes[0].vld_key == gateway_veilid_route.vld_key assert domain_client.name == proxy_domain_client.name # Gateway Asserts assert len(gateway_client.peers) == 1 assert gateway_peer.node_type == NodeType.DOMAIN assert isinstance(gateway_peer.node_routes[0], VeilidNodeRoute) - assert gateway_peer.node_routes[0].dht_key == domain_veilid_route.dht_key + assert gateway_peer.node_routes[0].vld_key == domain_veilid_route.vld_key assert gateway_client.name == domain_peer.name assert len(gateway_client.domains) == 1 assert len(gateway_client.enclaves) == 0