Skip to content

Commit 83dee52

Browse files
authored
Merge pull request #606 from input-output-hk/hjeljeli32/readme-demo-improvements
Update README instructions for running the Leios demo
2 parents 7fdc3a1 + 5d76126 commit 83dee52

File tree

1 file changed

+67
-48
lines changed

1 file changed

+67
-48
lines changed
Lines changed: 67 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,114 @@
1+
# Demo Scripts for Leios Crypto Benchmarks
12

3+
## Setup
24

3-
# Demo Scripts for Leios Crypto Benchmarks
5+
From the `demo/` directory, go one level up to the `crypto-benchmarks.rs` directory and build the CLI binary:
46

5-
This folder contains scripts that orchestrate end-to-end demonstrations of BLS-based vote aggregation and certificate generation/verification for the Leios project.
7+
```bash
8+
cd ..
9+
cargo build --release
10+
```
611

7-
## Prerequisites
12+
**Register the CLI path (while still in `crypto-benchmarks.rs/`)** so all demo scripts can find it:
813

9-
- Ensure the CLI built from the repository root is available; see `crypto-benchmarks.rs/ReadMe.md` for build instructions and usage details.
10-
- Ensure Python 3 is available with `cbor2` installed.
11-
For example:
14+
```bash
15+
./demo/scripts/00_set_cli.sh -p "$(pwd)/target/release/leios_crypto_benchmarks"
16+
```
1217

13-
```bash
14-
python3 -m venv .venv
15-
source .venv/bin/activate
16-
pip install cbor2
17-
```
18+
Now return to the `demo/` directory to proceed:
1819

19-
## Workflow
20+
```bash
21+
cd demo
22+
```
2023

21-
The scripts are designed to be run from the `demo/` directory.
24+
Verify the `.env_cli` file and sanity‑check the CLI:
2225

23-
### Run Step by Step (Manual Mode)
26+
```bash
27+
cat scripts/.env_cli
28+
source scripts/.env_cli
29+
echo "$CLI"
30+
$CLI --help
31+
```
2432

25-
You can run each script individually to understand and control each step of the process for a given number of voters (e.g., 100). Use the `-d` option to specify the output directory (e.g., `run100`).
33+
Ensure the CLI binary is accessible and working before proceeding.
2634

27-
#### 10_init_inputs.sh
35+
## Python Environment Setup
2836

29-
Initialize inputs for N voters:
37+
Create and activate a Python virtual environment, then install the required dependencies:
3038

3139
```bash
32-
scripts/10_init_inputs.sh -d run100 --pools 500 --stake 100000 --alpha 9 --beta 1
40+
python3 -m venv .venv
41+
source .venv/bin/activate
42+
pip install flask cbor2
3343
```
3444

35-
#### 20_make_registry.sh
45+
(Flask is required to serve the demo UI, and cbor2 is used for parsing CBOR files.)
46+
47+
## Run a Single End-to-End Demo
3648

37-
Build the registry from initialized inputs:
49+
From the `demo/` directory, run the combined script to generate a complete demo for a specified number of voters and pools. Ensure `.env_cli` exists in this directory:
50+
51+
(If you haven’t yet, run the **Setup** steps above to build the CLI and create `scripts/.env_cli`.)
3852

3953
```bash
40-
./scripts/20_make_registry.sh -d run100 -n 100
54+
scripts/70_run_one.sh -d run100 -p 500 -n 100 -f 0.75
4155
```
4256

43-
#### 30_cast_votes.sh
57+
This script will:
4458

45-
Cast votes with a specified fraction of voters voting (e.g., 1.0 means all vote):
59+
1. Initialize inputs
60+
2. Build the registry
61+
3. Cast votes
62+
4. Generate the aggregated certificate
63+
5. Verify the certificate
64+
6. Export data for the UI
4665

47-
```bash
48-
scripts/30_cast_votes.sh -d run100 -f 0.75
49-
```
66+
All output files will be placed under `demo/run100/`.
5067

51-
#### 40_make_certificate.sh
68+
## Launch the Demo UI
5269

53-
Generate the aggregated certificate:
70+
After generating a demo run, start the UI server from the `demo/` directory:
5471

5572
```bash
56-
scripts/40_make_certificate.sh -d run100
73+
python3 ui/server.py
5774
```
5875

59-
#### 50_verify_certificate.sh
76+
Open your browser at [http://127.0.0.1:5050/ui](http://127.0.0.1:5050/ui) to explore the results.
77+
78+
## Run Step by Step (Manual Mode)
79+
80+
For advanced users who want to control each phase individually, the following scripts can be run sequentially from the `demo/` directory. Use the `-d` option to specify the output directory (e.g., `run100`).
6081

61-
Verify the generated certificate:
82+
1. **Initialize inputs for N voters:**
6283

6384
```bash
64-
scripts/50_verify_certificate.sh -d run100
85+
scripts/10_init_inputs.sh -d run100 --pools 500 --stake 100000 --alpha 9 --beta 1
6586
```
6687

67-
### Run a Single End-to-End Demo
88+
2. **Build the registry:**
6889

6990
```bash
70-
scripts/70_run_one.sh -d run100 -p 500 -n 100 -f 0.75
91+
scripts/20_make_registry.sh -d run100 -n 100
7192
```
7293

73-
This will:
94+
3. **Cast votes with a fraction of voters participating:**
7495

75-
1. Initialize inputs (`10_init_inputs.sh`)
76-
2. Build a registry (`20_make_registry.sh`)
77-
3. Cast votes (`30_cast_votes.sh`)
78-
4. Make a certificate (`40_make_certificate.sh`)
79-
5. Verify the certificate (`50_verify_certificate.sh`)
80-
6. Export data for the UI (`60_export_demo_json.sh`)
96+
```bash
97+
scripts/30_cast_votes.sh -d run100 -f 0.75
98+
```
8199

82-
All files are placed in `demo/run100/`.
100+
4. **Generate the aggregated certificate:**
83101

84-
### Launch the Demo UI
102+
```bash
103+
scripts/40_make_certificate.sh -d run100
104+
```
85105

86-
After generating a demo run (for example via `scripts/70_run_one.sh`), start the UI server from this directory:
106+
5. **Verify the generated certificate:**
87107

88108
```bash
89-
python3 ui/server.py
109+
scripts/50_verify_certificate.sh -d run100
90110
```
91111

92-
Then open your browser at [http://127.0.0.1:5050/ui](http://127.0.0.1:5050/ui) to explore the results.
93-
94112
## Notes
95113

96114
- All scripts must be run from within the `demo/` directory.
@@ -101,4 +119,5 @@ Then open your browser at [http://127.0.0.1:5050/ui](http://127.0.0.1:5050/ui) t
101119
votes_bytes / certificate_bytes
102120
```
103121

104-
which illustrates the storage/bandwidth savings achieved by BLS aggregation.
122+
which illustrates the storage and bandwidth savings achieved by BLS aggregation.
123+
- The CLI path is stored in `scripts/.env_cli` (generated by `00_set_cli.sh`). Source it with `source scripts/.env_cli` to make `$CLI` available in your shell.

0 commit comments

Comments
 (0)