-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad0060c
commit 8d3a82b
Showing
3 changed files
with
170 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# cosmos-proposals-checker | ||
|
||
![Latest release](https://img.shields.io/github/v/release/freak12techno/cosmos-proposals-checker) | ||
[![Actions Status](https://github.com/freak12techno/cosmos-proposals-checker/workflows/test/badge.svg)](https://github.com/freak12techno/cosmos-proposals-checker/actions) | ||
|
||
cosmos-proposals-checker is a tool that checks all configured chains for new proposals in voting period, then notifies you if one or more of the configured wallets haven't voted on it. | ||
|
||
## How can I set it up? | ||
|
||
Download the latest release from [the releases page](https://github.com/freak12techno/cosmos-proposals-checker/releases/). After that, you should unzip it and you are ready to go: | ||
|
||
```sh | ||
wget <the link from the releases page> | ||
tar <downloaded file> | ||
./cosmos-proposals-checker --config <path to config> | ||
``` | ||
|
||
Alternatively, install `golang` (>1.18), clone the repo and build it. This will generate a `./main` binary file in the repository folder: | ||
``` | ||
git clone https://github.com/freak12techno/cosmos-proposals-checker | ||
cd cosmos-proposals-checker | ||
go build | ||
``` | ||
|
||
What you probably want to do is to have it running in the background. For that, first of all, we have to copy the file to the system apps folder: | ||
|
||
```sh | ||
sudo cp ./cosmos-proposals-checker /usr/bin | ||
``` | ||
|
||
Then we need to create a systemd service for our app: | ||
|
||
```sh | ||
sudo nano /etc/systemd/system/cosmos-proposals-checker.service | ||
``` | ||
|
||
You can use this template (change the user to whatever user you want this to be executed from. It's advised to create a separate user for that instead of running it from root): | ||
|
||
``` | ||
[Unit] | ||
Description=Cosmos Proposals Checker | ||
After=network-online.target | ||
[Service] | ||
User=<username> | ||
TimeoutStartSec=0 | ||
CPUWeight=95 | ||
IOWeight=95 | ||
ExecStart=cosmos-proposals-checker --config <config path> | ||
Restart=always | ||
RestartSec=2 | ||
LimitNOFILE=800000 | ||
KillSignal=SIGTERM | ||
[Install] | ||
WantedBy=multi-user.target | ||
``` | ||
|
||
Then we'll add this service to the autostart and run it: | ||
|
||
```sh | ||
sudo systemctl daemon-reload # reload config to reflect changed | ||
sudo systemctl enable cosmos-proposals-checker # put service to autostart | ||
sudo systemctl start cosmos-proposals-checker # start the service | ||
sudo systemctl status cosmos-proposals-checker # validate it's running | ||
``` | ||
|
||
If you need to, you can also see the logs of the process: | ||
|
||
```sh | ||
sudo journalctl -u cosmos-proposals-checker -f --output cat | ||
``` | ||
|
||
## How does it work? | ||
|
||
It queries LCD nodes for the proposals list in voting period, then for each wallet it queries its vote. If you haven't voted, it spawns an alert and sends it to configured notifiers. | ||
|
||
## How can I configure it? | ||
|
||
All configuration is done via `.toml` config file, which is mandatory. Run the app with `--config <path/to/config.toml>` to specify config. Check out `config.example.toml` to see the params that can be set. | ||
|
||
## Notifiers | ||
|
||
Currently this program supports the following notifications channels: | ||
1) Telegram | ||
|
||
Go to @BotFather in Telegram and create a bot. After that, there are two options: | ||
- you want to send messages to a user. This user should write a message to @getmyid_bot, then copy the `Your user ID` number. Also keep in mind that the bot won't be able to send messages unless you contact it first, so write a message to a bot before proceeding. | ||
- you want to send messages to a channel. Write something to a channel, then forward it to @getmyid_bot and copy the `Forwarded from chat` number. Then add the bot as an admin. | ||
|
||
To have fancy commands auto-suggestion, go to @BotFather again, select your bot -> Edit bot -> Edit description and paste the following: | ||
``` | ||
proposals_mute - Mutes a proposal | ||
proposals_mutes - List active proposal mutes | ||
help - Displays help | ||
``` | ||
|
||
Then add a Telegram config to your config file (see `config.example.toml` for reference). | ||
|
||
2) PagerDuty | ||
|
||
Go to your PaderDuty page, then go to Services. Create a service if you haven't created one already. Select this service, then go to "Integrations" tab, add an integration there. Copy the integration key and add it to the `pagerduty` part in config (see `config.example.toml` for reference). Additionally, override PagerDuty URL if you are using EU version. | ||
|
||
|
||
## Which networks this is guaranteed to work? | ||
|
||
In theory, it should work on a Cosmos-based blockchains that expose a REST server. | ||
|
||
## How can I contribute? | ||
|
||
Bug reports and feature requests are always welcome! If you want to contribute, feel free to open issues or PRs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# A path to a file that will store the state of the app. | ||
state-path = "cosmos-proposals-checker-state.json" | ||
# A path to a file that will store mutes of this app. Omitting it will disable the mute functionality. | ||
mutes-path = "cosmos-proposals-checker-mutes.json" | ||
# Interval to check and notify, in seconds. Defaults to 3600 (1 hour) | ||
interval = 60 | ||
|
||
# Logging configuration | ||
[log] | ||
# Log level. Defaults to "info". Set it to "debug" or "trace" to add more verbosity and for debugging. | ||
level = "trace" | ||
# Whether to write all logs in JSON instead of pretty-printing. Useful if you use a centralised logging | ||
# solition, like ELK. Defaults to false. | ||
json = false | ||
|
||
# Per-chain config. There can be multiple chains. | ||
[[chains]] | ||
# Chain name, used internally. Required. Should be unique. | ||
name = "sentinel" | ||
# Pretty name that is used when reporting. Optional. | ||
pretty-name = "Sentinel" | ||
# Chain name in Keplr wallet, to generate links to a proposal. Optional. | ||
keplr-name = "sentinel" | ||
# Mintscan prefix, to generate links to a proposal. Optional. | ||
mintscan-prefix = "sentinel" | ||
# List of LCD endpoints to get data from. At least 1 is required. You can use | ||
# multiple LCD endpoints, in case a single one fails. | ||
lcd-endpoints = ["https://lcd-sentinel-app.cosmostation.io", "https://lcd-sentinel.whispernode.com"] | ||
# List of wallets to monitor. At least 1 is required. | ||
wallets = [ | ||
"sent1rw9wtyhsus7jvx55v3qv5nzun054ma6kas4u3l" | ||
] | ||
|
||
[[chains]] | ||
name = "bitsong" | ||
pretty-name = "Bitsong" | ||
keplr-name = "bitsong" | ||
mintscan-prefix = "bitsong" | ||
lcd-endpoints = ["https://lcd-bitsong-app.cosmostation.io"] | ||
wallets = [ | ||
"bitsong14rvn7anf22e00vj5x3al4w50ns78s7n4t8yxcy" # freak12techno self delegate wallet | ||
] | ||
|
||
# PagerDuty notifier config. | ||
[pagerduty] | ||
# PagerDuty URL. You may need to override it if you use EU version of Pagerduty. | ||
# Defaults to "https://events.pagerduty.com" | ||
url = "https://events.eu.pagerduty.com" | ||
# PagerDuty API key. If omitted, the PagerDuty reporter will be disabled. | ||
api-key = "xxxyyyzzz" | ||
|
||
# Telegram notifier config. | ||
[telegram] | ||
# Telegram bot token. If omitted, the Telegram reporter will be disabled. | ||
token = "aaaa:bbbbb" | ||
# Chat ID to write to. Check README for integration info. | ||
chat = 123456 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters