Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avail onboarding #40

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions avail.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
WS_ENDPOINT="wss://mainnet-rpc.avail.so/ws"
WS_ENDPOINTS="wss://mainnet-rpc.avail.so/ws"
32 changes: 32 additions & 0 deletions avail.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: '3.4'

services:
avail_common_exporter:
build:
context: ./exporters/avail
args:
exporter: "common_exporter"
environment:
- "LISTEN=0.0.0.0"
- "PORT=9150"
- "CHAIN=avail"
env_file:
- ./avail.env
networks:
- exporters
restart: on-failure

avail_finality_exporter:
build:
context: ./exporters/avail
args:
exporter: "finality_exporter"
environment:
- "LISTEN=0.0.0.0"
- "PORT=9150"
- "CHAIN=avail"
env_file:
- ./avail.env
networks:
- exporters
restart: on-failure
84 changes: 74 additions & 10 deletions bot/alerts_tmpl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ rules:
description: "ParaValidator {{ $labels.account }} earned {{ $value }} points by end of epoch."
chain: "{{ $labels.chain }}"
account: "{{ $labels.account }}"
bot_description: "Will shout if some of selected validators been as a ParaValidator and earned epoch points less than threshold you selected by end of epoch.\nThreshold value - amount of reward points from 0 to 10000"
bot_description: "Will shout if some of selected validators been as a ParaValidator and earned epoch points less than threshold you selected by end of epoch.\nThreshold value - amount of reward points from 0 to 10000"

- alert: "[Polkadot] Offline validators"
expr: |
Expand Down Expand Up @@ -223,12 +223,76 @@ rules:
account: "{{ $labels.account }}"
bot_description: "Will shout if amount of slashed validators in network will reach or more than threshold value.\nThreshold value - amount of validators."

- alert: "[Avail] Reward points by end of era"
expr: |
avail_staking_eraPoints{chain="[[chain]]", account=~"[[accounts]]"} < [[threshold]] and on(account) avail_session_validators == 1 and on (chain) avail_staking_eraProgress >= 95
for: "[[interval]]"
labels:
uniqueid: 16
chat_id: "[[chat_id]]"
chain: "[[chain]]"
labels_source: avail_staking_eraPoints
annotations:
summary: "{{ $labels.chain }}: Validator has earned points less than choosen."
description: "Validator {{ $labels.account }} earned {{ $value }} points by end of era."
chain: "{{ $labels.chain }}"
account: "{{ $labels.account }}"
bot_description: "Will shout if some of selected validators earned era points less than threshold you selected by end of era.\nThreshold value - amount of reward points from 0 to 20000"

- alert: "[Avail] Finality GRANDPA precommits ratio"
expr: |
(avail_finality_precommits{chain="[[chain]]", account=~"[[accounts]]"} / on (chain) group_left() avail_finality_roundsProcessed * 100) < [[threshold]] and on(account) avail_session_validators == 1 and on (chain) avail_session_sessionProgress >= 3
for: "[[interval]]"
labels:
uniqueid: 17
chat_id: "[[chat_id]]"
chain: "[[chain]]"
labels_source: avail_finality_precommits
annotations:
summary: "{{ $labels.chain }}: Validator has problem with block finality participation!!!"
description: "Validator {{ $labels.account }} participate in finality for {{ $value }} percent."
chain: "{{ $labels.chain }}"
account: "{{ $labels.account }}"
bot_description: "Will shout if some of selected validators acts bellow threshold value as a consensus member(Precommits).\nThreshold value - percent of grandpa rounds when validator participated in consensus(0-100)"

- alert: "[Avail] Unapplied slashes"
expr: |
avail_staking_slashedValidators{chain="[[chain]]", account=~"[[accounts]]"} == 1
for: "[[interval]]"
labels:
uniqueid: 18
chat_id: "[[chat_id]]"
chain: "[[chain]]"
labels_source: avail_staking_slashedValidators
annotations:
summary: "{{ $labels.chain }}: Validator has been slashed!!!"
description: "Validator {{ $labels.account }} has been slashed."
chain: "{{ $labels.chain }}"
account: "{{ $labels.account }}"
bot_description: "Will shout if some of selected validators has been slashed.\nData from storage - possible also to catch it from events."

- alert: "[Avail] Unapplied slashes in a whole network"
expr: |
avail_staking_slashedValidatorsCount{chain="[[chain]]"} > [[threshold]]
for: "[[interval]]"
labels:
uniqueid: 19
chat_id: "[[chat_id]]"
chain: "[[chain]]"
labels_source: avail_staking_slashedValidatorsCount
annotations:
summary: "{{ $labels.chain }}: Lots of slashed validators in the network!"
description: "Amount of slashed validators {{ $value }}"
chain: "{{ $labels.chain }}"
account: "{{ $labels.account }}"
bot_description: "Will shout if amount of slashed validators in network will reach or more than threshold value.\nThreshold value - amount of validators."

- alert: "[Acala] Offline collators"
expr: |
rate(acala_activeCollators{chain="acala", account=~"[[accounts]]"}[30m]) > 0
for: "[[interval]]"
labels:
uniqueid: 16
uniqueid: 20
chat_id: "[[chat_id]]"
labels_source: acala_session_active_validators
annotations:
Expand All @@ -243,7 +307,7 @@ rules:
rate(acala_activeCollators{chain="karura", account=~"[[accounts]]"}[30m]) > 0
for: "[[interval]]"
labels:
uniqueid: 17
uniqueid: 21
chat_id: "[[chat_id]]"
labels_source: acala_session_active_validators
annotations:
Expand All @@ -259,7 +323,7 @@ rules:
moonbeam_blockAuthorship{chain="moonbeam", account=~"[[accounts]]"} < [[threshold]] and on(account) moonbeam_activeCollators == 1 and on (chain) moonbeam_roundProgress >= 90
for: "[[interval]]"
labels:
uniqueid: 18
uniqueid: 22
chat_id: "[[chat_id]]"
labels_source: moonbeam_blockAuthorship
annotations:
Expand All @@ -274,7 +338,7 @@ rules:
moonbeam_blockAuthorship{chain="moonriver", account=~"[[accounts]]"} < [[threshold]] and on(account) moonbeam_activeCollators == 1 and on (chain) moonbeam_roundProgress >= 90
for: "[[interval]]"
labels:
uniqueid: 19
uniqueid: 23
chat_id: "[[chat_id]]"
labels_source: moonbeam_blockAuthorship
annotations:
Expand All @@ -289,7 +353,7 @@ rules:
rate(moonbeam_activeCollators{chain="moonbeam", account=~"[[accounts]]"}[30m]) > 0
for: "[[interval]]"
labels:
uniqueid: 20
uniqueid: 24
chat_id: "[[chat_id]]"
labels_source: moonbeam_activeCollators
annotations:
Expand All @@ -304,7 +368,7 @@ rules:
rate(moonbeam_activeCollators{chain="moonriver", account=~"[[accounts]]"}[30m]) > 0
for: "[[interval]]"
labels:
uniqueid: 21
uniqueid: 25
chat_id: "[[chat_id]]"
labels_source: moonbeam_activeCollators
annotations:
Expand All @@ -319,7 +383,7 @@ rules:
rate(astar_activeCollators{chain="astar", account=~"[[accounts]]"}[30m]) > 0
for: "[[interval]]"
labels:
uniqueid: 22
uniqueid: 26
chat_id: "[[chat_id]]"
labels_source: astar_activeCollators
annotations:
Expand All @@ -334,7 +398,7 @@ rules:
rate(astar_activeCollators{chain="shiden", account=~"[[accounts]]"}[30m]) > 0
for: "[[interval]]"
labels:
uniqueid: 23
uniqueid: 27
chat_id: "[[chat_id]]"
labels_source: astar_activeCollators
annotations:
Expand All @@ -348,7 +412,7 @@ rules:
expr: vector(1)
for: "[[interval]]"
labels:
uniqueid: 24
uniqueid: 28
chat_id: "[[chat_id]]"
annotations:
summary: "This is a summary of test alert."
Expand Down
3 changes: 2 additions & 1 deletion bot/app/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import asyncio
from aiohttp import web
from aiogram import Bot, Dispatcher, Router
from aiogram.client.default import DefaultBotProperties
from aiogram.fsm.storage.memory import MemoryStorage
from message_handlers.setup import setup_message_handler
from web_apps.setup import setup_web_app
Expand Down Expand Up @@ -40,7 +41,7 @@
cache = CACHE(redis_host, redis_port, redis_password)
web_app = web.Application()
db = DB(db_name, db_user, db_pass,db_host,db_port)
bot = Bot(token=tg_token, parse_mode="HTML")
bot = Bot(token=tg_token, default=DefaultBotProperties(parse_mode='HTML'))

storage = MemoryStorage()
dp = Dispatcher(storage=storage)
Expand Down
2 changes: 1 addition & 1 deletion bot/app/callback_query_handlers/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def acc_menu(query: CallbackQuery):

menu = MenuBuilder()

text = "Here you can mange accounts you would like to track.\n\nFor now we are processing over " + str(cache.count()) + " uniq accounts of validators and collators.\n\nNetworks covered:\n🔸Polkadot/Kusama\n🔸Acala/Karura\n🔸Moonbeam/Moonriver\n🔸Astar/Shiden\n\n"
text = "Here you can mange accounts you would like to track.\n\nFor now we are processing over " + str(cache.count()) + " uniq accounts of validators and collators.\n\nNetworks covered:\n🔸Polkadot/Kusama\n🔸Avail/Turing(testnet)\n🔸Acala/Karura\n🔸Moonbeam/Moonriver\n🔸Astar/Shiden\n\n"

if not validators:
text += "☝️ No accounts in portfolio yet."
Expand Down
22 changes: 22 additions & 0 deletions exporters/avail/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM alpine/flake8:latest as linter
WORKDIR /apps/
COPY . /apps/
## ingore E501 line too long (XX > 79 characters)
RUN flake8 --ignore="E501" *.py

FROM --platform=linux/amd64 python:3.11-slim-buster

ARG exporter

WORKDIR /

RUN apt-get update && apt-get install -y gcc g++
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt --no-cache-dir
RUN groupadd -r exporter && useradd -r -g exporter exporter

COPY --from=linter /apps/${exporter}.py app.py
COPY --from=linter /apps/functions.py functions.py

USER exporter
CMD ["python3", "app.py"]
Loading