Skip to content

Commit

Permalink
Fix: use UUID types for request/execution IDs
Browse files Browse the repository at this point in the history
Problem: older versions of aleph-sdk-python do not support serializing
UUID objects.

Solution: use the latest version of aleph-sdk-python.
  • Loading branch information
odesenfans committed Sep 22, 2023
1 parent 7d21d73 commit 57b6ffe
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ package_dir =
# For more information, check out https://semver.org/.
install_requires =
aiohttp
aleph-sdk-python==0.7.0
aleph-sdk-python@git+https://github.com/aleph-im/aleph-sdk-python@28a10519a5dce4d1f25fb5d9d08c077eb60690e5
fastapi
importlib-metadata; python_version<"3.8"
utilitybelt
Expand Down
2 changes: 1 addition & 1 deletion src/aleph_vrf/coordinator/vrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async def generate_vrf(account: ETHAccount) -> VRFResponse:
nb_executors=nb_executors,
nonce=nonce,
vrf_function=ItemHash(settings.FUNCTION),
request_id=RequestId(str(uuid4())),
request_id=RequestId(uuid4()),
node_list_hash=sha3_256(selected_node_list).hexdigest(),
)

Expand Down
2 changes: 1 addition & 1 deletion src/aleph_vrf/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class VRFGenerationRequest(BaseModel):
nb_bytes: int
nonce: Nonce
request_id: RequestId
execution_id: ExecutionId = Field(default_factory=lambda: str(uuid4()))
execution_id: ExecutionId = Field(default_factory=uuid4)
vrf_function: ItemHash


Expand Down
5 changes: 2 additions & 3 deletions src/aleph_vrf/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
from pydantic import UUID4

Nonce = NewType("Nonce", int)
# TODO: use UUID once https://github.com/aleph-im/aleph-sdk-python/pull/61 is merged
RequestId = NewType("RequestId", str)
ExecutionId = NewType("ExecutionId", str)
RequestId = NewType("RequestId", UUID4)
ExecutionId = NewType("ExecutionId", UUID4)
3 changes: 2 additions & 1 deletion tests/executor/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import datetime as dt
from hashlib import sha256
from typing import Dict, Any, Union, Tuple
from uuid import UUID

import aiohttp
import pytest
Expand Down Expand Up @@ -70,7 +71,7 @@ def make_post_message(

@pytest.fixture
def mock_vrf_request() -> VRFRequest:
request_id = RequestId("513eb52c-cb74-463a-b40e-0e2adedafb8b")
request_id = RequestId(UUID("513eb52c-cb74-463a-b40e-0e2adedafb8b"))

vrf_request = VRFRequest(
nb_bytes=32,
Expand Down

0 comments on commit 57b6ffe

Please sign in to comment.