This project provides automated monitoring for Cartesi blockchain events and contract states, with notifications sent to Discord. The monitoring is designed to run both locally and automatically via GitHub Actions.
- Event Monitoring: Watches for
commitmentJoined
events on the blockchain and detects disputes in tournaments. - Balance Monitoring: Checks if a specified node address has a critically low balance.
- Settlement Monitoring: Monitors the
canSettle
andgetCurrentSealedEpoch
contract functions to detect when epochs can be settled or if there are issues with claims. - Discord Notifications: Sends alerts to a Discord channel via webhook when important events or issues are detected.
- Automated via GitHub Actions: Runs every 5 minutes and can also be triggered manually.
- The
monitor.js
script connects to the Sepolia network and listens forcommitmentJoined
events. - It tracks claims for each tournament and notifies Discord if multiple claims (disputes) are detected.
- It also checks the balance of a specified node address and sends an alert if the balance is below a threshold.
- The
canSettleMonitor.js
script checks the state of the DAVE contract to determine if an epoch can be settled. - It alerts if an epoch has been open for settlement for over an hour or if there are no claims for a new epoch after an hour.
- Both scripts use a Discord webhook (provided via environment variable) to send notifications.
Monitoring is automated using a GitHub Actions workflow defined in .github/workflows/monitor.yml
.
- Schedule: Runs every 5 minutes via cron.
- Manual Trigger: Can be started manually via the GitHub Actions UI.
- Steps:
- Checks out the repository.
- Sets up Node.js (version 22).
- Installs dependencies with
npm ci
. - Runs
monitor.js
andcanSettleMonitor.js
with required environment variables. - Commits and pushes any updated data files back to the repository.
Set the following secrets in your GitHub repository:
DISCORD_WEBHOOK
: Discord webhook URL for notifications.RPC_URL
: Ethereum node RPC URL (e.g., for Sepolia).GITHUB_TOKEN
: (Automatically provided by GitHub Actions).DAVE_CONTRACT_ADDRESS
: Used by consensus.
- Install dependencies:
npm ci
- Set the required environment variables:
DISCORD_WEBHOOK
RPC_URL
- (Optional)
DAVE_CONTRACT_ADDRESS
,BATCH_BLOCK
,NODE_ADDRESS
,MIN_BALANCE
- Run the scripts:
node monitor.js node canSettleMonitor.js
- Node.js (v22)