Skip to content
This repository was archived by the owner on Jan 30, 2026. It is now read-only.

Commit 23a65e1

Browse files
committed
feat: mixrunner
1 parent 70a17d1 commit 23a65e1

File tree

9 files changed

+766
-5
lines changed

9 files changed

+766
-5
lines changed

Dockerfile

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Build nim
2+
FROM debian:bookworm-slim AS build_nim
3+
4+
WORKDIR /
5+
6+
ENV DEBIAN_FRONTEND=noninteractive
7+
8+
RUN apt-get update && apt install -y git curl build-essential bash ca-certificates libssl-dev
9+
10+
ENV NIM_VERSION=version-2-0
11+
12+
RUN curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_nim.sh
13+
14+
RUN env MAKE="make -j$(nproc)" \
15+
ARCH_OVERRIDE=amd64 \
16+
NIM_COMMIT=$NIM_VERSION \
17+
QUICK_AND_DIRTY_COMPILER=1 \
18+
QUICK_AND_DIRTY_NIMBLE=1 \
19+
CC=gcc \
20+
bash build_nim.sh nim csources dist/nimble NimBinaries
21+
22+
23+
# =============================================================================
24+
# Build the app
25+
FROM debian:bookworm-slim AS build_app
26+
27+
WORKDIR /node
28+
29+
# Copy nim
30+
COPY --from=build_nim /nim /nim
31+
32+
ENV PATH="/root/.nimble/bin:/nim/bin:${PATH}"
33+
34+
ENV DEBIAN_FRONTEND=noninteractive
35+
36+
RUN apt-get update && apt install -y git build-essential bash ca-certificates libssl-dev
37+
38+
# Configure git and install dependencies
39+
RUN git config --global http.sslVerify false
40+
41+
# Install latest nimble version
42+
RUN nimble install nimble@0.20.1
43+
44+
# Copy only files needed to install Nimble deps (optimizes layer caching)
45+
COPY mix.nimble .
46+
47+
RUN nimble install -y --depsOnly.
48+
49+
# Copy full source AFTER deps are cached
50+
COPY . .
51+
52+
# Compile the Nim application
53+
RUN nimble c -d:chronicles_colors=None --threads:on -d:metrics -d:libp2p_network_protocols_metrics -d:enable_mix_benchmarks -d:release examples/mixrunner/main
54+
55+
# =============================================================================
56+
# Run the app
57+
FROM debian:bookworm AS prod
58+
59+
ENV DEBIAN_FRONTEND=noninteractive
60+
61+
RUN apt update && apt -y install cron libpcre3 libssl-dev
62+
63+
# Set the working directory
64+
WORKDIR /node
65+
66+
# Copy the compiled binary from the build stage
67+
COPY --from=build_app /node/examples/mixrunner/main /node/main
68+
69+
COPY ./examples/mixrunner/cron_runner.sh .
70+
71+
RUN chmod +x cron_runner.sh
72+
RUN chmod +x main
73+
74+
EXPOSE 5000 8008
75+
76+
ENV FILEPATH=/data
77+
VOLUME ["/data"]
78+
79+
ENTRYPOINT ["./cron_runner.sh"]

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,22 @@ Execute the test suite with:
4949

5050
## Usage
5151

52-
Run the Mix protocol proof-of-concept:
52+
Run the Mix protocol proof-of-concepts:
5353

5454
```bash
55-
nim c -r src/mix_poc.nim
55+
nim c -r examples/poc_gossipsub.nim
56+
nim c -r examples/poc_resp_ping.nim
57+
nim c -r examples/poc_noresp_ping.nim
5658
```
5759

60+
## Build mix runner Docker Image
61+
```
62+
docker build -t mixrunner .
63+
64+
# Run mixrunner
65+
./examples/mixrunner/mixrunner.sh
66+
```
67+
5868
## Current Implementation Challenges
5969

6070
1. **Protocol Handler Diversity**: Existing protocols have diverse input formats for handlers and send functions,

examples/mixrunner/cron_runner.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
if [ "$#" -ne 2 ]; then
4+
echo "Usage: $0 <minutes> <hours>"
5+
exit 1
6+
fi
7+
8+
minutes="$1"
9+
hours="$2"
10+
11+
cron_expression="$minutes $hours * * *"
12+
13+
cron_job_file="/etc/cron.d/my-cron-job"
14+
echo -e "$cron_expression /node/main > /proc/1/fd/1 2>&1 \n" > "$cron_job_file"
15+
16+
echo "Cron job file created at $cron_job_file"
17+
18+
env >> /etc/environment
19+
20+
crontab /etc/cron.d/my-cron-job
21+
22+
cron -f

0 commit comments

Comments
 (0)