Skip to content

Commit 0c643ee

Browse files
committed
chore: merge main
2 parents 9535af4 + 1330973 commit 0c643ee

File tree

7 files changed

+1234
-13
lines changed

7 files changed

+1234
-13
lines changed

README.md

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Data Availability metrics and monitoring tool for evstack using Celestia DA. Thi
99
- Retry logic with exponential backoff for pending DA submissions
1010
- Prometheus metrics for tracking unverified block ranges
1111
- Support for both streaming and one-shot block verification modes
12+
- Account balance monitoring via Celestia consensus RPC with automatic failover
1213

1314
## Quick Start
1415

@@ -32,8 +33,8 @@ The monitor command streams EVM block headers and verifies DA submission on Cele
3233

3334
```bash
3435
./ev-metrics monitor \
35-
--header-namespace collect_testnet_header \
36-
--data-namespace collect_testnet_data
36+
--header-namespace testnet_header \
37+
--data-namespace testnet_data
3738
```
3839

3940

@@ -54,8 +55,8 @@ Metrics will be available at `http://localhost:2112/metrics`
5455
### Command-Line Flags
5556

5657
**Required:**
57-
- `--header-namespace`: Header namespace (e.g. collect_testnet_header )
58-
- `--data-namespace`: Data namespace (e.g. collect_testnet_data )
58+
- `--header-namespace`: Header namespace (e.g. testnet_header )
59+
- `--data-namespace`: Data namespace (e.g. testnet_data )
5960

6061
**Optional:**
6162
- `--evnode-addr`: ev-node Connect RPC address (default: `http://localhost:7331`)
@@ -71,6 +72,9 @@ Metrics will be available at `http://localhost:2112/metrics`
7172
- `--reference-node`: Reference node RPC endpoint URL (sequencer) for drift monitoring
7273
- `--full-nodes`: Comma-separated list of full node RPC endpoint URLs for drift monitoring
7374
- `--polling-interval`: Polling interval in seconds for checking node block heights (default: 10)
75+
- `--balance.addresses`: Comma-separated Celestia addresses to monitor (enables balance checking)
76+
- `--balance.consensus-rpc-urls`: Comma-separated consensus RPC URLs for balance queries (required if balance.addresses is set)
77+
- `--balance.scrape-interval`: Balance check scrape interval in seconds (default: 30)
7478
- `--verbose`: Enable verbose logging (default: false)
7579

7680
### Example with Custom Endpoints
@@ -100,6 +104,22 @@ Enable JSON-RPC request duration monitoring by providing the `--evm-rpc-url` fla
100104

101105
This will periodically send `eth_blockNumber` JSON-RPC requests to monitor node health and response times.
102106

107+
### Example with Balance Monitoring
108+
109+
Monitor native token balances for one or more Celestia addresses:
110+
111+
```bash
112+
./ev-metrics monitor \
113+
--header-namespace collect_testnet_header \
114+
--data-namespace collect_testnet_data \
115+
--balance.addresses "celestia1abc...,celestia1def..." \
116+
--balance.consensus-rpc-urls "https://rpc.celestia.org,https://rpc-mocha.pops.one" \
117+
--balance.scrape-interval 30 \
118+
--enable-metrics
119+
```
120+
121+
This will query account balances every 30 seconds with automatic failover between RPC endpoints.
122+
103123
## Prometheus Metrics
104124

105125
When metrics are enabled, the following metrics are exposed:
@@ -163,3 +183,22 @@ When `--reference-node` and `--full-nodes` are provided:
163183
- **Type**: Gauge
164184
- **Labels**: `chain_id`, `target_endpoint`
165185
- **Description**: Block height difference between reference and target endpoints (positive = target behind, negative = target ahead)
186+
187+
### Balance Monitoring Metrics
188+
189+
When `--balance.addresses` and `--balance.consensus-rpc-urls` are provided:
190+
191+
### `ev_metrics_account_balance`
192+
- **Type**: Gauge
193+
- **Labels**: `chain_id`, `address`, `denom`
194+
- **Description**: Native token balance for Celestia addresses
195+
196+
### `ev_metrics_consensus_rpc_endpoint_availability`
197+
- **Type**: Gauge
198+
- **Labels**: `chain_id`, `endpoint`
199+
- **Description**: Consensus RPC endpoint availability status (1.0 = available, 0.0 = unavailable)
200+
201+
### `ev_metrics_consensus_rpc_endpoint_errors_total`
202+
- **Type**: Counter
203+
- **Labels**: `chain_id`, `endpoint`, `error_type`
204+
- **Description**: Total number of consensus RPC endpoint errors by type

cmd/monitor.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/evstack/ev-metrics/internal/clients/celestia"
1414
"github.com/evstack/ev-metrics/internal/clients/evm"
1515
"github.com/evstack/ev-metrics/internal/clients/evnode"
16+
"github.com/evstack/ev-metrics/pkg/exporters/balance"
1617
"github.com/evstack/ev-metrics/pkg/exporters/drift"
1718
"github.com/evstack/ev-metrics/pkg/exporters/jsonrpc"
1819
"github.com/evstack/ev-metrics/pkg/exporters/verifier"
@@ -38,6 +39,9 @@ const (
3839
flagFullNodes = "full-nodes"
3940
flagPollingInterval = "polling-interval"
4041
flagJsonRpcScrapeInterval = "jsonrpc-scrape-interval"
42+
flagBalanceAddresses = "balance.addresses"
43+
flagBalanceRpcUrls = "balance.consensus-rpc-urls"
44+
flagBalanceScrapeInterval = "balance.scrape-interval"
4145

4246
metricsPath = "/metrics"
4347
)
@@ -60,6 +64,9 @@ type flagValues struct {
6064
fullNodes string
6165
pollingInterval int
6266
jsonRpcScrapeInterval int
67+
balanceAddresses string
68+
balanceRpcUrls string
69+
balanceScrapeInterval int
6370
}
6471

6572
func NewMonitorCmd() *cobra.Command {
@@ -89,6 +96,9 @@ func NewMonitorCmd() *cobra.Command {
8996
cmd.Flags().StringVar(&flags.fullNodes, flagFullNodes, "", "Comma-separated list of full node RPC endpoint URLs for drift monitoring")
9097
cmd.Flags().IntVar(&flags.pollingInterval, flagPollingInterval, 10, "Polling interval in seconds for checking node block heights (default: 10)")
9198
cmd.Flags().IntVar(&flags.jsonRpcScrapeInterval, flagJsonRpcScrapeInterval, 10, "JSON-RPC health check scrape interval in seconds (default: 10)")
99+
cmd.Flags().StringVar(&flags.balanceAddresses, flagBalanceAddresses, "", "Comma-separated celestia addresses to monitor (enables balance checking)")
100+
cmd.Flags().StringVar(&flags.balanceRpcUrls, flagBalanceRpcUrls, "", "Comma-separated consensus rpc urls for balance queries (required if balance.addresses is set)")
101+
cmd.Flags().IntVar(&flags.balanceScrapeInterval, flagBalanceScrapeInterval, 30, "Balance check scrape interval in seconds (default: 30)")
92102

93103
if err := cmd.MarkFlagRequired(flagHeaderNS); err != nil {
94104
panic(err)
@@ -208,6 +218,30 @@ func monitorAndExportMetrics(_ *cobra.Command, _ []string) error {
208218
exporters = append(exporters, jsonrpc.NewMetricsExporter(flags.chainID, cfg.EvmClient, flags.jsonRpcScrapeInterval, logger))
209219
}
210220

221+
// start balance monitoring if balance.addresses is provided
222+
if flags.balanceAddresses != "" {
223+
if flags.balanceRpcUrls == "" {
224+
return fmt.Errorf("--balance.consensus-rpc-urls is required when --balance.addresses is set")
225+
}
226+
227+
addressList := strings.Split(flags.balanceAddresses, ",")
228+
rpcUrls := strings.Split(flags.balanceRpcUrls, ",")
229+
230+
exporters = append(exporters, balance.NewMetricsExporter(
231+
flags.chainID,
232+
addressList,
233+
rpcUrls,
234+
flags.balanceScrapeInterval,
235+
logger,
236+
))
237+
238+
logger.Info().
239+
Strs("addresses", addressList).
240+
Strs("rpc_urls", rpcUrls).
241+
Int("scrape_interval", flags.balanceScrapeInterval).
242+
Msg("balance monitoring enabled")
243+
}
244+
211245
err = metrics.StartServer(ctx, metricsPath, flags.port, logger, exporters...)
212246

213247
// context.Canceled is expected during graceful shutdown, not an error

go.mod

Lines changed: 113 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.24.6
44

55
require (
66
connectrpc.com/connect v1.19.1
7+
github.com/cosmos/cosmos-sdk v0.50.14
78
github.com/ethereum/go-ethereum v1.16.5
89
github.com/evstack/ev-node v1.0.0-beta.8
910
github.com/evstack/ev-node/core v1.0.0-beta.3
@@ -13,51 +14,161 @@ require (
1314
github.com/spf13/cobra v1.10.1
1415
github.com/stretchr/testify v1.11.1
1516
golang.org/x/sync v0.17.0
17+
google.golang.org/grpc v1.75.0
1618
google.golang.org/protobuf v1.36.10
1719
)
1820

1921
require (
22+
cosmossdk.io/api v0.7.6 // indirect
23+
cosmossdk.io/collections v0.4.0 // indirect
24+
cosmossdk.io/core v0.11.1 // indirect
25+
cosmossdk.io/depinject v1.1.0 // indirect
26+
cosmossdk.io/errors v1.0.1 // indirect
27+
cosmossdk.io/log v1.4.1 // indirect
28+
cosmossdk.io/math v1.4.0 // indirect
29+
cosmossdk.io/store v1.1.1 // indirect
30+
cosmossdk.io/x/tx v0.13.7 // indirect
31+
filippo.io/edwards25519 v1.0.0 // indirect
32+
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
33+
github.com/99designs/keyring v1.2.1 // indirect
34+
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
35+
github.com/DataDog/zstd v1.5.5 // indirect
2036
github.com/Microsoft/go-winio v0.6.2 // indirect
2137
github.com/StackExchange/wmi v1.2.1 // indirect
2238
github.com/beorn7/perks v1.0.1 // indirect
39+
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
2340
github.com/bits-and-blooms/bitset v1.20.0 // indirect
41+
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
2442
github.com/cespare/xxhash/v2 v2.3.0 // indirect
43+
github.com/cockroachdb/errors v1.11.3 // indirect
44+
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
45+
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
46+
github.com/cockroachdb/pebble v1.1.5 // indirect
47+
github.com/cockroachdb/redact v1.1.5 // indirect
48+
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
49+
github.com/cometbft/cometbft v0.38.19 // indirect
50+
github.com/cometbft/cometbft-db v0.14.1 // indirect
2551
github.com/consensys/gnark-crypto v0.18.1 // indirect
52+
github.com/cosmos/btcutil v1.0.5 // indirect
53+
github.com/cosmos/cosmos-db v1.1.1 // indirect
54+
github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect
55+
github.com/cosmos/go-bip39 v1.0.0 // indirect
56+
github.com/cosmos/gogogateway v1.2.0 // indirect
57+
github.com/cosmos/gogoproto v1.7.0 // indirect
58+
github.com/cosmos/iavl v1.2.2 // indirect
59+
github.com/cosmos/ics23/go v0.11.0 // indirect
60+
github.com/cosmos/ledger-cosmos-go v0.15.0 // indirect
2661
github.com/crate-crypto/go-eth-kzg v1.4.0 // indirect
2762
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
63+
github.com/danieljoos/wincred v1.1.2 // indirect
2864
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2965
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
3066
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
67+
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
68+
github.com/dgraph-io/badger/v4 v4.5.1 // indirect
69+
github.com/dgraph-io/ristretto/v2 v2.1.0 // indirect
70+
github.com/dustin/go-humanize v1.0.1 // indirect
71+
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
72+
github.com/emicklei/dot v1.6.2 // indirect
3173
github.com/ethereum/c-kzg-4844/v2 v2.1.3 // indirect
3274
github.com/ethereum/go-verkle v0.2.2 // indirect
75+
github.com/fatih/color v1.16.0 // indirect
76+
github.com/felixge/httpsnoop v1.0.4 // indirect
3377
github.com/filecoin-project/go-jsonrpc v0.8.0 // indirect
78+
github.com/fsnotify/fsnotify v1.9.0 // indirect
79+
github.com/getsentry/sentry-go v0.27.0 // indirect
80+
github.com/go-kit/kit v0.13.0 // indirect
81+
github.com/go-kit/log v0.2.1 // indirect
82+
github.com/go-logfmt/logfmt v0.6.0 // indirect
3483
github.com/go-ole/go-ole v1.3.0 // indirect
84+
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
85+
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
86+
github.com/gogo/googleapis v1.4.1 // indirect
87+
github.com/gogo/protobuf v1.3.2 // indirect
3588
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
89+
github.com/golang/protobuf v1.5.4 // indirect
90+
github.com/golang/snappy v1.0.0 // indirect
91+
github.com/google/btree v1.1.3 // indirect
92+
github.com/google/flatbuffers v24.12.23+incompatible // indirect
93+
github.com/google/go-cmp v0.7.0 // indirect
3694
github.com/google/uuid v1.6.0 // indirect
95+
github.com/gorilla/handlers v1.5.1 // indirect
96+
github.com/gorilla/mux v1.8.0 // indirect
3797
github.com/gorilla/websocket v1.5.3 // indirect
98+
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
99+
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
100+
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
101+
github.com/hashicorp/go-hclog v1.5.0 // indirect
102+
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
103+
github.com/hashicorp/go-metrics v0.5.3 // indirect
104+
github.com/hashicorp/go-plugin v1.5.2 // indirect
105+
github.com/hashicorp/golang-lru v1.0.2 // indirect
106+
github.com/hashicorp/yamux v0.1.1 // indirect
107+
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
38108
github.com/holiman/uint256 v1.3.2 // indirect
109+
github.com/huandu/skiplist v1.2.0 // indirect
110+
github.com/iancoleman/strcase v0.3.0 // indirect
111+
github.com/improbable-eng/grpc-web v0.15.0 // indirect
39112
github.com/inconshreveable/mousetrap v1.1.0 // indirect
40113
github.com/ipfs/go-log/v2 v2.8.1 // indirect
114+
github.com/jmhodges/levigo v1.0.0 // indirect
115+
github.com/klauspost/compress v1.18.0 // indirect
116+
github.com/kr/pretty v0.3.1 // indirect
117+
github.com/kr/text v0.2.0 // indirect
118+
github.com/linxGnu/grocksdb v1.8.14 // indirect
41119
github.com/mattn/go-colorable v0.1.14 // indirect
42120
github.com/mattn/go-isatty v0.0.20 // indirect
121+
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
122+
github.com/mtibben/percent v0.2.1 // indirect
43123
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
124+
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
125+
github.com/oklog/run v1.1.0 // indirect
126+
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
127+
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
128+
github.com/pkg/errors v0.9.1 // indirect
44129
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
45130
github.com/prometheus/client_model v0.6.2 // indirect
46131
github.com/prometheus/common v0.66.1 // indirect
47132
github.com/prometheus/procfs v0.17.0 // indirect
133+
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
134+
github.com/rogpeppe/go-internal v1.14.1 // indirect
135+
github.com/rs/cors v1.11.1 // indirect
136+
github.com/sagikazarmark/locafero v0.11.0 // indirect
137+
github.com/sasha-s/go-deadlock v0.3.5 // indirect
48138
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
139+
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
140+
github.com/spf13/afero v1.15.0 // indirect
141+
github.com/spf13/cast v1.10.0 // indirect
49142
github.com/spf13/pflag v1.0.10 // indirect
143+
github.com/spf13/viper v1.21.0 // indirect
144+
github.com/subosito/gotenv v1.6.0 // indirect
50145
github.com/supranational/blst v0.3.16-0.20250831170142-f48500c1fdbe // indirect
146+
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
147+
github.com/tendermint/go-amino v0.16.0 // indirect
148+
github.com/tidwall/btree v1.7.0 // indirect
51149
github.com/tklauser/go-sysconf v0.3.12 // indirect
52150
github.com/tklauser/numcpus v0.6.1 // indirect
151+
github.com/zondax/hid v0.9.2 // indirect
152+
github.com/zondax/ledger-go v1.0.0 // indirect
153+
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
53154
go.opencensus.io v0.24.0 // indirect
54155
go.uber.org/multierr v1.11.0 // indirect
55156
go.uber.org/zap v1.27.0 // indirect
56157
go.yaml.in/yaml/v2 v2.4.3 // indirect
158+
go.yaml.in/yaml/v3 v3.0.4 // indirect
57159
golang.org/x/crypto v0.43.0 // indirect
160+
golang.org/x/exp v0.0.0-20250911091902-df9299821621 // indirect
161+
golang.org/x/net v0.45.0 // indirect
58162
golang.org/x/sys v0.37.0 // indirect
163+
golang.org/x/term v0.36.0 // indirect
164+
golang.org/x/text v0.30.0 // indirect
59165
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
166+
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
167+
google.golang.org/genproto/googleapis/api v0.0.0-20250707201910-8d1bb00bc6a7 // indirect
168+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250728155136-f173205681a0 // indirect
60169
gopkg.in/yaml.v3 v3.0.1 // indirect
170+
gotest.tools/v3 v3.5.1 // indirect
171+
nhooyr.io/websocket v1.8.6 // indirect
172+
pgregory.net/rapid v1.1.0 // indirect
173+
sigs.k8s.io/yaml v1.4.0 // indirect
61174
)
62-
63-
//replace github.com/evstack/ev-node => /Users/chatton/checkouts/evstack/ev-node

0 commit comments

Comments
 (0)