From fb009b2b3ed945eabdad41937b7ae2e0f5ae8e90 Mon Sep 17 00:00:00 2001 From: Diego Campo Date: Sat, 13 Apr 2024 13:46:43 +0200 Subject: [PATCH] Minor fixes and README --- .gitignore | 1 + Dockerfile_b7s | 2 +- README.md | 2 ++ app.py | 6 +++--- docker-compose.yml | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 65b57b1..ec1cbce 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ logs/* worker-data head-data truth-data +prices.db diff --git a/Dockerfile_b7s b/Dockerfile_b7s index 4f00402..31f346f 100644 --- a/Dockerfile_b7s +++ b/Dockerfile_b7s @@ -1,4 +1,4 @@ -FROM --platform=linux/amd64 alloranetwork/allora-inference-base:latest +FROM --platform=linux/amd64 allora-inference-base:dev-latest USER root RUN pip install requests diff --git a/README.md b/README.md index 761ab12..b586e76 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ The `Dockerfile_b7s` file is functional but simple, so you may want to change it For further details, please check the base repo [allora-inference-base](https://github.com/allora-network/allora-inference-base). +Note: The reputers use an internal blockless topic adding the suffix `/reputer` to be added to the `--topic` flag, but not to the `--allora-chain-topic-id`. + ### Application path By default, the application runtime lives under `/app`, as well as the Python code the worker provides (`/app/main.py`). The current user needs to have write permissions on `/app/runtime`. diff --git a/app.py b/app.py index 1d7c3ce..f2cb621 100644 --- a/app.py +++ b/app.py @@ -50,7 +50,7 @@ def update_price(token_name, token_from, token_to): return jsonify({'error': 'Invalid token ID'}), 400 timestamp = int(datetime.now().timestamp()) - token = token_name.upper() + token = token_name.lower() # Save price into database conn = sqlite3.connect(DATABASE_PATH) @@ -84,7 +84,7 @@ def init_price_token(token_name, token_from, token_to): # Check if there is any existing data for the specified token conn = sqlite3.connect(DATABASE_PATH) cursor = conn.cursor() - cursor.execute("SELECT COUNT(*) FROM prices WHERE token=? LIMIT 1", (token_name.upper(),)) + cursor.execute("SELECT COUNT(*) FROM prices WHERE token=? LIMIT 1", (token_name.lower(),)) count = cursor.fetchone()[0] conn.close() @@ -111,7 +111,7 @@ def init_price_token(token_name, token_from, token_to): for data_point in historical_data: timestamp = int(data_point[0] / 1000) # Convert milliseconds to seconds price = data_point[1] - cursor.execute("INSERT INTO prices (timestamp, token, price) VALUES (?, ?, ?)", (timestamp, token_name.upper(), price)) + cursor.execute("INSERT INTO prices (timestamp, token, price) VALUES (?, ?, ?)", (timestamp, token_name.lower(), price)) print(f"inserting data point {timestamp} : {price}" ) conn.commit() conn.close() diff --git a/docker-compose.yml b/docker-compose.yml index a56f7e4..28abccf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -45,7 +45,7 @@ services: --runtime-path=/app/runtime --runtime-cli=bls-runtime --workspace=/data/workspace \ --private-key=/data/keys/priv.bin --log-level=debug --port=9011 \ --boot-nodes=/ip4/172.20.0.100/tcp/9010/p2p/12D3KooWNbKMnvUWZ2e3Z5bm4GzSJht7SALzpW2MsS2CBKfXuFfK \ - --topic=1 + --topic=1/reputer volumes: - ./worker-data:/data working_dir: /data