Skip to content

Commit 688ddbd

Browse files
authored
100 TPS for linear leios (#463)
* Experimental design * Analysis of results * Analyzed disposition of blocks * Updated logbook
1 parent 0b229d3 commit 688ddbd

Some content is hidden

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

81 files changed

+9659
-0
lines changed

Logbook.md

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

3+
## 2025-07-19
4+
5+
### 100 TPS experiment for Stracciatella and Linear Leios
6+
7+
Experiments using the Rust simulation demonstrated the viability of Stracciatella and Linear Leios at 100 TPS if appropriate stage lengths and maximum EB sizes are chosen.
8+
9+
- Variants
10+
- Linear Leios, linear
11+
- Linear Leios with tx references, linear-with-tx-references
12+
- Stracciatella, full-without-ibs
13+
- 100 tx/s for first 900 seconds
14+
- 1400 B/tx
15+
16+
Findings:
17+
18+
1. 5 slot/stage is too short for Linear Leios at 100 tx/s.
19+
2. Including transactions in EBs (instead of references) results in congestion and delays at 100 tx/s.
20+
3. 10 MB/EB is sufficient for 100 tx/s but 5 MB/EB is not.
21+
4. EB-sortition unluckiness in Stracciatella can lengthen the transaction lifecycle, but this could be remedied by increasing the EB production rate.
22+
5. CPU and network usage peak high when transactions are included in EBs.
23+
6. Caveat: this conclusion may change when better transaction validation times are used in the simulator configuration.
24+
25+
Artifacts:
26+
27+
- [Slides](analysis/sims/2025w29b/ReadMe.pdf)
28+
- [Jupyter notebook](analysis/sims/2025w29b/analysis)
29+
- [Configurations](analysis/sims/2025w29b/)
30+
331
## 2025-07-18
432

533
### Rust simulation

analysis/sims/2025w29b/ReadMe.pdf

3.07 MB
Binary file not shown.

analysis/sims/2025w29b/analysis.ipynb

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

0 commit comments

Comments
 (0)