Skip to content

Commit 42dd661

Browse files
authored
Stracciatella experiment (#451)
* Designed stracciatella experiment * Stracciatella results * Increased size constraint on EBs * Reran 1000 TPS at 8 slot/stage for larger EBs * Updated logbook
1 parent b9730df commit 42dd661

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+6440
-6
lines changed

Logbook.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
## 2025-07-11
44

5+
### Stracciatella experiment
6+
7+
The Stracciatella variant of Leios (i.e., no IBs, tx refrences in EBs, and a two-stage pipeline) is analyzed in the Jupyter notebook [analysis/sims/2025w28/analysis-stracciatella.ipynb](analysis/sims/2025w28/analysis-stracciatella.ipynb). Findings follow:
8+
9+
- 1000+ TPS is attainable.
10+
- Congestion does appear at this throughput.
11+
- 5 slot/stage performs less well but appears to scale better than 8 slot/stage.
12+
- Spatial efficiency is better than 95%.
13+
- Time to ledger is better than two minutes (subject to RB randomness, of course).
14+
- Only the tiniest fraction of transactions don't reach the ledger, likely due to EBs expiring before the reach an RB.
15+
- Network usage is slightly heavy.
16+
- CPU usage seems suspiciously light.
17+
518
### Throughput efficiency of Linear Leios
619

720
The Linear Leios variant's formulation is straightforward enough that its probability of including a certified EB on chain can be computed analytically.

analysis/sims/2025w28/analysis-stracciatella.ipynb

Lines changed: 2672 additions & 0 deletions
Large diffs are not rendered by default.

analysis/sims/2025w28/combine-results.sh

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
11
#!/usr/bin/env nix-shell
2-
#!nix-shell -i bash -p gzip
2+
#!nix-shell -i bash -p gnused gzip pigz "rWrapper.override { packages = with rPackages; [ data_table R_utils bit64 ggplot2 magrittr stringr ]; }"
33

44
set -e
55

6-
for d in quick
6+
for d in stracciatella
77
do
88
mkdir -p results/$d
9-
for f in cpus lifecycle resources receipts
9+
for f in lifecycle resources receipts cpus
1010
do
1111
DIR=$(find $d -type f -name $f.csv.gz \( -not -empty \) -printf %h\\n -quit)
1212
HL=$(sed -n -e '1p' "$DIR/case.csv")
1313
HR=$(zcat "$DIR/$f.csv.gz" | sed -n -e '1p')
14+
if [[ "$f" == "lifecycle" || "$f" == "resources" ]]
15+
then
16+
FRACT=1
17+
else
18+
FRACT=0.25
19+
fi
1420
(
1521
echo "$HL,$HR"
1622
for g in $(find $d -type f -name $f.csv.gz \( -not -empty \) -printf %h\\n)
1723
do
24+
if [[ "$(echo $g | sed -e 's/^.*,//')" == "10" || "$(echo $g | sed -e 's/^.*,//')" == "30" ]]
25+
then
26+
echo "Skipping $g due to filter." >> /dev/stderr
27+
continue
28+
fi
1829
if [ ! -e "$g/stderr" ]
1930
then
2031
echo "Skipping $g because it has no stderr." >> /dev/stderr
@@ -23,10 +34,16 @@ do
2334
echo "Skipping $g because its stderr is not empty." >> /dev/stderr
2435
else
2536
BL=$(sed -n -e '2p' "$g/case.csv")
26-
zcat "$g/$f.csv.gz" | sed -e "1d;s/^/$BL,/;s/null/NA/g"
37+
zcat "$g/$f.csv.gz" | gawk 'FNR > 1 && rand() <= '"$FRACT"' { print "'"$BL"'" "," $0}'
2738
fi
2839
done
29-
) | pigz -p 3 -9c > results/$d/$f.csv.gz &
40+
) | pigz -p 3 -9c > results/$d/$f.csv.gz
41+
R --vanilla << EOI > /dev/null
42+
require(data.table)
43+
sampleSize <- $FRACT
44+
print(sampleSize)
45+
$f <- fread("results/$d/$f.csv.gz", stringsAsFactors=TRUE)
46+
save($f, sampleSize, file="results/$d/$f.Rdata", compression_level=9)
47+
EOI
3048
done
3149
done
32-
wait
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
stracciatella/8,2000/run.sh
2+
stracciatella/5,2000/run.sh
3+
stracciatella/8,1000/run.sh
4+
stracciatella/8,10/run.sh
5+
stracciatella/5,10/run.sh
6+
stracciatella/8,30/run.sh
7+
stracciatella/5,30/run.sh
8+
stracciatella/8,100/run.sh
9+
stracciatella/5,100/run.sh
10+
stracciatella/8,300/run.sh
11+
stracciatella/5,300/run.sh
12+
stracciatella/5,1000/run.sh
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Simulator,Stage length,TPS
2+
Rust,5 slot/stage,10 tx/s
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
# yaml-language-server: $schema=./config.schema.json
2+
3+
################################################################################
4+
# Simulation Configuration File
5+
################################################################################
6+
#
7+
# This file contains the default configuration for running Leios simulations in
8+
# the Haskell simulation (`simulation/`) and the Rust simulation (`sim-rs/`).
9+
#
10+
################################################################################
11+
# Simulation Configuration
12+
################################################################################
13+
14+
relay-strategy: "request-from-first"
15+
tcp-congestion-control: true
16+
multiplex-mini-protocols: true
17+
simulate-transactions: true
18+
treat-blocks-as-full: false
19+
cleanup-policies: ["cleanup-expired-vote"]
20+
timestamp-resolution-ms: 0.1
21+
22+
################################################################################
23+
# Leios Protocol Configuration
24+
################################################################################
25+
26+
leios-variant: full-without-ibs
27+
leios-stage-length-slots: 5
28+
leios-stage-active-voting-slots: 1
29+
leios-vote-send-recv-stages: false
30+
leios-late-ib-inclusion: true
31+
leios-header-diffusion-time-ms: 1000.0
32+
leios-mempool-sampling-strategy: ordered-by-id
33+
leios-mempool-aggressive-pruning: true
34+
# TODO: revise default
35+
praos-chain-quality: 100
36+
praos-fallback-enabled: false
37+
38+
################################################################################
39+
# Transaction Configuration
40+
################################################################################
41+
42+
tx-generation-distribution:
43+
distribution: exp
44+
lambda: 0.85
45+
scale: 120.000
46+
tx-size-bytes-distribution:
47+
distribution: log-normal
48+
mu: 6.833
49+
sigma: 1.127
50+
tx-conflict-fraction: 0
51+
tx-overcollateralization-factor-distribution:
52+
distribution: constant
53+
value: 0
54+
tx-validation-cpu-time-ms: 0.065
55+
tx-max-size-bytes: 16384
56+
tx-start-time: 60
57+
tx-stop-time: 360
58+
59+
################################################################################
60+
# Ranking Block Configuration
61+
################################################################################
62+
63+
# 1/leios-stage-length-slots, targeting one RB per pipeline.
64+
# Also 20s is current rate of praos blocks.
65+
rb-generation-probability: 5.0e-2
66+
# Eng. team targets 1kB as worst case upper bound.
67+
# Actual size fairly close.
68+
rb-head-size-bytes: 1024
69+
rb-body-max-size-bytes: 90112
70+
# Note: certificate generation/validation is not included in the
71+
# timings here, see cert-* fields.
72+
rb-generation-cpu-time-ms: 1.0
73+
rb-head-validation-cpu-time-ms: 1.0
74+
75+
# On average, no Txs directly embedded in blocks.
76+
rb-body-legacy-praos-payload-avg-size-bytes: 0
77+
rb-body-legacy-praos-payload-validation-cpu-time-ms-constant: 50.0
78+
# the -per-byte component is meant to be using size as a (bad)
79+
# proxy for the complexity of the Txs included.
80+
rb-body-legacy-praos-payload-validation-cpu-time-ms-per-byte: 0.0005
81+
82+
################################################################################
83+
# Input Block Configuration
84+
################################################################################
85+
86+
ib-generation-probability: 2.0
87+
ib-shards: 1
88+
ib-shard-period-length-slots: 1
89+
ib-shard-group-count: 1
90+
91+
# ProducerId 32
92+
# SlotNo 64
93+
# VRF proof 80
94+
# Body hash 32
95+
# RB Ref 32
96+
# Signature 64
97+
# Total 304
98+
#
99+
# NOTE: using a KES Signature (like for Praos headers)
100+
# would instead more than double the total to 668.
101+
# And even 828 including Op Cert.
102+
ib-head-size-bytes: 304
103+
# 98KB to optimize for 3 TCP round trips
104+
ib-body-avg-size-bytes: 98304
105+
ib-body-max-size-bytes: 262144
106+
# Here we also use praos blocks as ballpark estimate.
107+
# Sec 2.3 Forging, of the benchmark cluster report, lists
108+
# * Slot start to announced: 0.12975s
109+
ib-generation-cpu-time-ms: 130.0
110+
ib-head-validation-cpu-time-ms: 1.0
111+
ib-body-validation-cpu-time-ms-constant: 50.0
112+
ib-body-validation-cpu-time-ms-per-byte: 0.0005
113+
ib-diffusion-strategy: "freshest-first"
114+
115+
# Haskell prototype relay mini-protocol parameters.
116+
ib-diffusion-max-bodies-to-request: 1
117+
ib-diffusion-max-headers-to-request: 100
118+
ib-diffusion-max-window-size: 100
119+
120+
################################################################################
121+
# Endorsement Block Configuration
122+
################################################################################
123+
124+
# We want one per pipeline, but not too many.
125+
eb-generation-probability: 1.0
126+
# ProducerId 32
127+
# SlotNo 64
128+
# VRF proof 80
129+
# Signature 64
130+
# Total 240
131+
#
132+
# See Note about signatures on ib-head-size-bytes.
133+
eb-size-bytes-constant: 240
134+
# IB hash
135+
eb-size-bytes-per-ib: 32
136+
# Collecting the IBs to reference and cryptography are the main tasks.
137+
# A comparable task is maybe mempool snapshotting.
138+
# Sec 2.3 Forging, of the benchmark cluster report, lists
139+
# * Mempool snapshotting: 0.07252s
140+
# 75ms then seems a generous estimate for eb generation.
141+
eb-generation-cpu-time-ms: 75.0
142+
# Validating signature and vrf proof, as in other headers.
143+
eb-validation-cpu-time-ms: 1.0
144+
145+
eb-diffusion-strategy: "peer-order"
146+
147+
# Haskell prototype relay mini-protocol parameters.
148+
eb-diffusion-max-bodies-to-request: 1
149+
eb-diffusion-max-headers-to-request: 100
150+
eb-diffusion-max-window-size: 100
151+
152+
# The maximum age of EBs included in RBs.
153+
# A an EB from slot `s` can only be included in RBs
154+
# up to slot `s+eb-max-age-slots`.
155+
# In short leios we expect votes to diffuse within 3 stages lengths of
156+
# EB generation, we allow for 2 more stage lengths to account for
157+
# variance in the interval within RBs.
158+
eb-max-age-slots: 240
159+
160+
# The maximum age of EBs to be relayed.
161+
# An EB from slot `s` will only be relayed
162+
# up to slot `s+eb-max-age-for-relay-slots`.
163+
eb-max-age-for-relay-slots: 40
164+
165+
# The maximum size of transactions (in bytes) which an EB can reference.
166+
# Only relevant when running with the "full-without-ibs" variant.
167+
eb-referenced-txs-max-size-bytes: 50000000
168+
169+
################################################################################
170+
# Vote Configuration
171+
################################################################################
172+
173+
# Cryptography related values taken from [vote-spec](crypto-benchmarks.rs/Specification.md)
174+
# using weighted averages of 80% persistent and 20% non-persistent.
175+
176+
# vote-spec#Committe and quorum size
177+
#
178+
# Note: this is used as the expected amount of total weight of
179+
# generated votes in the sims.
180+
vote-generation-probability: 500.0
181+
# vote-spec#"Committe and quorum size"
182+
# 60% of `vote-generation-probability`
183+
vote-threshold: 300
184+
# vote-spec#"Generate vote" 0.8*135e-3 + 0.2*280e-3
185+
vote-generation-cpu-time-ms-constant: 164.0e-3
186+
# No benchmark yet.
187+
vote-generation-cpu-time-ms-per-ib: 0
188+
# vote-spec#"Verify vote" 0.8*670e-3 + 0.2*1.4
189+
vote-validation-cpu-time-ms: 816.0e-3
190+
# The `Vote` structure counted in the -per-eb already identifies slot
191+
# (in Eid) and voter. We can assume a vote bundle is all for the same
192+
# voter and slot, so for non-persistent voters we could factor their
193+
# PoolKeyHash (28bytes) here, but that is for 20% of cases.
194+
# More relevant if EB generation is very high.
195+
vote-bundle-size-bytes-constant: 0
196+
# vote-spec#Votes 0.8*90 + 0.2*164
197+
vote-bundle-size-bytes-per-eb: 105
198+
199+
vote-diffusion-strategy: "peer-order"
200+
201+
# Haskell prototype relay mini-protocol parameters.
202+
vote-diffusion-max-bodies-to-request: 1
203+
vote-diffusion-max-headers-to-request: 100
204+
vote-diffusion-max-window-size: 100
205+
206+
################################################################################
207+
# Certificate Configuration
208+
################################################################################
209+
210+
# vote-spec - certificate size plot.
211+
# Realistic stake distributions need about 7 kilobytes for the certificate.
212+
cert-size-bytes-constant: 7168
213+
cert-size-bytes-per-node: 0
214+
215+
# For certificate timings we have bulk figures for realistic scenarios,
216+
# so we do not attempt to give -per-node (i.e. per-voter) timings.
217+
#
218+
# vote-spec#"Generate certificate"
219+
cert-generation-cpu-time-ms-constant: 90.0
220+
cert-generation-cpu-time-ms-per-node: 0
221+
# vote-spec#"Verify certificate"
222+
cert-validation-cpu-time-ms-constant: 130.0
223+
cert-validation-cpu-time-ms-per-node: 0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../8,10/run.sh

0 commit comments

Comments
 (0)