Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
270 changes: 110 additions & 160 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ parking_lot = "0.11.2"
portalnet = { path = "portalnet" }
prometheus_exporter = "0.8.4"
rand = "0.8.4"
reth-ipc = { version = "0.1.0", git = "https://github.com/paradigmxyz/reth.git"}
rlp = "0.5.0"
rocksdb = "0.18.0"
rpc = { path = "rpc"}
Expand All @@ -44,6 +43,9 @@ trin-utils = { path = "trin-utils" }
trin-validation = { path = "trin-validation" }
utp-rs = "0.1.0-alpha.4"

[target.'cfg(not(windows))'.dependencies]
reth-ipc = { version = "0.1.0", git = "https://github.com/paradigmxyz/reth.git"}

[dev-dependencies]
ethportal-peertest = { path = "ethportal-peertest" }
ureq = { version = "2.5.0", features = ["json"] }
Expand All @@ -55,7 +57,6 @@ members = [
"light-client",
"rpc",
"trin-beacon",
"trin-cli",
"trin-history",
"trin-state",
"trin-types",
Expand Down
34 changes: 33 additions & 1 deletion book/src/users/monitoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ htop
```

## Metrics
[Metrics setup no docker](#metrics-setup-no-docker)

[Metrics setup with docker](#metrics-setup-with-docker)

## Metrics setup no docker
Prometheus maintains a database of metrics (trin & system). Grafana converts metrics into graphs. Node exporter provides system information.
```mermaid
graph TD;
Expand Down Expand Up @@ -234,7 +238,7 @@ This will serve metrics over port 3000.

Generate a grafana dashboard. From trin root directory:
```sh
cargo run -p trin-cli -- create-dashboard
cargo run -p trin -- create-dashboard http://localhost:3000 admin admin http://127.0.0.1:9090
```
This will create a new monitoring database for trin. This will
be visible in the grafana GUI, or directly at a URL similar to:
Expand Down Expand Up @@ -279,3 +283,31 @@ ssh -N -L 3000:127.0.0.1:3000 username@mycomputer
Then navigate to [http://127.0.0.1:3000](http://127.0.0.1:3000)` in a browser and login
with username: admin, password: admin. Then navigate to the trin-app-metrics dashboard.

## Metrics setup with docker
1. Install Docker.
2. Run Prometheus, note that you MUST manually set the absolute path to your copy of Trin's `docs/metrics_config/`:
```sh
docker run -p 9090:9090 -v /**absolute/path/to/trin/docs/metrics_config**:/etc/prometheus --add-host=host.docker.internal:host-gateway prom/prometheus
```
3. Run Grafana:
```sh
docker run -p 3000:3000 --add-host=host.docker.internal:host-gateway grafana/grafana:latest
```
4. Start your Trin process with:
```sh
cargo run -p trin -- --enable-metrics-with-url 0.0.0.0:9100 --web3-http-address http://0.0.0.0:8545 --web3-transport http
```
- The addresses must be bound to 0.0.0.0, because 127.0.0.1 only allows internal requests to
complete, and requests from docker instances are considered external.
- The `--enable-metrics-with-url` parameter is the address that Trin exports metrics to, and should be equal to the port to which your Prometheus server is targeting at the bottom of `metrics_config/prometheus.yml`
- The `--web-transport http` will allow Grafana to request routing table information from Trin via JSON-RPC over HTTP
5. From the root of the Trin repo, run `cargo run -p trin -- create-dashboard`. If you used different ports than detailed in the above steps, or you are not using docker, then this command's defaults will not work. Run the command with the `-h` flag to see how to provide non-default addresses or credentials.
6. Upon successful dashboard creation, navigate to the dashboard URL that the `create-dashboard` outputs. Use `admin`/`admin` to login.

## Gotchas

- If `create-dashboard` fails with an error, the most likely reason is that it has already been run. From within the Grafana UI, delete the "json-rpc" and "prometheus" datasources and the "trin" dashboard and re-run the command.

- There is a limit on concurrent connections given by the threadpool. At last
doc update, that number was 2, but will surely change. If you leave
connections open, then new connections will block.
6 changes: 2 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,21 @@ COPY ./rpc ./rpc
COPY ./src ./src
COPY ./trin-beacon ./trin-beacon
COPY ./trin-bridge ./trin-bridge
COPY ./trin-cli ./trin-cli
COPY ./trin-history ./trin-history
COPY ./trin-history ./trin-history
COPY ./trin-state ./trin-state
COPY ./trin-types ./trin-types
COPY ./trin-utils ./trin-utils
COPY ./trin-validation ./trin-validation
COPY ./utp-testing ./utp-testing

# build for release
RUN cargo build -p trin -p trin-cli --release
RUN cargo build -p trin --release

# final base
FROM ubuntu:22.04

# copy build artifacts from build stage
COPY --from=builder /trin/target/release/trin /usr/bin/
COPY --from=builder /trin/target/release/trin-cli /usr/bin/
COPY --from=builder /trin/target/release/purge_db /usr/bin/

ENV RUST_LOG=debug
Expand Down
3 changes: 1 addition & 2 deletions docker/Dockerfile.bridge
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ COPY ./light-client ./light-client
COPY ./src ./src
COPY ./trin-beacon ./trin-beacon
COPY ./trin-bridge ./trin-bridge
COPY ./trin-cli ./trin-cli
COPY ./trin-history ./trin-history
COPY ./trin-history ./trin-history
COPY ./trin-state ./trin-state
COPY ./trin-types ./trin-types
COPY ./trin-utils ./trin-utils
Expand Down
6 changes: 3 additions & 3 deletions ethportal-peertest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ hex = "0.4.3"
hyper = { version = "0.14", features = ["full"] }
jsonrpsee = {version="0.16.2", features = ["async-client", "client", "macros", "server"]}
rand = "0.8.4"
reth-ipc = { version = "0.1.0", git = "https://github.com/paradigmxyz/reth.git"}

rocksdb = "0.18.0"
serde_json = "1.0.89"
structopt = "0.3.26"
Expand All @@ -39,5 +39,5 @@ trin-types = { path = "../trin-types" }
trin-utils = { path = "../trin-utils" }
ureq = { version = "2.5.0", features = ["json"] }

[target.'cfg(windows)'.dependencies]
uds_windows = "1.0.1"
[target.'cfg(not(windows))'.dependencies]
reth-ipc = { version = "0.1.0", git = "https://github.com/paradigmxyz/reth.git"}
1 change: 1 addition & 0 deletions ethportal-peertest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(unix)]
pub mod constants;
pub mod scenarios;

Expand Down
7 changes: 7 additions & 0 deletions newsfragments/736.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### Remove cli, fix windows compilation, move grafana create to TrinConfig, update trin-types to use clap

1. removed json-rpc from ``trin-cli``
2. removed encodekey from ``trin-cli``
3. add cfg and add a few panics to clearly define what is not supported by windows so it can compile
4. remove ``trin-cli``, move Create Grafana dashboard to TrinConfig (as discussed in the meeting 5/11/2023), update ``trin-types`` from structopt to clap
5. update Trin Book
3 changes: 0 additions & 3 deletions portalnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ validator = { version = "0.13.0", features = ["derive"] }
url = "2.3.1"
utp-rs = "0.1.0-alpha.4"

[target.'cfg(windows)'.dependencies]
uds_windows = "1.0.1"

[dev-dependencies]
env_logger = "0.9.0"
quickcheck = "1.0.3"
Expand Down
4 changes: 3 additions & 1 deletion rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ portalnet = { path = "../portalnet"}
trin-types = { path = "../trin-types"}
trin-utils = { path = "../trin-utils"}
tokio = { version = "1.14.0", features = ["full"] }
reth-ipc = { version = "0.1.0", git = "https://github.com/paradigmxyz/reth.git"}
url = "2.3.1"
serde_json = "1.0.95"

[target.'cfg(not(windows))'.dependencies]
reth-ipc = { version = "0.1.0", git = "https://github.com/paradigmxyz/reth.git"}
11 changes: 11 additions & 0 deletions rpc/src/server_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::jsonrpsee::server::{ServerBuilder as HttpServerBuilder, ServerHandle}
use crate::{Discv5Api, HistoryNetworkApi, Web3Api};
use ethportal_api::{Discv5ApiServer, HistoryNetworkApiServer, Web3ApiServer};
use portalnet::discovery::Discovery;
#[cfg(unix)]
use reth_ipc::server::Builder as IpcServerBuilder;
use std::net::SocketAddr;
use std::path::Path;
Expand Down Expand Up @@ -31,6 +32,7 @@ impl JsonRpcServer {
Ok(handle)
}

#[cfg(unix)]
pub async fn run_ipc(
ipc_path: Box<dyn AsRef<Path>>,
discv5: Arc<Discovery>,
Expand All @@ -46,4 +48,13 @@ impl JsonRpcServer {
let handle = server.start(api).await?;
Ok(handle)
}

#[cfg(windows)]
pub async fn run_ipc(
_ipc_path: Box<dyn AsRef<Path>>,
_discv5: Arc<Discovery>,
_history_handler: mpsc::UnboundedSender<HistoryJsonRpcRequest>,
) -> anyhow::Result<ServerHandle> {
panic!("Windows doesn't support Unix Domain Sockets IPC, use --web3-transport http")
}
}
2 changes: 1 addition & 1 deletion tests/self_peertest.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(test)]
#[cfg(all(unix, test))]
mod test {
use std::{
net::{IpAddr, Ipv4Addr},
Expand Down
31 changes: 0 additions & 31 deletions trin-cli/Cargo.toml

This file was deleted.

122 changes: 0 additions & 122 deletions trin-cli/README.md

This file was deleted.

Loading