Skip to content

Commit 1048b78

Browse files
JuArceavilagaston9JulianVenturaJulian Venturauri-99
authored
refactor(tracker): rewrite operator tracker in elixir (#1000)
Co-authored-by: Avila Gastón <[email protected]> Co-authored-by: Julian Ventura <[email protected]> Co-authored-by: Julian Ventura <[email protected]> Co-authored-by: avilagaston9 <[email protected]> Co-authored-by: Urix <[email protected]>
1 parent 08f91d1 commit 1048b78

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1768
-4
lines changed

Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,3 +656,41 @@ tracker_dump_db:
656656
@cd operator_tracker && \
657657
docker exec -t tracker-postgres-container pg_dumpall -c -U tracker_user > dump.$$(date +\%Y\%m\%d_\%H\%M\%S).sql
658658
@echo "Dumped database successfully to /operator_tracker"
659+
660+
__TELEMETRY__:
661+
open_telemetry_start: ## Run open telemetry services using telemetry-docker-compose.yaml
662+
## TODO(juarce) ADD DOCKER COMPOSE
663+
@echo "Running telemetry..."
664+
@docker compose -f telemetry-docker-compose.yaml up -d
665+
666+
telemetry_start: telemetry_run_db telemetry_ecto_migrate ## Run Telemetry API
667+
@cd telemetry_api && \
668+
./start.sh
669+
670+
telemetry_ecto_migrate: ##
671+
@cd telemetry_api && \
672+
./ecto_setup_db.sh
673+
674+
telemetry_build_db:
675+
@cd telemetry_api && \
676+
docker build -t telemetry-postgres-image .
677+
678+
telemetry_run_db: telemetry_build_db telemetry_remove_db_container
679+
@cd telemetry_api && \
680+
docker run -d --name telemetry-postgres-container -p 5434:5432 -v telemetry-postgres-data:/var/lib/postgresql/data telemetry-postgres-image
681+
682+
telemetry_remove_db_container:
683+
@docker stop telemetry-postgres-container || true && \
684+
docker rm telemetry-postgres-container || true
685+
686+
telemetry_clean_db: telemetry_remove_db_container
687+
@docker volume rm telemetry-postgres-data || true
688+
689+
telemetry_dump_db:
690+
@cd telemetry_api && \
691+
docker exec -t telemetry-postgres-container pg_dumpall -c -U telemetry_user > dump.$$(date +\%Y\%m\%d_\%H\%M\%S).sql
692+
@echo "Dumped database successfully to /telemetry_api"
693+
694+
telemetry_create_env:
695+
@cd telemetry_api && \
696+
cp .env.dev .env

config-files/config-operator-1.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ bls:
2222
## Operator Configurations
2323
operator:
2424
aggregator_rpc_server_ip_port_address: localhost:8090
25-
operator_tracker_ip_port_address: http://localhost:3030
25+
operator_tracker_ip_port_address: http://localhost:4001
2626
address: 0x70997970C51812dc3A010C7d01b50e0d17dc79C8
2727
earnings_receiver_address: 0x70997970C51812dc3A010C7d01b50e0d17dc79C8
2828
delegation_approver_address: '0x0000000000000000000000000000000000000000'

config-files/config-operator-2.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ bls:
2222
## Operator Configurations
2323
operator:
2424
aggregator_rpc_server_ip_port_address: localhost:8090
25-
operator_tracker_ip_port_address: http://localhost:3030
25+
operator_tracker_ip_port_address: http://localhost:4001
2626
address: 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC
2727
earnings_receiver_address: 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC
2828
delegation_approver_address: '0x0000000000000000000000000000000000000000'

config-files/config-operator-3.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ bls:
2222
## Operator Configurations
2323
operator:
2424
aggregator_rpc_server_ip_port_address: localhost:8090
25-
operator_tracker_ip_port_address: http://localhost:3030
25+
operator_tracker_ip_port_address: http://localhost:4001
2626
address: 0x90F79bf6EB2c4f870365E785982E1f101E93b906
2727
earnings_receiver_address: 0x90F79bf6EB2c4f870365E785982E1f101E93b906
2828
delegation_approver_address: '0x0000000000000000000000000000000000000000'

config-files/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ aggregator:
3939
## Operator Configurations
4040
operator:
4141
aggregator_rpc_server_ip_port_address: localhost:8090
42-
operator_tracker_ip_port_address: http://localhost:3030
42+
operator_tracker_ip_port_address: http://localhost:4001
4343
address: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
4444
earnings_receiver_address: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
4545
delegation_approver_address: '0x0000000000000000000000000000000000000000'

telemetry_api/.env.dev

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALIGNED_CONFIG_FILE="../contracts/script/output/devnet/alignedlayer_deployment_output.json"
2+
ENVIRONMENT=devnet

telemetry_api/.formatter.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[
2+
import_deps: [:ecto, :ecto_sql, :phoenix],
3+
subdirectories: ["priv/*/migrations"],
4+
inputs: ["*.{ex,exs}", "{config,lib,test}/**/*.{ex,exs}", "priv/*/seeds.exs"]
5+
]

telemetry_api/.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# The directory Mix will write compiled artifacts to.
2+
/_build/
3+
4+
# If you run "mix test --cover", coverage assets end up here.
5+
/cover/
6+
7+
# The directory Mix downloads your dependencies sources to.
8+
/deps/
9+
10+
# Where 3rd-party dependencies like ExDoc output generated docs.
11+
/doc/
12+
13+
# Ignore .fetch files in case you like to edit your project deps locally.
14+
/.fetch
15+
16+
# If the VM crashes, it generates a dump, let's ignore it too.
17+
erl_crash.dump
18+
19+
# Also ignore archive artifacts (built via "mix archive.build").
20+
*.ez
21+
22+
# Temporary files, for example, from tests.
23+
/tmp/
24+
25+
# Ignore package tarball (built via "mix hex.build").
26+
telemetry_api-*.tar
27+
28+
# Elixir lsp server
29+
.elixir_ls

telemetry_api/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# https://hub.docker.com/_/postgres
2+
FROM postgres:16.3
3+
4+
# Environment variables
5+
ENV POSTGRES_USER=telemetry_user
6+
ENV POSTGRES_PASSWORD=telemetry_pass
7+
ENV POSTGRES_DB=telemetry_db
8+
9+
# Expose the default PostgreSQL port
10+
EXPOSE 5432

telemetry_api/README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# TelemetryApi
2+
3+
## Database Setup
4+
5+
To create a Postgres container and run it:
6+
7+
```shell
8+
make telemetry_run_db
9+
```
10+
11+
This will create and run the container using the credentials set in `Dockerfile`
12+
13+
> [!CAUTION]
14+
> Do not use default credentials in Production environments.
15+
16+
### Delete database
17+
18+
If you want to delete the container:
19+
20+
```shell
21+
make telemetry_remove_db_container
22+
```
23+
24+
This will remove the container but will keep the storage
25+
26+
If you also want to delete the storage run:
27+
28+
```shell
29+
make telemetry_clean_db
30+
```
31+
32+
## Run Server
33+
34+
First you need to manually set the `telemetry_api/.env` file.
35+
36+
To use `telemetry_api/.env.dev`, run:
37+
38+
```shell
39+
make telemetry_create_env
40+
```
41+
42+
To start your Phoenix server:
43+
44+
```shell
45+
make telemetry_start
46+
```
47+
48+
On startup, it will run ecto migrations.
49+
50+
* Run `mix setup` to install and setup dependencies
51+
* Start Phoenix endpoint with `mix phx.server` or inside IEx with `iex -S mix phx.server`
52+
53+
Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
54+
55+
## Database Migrations
56+
57+
This API uses Ecto for migrations. To apply migrations, run:
58+
59+
```shell
60+
make telemetry_ecto_migrate
61+
```
62+
63+

0 commit comments

Comments
 (0)