A robust service that monitors and tracks upgrades for Cosmos-based blockchains, providing real-time notifications and comprehensive chain information through a RESTful API.
-
🔍 Chain Monitoring
- Tracks multiple Cosmos-based chains simultaneously
- Supports both mainnet and testnet environments
- Real-time upgrade tracking and notifications
- Automatic chain registry updates
-
📢 Notifications
- Slack integration for upgrade notifications
- Configurable notification thresholds
- Custom notification formatting
-
📊 Data Sources
- GitHub Chain Registry integration
- Polkachu API integration for upgrade information
- Configurable data refresh intervals
- Fallback mechanisms for data sources
-
💾 Caching
- In-memory caching for chain information
- Configurable cache invalidation
- Thread-safe cache operations
- Optimized data refresh strategies
- Go 1.24 or later
- GitHub API token (recommended for higher rate limits)
- Slack webhook URL (optional, for notifications)
- Clone the repository:
git clone https://github.com/0xPuncker/cosmos-watcher.git
cd devops-cosmos-watcher
- Install dependencies:
go mod download
- Copy and configure the sample configuration:
cp config.json.example config.json
- Build the application:
go build -o cosmos-watcher ./cmd/server
- Run:
go run cmd/server/main.go
The project includes a Makefile with several useful commands:
Command | Description |
---|---|
make build |
Build the application |
make run |
Run the application |
make clean |
Clean build artifacts |
make deps |
Install dependencies |
make test |
Run all tests |
make test-coverage |
Run tests with coverage |
make test-integration |
Run integration tests |
make lint |
Run linters |
make setup |
Setup initial configuration |
make test-slack |
Test Slack notifications |
make help |
Show help message with all commands |
Run make help
to see all available commands and their descriptions.
The application is configured via config.json
:
{
"server": {
"port": "8080",
"read_timeout": "5s",
"write_timeout": "10s"
},
"github": {
"api_url": "https://api.github.com",
"token": "your-github-token",
"timeout": "30s"
},
"registry": {
"url": "https://raw.githubusercontent.com/cosmos/chain-registry/master",
"refresh_interval": "1h"
},
"poller": {
"interval": "5m",
"timeout": "30s"
},
"slack": {
"webhook_url": "your-slack-webhook-url",
"notification_threshold": "24h"
}
}
All endpoints are prefixed with /api/v1
.
Returns the service health status.
Response:
{
"status": "healthy",
"uptime": "24h10m",
"last_update": "2024-03-20T15:04:05Z",
"version": "1.0.0"
}
Returns detailed information about a specific chain.
Parameters:
chainName
: The name of the chain (e.g., "cosmoshub", "osmosis")
Response:
{
"name": "cosmoshub",
"network": "mainnet",
"chain_id": "cosmoshub-4",
"current_version": "v10.0.0",
"binary": "gaiad",
"last_upgrade": {
"name": "v10",
"height": 17343000,
"time": "2024-02-15T14:00:00Z"
}
}
Returns all upcoming and recent upgrades across all networks.
Query Parameters:
network
: Filter by network type (mainnet|testnet)status
: Filter by status (pending|completed|failed)days
: Number of days to look back for completed upgrades (default: 7)
Response:
{
"upgrades": [
{
"chain_name": "osmosis",
"network": "mainnet",
"name": "v20",
"height": 11250000,
"time": "2024-04-01T15:00:00Z",
"status": "pending",
"proposal_link": "https://www.mintscan.io/osmosis/proposals/1234"
}
]
}
Lists all configured monitoring jobs.
Response:
{
"jobs": [
{
"name": "chain-monitor",
"type": "periodic",
"interval": "5m",
"last_run": "2024-03-20T15:04:05Z",
"status": "running"
}
]
}
Adds a new monitoring job.
Request Body:
{
"name": "custom-monitor",
"type": "periodic",
"interval": "10m",
"chains": ["osmosis", "juno"]
}
Response:
{
"id": "job-123",
"status": "created",
"message": "Job successfully added"
}
Removes a monitoring job.
Parameters:
name
: The name of the job to remove
Response:
{
"status": "success",
"message": "Job successfully removed"
}
Starts the job scheduler.
Response:
{
"status": "running",
"started_at": "2024-03-20T15:04:05Z"
}
Stops the job scheduler.
Response:
{
"status": "stopped",
"stopped_at": "2024-03-20T15:04:05Z"
}
All responses follow a standard format:
- Success responses return HTTP 200/201 with the requested data
- Error responses return appropriate HTTP status codes (4xx/5xx) with error details:
{
"error": {
"code": "ERROR_CODE",
"message": "Human readable error message",
"details": {}
}
}
Run the full test suite:
go test ./...
Run tests for a specific package:
go test ./internal/chain/...
Run tests with coverage:
go test -cover ./...
Run integration tests (requires configuration):
go test -tags=integration ./...
Test Slack notifications:
go test -v ./internal/notifications -run TestSlackNotificationManual
Run all linters:
golangci-lint run
Run specific linters:
go vet ./...
staticcheck ./...
- Add chain configuration to
config/chains.yaml
- Implement chain-specific upgrade detection if needed
- Add relevant test cases
- Rate Limiting: Ensure GitHub token is configured
- Missing Upgrades: Check chain registry data freshness
- Notification Delays: Verify poller interval configuration
- Logs are written to stdout/stderr
- Use
-v
flag for verbose logging - Set LOG_LEVEL environment variable for custom log levels
MIT License - See MIT License file for details.