Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/metrics #4

Merged
merged 9 commits into from
Jun 29, 2024
Merged
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ Cargo.lock

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

.env
.config.toml
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "da-commit-dockerized"]
path = da-commit-dockerized
url = https://github.com/LimeChain/da-commit-dockerized.git
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ members = [
"crates/common",
"crates/crypto",
"crates/pbs",
"crates/metrics",

"tests",
"examples",
"examples"
]
resolver = "2"

Expand All @@ -22,6 +23,7 @@ cb-cli = { path = "crates/cli" }
cb-common = { path = "crates/common" }
cb-crypto = { path = "crates/crypto" }
cb-pbs = { path = "crates/pbs" }
cb-metrics = { path = "crates/metrics" }

# ethereum
ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "cf3c404043230559660810bc0c9d6d5a8498d819" }
Expand Down
44 changes: 44 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Start from the latest Rust image for the build stage
FROM rust:latest AS builder

# Set the working directory
WORKDIR /usr/src/app

# Copy the Cargo.toml and Cargo.lock files
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock

# Copy the source code
COPY ./bin ./bin
COPY ./crates ./crates
COPY ./tests ./tests
COPY ./examples ./examples

# Build the application
RUN cargo build --bin commit-boost

# Use Ubuntu 22.04 for runtime to ensure OpenSSL 3.x is available
FROM ubuntu:22.04

# Install OpenSSL and necessary libraries
RUN apt-get update && apt-get install -y \
openssl \
ca-certificates \
libssl3 \
&& rm -rf /var/lib/apt/lists/*

# Copy the built binary from the builder stage
COPY --from=builder /usr/src/app/target/debug/commit-boost /usr/local/bin/commit-boost

# Copy the configuration file
COPY ./config.dockerized.toml /etc/commit-boost/config.toml
COPY ./keys.example.json ./keys.example.json
COPY ./metrics_jwt.txt ./metrics_jwt.txt

# Expose the necessary ports for metrics
EXPOSE 13030
EXPOSE 18551
EXPOSE 33951

# Set the entrypoint with the 'start' subcommand and the correct config path
ENTRYPOINT ["commit-boost", "start", "/etc/commit-boost/config.toml"]
13 changes: 13 additions & 0 deletions Dockerfile.prometheus
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM prom/prometheus:latest

# Copy the Prometheus configuration file
COPY prometheus.yml /etc/prometheus/prometheus.yml

# Expose the port for Prometheus
EXPOSE 9090

# Set the entrypoint
ENTRYPOINT ["/bin/prometheus"]

# Set the command to use the custom configuration file
CMD ["--config.file=/etc/prometheus/prometheus.yml"]
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
# Commit-Boost

## Dependencies

- Docker Desktop v4.29 or later. We are using the `host` network driver on docker container instantiation, so our client needs to support the feature.

## Usage
Note: Ensure that the ports used by the docker-compose are set up in the config.toml are not already in use by other processes and are not blocked by a firewall

First, initialize the submodule with:
```bash
git submodule update --init --recursive
```

Then, build and run the grafana and prometheus docker containers with:
```bash
docker-compose build
docker-compose up -d
```

Finally, run the project with:
```bash
cargo run --bin commit-boost -- start config.example.toml
```

## Configurations
All configurable settings can be found in config.example.toml file.

### Note
- THIS IS JUST A PROOF OF CONCEPT TO ILLUSTRATE DESIGN PRINCIPLES, THERE ARE STILL COUNTLESS DECISIONS AND ASSUMPTION ON THE DESIGN THAT NEED TO BE MADE
- The code is unaudited and are from being / NOT ready for production
Expand Down
31 changes: 31 additions & 0 deletions config.dockerized.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
chain = "Holesky"

[pbs]
# path = "target/debug/custom_boost"
address = "commit-boost:18551"
relays = []
relay_check = true
timeout_get_header_ms = 950
timeout_get_payload_ms = 4000
timeout_register_validator_ms = 3000
skip_sigverify = true
min_bid_eth = 0.0

[signer]
address = "commit-boost:33951"
[signer.loader]
key_path = "keys.example.json"

[metrics]
address = "commit-boost:13030"
jwt_path = "metrics_jwt.txt"

# [[modules]]
# id = "DA_COMMIT"
# path = "target/debug/da_commit"
# sleep_secs = 5

[[modules]]
id = "DA_COMMIT"
docker_image="da_commit"
sleep_secs = 5
12 changes: 10 additions & 2 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ chain = "Holesky"

[pbs]
# path = "target/debug/custom_boost"
address = "127.0.0.1:18550"
address = "127.0.0.1:18551"
relays = []
relay_check = true
timeout_get_header_ms = 950
Expand All @@ -12,10 +12,18 @@ skip_sigverify = true
min_bid_eth = 0.0

[signer]
address = "127.0.0.1:33950"
address = "127.0.0.1:33951"
[signer.loader]
key_path = "keys.example.json"

[metrics]
address = "127.0.0.1:13030"

# [[modules]]
# id = "DA_COMMIT"
# path = "target/debug/da_commit"
# sleep_secs = 5

[[modules]]
id = "DA_COMMIT"
docker_image="da_commit"
Expand Down
31 changes: 31 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
chain = "Holesky"

[pbs]
# path = "target/debug/custom_boost"
address = "127.0.0.1:18550"
relays = []
relay_check = true
timeout_get_header_ms = 950
timeout_get_payload_ms = 4000
timeout_register_validator_ms = 3000
skip_sigverify = true
min_bid_eth = 0.0

[signer]
address = "127.0.0.1:33950"
[signer.loader]
key_path = "keys.example.json"

[metrics]
address = "127.0.0.1:3030"
jwt_path = "metrics_jwt.txt"

# [[modules]]
# id = "DA_COMMIT"
# path = "target/debug/da_commit"
# sleep_secs = 5

[[modules]]
id = "DA_COMMIT"
docker_image="da_commit"
sleep_secs = 5
1 change: 1 addition & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ rust-version.workspace = true
cb-common.workspace = true
cb-pbs.workspace = true
cb-crypto.workspace = true
cb-metrics.workspace = true

alloy-primitives.workspace = true
alloy-rpc-types-beacon.workspace = true
Expand Down
Loading