Skip to content

Commit 21d417c

Browse files
committed
feat(error-sink-service): WIP
1 parent 5278d2c commit 21d417c

File tree

9 files changed

+830
-11
lines changed

9 files changed

+830
-11
lines changed

Cargo.lock

Lines changed: 314 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ members = [
3131
"tools/fuzzing",
3232
"tools/archive-breadcrumb-compare",
3333
"tools/heartbeats-processor",
34+
"tools/error-sink-service",
3435
"tools/webrtc-sniffer",
3536

3637
"producer-dashboard",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
target/
2+
dumps/
3+
Dockerfile
4+
docker-compose.yml
5+
.dockerignore

tools/error-sink-service/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dumps/
2+
reports/

tools/error-sink-service/Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "error-sink-service"
3+
version = "0.1.0"
4+
edition = "2021"
5+
description = "A service to collect and store error reports from OpenMina nodes"
6+
7+
[dependencies]
8+
actix-web = "4.3"
9+
log = "0.4"
10+
env_logger = "0.11"
11+
chrono = "0.4"
12+
uuid = { version = "1", features = ["v4"] }
13+
anyhow = "1.0"
14+
serde = { version = "1.0", features = ["derive"] }
15+
serde_json = "1.0"
16+
base64 = "0.22"
17+
bs58 = "0.5.0"

tools/error-sink-service/Dockerfile

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Build Stage
2+
FROM rust:bookworm AS builder
3+
4+
WORKDIR /usr/src/app
5+
6+
# Copy Cargo.toml and Cargo.lock
7+
COPY Cargo.toml ./
8+
9+
# Create a dummy main.rs to build dependencies
10+
RUN mkdir -p src && echo 'fn main() {}' > src/main.rs
11+
12+
# Build dependencies
13+
RUN cargo build --release
14+
15+
# Remove the dummy files
16+
RUN rm -rf src
17+
18+
# Copy the actual source code
19+
COPY src ./src
20+
21+
RUN ls -la src; cat src/main.rs
22+
23+
# Build the actual application
24+
RUN cargo build --release
25+
26+
# Runtime Stage
27+
FROM debian:bookworm-slim
28+
29+
WORKDIR /app
30+
31+
# Install necessary runtime dependencies
32+
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates \
33+
&& rm -rf /var/lib/apt/lists/*
34+
35+
# Copy the binary from the build stage
36+
COPY --from=builder /usr/src/app/target/release/error-sink-service .
37+
38+
# Create directory for reports (using "reports" instead of "dumps")
39+
RUN mkdir -p /app/reports
40+
41+
# Set environment variables
42+
ENV ERROR_SINK_PORT=8080
43+
ENV ERROR_SINK_DIR=/app/reports
44+
ENV ERROR_SINK_VERIFY_SIGNATURES=true
45+
ENV RUST_LOG=info
46+
47+
# Expose the service port
48+
EXPOSE 8080
49+
50+
# Set the volume for persisting reports
51+
VOLUME /app/reports
52+
53+
# Run the binary
54+
CMD ["./error-sink-service"]

tools/error-sink-service/README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Error Sink Service
2+
3+
A simple HTTP service for collecting and cataloging error reports from OpenMina nodes.
4+
5+
## Usage
6+
7+
### Running the service
8+
9+
```bash
10+
# Basic usage with default settings
11+
cargo run
12+
13+
# Specify a custom port and storage directory
14+
ERROR_SINK_PORT=9090 ERROR_SINK_DIR=/path/to/reports cargo run
15+
16+
# Disable signature verification
17+
ERROR_SINK_VERIFY_SIGNATURES=false cargo run
18+
```
19+
20+
### Environment variables
21+
22+
| Variable | Description | Default |
23+
|----------|-------------|---------|
24+
| `ERROR_SINK_PORT` | HTTP port to listen on | `8080` |
25+
| `ERROR_SINK_DIR` | Directory to store reports | `./reports` |
26+
| `ERROR_SINK_VERIFY_SIGNATURES` | Enable/disable signature verification | `true` |
27+
28+
### Docker usage
29+
30+
```bash
31+
docker run -p 8080:8080 -v ./reports:/app/reports openmina/error-sink-service
32+
```
33+
34+
## API Endpoints
35+
36+
### `POST /error-report`
37+
38+
Submit a new error report. The endpoint accepts JSON data with the following structure:
39+
40+
```json
41+
{
42+
"submitter": "B62qrPN5Y5yq8kGE3FbVKbGTdTAJNdtNtB5sNVpxyRwWGcDEhpMzc8g",
43+
"category": "blockProofFailure",
44+
"data": "base64-encoded-binary-data",
45+
"signature": "base64-encoded-signature"
46+
}
47+
```
48+
49+
Field descriptions:
50+
- `submitter`: Valid base58-encoded Mina public key of the submitting entity
51+
- `category`: Classification of the error type (string, must be one of the valid categories)
52+
- `data`: Base64-encoded binary data containing the error report
53+
- `signature`: Base64-encoded cryptographic signature of the data, created using the private key corresponding to the submitter public key
54+
55+
Example submission:
56+
57+
```bash
58+
curl -X POST -H "Content-Type: application/json" -d '{
59+
"submitter": "B62qrPN5Y5yq8kGE3FbVKbGTdTAJNdtNtB5sNVpxyRwWGcDEhpMzc8g",
60+
"category": "blockProofFailure",
61+
"data": "SGVsbG8gV29ybGQ=",
62+
"signature": "7mXGPhek8iTKjKrYbg7G9U2X5Bk8P5HBDSdwMCJYdPoE5MvJ9Rdho2C4xNe7LcDNPJM9Lrb3r8CpQyUrSS7bDtvm1ZrqZgL"
63+
}' http://localhost:8080/error-report
64+
```
65+
66+
## File Storage Format
67+
68+
Error reports are stored with descriptive filenames using the following format:
69+
```
70+
{category}-{submitter_public_key}_{timestamp}_{uuid}.report
71+
```
72+
73+
For example:
74+
```
75+
blockProofFailure-B62qrPN5Y5yq8kGE3FbVKbGTdTAJNdtNtB5sNVpxyRwWGcDEhpMzc8g_20230405-123015_550e8400-e29b-41d4-a716-446655440000.report
76+
```
77+
78+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '3.8'
2+
3+
services:
4+
error-sink-service:
5+
build: .
6+
container_name: error-sink-service
7+
ports:
8+
- "8080:8080"
9+
volumes:
10+
- ./reports:/app/reports
11+
environment:
12+
- ERROR_SINK_PORT=8080
13+
- ERROR_SINK_DIR=/app/reports
14+
- ERROR_SINK_VERIFY_SIGNATURES=true
15+
- RUST_LOG=info
16+
restart: unless-stopped

0 commit comments

Comments
 (0)