Skip to content

Commit ef6adb3

Browse files
authored
Merge branch 'main' into conformance-testing
2 parents ad08bdf + 616e6a3 commit ef6adb3

File tree

16 files changed

+729
-6286
lines changed

16 files changed

+729
-6286
lines changed

.dockerignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Ignore everything
2+
*
3+
!sim-rs/
4+
!simulation/
5+
!data/simulation/*.yaml
6+
!cabal.project
7+
8+
# Ignore unnecessary files even in sim-rs
9+
sim-rs/target/
10+
sim-rs/.git/
11+
sim-rs/output/
12+
**/*.rs.bk
13+
**/.DS_Store
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Docker Build and Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- "leios-[0-9][0-9][0-9][0-9]w[0-9][0-9]"
7+
- "v[0-9]+.[0-9]+.[0-9]+"
8+
- "[0-9]+.[0-9]+.[0-9]+"
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
OWNER: input-output-hk
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Log in to the Container registry
26+
uses: docker/login-action@v3
27+
with:
28+
registry: ${{ env.REGISTRY }}
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Extract metadata (tags, labels)
33+
id: meta
34+
uses: docker/metadata-action@v5
35+
with:
36+
images: |
37+
${{ env.REGISTRY }}/${{ env.OWNER }}/ouroboros-leios-sim-rs
38+
${{ env.REGISTRY }}/${{ env.OWNER }}/ouroboros-leios-sim-hs
39+
tags: |
40+
type=ref,event=tag
41+
type=raw,value=latest
42+
43+
- name: Build and push Rust simulation image
44+
uses: docker/build-push-action@v5
45+
with:
46+
context: .
47+
target: rs
48+
push: true
49+
tags: |
50+
${{ env.REGISTRY }}/${{ env.OWNER }}/ouroboros-leios-sim-rs:${{ github.ref_name }}
51+
${{ env.REGISTRY }}/${{ env.OWNER }}/ouroboros-leios-sim-rs:latest
52+
labels: ${{ steps.meta.outputs.labels }}
53+
54+
- name: Build and push Haskell simulation image
55+
uses: docker/build-push-action@v5
56+
with:
57+
context: .
58+
target: hs
59+
push: true
60+
tags: |
61+
${{ env.REGISTRY }}/${{ env.OWNER }}/ouroboros-leios-sim-hs:${{ github.ref_name }}
62+
${{ env.REGISTRY }}/${{ env.OWNER }}/ouroboros-leios-sim-hs:latest
63+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
FROM debian:bookworm-slim AS base
2+
3+
# Create shared directories and install dependencies in one layer
4+
RUN apt-get update && apt-get install -y --no-install-recommends \
5+
ca-certificates \
6+
libgmp10 \
7+
libgtk-3-0 \
8+
libglib2.0-0 \
9+
libcairo2 \
10+
libpango-1.0-0 \
11+
libpangocairo-1.0-0 \
12+
&& rm -rf /var/lib/apt/lists/* \
13+
&& mkdir -p /usr/local/share/leios \
14+
&& mkdir -p /output
15+
16+
VOLUME /output
17+
18+
# Copy shared configuration files
19+
COPY data/simulation/config.default.yaml /usr/local/share/leios/config.default.yaml
20+
COPY data/simulation/topo-default-100.yaml /usr/local/share/leios/topology.default.yaml
21+
22+
# Build Rust simulation
23+
FROM rust:1.82-slim AS rs-builder
24+
WORKDIR /usr/src/sim-rs
25+
COPY sim-rs/ .
26+
RUN cargo build --release
27+
28+
# Build Haskell simulation
29+
FROM haskell:9.8.2-slim AS hs-builder
30+
WORKDIR /build
31+
32+
# Install git, SSL certificates, and GTK3 development dependencies
33+
RUN apt-get update && \
34+
apt-get install -y \
35+
git \
36+
ca-certificates \
37+
curl \
38+
pkg-config \
39+
libgtk-3-dev \
40+
libcairo2-dev \
41+
libpango1.0-dev \
42+
libgmp-dev \
43+
libtinfo-dev \
44+
zlib1g-dev \
45+
&& rm -rf /var/lib/apt/lists/*
46+
47+
# Copy project files
48+
COPY . .
49+
50+
# Build simulation
51+
WORKDIR /build/simulation
52+
RUN cabal update && \
53+
cabal build all && \
54+
# Find the actual binary path and copy it to a known location
55+
find /build/dist-newstyle -type f -name "ols" -exec cp {} /build/ols \;
56+
57+
# Create Rust simulation image
58+
FROM base AS rs
59+
WORKDIR /output
60+
61+
# Copy the sim-cli binary
62+
COPY --from=rs-builder /usr/src/sim-rs/target/release/sim-cli /usr/local/bin/
63+
64+
# Create entrypoint script
65+
RUN echo '#!/bin/sh\n\
66+
set -e\n\
67+
\n\
68+
# Create output directory if it doesnt exist\n\
69+
mkdir -p /output\n\
70+
\n\
71+
if [ $# -eq 0 ]; then\n\
72+
exec /usr/local/bin/sim-cli\n\
73+
elif [ $# -eq 1 ] && [ "${1#-}" = "$1" ]; then\n\
74+
# If only one argument and it doesnt start with -, treat it as output file\n\
75+
output_dir=$(dirname "$1")\n\
76+
mkdir -p "$output_dir"\n\
77+
exec /usr/local/bin/sim-cli /usr/local/share/leios/topology.default.yaml "$1"\n\
78+
else\n\
79+
# Pass all arguments to sim-cli\n\
80+
exec /usr/local/bin/sim-cli "$@"\n\
81+
fi' > /usr/local/bin/entrypoint-rs.sh && chmod +x /usr/local/bin/entrypoint-rs.sh
82+
83+
ENTRYPOINT ["/usr/local/bin/entrypoint-rs.sh"]
84+
CMD []
85+
86+
# Create Haskell simulation image
87+
FROM base AS hs
88+
WORKDIR /output
89+
90+
# Copy the ols binary and necessary files
91+
COPY --from=hs-builder /build/ols /usr/local/bin/
92+
93+
# Create entrypoint script for Haskell simulation
94+
RUN echo '#!/bin/sh\n\
95+
set -e\n\
96+
\n\
97+
# Create output directory if it doesnt exist\n\
98+
mkdir -p /output\n\
99+
\n\
100+
# Default values\n\
101+
TOPOLOGY_FILE="/usr/local/share/leios/topology.default.yaml"\n\
102+
CONFIG_FILE="/usr/local/share/leios/config.default.yaml"\n\
103+
OUTPUT_SECONDS=40\n\
104+
SEED=0\n\
105+
\n\
106+
# Parse arguments\n\
107+
while [ $# -gt 0 ]; do\n\
108+
case "$1" in\n\
109+
--topology|-t)\n\
110+
TOPOLOGY_FILE="$2"\n\
111+
shift 2\n\
112+
;;\n\
113+
--config|-l)\n\
114+
CONFIG_FILE="$2"\n\
115+
shift 2\n\
116+
;;\n\
117+
--output-seconds)\n\
118+
OUTPUT_SECONDS="$2"\n\
119+
shift 2\n\
120+
;;\n\
121+
--seed)\n\
122+
SEED="$2"\n\
123+
shift 2\n\
124+
;;\n\
125+
--output-file)\n\
126+
OUTPUT_FILE="$2"\n\
127+
shift 2\n\
128+
;;\n\
129+
*)\n\
130+
break\n\
131+
;;\n\
132+
esac\n\
133+
done\n\
134+
\n\
135+
if [ -z "$OUTPUT_FILE" ]; then\n\
136+
TIMESTAMP=$(date +%Y%m%d_%H%M%S)\n\
137+
OUTPUT_FILE="/output/simulation_${TIMESTAMP}.log"\n\
138+
fi\n\
139+
\n\
140+
# Create a temporary file\n\
141+
TEMP_FILE="${OUTPUT_FILE}.tmp"\n\
142+
\n\
143+
# Ensure output directory exists\n\
144+
mkdir -p "$(dirname "$OUTPUT_FILE")"\n\
145+
\n\
146+
# Run simulation with arguments, writing to temp file\n\
147+
/usr/local/bin/ols sim short-leios \\\n\
148+
--seed "$SEED" \\\n\
149+
--leios-config-file "$CONFIG_FILE" \\\n\
150+
--topology-file "$TOPOLOGY_FILE" \\\n\
151+
--output-seconds "$OUTPUT_SECONDS" \\\n\
152+
--output-file "$TEMP_FILE" \\\n\
153+
"$@" && \\\n\
154+
mv "$TEMP_FILE" "$OUTPUT_FILE"' > /usr/local/bin/entrypoint-hs.sh && chmod +x /usr/local/bin/entrypoint-hs.sh
155+
156+
ENTRYPOINT ["/usr/local/bin/entrypoint-hs.sh"]
157+
CMD []

Logbook.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# Leios logbook
22

3+
## 2025-02-18
4+
5+
### CPS-0018
6+
7+
[CIPS-0018 "Greater Transaction Throughput"](https://github.com/cardano-foundation/CIPs/blob/master/CPS-0018/README.md) has been officially approved and merged into the Cardano Foundation's CIP/CPS repository. This Cardano Problem Statement motivates the need for higher transaction throughput on Cardano and provides evidence for its urgency. It also defines goals for initiatives like Leios, summarizes use cases, and identifies open questions.
8+
9+
### Docker Support for Simulations
10+
11+
Added Docker support for both the Rust and Haskell simulations, making it easier to run and generate simulation traces without setting up the development environment. The Docker images are built using a multi-stage Dockerfile that creates optimized images for both simulations.
12+
13+
Basic usage examples:
14+
15+
```bash
16+
# Run Rust simulation with default settings
17+
docker run -v $(pwd)/output:/output ouroboros-leios/sim-rs:latest
18+
19+
# Run Haskell simulation for 120 seconds
20+
docker run -v $(pwd)/output:/output ouroboros-leios/sim-hs:latest --output-seconds 120
21+
```
22+
23+
See the [Docker Simulation section in README.md](README.md#docker-simulation) for detailed usage instructions, including how to use custom topology files and configuration options.
24+
325
## 2025-02-16
426

527
### DeltaQ Update

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,99 @@ More documentation about Leios can be found in the [web site](https://leios.card
2424
- [sim-rs](sim-rs) contains experimental Rust code to simulate the Leios protocol
2525
- [site](site) contains the sources of the aforementioned web site
2626

27+
## Docker Simulation
28+
29+
You can run both the Rust and Haskell simulations using Docker to generate simulation trace logs.
30+
31+
### Building the Docker Images
32+
33+
```bash
34+
# Build the Rust simulation image
35+
docker build --target rs -t ouroboros-leios/sim-rs:latest -f Dockerfile .
36+
37+
# Build the Haskell simulation image
38+
docker build --target hs -t ouroboros-leios/sim-hs:latest -f Dockerfile .
39+
```
40+
41+
### Running the Rust Simulation
42+
43+
The Rust simulation generates JSONL trace files that can be visualized using the web-based UI:
44+
45+
#### Basic Usage (Default Settings)
46+
```bash
47+
# Run with default settings
48+
docker run -v $(pwd)/output:/output ouroboros-leios/sim-rs:latest
49+
```
50+
51+
#### Specifying Output File
52+
```bash
53+
# Run with custom output file location
54+
docker run -v $(pwd)/output:/output ouroboros-leios/sim-rs:latest /output/simulation.jsonl
55+
```
56+
57+
#### Using Custom Topology and Config Files
58+
```bash
59+
# Mount your config directory and use custom files
60+
docker run \
61+
-v $(pwd)/output:/output \
62+
-v $(pwd)/data/simulation:/config \
63+
ouroboros-leios/sim-rs:latest /config/topology-dense-52.yaml /output/simulation.jsonl -s 20 -p /config/config.default.yaml
64+
```
65+
66+
Common arguments for Rust simulation:
67+
- `-s NUMBER`: Number of slots to simulate
68+
- `-p PATH`: Path to custom parameters file
69+
- `--trace-node NODE_ID`: Enable tracing for specific node
70+
- `--timescale SCALE`: Adjust simulation speed (e.g., 16 for 16x faster)
71+
72+
### Running the Haskell Simulation
73+
74+
The Haskell simulation generates log files with simulation data:
75+
76+
#### Basic Usage (Default Settings)
77+
```bash
78+
# Run with default settings (40 seconds)
79+
docker run -v $(pwd)/output:/output ouroboros-leios/sim-hs:latest
80+
```
81+
82+
#### Custom Duration and Output File
83+
```bash
84+
# Run for 120 seconds with specific output file
85+
docker run -v $(pwd)/output:/output ouroboros-leios/sim-hs:latest \
86+
--output-seconds 120 \
87+
--output-file /output/my-simulation.log
88+
```
89+
90+
#### Using Custom Configuration
91+
```bash
92+
# Run with custom topology and config files
93+
docker run \
94+
-v $(pwd)/output:/output \
95+
-v $(pwd)/data/simulation:/config \
96+
ouroboros-leios/sim-hs:latest \
97+
--topology /config/topology-dense-52.yaml \
98+
--config /config/config.default.yaml \
99+
--output-seconds 60 \
100+
--seed 12345
101+
```
102+
103+
Common arguments for Haskell simulation:
104+
- `--output-seconds NUMBER`: Duration of simulation in seconds (default: 40)
105+
- `--seed NUMBER`: Random seed for reproducible runs
106+
- `--topology PATH`: Custom topology file
107+
- `--config PATH`: Custom configuration file
108+
- `--output-file PATH`: Custom output file location
109+
110+
> [!NOTE]
111+
> The Rust simulation generates JSONL trace files that can be visualized using the web-based UI in the `ui` directory.
112+
> The Haskell simulation generates log files in its own format.
113+
>
114+
> To visualize Rust simulation traces:
115+
> 1. Generate a trace file using the Rust simulation
116+
> 2. Use the web UI in the `ui` directory to load and visualize the trace
117+
>
118+
> For Haskell simulation visualization, use the `viz` command option directly in the Haskell simulation binary (not available in Docker).
119+
27120
## Specification
28121

29122
Build the Agda specification for Leios using either

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ source-repository-package
5555
type: git
5656
location: https://github.com/wenkokke/gtk2hs.git
5757
tag: ca7f98bd3e9462deac3661244dc76004a36fc8c3
58-
--sha256: IXuR7ZdTltFT4IQQMdBbDE6ikVsoWVON57THdarUsDw=
58+
--sha256: 0g5hsjm7bixlwy6m6n98bf8s4khcbg832444w19x35jkjznr2yr1
5959
subdir:
6060
pango
6161

0 commit comments

Comments
 (0)