Skip to content

Commit

Permalink
Fix: vm-connector used obsolete software
Browse files Browse the repository at this point in the history
The vm-connector service used to run with obsolete versions of the aleph-sdk and Python.

Solution: Use the latest the version of the SDK and pin the version of dependencies.
  • Loading branch information
hoh committed Apr 10, 2024
1 parent ab29137 commit cc6f432
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
4 changes: 2 additions & 2 deletions docker/vm_connector.dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM python:3.9
FROM python:3.11

RUN apt-get update && apt-get -y upgrade && apt-get install -y \
libsecp256k1-dev \
zip \
&& rm -rf /var/lib/apt/lists/*

RUN pip install fastapi aiofiles uvicorn aleph-client eth-account
RUN pip install 'fastapi==0.110.0' 'aiofiles==23.2.1' 'uvicorn==0.29.0' 'aleph-sdk-python==0.9.1'

WORKDIR /opt
ENV PYTHONPATH=/opt
Expand Down
35 changes: 20 additions & 15 deletions vm_connector/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
from typing import Dict, Optional, Union

import aiohttp
from aleph_client.asynchronous import create_post
from aleph_client.chains.common import get_fallback_private_key
from aleph_client.chains.ethereum import ETHAccount
from aleph_client.types import StorageEnum
from aleph.sdk import AuthenticatedAlephHttpClient
from aleph.sdk.chains.common import get_fallback_private_key
from aleph.sdk.chains.ethereum import ETHAccount
from aleph.sdk.types import StorageEnum
from aleph_message.status import MessageStatus
from fastapi import FastAPI, HTTPException, Request
from fastapi.responses import Response, StreamingResponse
from pydantic import BaseModel
Expand Down Expand Up @@ -167,17 +168,21 @@ async def publish_data(body: PostBody):
content = json.loads(message["item_content"])
content_content = content["content"]

result = await create_post(
account=account,
post_content=content_content,
post_type=content["type"],
address=content["address"],
ref=None,
channel=message["channel"],
inline=True,
storage_engine=StorageEnum.storage,
)
return {"status": "success"}
async with AuthenticatedAlephHttpClient(account) as client:
result, status = await client.create_post(
post_content=content_content,
post_type=content["type"],
address=content["address"],
ref=None,
channel=message["channel"],
inline=True,
storage_engine=StorageEnum.storage,
sync=True,
)
if status == MessageStatus.PROCESSED:
return {"status": "success"}
else:
return {"status": "error"}


@app.get("/properties")
Expand Down

0 comments on commit cc6f432

Please sign in to comment.