Collect packets relayed to and from a given blockchain, computing which packets are effected or not and by whom they were relayed.
The collected data is stored in a SQLite database and the metrics are exported to Prometheus.
-
Clone this repository
$ git clone https://github.com/informalsystems/chainpulse
-
Build the
chainpulse
executable$ cargo build --release
-
The
chainpulse
executable can now be found intarget/release
Alternatively, Docker images are available on Docker Hub.
Read the next section, then get started with:
$ docker run informalsystems/chainpulse:latest --config chainpulse.toml
Create a configuration file at chainpulse.toml
with the following content:
[chains.osmosis-1]
url = "wss://rpc.osmosis.zone/websocket"
comet_version = "0.34"
[database]
path = "data.db"
[metrics]
enabled = true
port = 3000
Note: The comet_version
field is optional and defaults to "0.34".
Collect and analyze txs containing IBC messages, export the collected metrics for Prometheus
Usage: chainpulse [OPTIONS]
Options:
-c, --config <CONFIG> Path to the configuration file [default: chainpulse.toml]
-h, --help Print help
Run the collector using the configuration file above to collect packet metrics on Osmosis:
$ chainpulse --config chainpulse.toml
2023-05-26T10:17:28.378380Z INFO Metrics server listening at http://localhost:3000/metrics
2023-05-26T10:17:28.386951Z INFO collect{chain=osmosis}: Connecting to wss://rpc.osmosis.zone/websocket...
2023-05-26T10:17:29.078725Z INFO collect{chain=osmosis}: Subscribing to NewBlock events...
2023-05-26T10:17:29.254485Z INFO collect{chain=osmosis}: Waiting for new blocks...
...
The built-in HTTP server at /metrics
exports the following Prometheus metrics:
# HELP ibc_effected_packets The number of IBC packets that are effected
# TYPE ibc_effected_packets counter
ibc_effected_packets{chain_id, src_channel, src_port, dst_channel, dst_port, signer, memo}
# HELP ibc_uneffected_packets The number of IBC packets that are not effected
# TYPE ibc_uneffected_packets counter
ibc_uneffected_packets{chain_id, src_channel, src_port, dst_channel, dst_port, signer, memo}
# HELP ibc_frontrun_counter The number of times a signer gets frontrun by the original signer
# TYPE ibc_frontrun_counter counter
ibc_frontrun_counter{chain_id, src_channel, src_port, dst_channel, dst_port, signer, frontrunned_by, memo, effected_memo}
# HELP ibc_stuck_packets The number of packets stuck on an IBC channel
# TYPE ibc_stuck_packets gauge
ibc_stuck_packets{dst_chain,src_chain,src_channel} 1
The following internal metrics are also available, for monitor Chain Pulse itself:
# HELP chainpulse_chains The number of chains being monitored
# TYPE chainpulse_chains gauge
chainpulse_chains 2
# HELP chainpulse_packets The number of packets processed
# TYPE chainpulse_packets counter
chainpulse_packets{chain_id}
# HELP chainpulse_reconnects The number of times we had to reconnect to the WebSocket
# TYPE chainpulse_reconnects counter
chainpulse_reconnects{chain_id}
# HELP chainpulse_txs The number of txs processed
# TYPE chainpulse_txs counter
chainpulse_txs{chain_id}
This project is heavily inspired and partly ported from @clemensgg's relayer-metrics-exporter
Copyright © 2023 Informal Systems Inc. and Hermes authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use the files in this repository except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.