Skip to content

Experiments for Linear Leois #457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions analysis/sims/2025w29/combine-plots.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p imagemagick poppler

set -e

for d in plots/stracciatella/*.png
do
FILE=$(basename $d)
if [[ -f "plots/notxs/$FILE" ]]
then
magick montage plots/{txrefs,stracciatella,linear,notxs}/$FILE -tile 2x2 -geometry +0+0 plots/$FILE
else
magick montage plots/{txrefs,stracciatella,linear}/$FILE -tile 2x2 -geometry +0+0 plots/$FILE
fi
done

magick plots/{sizes,spatial-efficiency,reach-eb-tx,reach-rb-tx,temporal-efficiency-bar,elapsed-EB,elapsed-RB,elapsed-TX,elapsed-VT,ingress-average-area,ingress-peak-point,cpu-peak-histogram,cpu-mean-histogram}.png content.pdf

pdfunite front-matter.pdf content.pdf plots.pdf
44 changes: 44 additions & 0 deletions analysis/sims/2025w29/combine-results.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p gnused gzip pigz "rWrapper.override { packages = with rPackages; [ data_table R_utils bit64 ggplot2 magrittr stringr ]; }"

set -e

for d in stracciatella txrefs linear notxs
do
mkdir -p results/$d
for f in lifecycle resources receipts cpus
do
DIR=$(find $d -type f -name $f.csv.gz \( -not -empty \) -printf %h\\n -quit)
HL=$(sed -n -e '1p' "$DIR/case.csv")
HR=$(zcat "$DIR/$f.csv.gz" | sed -n -e '1p')
if [[ "$f" == "lifecycle" || "$f" == "resources" ]]
then
FRACT=1
else
FRACT=1
fi
(
echo "$HL,$HR"
for g in $(find $d -type f -name $f.csv.gz \( -not -empty \) -printf %h\\n)
do
if [ ! -e "$g/stderr" ]
then
echo "Skipping $g because it has no stderr." >> /dev/stderr
elif [ -s "$g/stderr" ]
then
echo "Skipping $g because its stderr is not empty." >> /dev/stderr
else
BL=$(sed -n -e '2p' "$g/case.csv")
zcat "$g/$f.csv.gz" | gawk 'FNR > 1 && rand() <= '"$FRACT"' { print "'"$BL"'" "," $0}'
fi
done
) | pigz -p 3 -9c > results/$d/$f.csv.gz
####R --vanilla << EOI > /dev/null
####require(data.table)
####sampleSize <- $FRACT
####print(sampleSize)
####$f <- fread("results/$d/$f.csv.gz", stringsAsFactors=TRUE)
####save($f, sampleSize, file="results/$d/$f.Rdata", compression_level=9)
####EOI
done
done
2,789 changes: 2,789 additions & 0 deletions analysis/sims/2025w29/linear.ipynb

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions analysis/sims/2025w29/linear.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
linear/5,500000/run.sh
linear/5,1000000/run.sh
linear/5,2000000/run.sh
linear/5,5000000/run.sh
linear/8,500000/run.sh
linear/8,1000000/run.sh
linear/8,2000000/run.sh
linear/8,5000000/run.sh
2 changes: 2 additions & 0 deletions analysis/sims/2025w29/linear/5,1000000/case.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Simulator,Stage length,Max EB size
Rust,5 slot/stage,1.0 MB/EB
226 changes: 226 additions & 0 deletions analysis/sims/2025w29/linear/5,1000000/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
# yaml-language-server: $schema=./config.schema.json

################################################################################
# Simulation Configuration File
################################################################################
#
# This file contains the default configuration for running Leios simulations in
# the Haskell simulation (`simulation/`) and the Rust simulation (`sim-rs/`).
#
################################################################################
# Simulation Configuration
################################################################################

relay-strategy: "request-from-first"
tcp-congestion-control: true
multiplex-mini-protocols: true
simulate-transactions: true
treat-blocks-as-full: false
cleanup-policies: ["cleanup-expired-vote"]
timestamp-resolution-ms: 0.1

################################################################################
# Leios Protocol Configuration
################################################################################

leios-variant: linear
linear-vote-stage-length-slots: 5
linear-diffuse-stage-length-slots: 5
leios-stage-length-slots: 5
leios-stage-active-voting-slots: 1
leios-vote-send-recv-stages: false
leios-late-ib-inclusion: true
leios-header-diffusion-time-ms: 1000.0
leios-mempool-sampling-strategy: ordered-by-id
leios-mempool-aggressive-pruning: true
# TODO: revise default
praos-chain-quality: 100
praos-fallback-enabled: true

################################################################################
# Transaction Configuration
################################################################################

tx-generation-distribution:
distribution: exp
lambda: 0.85
scale: 68.9
tx-size-bytes-distribution:
distribution: log-normal
mu: 6.833
sigma: 1.127
tx-conflict-fraction: 0
tx-overcollateralization-factor-distribution:
distribution: constant
value: 0
tx-validation-cpu-time-ms: 0.065
tx-max-size-bytes: 16384
tx-start-time: 60
tx-stop-time: 660

################################################################################
# Ranking Block Configuration
################################################################################

# 1/leios-stage-length-slots, targeting one RB per pipeline.
# Also 20s is current rate of praos blocks.
rb-generation-probability: 5.0e-2
# Eng. team targets 1kB as worst case upper bound.
# Actual size fairly close.
rb-head-size-bytes: 1024
rb-body-max-size-bytes: 90112
# Note: certificate generation/validation is not included in the
# timings here, see cert-* fields.
rb-generation-cpu-time-ms: 1.0
rb-head-validation-cpu-time-ms: 1.0

# On average, no Txs directly embedded in blocks.
rb-body-legacy-praos-payload-avg-size-bytes: 0
rb-body-legacy-praos-payload-validation-cpu-time-ms-constant: 50.0
# the -per-byte component is meant to be using size as a (bad)
# proxy for the complexity of the Txs included.
rb-body-legacy-praos-payload-validation-cpu-time-ms-per-byte: 0.0005

################################################################################
# Input Block Configuration
################################################################################

ib-generation-probability: 2.0
ib-shards: 1
ib-shard-period-length-slots: 1
ib-shard-group-count: 1

# ProducerId 32
# SlotNo 64
# VRF proof 80
# Body hash 32
# RB Ref 32
# Signature 64
# Total 304
#
# NOTE: using a KES Signature (like for Praos headers)
# would instead more than double the total to 668.
# And even 828 including Op Cert.
ib-head-size-bytes: 304
# 98KB to optimize for 3 TCP round trips
ib-body-avg-size-bytes: 98304
ib-body-max-size-bytes: 262144
# Here we also use praos blocks as ballpark estimate.
# Sec 2.3 Forging, of the benchmark cluster report, lists
# * Slot start to announced: 0.12975s
ib-generation-cpu-time-ms: 130.0
ib-head-validation-cpu-time-ms: 1.0
ib-body-validation-cpu-time-ms-constant: 50.0
ib-body-validation-cpu-time-ms-per-byte: 0.0005
ib-diffusion-strategy: "freshest-first"

# Haskell prototype relay mini-protocol parameters.
ib-diffusion-max-bodies-to-request: 1
ib-diffusion-max-headers-to-request: 100
ib-diffusion-max-window-size: 100

################################################################################
# Endorsement Block Configuration
################################################################################

# We want one per pipeline, but not too many.
eb-generation-probability: 1.0
# ProducerId 32
# SlotNo 64
# VRF proof 80
# Signature 64
# Total 240
#
# See Note about signatures on ib-head-size-bytes.
eb-size-bytes-constant: 240
# IB hash
eb-size-bytes-per-ib: 32
# Collecting the IBs to reference and cryptography are the main tasks.
# A comparable task is maybe mempool snapshotting.
# Sec 2.3 Forging, of the benchmark cluster report, lists
# * Mempool snapshotting: 0.07252s
# 75ms then seems a generous estimate for eb generation.
eb-generation-cpu-time-ms: 75.0
# Validating signature and vrf proof, as in other headers.
eb-validation-cpu-time-ms: 1.0

eb-diffusion-strategy: "peer-order"

# Haskell prototype relay mini-protocol parameters.
eb-diffusion-max-bodies-to-request: 1
eb-diffusion-max-headers-to-request: 100
eb-diffusion-max-window-size: 100

# The maximum age of EBs included in RBs.
# A an EB from slot `s` can only be included in RBs
# up to slot `s+eb-max-age-slots`.
# In short leios we expect votes to diffuse within 3 stages lengths of
# EB generation, we allow for 2 more stage lengths to account for
# variance in the interval within RBs.
eb-max-age-slots: 240

# The maximum age of EBs to be relayed.
# An EB from slot `s` will only be relayed
# up to slot `s+eb-max-age-for-relay-slots`.
eb-max-age-for-relay-slots: 40

# The maximum size of transactions (in bytes) which an EB can reference.
# Only relevant when running with the "full-without-ibs" variant.
eb-referenced-txs-max-size-bytes: 1000000
eb-body-avg-size-bytes: 1000000

################################################################################
# Vote Configuration
################################################################################

# Cryptography related values taken from [vote-spec](crypto-benchmarks.rs/Specification.md)
# using weighted averages of 80% persistent and 20% non-persistent.

# vote-spec#Committe and quorum size
#
# Note: this is used as the expected amount of total weight of
# generated votes in the sims.
vote-generation-probability: 500.0
# vote-spec#"Committe and quorum size"
# 60% of `vote-generation-probability`
vote-threshold: 300
# vote-spec#"Generate vote" 0.8*135e-3 + 0.2*280e-3
vote-generation-cpu-time-ms-constant: 164.0e-3
# No benchmark yet.
vote-generation-cpu-time-ms-per-ib: 0
# vote-spec#"Verify vote" 0.8*670e-3 + 0.2*1.4
vote-validation-cpu-time-ms: 816.0e-3
# The `Vote` structure counted in the -per-eb already identifies slot
# (in Eid) and voter. We can assume a vote bundle is all for the same
# voter and slot, so for non-persistent voters we could factor their
# PoolKeyHash (28bytes) here, but that is for 20% of cases.
# More relevant if EB generation is very high.
vote-bundle-size-bytes-constant: 0
# vote-spec#Votes 0.8*90 + 0.2*164
vote-bundle-size-bytes-per-eb: 105

vote-diffusion-strategy: "peer-order"

# Haskell prototype relay mini-protocol parameters.
vote-diffusion-max-bodies-to-request: 1
vote-diffusion-max-headers-to-request: 100
vote-diffusion-max-window-size: 100

################################################################################
# Certificate Configuration
################################################################################

# vote-spec - certificate size plot.
# Realistic stake distributions need about 7 kilobytes for the certificate.
cert-size-bytes-constant: 7168
cert-size-bytes-per-node: 0

# For certificate timings we have bulk figures for realistic scenarios,
# so we do not attempt to give -per-node (i.e. per-voter) timings.
#
# vote-spec#"Generate certificate"
cert-generation-cpu-time-ms-constant: 90.0
cert-generation-cpu-time-ms-per-node: 0
# vote-spec#"Verify certificate"
cert-validation-cpu-time-ms-constant: 130.0
cert-validation-cpu-time-ms-per-node: 0
1 change: 1 addition & 0 deletions analysis/sims/2025w29/linear/5,1000000/run.sh
91 changes: 91 additions & 0 deletions analysis/sims/2025w29/linear/5,1000000/summary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
INFO praos: sim_cli::events: 7487 transactions(s) were generated in total.
INFO praos: sim_cli::events: 64 naive praos block(s) were published.
INFO praos: sim_cli::events: 1136 slot(s) had no naive praos blocks.
INFO praos: sim_cli::events: 7487 transaction(s) (12.78 MB) finalized in a naive praos block.
INFO praos: sim_cli::events: 0 transaction(s) (0 B) did not reach a naive praos block.
INFO praos: sim_cli::events: Pool 1 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 38 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 40 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 41 published 2 naive praos block(s)
INFO praos: sim_cli::events: Pool 44 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 48 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 50 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 52 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 53 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 56 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 62 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 77 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 108 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 122 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 123 published 2 naive praos block(s)
INFO praos: sim_cli::events: Pool 126 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 130 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 131 published 2 naive praos block(s)
INFO praos: sim_cli::events: Pool 134 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 136 published 2 naive praos block(s)
INFO praos: sim_cli::events: Pool 351 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 362 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 363 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 364 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 366 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 371 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 418 published 2 naive praos block(s)
INFO praos: sim_cli::events: Pool 423 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 430 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 439 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 444 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 474 published 3 naive praos block(s)
INFO praos: sim_cli::events: Pool 477 failed to publish 1 naive praos block(s) due to slot battles.
INFO praos: sim_cli::events: Pool 478 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 482 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 508 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 509 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 514 published 2 naive praos block(s)
INFO praos: sim_cli::events: Pool 516 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 525 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 527 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 530 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 532 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 537 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 538 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 539 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 551 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 554 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 561 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 565 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 567 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 568 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 742 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 745 published 1 naive praos block(s)
INFO praos: sim_cli::events: Pool 746 published 2 naive praos block(s)
INFO praos: sim_cli::events: Pool 749 published 1 naive praos block(s)
INFO leios: sim_cli::events: 0 IB(s) were generated, on average 0.000 IB(s) per slot.
INFO leios: sim_cli::events: 0 out of 7487 transaction(s) were included in at least one IB.
INFO leios: sim_cli::events: The average age of the pending transactions is NaNs (stddev NaN).
INFO leios: sim_cli::events: Each transaction was included in an average of NaN IB(s) (stddev NaN).
INFO leios: sim_cli::events: Each IB contained an average of NaN transaction(s) (stddev NaN) and an average of 0 B (stddev 0 B). 0 IB(s) were empty.
INFO leios: sim_cli::events: Each node received an average of 0.000 IB(s) (stddev 0.000).
INFO leios: sim_cli::events: 65 EB(s) were generated; on average there were 0.054 EB(s) per slot.
INFO leios: sim_cli::events: Each EB contained an average of 156.800 transaction(s) (stddev 186.501). 32 EB(s) were empty.
INFO leios: sim_cli::events: Each EB contained an average of 0.000 IB(s) (stddev 0.000). 32 EB(s) were empty.
INFO leios: sim_cli::events: Each IB was included in an average of NaN EB(s) (stddev NaN).
INFO leios: sim_cli::events: 0 out of 0 IBs were included in at least one EB.
INFO leios: sim_cli::events: 0 out of 0 IBs expired before they reached an EB.
INFO leios: sim_cli::events: 24 out of 65 EBs expired before an EB from their stage reached an RB.
INFO leios: sim_cli::events: 6567 out of 7487 transaction(s) were included in at least one EB.
INFO leios: sim_cli::events: 30703 total votes were generated.
INFO leios: sim_cli::events: Each stake pool produced an average of 142.144 vote(s) (stddev 27.850).
INFO leios: sim_cli::events: Each EB received an average of 472.354 vote(s) (stddev 102.564).
INFO leios: sim_cli::events: There were 11841 bundle(s) of votes. Each bundle contained 2.593 vote(s) (stddev 1.436).
INFO leios: sim_cli::events: 35 L1 block(s) had a Leios endorsement.
INFO leios: sim_cli::events: 5807 tx(s) (9.88 MB) were referenced by a Leios endorsement.
INFO leios: sim_cli::events: 1680 tx(s) (2.90 MB) were included directly in a Praos block.
INFO leios: sim_cli::events: Spatial efficiency: 9.88 MB/17.43 MB (56.674%) of Leios bytes were unique transactions.
INFO leios: sim_cli::events: 0 tx(s) (0.000%) referenced by a Leios endorsement were redundant.
INFO leios: sim_cli::events: Each transaction took an average of NaNs (stddev NaN) to be included in an IB.
INFO leios: sim_cli::events: Each transaction took an average of 18.908s (stddev 16.453) to be included in an EB.
INFO leios: sim_cli::events: Each transaction took an average of 46.402s (stddev 23.262) to be included in a block.
INFO network: sim_cli::events: 5607763 TX message(s) were sent. 5607763 of them were received (100.000%).
INFO network: sim_cli::events: 0 IB message(s) were sent. 0 of them were received (NaN%).
INFO network: sim_cli::events: 48165 EB message(s) were sent. 48165 of them were received (100.000%).
INFO network: sim_cli::events: 8868909 Vote message(s) were sent. 8868909 of them were received (100.000%).
Loading