Skip to content

Commit

Permalink
Merge branch 'main' into jean/economic-model-sigmoid-based
Browse files Browse the repository at this point in the history
  • Loading branch information
jeandemeusy committed Jun 7, 2024
2 parents f27a0b3 + 3f3e167 commit eaaa0db
Show file tree
Hide file tree
Showing 48 changed files with 959 additions and 935 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ __pycache__/
.pytest_cache/

# envs
.venv*/
env*/

.direnv/
simulation.env
.vscode/
Expand All @@ -16,6 +18,7 @@ net_viz-*.png
out.mp4
websocket_client.log
logs/
*.log

#misc
.coverage
Expand Down
19 changes: 13 additions & 6 deletions ct-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ Parameter | Recommanded value (staging) | Description
`GCP_FILE_PREFIX``expected_reward` | File prefix for GCP distribution list storage
`GCP_FOLDER``staging` | Folder on GCP where to store distribution list
`PEER_MIN_VERSION``2.0.0` | Minimum node version to be eligible

`RABBITMQ_HOST` | (check Bitwarden) |
`RABBITMQ_PASSWORD` | (check Bitwarden) |
`RABBITMQ_PROJECT_NAME``ct-app` | Name of the RabbitMQ project
Expand Down Expand Up @@ -179,21 +180,26 @@ Flag | Recommanded value (staging)
`FLAG_NODE_CLOSE_INCOMING_CHANNELS` (Not available) |--
`FLAG_NODE_GET_TOTAL_CHANNEL_FUNDS` |--


Those flags turn on the corresponding feature if the variable exist. Also, the value associated to the flag defines the delay between two executions of the methods.

#### postman
This module handles message distribution. It relies on a bunch of parameters:

Parameter | Recommanded value (staging) | Description
--|--|--
`PARAM_BATCH_SIZE` | `50` |
`PARAM_BATCH_SIZE` | `50` | Number of messages to send before checking the inbox
`PARAM_DELAY_BETWEEN_TWO_MESSAGES` | `0.25` | Delay between two messages
`PARAM_MESSAGE_DELIVERY_TIMEOUT` | `10` | Delay between two batches
`PARAM_MAX_ATTEMPTS` | `4` | Maximum number of retries before timing out
`RABBITMQ_PROJECT_NAME``ct-app` | Name of the RabbitMQ project
`PARAM_MESSAGE_DELIVERY_TIMEOUT` | `10` | Delay between two batches

#### Common parameters
In addition to the above-mentioned parameters, there's a bunch of parameters that are required to be able to communicate with databases, RabbitMQ brokers, and nodes.
Parameter | Recommanded value (staging) | Description
--|--|--
`RABBITMQ_HOST` | (check Bitwarden) |
`RABBITMQ_PASSWORD` | (check Bitwarden) |
`RABBITMQ_PROJECT_NAME``ct-app` | Name of the RabbitMQ project
`RABBITMQ_TASK_NAME``fake_task` | Task to create when distributing rewards
`RABBITMQ_USERNAME` | (check Bitwarden) |
`RABBITMQ_VIRTUALHOST` | (check Bitwarden) |
`PGHOST` | (from gcloud) |
Expand All @@ -205,8 +211,9 @@ Parameter | Recommanded value (staging) | Description
`PGSSLKEY` |  | Path to the SSL user key
`PGSSLROOTCERT` |  | Path to the SSL root certificate
`PGSSLMODE` | `verify-ca` |
`NODE_ADDRESS_X` (multiple, min. 2) | (check Bitwarden) |
`NODE_KEY` | (check Bitwarden) |
`NODE_ADDRESS_X` (multiple, min. 2) | (check Bitwarden) | Node endpoints in the format `http://ip:port`
`NODE_KEY_X` (multiple, min. 2) | (check Bitwarden) | Node API token


This program logs to STDOUT. The log level is set to INFO by default.

Expand Down
3 changes: 3 additions & 0 deletions ct-app/core/components/baseclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@


class Base:
"""
Base class for logging and printing messages with different colors.
"""
handler = logging.StreamHandler()
handler.setFormatter(formatter)

Expand Down
16 changes: 13 additions & 3 deletions ct-app/core/components/graphql_providers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
from pathlib import Path

from gql import Client, gql
Expand Down Expand Up @@ -54,7 +55,13 @@ async def _test_query(self, key: str, **kwargs) -> bool:
"""
vars = {"first": 1, "skip": 0}
vars.update(kwargs)
response = await self._execute(self._sku_query, vars)

# call `self._execute(self._sku_query, vars)` with a timeout
try:
response = await asyncio.wait_for(self._execute(self._sku_query, vars), timeout=30)
except asyncio.TimeoutError:
self.error("Query timeout occurred")
return False

return response and key in response

Expand All @@ -73,8 +80,11 @@ async def _get(self, key: str, **kwargs) -> dict:
vars = {"first": page_size, "skip": skip}
vars.update(kwargs)

response = await self._execute(self._sku_query, vars)

try:
response = await asyncio.wait_for(self._execute(self._sku_query, vars), timeout=30)
except asyncio.TimeoutError:
self.error("Timeout error while fetching data from subgraph.")
break
if response is None:
break

Expand Down
Loading

0 comments on commit eaaa0db

Please sign in to comment.