Skip to content

Commit cbc34bf

Browse files
committed
task sender ansible
1 parent 882d9e5 commit cbc34bf

8 files changed

Lines changed: 493 additions & 4 deletions

File tree

Makefile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,6 +1829,52 @@ grafana_deploy: ## Deploy Grafana only. Usage: make grafana_deploy ENV=hoodi
18291829
-e "host=metrics" \
18301830
-e "env=$(ENV)"
18311831

1832+
# ------------------------------------------------------------------------------
1833+
# Task Sender Deployment
1834+
# ------------------------------------------------------------------------------
1835+
1836+
.PHONY: task_sender_deploy
1837+
task_sender_deploy: ## Deploy task sender. Usage: make task_sender_deploy ENV=hoodi
1838+
@if [ -z "$(ENV)" ]; then \
1839+
echo "Error: ENV must be set (hoodi or mainnet)"; \
1840+
exit 1; \
1841+
fi
1842+
@ansible-playbook $(AGG_MODE_PLAYBOOKS_DIR)/task_sender.yaml \
1843+
-i $(AGG_MODE_ANSIBLE_DIR)/$(ENV)-inventory.yaml \
1844+
-e "host=task_sender" \
1845+
-e "env=$(ENV)"
1846+
1847+
.PHONY: task_sender_status
1848+
task_sender_status: ## Check task sender status. Usage: make task_sender_status ENV=hoodi
1849+
@if [ -z "$(ENV)" ]; then \
1850+
echo "Error: ENV must be set (hoodi or mainnet)"; \
1851+
exit 1; \
1852+
fi
1853+
@echo "Checking task sender tmux session..."
1854+
@ansible -i $(AGG_MODE_ANSIBLE_DIR)/$(ENV)-inventory.yaml task_sender \
1855+
-m shell \
1856+
-a "tmux has-session -t task_sender && echo 'Task sender is running' || echo 'Task sender is not running'"
1857+
1858+
.PHONY: task_sender_logs
1859+
task_sender_logs: ## View task sender logs. Usage: make task_sender_logs ENV=hoodi
1860+
@if [ -z "$(ENV)" ]; then \
1861+
echo "Error: ENV must be set (hoodi or mainnet)"; \
1862+
exit 1; \
1863+
fi
1864+
@echo "Use: ssh app@agg-mode-$(ENV)-task-sender 'tmux attach -t task_sender'"
1865+
@echo "Or: ssh app@agg-mode-$(ENV)-task-sender 'tmux capture-pane -t task_sender -p'"
1866+
1867+
.PHONY: task_sender_restart
1868+
task_sender_restart: ## Restart task sender. Usage: make task_sender_restart ENV=hoodi
1869+
@if [ -z "$(ENV)" ]; then \
1870+
echo "Error: ENV must be set (hoodi or mainnet)"; \
1871+
exit 1; \
1872+
fi
1873+
@ansible-playbook $(AGG_MODE_PLAYBOOKS_DIR)/task_sender.yaml \
1874+
-i $(AGG_MODE_ANSIBLE_DIR)/$(ENV)-inventory.yaml \
1875+
-e "host=task_sender" \
1876+
-e "env=$(ENV)"
1877+
18321878
# ------------------------------------------------------------------------------
18331879
# Full Deployment
18341880
# ------------------------------------------------------------------------------

infra/aggregation_mode/ansible/README.md

Lines changed: 190 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ The Ansible automation deploys a complete aggregation mode stack consisting of:
3737
- Grafana for visualization
3838
- 90-day retention
3939

40+
5. **Task Sender** (1 server)
41+
- Automated proof submission service
42+
- Runs continuously in tmux session
43+
- Configurable interval and proof files
44+
4045
## Architecture
4146

4247
```
@@ -65,6 +70,11 @@ The Ansible automation deploys a complete aggregation mode stack consisting of:
6570
│ │ └─ Grafana (3000) │ │
6671
│ └────────────────────────┘ │
6772
│ │
73+
│ ┌────────────────────────┐ │
74+
│ │ Task Sender │ │
75+
│ │ (tmux session) │ │
76+
│ └────────────────────────┘ │
77+
│ │
6878
└─────────────────────────────────────────────────────────────────┘
6979
```
7080

@@ -120,6 +130,9 @@ tls_key_source_path=/path/to/your/key.pem
120130

121131
# REQUIRED: Same password for Grafana Postgres datasource
122132
grafana_postgres_password=your_secure_password_here
133+
134+
# REQUIRED: Private key for task sender (sends proofs to network)
135+
task_sender_private_key=0xYourPrivateKeyHere
123136
```
124137

125138
**⚠️ CRITICAL**: All three password fields must be set to the same value before deploying!
@@ -143,6 +156,9 @@ grafana_postgres_password=your_secure_password_here
143156
tls_cert_source_path=/path/to/your/cert.pem
144157
tls_key_source_path=/path/to/your/key.pem
145158

159+
# REQUIRED: Private key for task sender
160+
task_sender_private_key=0xYourPrivateKeyHere
161+
146162
# TODO: Update these for mainnet deployment
147163
gateway_payment_service_address=0xYourMainnetPaymentServiceAddress
148164
gateway_eth_rpc_url=https://your-mainnet-rpc-url
@@ -181,6 +197,13 @@ tls_key_source_path= # ← FILL THIS IN
181197
# Metrics Configuration
182198
grafana_postgres_password= # ← FILL THIS IN (same as db_password)
183199
# ... other metrics settings ...
200+
201+
# Task Sender Configuration
202+
task_sender_interval_hours=1
203+
task_sender_proof_path=scripts/test_files/sp1/sp1_fibonacci_5_0_0.proof
204+
task_sender_vk_path=scripts/test_files/sp1/sp1_fibonacci_5_0_0_vk.bin
205+
task_sender_private_key= # ← FILL THIS IN
206+
task_sender_network=hoodi
184207
```
185208

186209
The Ansible templates will automatically generate two separate database connection URLs for failover:
@@ -204,6 +227,7 @@ This will:
204227
2. Run database migrations
205228
3. Deploy gateway and poller on both servers
206229
4. Deploy Prometheus and Grafana
230+
5. Deploy task sender
207231

208232
### Step-by-Step Deployment
209233

@@ -279,6 +303,49 @@ make grafana_deploy ENV=hoodi
279303
- Prometheus: `http://<metrics-server-ip>:9090`
280304
- Grafana: `http://<metrics-server-ip>:3000` (default credentials: admin/admin)
281305

306+
#### 4. Deploy Task Sender
307+
308+
```bash
309+
# Deploy task sender
310+
make task_sender_deploy ENV=hoodi
311+
```
312+
313+
The task sender runs in a tmux session and continuously sends proofs to the network at the configured interval (default: 1 hour).
314+
315+
**Automatic Deposit Check:**
316+
317+
The deployment automatically:
318+
1. Derives the wallet address from the configured private key
319+
2. Checks if the address has an active subscription on the payment contract
320+
3. If not subscribed or expired, automatically deposits 0.0035 ETH to the payment contract
321+
4. Waits for transaction confirmation before starting the task sender
322+
323+
**Requirements:**
324+
- The account must have sufficient ETH for:
325+
- Payment deposit: **0.0035 ETH**
326+
- Gas fees: ~**0.001 ETH** (estimated)
327+
- Foundry (cast) will be automatically installed if not present
328+
329+
**Verify task sender is running:**
330+
```bash
331+
make task_sender_status ENV=hoodi
332+
```
333+
334+
**View task sender logs:**
335+
```bash
336+
# Show how to view logs
337+
make task_sender_logs ENV=hoodi
338+
339+
# Or directly attach to the tmux session
340+
ssh app@agg-mode-hoodi-sender 'tmux attach -t task_sender'
341+
# Press Ctrl+B then D to detach without stopping
342+
```
343+
344+
**Restart task sender:**
345+
```bash
346+
make task_sender_restart ENV=hoodi
347+
```
348+
282349
## Service Management
283350

284351
### Restart Services
@@ -295,6 +362,11 @@ make poller_restart ENV=hoodi HOST=gateway_primary
295362
make poller_restart ENV=hoodi HOST=gateway_secondary
296363
```
297364

365+
**Task Sender:**
366+
```bash
367+
make task_sender_restart ENV=hoodi
368+
```
369+
298370
### Check Service Status
299371

300372
**PostgreSQL Cluster:**
@@ -324,6 +396,13 @@ ssh admin@agg-mode-hoodi-metrics "systemctl --user status prometheus"
324396
ssh admin@agg-mode-hoodi-metrics "sudo systemctl status grafana-server"
325397
```
326398

399+
**Task Sender:**
400+
```bash
401+
make task_sender_status ENV=hoodi
402+
# Or check tmux session directly
403+
ssh app@agg-mode-hoodi-sender "tmux has-session -t task_sender && echo 'Running' || echo 'Not running'"
404+
```
405+
327406
### View Logs
328407

329408
**Gateway:**
@@ -341,6 +420,16 @@ ssh app@agg-mode-hoodi-gateway-1 "journalctl --user -u poller -f"
341420
ssh admin@agg-mode-hoodi-postgres-1 "sudo journalctl -u pgautofailover -f"
342421
```
343422

423+
**Task Sender:**
424+
```bash
425+
# Attach to tmux session to view live logs
426+
ssh app@agg-mode-hoodi-sender 'tmux attach -t task_sender'
427+
# Press Ctrl+B then D to detach
428+
429+
# Or capture current pane output
430+
ssh app@agg-mode-hoodi-sender 'tmux capture-pane -t task_sender -p'
431+
```
432+
344433
## Verification
345434

346435
### PostgreSQL Cluster Health
@@ -416,6 +505,23 @@ ssh admin@agg-mode-hoodi-postgres-1 "sudo journalctl -u pgautofailover -f"
416505
- Go to Configuration → Data Sources
417506
- Verify Prometheus and PostgreSQL datasources are connected
418507

508+
### Task Sender
509+
510+
1. **Check tmux session is running:**
511+
```bash
512+
make task_sender_status ENV=hoodi
513+
```
514+
515+
2. **View recent logs:**
516+
```bash
517+
ssh app@agg-mode-hoodi-sender 'tmux capture-pane -t task_sender -p'
518+
```
519+
520+
3. **Verify proof submissions:**
521+
- Check logs for successful proof submissions
522+
- Look for transaction hashes in the output
523+
- Verify proofs are appearing on the network
524+
419525
## Troubleshooting
420526

421527
### PostgreSQL Issues
@@ -508,6 +614,83 @@ Check Prometheus config:
508614
ssh admin@agg-mode-hoodi-metrics "cat ~/config/prometheus.yaml"
509615
```
510616

617+
### Task Sender Issues
618+
619+
**Problem: Task sender not running**
620+
621+
Check if tmux session exists:
622+
```bash
623+
ssh app@agg-mode-hoodi-sender "tmux list-sessions"
624+
```
625+
626+
If missing, redeploy:
627+
```bash
628+
make task_sender_deploy ENV=hoodi
629+
```
630+
631+
**Problem: Task sender crashes or exits**
632+
633+
Check logs for errors:
634+
```bash
635+
ssh app@agg-mode-hoodi-sender 'tmux capture-pane -t task_sender -p -S -100'
636+
```
637+
638+
Common issues:
639+
- Invalid private key → Check `task_sender_private_key` in `config-{{ env }}.ini`
640+
- Missing proof/vk files → Verify files exist: `task_sender_proof_path`, `task_sender_vk_path`
641+
- Network connectivity → Test RPC: `curl https://aligned-hoodi-rpc-geth.tail665ae.ts.net`
642+
- Insufficient balance → Check account has ETH for gas fees
643+
644+
**Problem: Proofs not being submitted**
645+
646+
Check interval configuration:
647+
```bash
648+
ssh app@agg-mode-hoodi-sender "cat ~/repos/sender/aligned_layer/scripts/.agg_mode.task_sender.env"
649+
```
650+
651+
Verify `INTERVAL_HOURS` is set correctly (default: 1 hour). Attach to session to see live activity:
652+
```bash
653+
ssh app@agg-mode-hoodi-sender 'tmux attach -t task_sender'
654+
```
655+
656+
**Problem: Deployment fails with insufficient balance**
657+
658+
The automatic deposit check requires the account to have at least **0.0045 ETH** (0.0035 for deposit + ~0.001 for gas).
659+
660+
Check account balance:
661+
```bash
662+
ssh app@agg-mode-hoodi-sender
663+
export PATH=$HOME/.foundry/bin:$PATH
664+
cast balance <YOUR_WALLET_ADDRESS> --rpc-url <RPC_URL>
665+
```
666+
667+
If balance is insufficient, send ETH to the account and redeploy:
668+
```bash
669+
make task_sender_deploy ENV=hoodi
670+
```
671+
672+
**Problem: Automatic deposit fails**
673+
674+
If the automatic deposit fails during deployment, check the Ansible output for error messages. Common issues:
675+
- Insufficient ETH balance in the account
676+
- RPC connection issues
677+
- Gas price too high
678+
679+
To manually deposit after fixing the issue:
680+
```bash
681+
ssh app@agg-mode-hoodi-sender
682+
export PATH=$HOME/.cargo/bin:$PATH
683+
agg_mode_cli deposit \
684+
--network hoodi \
685+
--rpc-url https://aligned-hoodi-rpc-geth.tail665ae.ts.net \
686+
--private-key <YOUR_PRIVATE_KEY>
687+
```
688+
689+
Then restart the task sender:
690+
```bash
691+
make task_sender_restart ENV=hoodi
692+
```
693+
511694
### General Debugging
512695

513696
**Check Tailscale connectivity:**
@@ -663,6 +846,7 @@ infra/aggregation_mode/ansible/
663846
├── poller.yaml # Poller deployment
664847
├── prometheus_agg_mode.yaml # Prometheus deployment
665848
├── grafana_agg_mode.yaml # Grafana deployment
849+
├── task_sender.yaml # Task sender deployment
666850
├── postgres_cluster.yaml # Postgres orchestration
667851
├── gateway_stack.yaml # Gateway + poller orchestration
668852
├── metrics_stack.yaml # Metrics orchestration
@@ -673,13 +857,15 @@ infra/aggregation_mode/ansible/
673857

674858
1. **Passwords**: Config files are tracked in git with empty password fields. Fill in passwords locally. Use `git update-index --assume-unchanged config-*.ini` after filling passwords to prevent accidentally committing them.
675859

676-
2. **TLS Certificates**: Keep private keys secure. The playbooks set appropriate permissions (0600).
860+
2. **Private Keys**: The `task_sender_private_key` field must be filled with a valid Ethereum private key. Never commit this value to git. The playbook sets appropriate permissions (0600) on the environment file.
861+
862+
3. **TLS Certificates**: Keep private keys secure. The playbooks set appropriate permissions (0600).
677863

678-
3. **SSH Access**: All servers are only accessible via Tailscale VPN (100.64.0.0/10).
864+
4. **SSH Access**: All servers are only accessible via Tailscale VPN (100.64.0.0/10).
679865

680-
4. **PostgreSQL**: Uses scram-sha-256 password authentication, not trust mode.
866+
5. **PostgreSQL**: Uses scram-sha-256 password authentication, not trust mode.
681867

682-
5. **Firewall**: UFW is configured on all servers with deny-by-default policy.
868+
6. **Firewall**: UFW is configured on all servers with deny-by-default policy.
683869

684870
## Support
685871

infra/aggregation_mode/ansible/hoodi-inventory.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,19 @@ metrics:
6565
ansible_user: admin
6666
ansible_python_interpreter: /usr/bin/python3
6767

68+
# Task Sender
69+
task_sender:
70+
hosts:
71+
agg-mode-hoodi-sender:
72+
ansible_host: agg-mode-hoodi-sender
73+
admin_user: admin
74+
ansible_user: app
75+
ansible_python_interpreter: /usr/bin/python3
76+
6877
# All aggregation mode servers
6978
aggregation_mode:
7079
children:
7180
postgres_cluster:
7281
gateway_cluster:
7382
metrics:
83+
task_sender:

infra/aggregation_mode/ansible/mainnet-inventory.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,19 @@ metrics:
6565
ansible_user: admin
6666
ansible_python_interpreter: /usr/bin/python3
6767

68+
# Task Sender
69+
task_sender:
70+
hosts:
71+
agg-mode-mainnet-sender:
72+
ansible_host: agg-mode-mainnet-sender
73+
admin_user: admin
74+
ansible_user: app
75+
ansible_python_interpreter: /usr/bin/python3
76+
6877
# All aggregation mode servers
6978
aggregation_mode:
7079
children:
7180
postgres_cluster:
7281
gateway_cluster:
7382
metrics:
83+
task_sender:

infra/aggregation_mode/ansible/playbooks/deploy_all.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,9 @@
2020
vars:
2121
host: metrics
2222
env: "{{ env }}"
23+
24+
- name: Deploy Task Sender
25+
ansible.builtin.import_playbook: task_sender.yaml
26+
vars:
27+
host: task_sender
28+
env: "{{ env }}"

0 commit comments

Comments
 (0)