Skip to content

Commit e271b13

Browse files
bwbushBrian W Bush
andauthored
Time step influence upon accuracy of the Rust simulation (#447)
* Designed experiment for high TPS of small transactions * Completed first 1000 tps run * Completed timestep analysis * Updated logbook --------- Co-authored-by: Brian W Bush <[email protected]>
1 parent 688ddbd commit e271b13

File tree

15 files changed

+1057
-870
lines changed

15 files changed

+1057
-870
lines changed

Logbook.md

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

33
## 2025-07-19
44

5+
### Study of timestep effects in simulators
6+
7+
We compared the 1000 TPS Full Leios simulation results (Rust) at two time resolutions, 0.100 ms and 0.025 ms. No significant differences in results were found. This means that we can safely run simulations at the coarser time step; such enable greater parallelism in the simulator and shorter wallclock times. See [the Jupyter notebook](analysis/sims/2025w27/analysis.ipynb) for comparisons, evidence, and details.
8+
9+
## 2025-07-18
10+
511
### 100 TPS experiment for Stracciatella and Linear Leios
612

713
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.
@@ -28,8 +34,6 @@ Artifacts:
2834
- [Jupyter notebook](analysis/sims/2025w29b/analysis)
2935
- [Configurations](analysis/sims/2025w29b/)
3036

31-
## 2025-07-18
32-
3337
### Rust simulation
3438

3539
Revised Linear Leios model in response to analysis: in particular we discovered that sufficient throughput depends on only partially validating EBs before propagating them to peers.

analysis/sims/2025w27/analysis.ipynb

Lines changed: 631 additions & 829 deletions
Large diffs are not rendered by default.

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

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

analysis/sims/2025w27/quick/run.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
cd "$(dirname "${BASH_SOURCE[0]}")"
6+
7+
BW=50
8+
9+
ulimit -S -m 64000000 -v 64000000
10+
11+
mkfifo sim.log
12+
13+
sed -e 's/"bandwidth-bytes-per-second":125000000/"bandwidth-bytes-per-second":'"$((125000 * BW))"'/g' \
14+
../../../../data/simulation/pseudo-mainnet/topology-v2.yaml \
15+
> network.yaml
16+
17+
function cleanup() {
18+
rm sim.log
19+
rm network.yaml
20+
}
21+
trap cleanup EXIT
22+
23+
grep -E -v '(Slot|No.*Generated|CpuTask|Lottery)' sim.log | pigz -p 3 -9c > sim.log.gz &
24+
25+
../sim-cli --parameters config.yaml network.yaml --slots 900 --conformance-events sim.log > stdout 2> stderr
26+
27+
wait
28+
29+
cat << EOI > case.csv
30+
Simulator,Variant,Sharding
31+
Rust,full-without-ibs,unsharded
32+
EOI
33+
34+
zcat sim.log.gz \
35+
| ../leios-trace-processor \
36+
+RTS -N5 -RTS \
37+
--trace-file /dev/stdin \
38+
--lifecycle-file lifecycle.csv \
39+
--cpu-file cpus.csv \
40+
--resource-file resources.csv \
41+
--receipt-file receipts.csv
42+
43+
pigz -p 3 -9f {lifecycle,cpus,resources,receipts}.csv
44+
45+
cat case.csv
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Simulator,timestamp-resolution-ms
2+
Rust,dt = 0.025 ms

analysis/sims/2025w27/tsr/0.010/config.yaml renamed to analysis/sims/2025w27/tsr/0.025/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ multiplex-mini-protocols: true
1717
simulate-transactions: true
1818
treat-blocks-as-full: false
1919
cleanup-policies: ["cleanup-expired-vote"]
20-
timestamp-resolution-ms: 0.010
20+
timestamp-resolution-ms: 0.025
2121

2222
################################################################################
2323
# Leios Protocol Configuration

analysis/sims/2025w27/tsr/0.010/run.sh renamed to analysis/sims/2025w27/tsr/0.025/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cd "$(dirname "${BASH_SOURCE[0]}")"
77
LABEL="$(basename "$PWD")"
88
BW=50
99

10-
ulimit -S -m 64000000 -v 64000000
10+
ulimit -S -m 144000000 -v 144000000
1111

1212
mkfifo sim.log
1313

0 commit comments

Comments
 (0)