Skip to content

Commit 947bc03

Browse files
authored
Merge pull request #355 from gnosischain/develop
feat: alerts and update validator addresses
2 parents ce51d72 + 9d6129d commit 947bc03

24 files changed

+1155
-370
lines changed

alerts/.dockerignore

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Dependencies
2+
node_modules
3+
npm-debug.log*
4+
yarn-debug.log*
5+
yarn-error.log*
6+
7+
# Runtime data
8+
pids
9+
*.pid
10+
*.seed
11+
*.pid.lock
12+
13+
# Coverage directory used by tools like istanbul
14+
coverage
15+
*.lcov
16+
17+
# nyc test coverage
18+
.nyc_output
19+
20+
# Grunt intermediate storage
21+
.grunt
22+
23+
# Bower dependency directory
24+
bower_components
25+
26+
# node-waf configuration
27+
.lock-wscript
28+
29+
# Compiled binary addons
30+
build/Release
31+
32+
# Dependency directories
33+
jspm_packages/
34+
35+
# Optional npm cache directory
36+
.npm
37+
38+
# Optional eslint cache
39+
.eslintcache
40+
41+
# Optional REPL history
42+
.node_repl_history
43+
44+
# Output of 'npm pack'
45+
*.tgz
46+
47+
# Yarn Integrity file
48+
.yarn-integrity
49+
50+
# Environment files
51+
.env
52+
.env.local
53+
.env.development.local
54+
.env.test.local
55+
.env.production.local
56+
57+
# Runtime logs
58+
logs
59+
*.log
60+
61+
# Build outputs (already copied from builder stage)
62+
dist
63+
64+
# Development files
65+
src/**/*.test.ts
66+
src/**/*.spec.ts
67+
**/*.test.js
68+
**/*.spec.js
69+
70+
# IDE files
71+
.vscode
72+
.idea
73+
*.swp
74+
*.swo
75+
*~
76+
77+
# OS files
78+
.DS_Store
79+
.DS_Store?
80+
._*
81+
.Spotlight-V100
82+
.Trashes
83+
ehthumbs.db
84+
Thumbs.db
85+
86+
# Git
87+
.git
88+
.gitignore
89+
.gitattributes
90+
91+
# Docker
92+
Dockerfile
93+
docker-compose.yml
94+
docker-compose.*.yml
95+
.dockerignore
96+
97+
# Documentation
98+
README.md
99+
*.md
100+
docs/
101+
102+
# Alert state data (will be mounted as volume)
103+
data/
104+
105+
# Monitoring config
106+
monitoring/

alerts/.env.example

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,36 @@ SLACK_TOKEN=
44
# Slack Channel to send a message
55
SLACK_CHANNEL=
66

7+
# self-contained slack webhook, doesn't required SLACK_TOKEN & SLACK_CHANNEL if SLACK_WEBHOOK_URL is created
8+
SLACK_WEBHOOK_URL=
9+
710
# Providers URLs
811
MAINNET_RPC_URL=https://rpc.ankr.com/eth
912
GNOSIS_RPC_URL=https://rpc.ankr.com/gnosis
1013

11-
# Subgraph URLs
12-
SUBGRAPH_API_NATIVE=https://api.thegraph.com/subgraphs/name/laimejesus/bridge-monitor-native
13-
SUBGRAPH_API_FOREIGN=https://api.thegraph.com/subgraphs/name/laimejesus/bridge-monitor-foreign
14+
# Envio Indexer URL
15+
ENVIO_INDEXER_URL=
16+
17+
## Validator balance
18+
# true= only track validator balance on Gnosis Chain
19+
IS_VALIDATOR_BALANCE_ON_GC=true
20+
MIN_XDAI_BALANCE_THRESHOLD=1 # 1xdai
21+
MIN_ETH_BALANCE_THRESHOLD=0 # set to 0 because the validator doesn't require balance to claim on Ethereum
22+
23+
## Inactive validator
24+
# max hrs to consider a validator inactive (not calling on chain function)
25+
INACTIVITY_THRESHOLD_HOURS=12
26+
27+
## Stucked tx
28+
# max hrs after first initiated a tx but still at 'COLLECTING' status
29+
TRANSACTION_TIMEOUT_HOURS=1
30+
31+
# Scheduler Configuration
32+
SCHEDULE_ENABLED=true
33+
SCHEDULE_CRON=*/15 * * * *
34+
RUN_ONCE_ON_START=true
35+
36+
# Alert State Management
37+
ALERT_STATE_FILE=./data/stuck-tx-alerts.json
38+
ALERT_CLEANUP_HOURS=48
39+
NODE_ENV=PROD # or DEV

alerts/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,10 @@
1010
# custom logs
1111
/logs
1212

13+
# alert state data
14+
/data
15+
1316
#types
1417
src/types/
18+
19+
/dist

alerts/Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Production stage
2+
FROM node:22-alpine
3+
4+
# Accept build arguments
5+
ARG ENVIO_INDEXER_URL
6+
7+
ENV ENVIO_INDEXER_URL=$ENVIO_INDEXER_URL
8+
9+
# Install dumb-init for proper signal handling
10+
RUN apk add --no-cache dumb-init
11+
12+
# Set working directory
13+
WORKDIR /app
14+
15+
# Copy package files
16+
COPY package.json ./
17+
18+
# Install dependencies using pnpm
19+
RUN corepack enable && corepack prepare pnpm@latest --activate
20+
COPY pnpm-lock.yaml ./
21+
RUN pnpm install --frozen-lockfile
22+
23+
# Copy source code
24+
COPY . .
25+
26+
# Generate types
27+
RUN pnpm typechain
28+
RUN pnpm build
29+
30+
# Create data directory with correct ownership
31+
RUN mkdir -p /app/data
32+
33+
# Use dumb-init to handle signals properly
34+
ENTRYPOINT ["dumb-init", "--"]
35+
36+
# Default command
37+
CMD ["pnpm", "start"]

alerts/README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,22 @@ The alerts that will be sent are:
66

77
- Low Balance (XDAI or ETH) for validators
88
- Low Limits for XDAI Native and Foreign Bridge Contracts (dailyLimit and executionDailyLimit)
9-
- ....
9+
- Invalid validator: When validator is not signing transactions for threshold amount of time
10+
- Stucked Transaction: When a transaction is initiated but still in 'Collecting' status for threshold amount of time
11+
12+
# Dev
13+
14+
```shell
15+
cp .env.example .env
16+
pnpm install && pnpm typechain && pnpm build
17+
pnpm dev # or pnpm start
18+
```
19+
20+
# Run docker
21+
22+
```shell
23+
docker compose up --build
24+
```
1025

1126
### Validators
1227

@@ -19,6 +34,7 @@ A limit is low when it is under 25%? of the total limit per day. (TBD)
1934
## Configuration
2035

2136
Remember to configure Slack App:
37+
2238
- create slack app
2339
- add slack into workspace
2440
- create scope permissions for slack
@@ -29,10 +45,10 @@ Remember to configure Slack App:
2945

3046
- Setup Env Variables
3147
- cp .env.example .env
32-
- Install npm dependencies
33-
- yarn install
48+
- Install dependencies
49+
- pnpm install
3450
- Run script
35-
- yarn dev
51+
- pnpm dev
3652

3753
### References
3854

alerts/docker-compose.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: "3.8"
2+
3+
services:
4+
alerts:
5+
build:
6+
context: .
7+
args:
8+
- ENVIO_INDEXER_URL=${ENVIO_INDEXER_URL}
9+
environment:
10+
- SLACK_TOKEN=${SLACK_TOKEN}
11+
- SLACK_CHANNEL=${SLACK_CHANNEL}
12+
- SLACK_WEBHOOK_URL=${SLACK_WEBHOOK_URL}
13+
- MAINNET_RPC_URL=${MAINNET_RPC_URL}
14+
- GNOSIS_RPC_URL=${GNOSIS_RPC_URL}
15+
- ENVIO_INDEXER_URL=${ENVIO_INDEXER_URL}
16+
- IS_VALIDATOR_BALANCE_ON_GC=${IS_VALIDATOR_BALANCE_ON_GC}
17+
- INACTIVITY_THRESHOLD_HOURS=${INACTIVITY_THRESHOLD_HOURS}
18+
- TRANSACTION_TIMEOUT_HOURS=${TRANSACTION_TIMEOUT_HOURS}
19+
- SCHEDULE_ENABLED=${SCHEDULE_ENABLED:-true}
20+
- SCHEDULE_CRON=${SCHEDULE_CRON}
21+
- RUN_ONCE_ON_START=${RUN_ONCE_ON_START}
22+
- ALERT_STATE_FILE=${ALERT_STATE_FILE:-./data/stuck-tx-alerts.json}
23+
- ALERT_CLEANUP_HOURS=${ALERT_CLEANUP_HOURS:-48}
24+
env_file:
25+
- .env
26+
volumes:
27+
- ./data:/app/data
28+
restart: unless-stopped

alerts/package.json

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,39 @@
99
],
1010
"scripts": {
1111
"dev": "ts-node src/index.ts",
12+
"dev:schedule": "SCHEDULE_ENABLED=true RUN_ONCE_ON_START=true ts-node src/index.ts",
13+
"dev:once": "SCHEDULE_ENABLED=false ts-node src/index.ts",
1214
"start": "node ./dist/index.js",
13-
"build": "tsc --build --clean",
15+
"start:schedule": "SCHEDULE_ENABLED=true node ./dist/index.js",
16+
"start:once": "SCHEDULE_ENABLED=false node ./dist/index.js",
17+
"build": "tsc",
1418
"typechain": "typechain --target=ethers-v5 ./src/abis/**/*.json --out-dir ./src/types/typechain",
15-
"subgraph": "graphql-codegen --config subgraph-config.js",
1619
"types": "tsc --project tsconfig.json",
17-
"postinstall": "yarn typechain && yarn subgraph",
1820
"test": "echo \"Error: no test specified\" && exit 1"
1921
},
2022
"keywords": [],
2123
"author": "",
2224
"license": "MIT",
2325
"dependencies": {
24-
"@ethersproject/address": "^5.7.0",
25-
"@ethersproject/bignumber": "^5.7.0",
26-
"@ethersproject/contracts": "^5.7.0",
27-
"@ethersproject/providers": "^5.7.1",
28-
"@slack/web-api": "^6.7.2",
29-
"dotenv": "^16.0.3",
30-
"ethers": "^5.7.1",
31-
"graphql": "^16.6.0",
32-
"graphql-request": "^5.0.0",
33-
"graphql-tag": "^2.12.6"
26+
"@ethersproject/address": "5.7.0",
27+
"@ethersproject/bignumber": "5.7.0",
28+
"@ethersproject/contracts": "5.7.0",
29+
"@ethersproject/providers": "5.7.1",
30+
"@slack/web-api": "6.7.2",
31+
"dotenv": "17.2.3",
32+
"ethers": "5.7.1",
33+
"graphql": "16.6.0",
34+
"graphql-request": "5.2.0",
35+
"graphql-tag": "2.12.6",
36+
"node-cron": "3.0.3"
3437
},
3538
"devDependencies": {
36-
"@graphql-codegen/cli": "^2.13.6",
37-
"@graphql-codegen/introspection": "^2.2.1",
38-
"@graphql-codegen/typescript": "^2.7.4",
39-
"@graphql-codegen/typescript-graphql-request": "^4.5.6",
40-
"@graphql-codegen/typescript-operations": "^2.5.4",
41-
"@typechain/ethers-v5": "^10.1.0",
42-
"@types/node": "^18.8.3",
43-
"ts-node": "^10.9.1",
44-
"typechain": "^8.1.0",
45-
"typescript": "^4.8.4",
46-
"typescript-graphql-request": "^4.4.6"
39+
"@typechain/ethers-v5": "11.1.2",
40+
"@types/node": "25.0.10",
41+
"@types/node-cron": "3.0.11",
42+
"@types/node-fetch": "2.6.13",
43+
"ts-node": "10.9.2",
44+
"typechain": "8.1.0",
45+
"typescript": "4.8.4"
4746
}
4847
}

0 commit comments

Comments
 (0)