Skip to content

Commit b2d1ad1

Browse files
committed
Updated instructions and example in readme file
1 parent 757ef49 commit b2d1ad1

File tree

3 files changed

+87
-63
lines changed

3 files changed

+87
-63
lines changed

analysis/markov/Linleios/Evolve.lean

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ def ebDistribution : Probabilities → HashMap Nat Probability :=
8080
8181

8282
def ebDistributionJson : Probabilities → Json :=
83-
Json.mkObj ∘ List.map (fun ⟨k, v⟩ => ⟨toString k, toJson v⟩) ∘ HashMap.toList ∘ ebDistribution
83+
Json.mkObj
84+
∘ List.map (fun ⟨k, v⟩ => ⟨toString k, toJson v⟩)
85+
∘ (fun z => z.mergeSort (by exact fun x y => x.fst ≤ y.fst))
86+
∘ HashMap.toList
87+
∘ ebDistribution
8488

8589
def rbEfficiency (states : Probabilities) : Float :=
8690
let clock := states.keys.head!.clock

analysis/markov/Main.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def markov : Cmd := `[Cli|
5050
"quorum-fraction" : Float ; "τ protocol parameter, in %/100."
5151
"p-rb-header-arrives" : Float ; "Probability that the RB header arrives before L_header."
5252
"p-eb-validates" : Float ; "Probability that the EB is fully validated before 3 L_header + L_vote."
53-
"adversary-fraction" : Float ; "Fraction of stake that is adversarial."
53+
"adversary-fraction" : Float ; "Fraction of stake that is adversarial: the adversary never produces RBs or EBs and never votes."
5454
"tolerance" : Float ; "Discard states with less than this probability."
5555
"rb-count" : Nat ; "Number of potential RBs to simulate."
5656
"output-file" : String ; "Path to the JSON output file for the EB distribution."

analysis/markov/ReadMe.md

Lines changed: 81 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -7,68 +7,86 @@ This Markovian model of Linear Leios computes the probability of EB certificatio
77

88
The `linleios` program executes the Markov model for EB production in Linear Leios. The protocol parameters and network characteristic are specified as flags on the command line. The program outputs the following information:
99

10-
- The efficiency of EB production, defined as the expected number of certified EBs per RB, on `/dev/stdout`.
10+
- The efficiencies, on `/dev/stdout`.
11+
- RB efficiency: the fraction of possible RBs that were actually produced.
12+
- EB efficiency: the fraction of possible EBs that were actually produced.
13+
- Efficiency: the fraction o possible payload bytes that were actual produced.
1114
- The "missing probability" resulting from the finite-resolution arithmetic of the computations, on `/dev/stderr`.
1215
- Optionally, a JSON file containing the probabilities of the given number of certified EBs.
1316

17+
```bash
18+
lake exe linleios \
19+
--l-header 1 \
20+
--l-vote 4 \
21+
--l-diff 5 \
22+
--committee-size 600 \
23+
--quorum-fraction 0.80 \
24+
--p-rb-header-arrives 0.95 \
25+
--p-eb-validates 0.85 \
26+
--rb-count 100 \
27+
--adversary-fraction 0.1 \
28+
--output-file tmp.json
29+
```
30+
1431
```console
15-
$ lake exe linleios --l-header 1 --l-vote 4 --l-diff 5 --committee-size 600 --quorum-fraction 0.80 --p-rb-header-arrives 0.95 --p-eb-validates 0.85 --rb-count 100 --output-file tmp.json
16-
17-
Efficiency: 0.358416
18-
Missing probability: 0.000001
19-
20-
$ json2yaml tmp.json
21-
22-
'61': 0
23-
'60': 0
24-
'59': 1e-06
25-
'58': 2e-06
26-
'57': 5e-06
27-
'56': 1.2e-05
28-
'55': 2.8e-05
29-
'54': 6.2e-05
30-
'53': 0.00013
31-
'52': 0.000263
32-
'51': 0.00051
33-
'50': 0.00095
34-
'49': 0.0017
35-
'48': 0.002924
36-
'47': 0.004832
37-
'46': 0.00767
38-
'45': 0.011695
39-
'44': 0.017128
40-
'43': 0.024091
41-
'42': 0.032532
42-
'41': 0.042169
43-
'40': 0.052455
44-
'39': 0.062599
45-
'38': 0.071642
46-
'37': 0.0786
47-
'36': 0.082632
48-
'35': 0.083203
49-
'34': 0.080197
50-
'33': 0.073954
51-
'32': 0.065202
52-
'31': 0.054925
53-
'30': 0.044172
54-
'29': 0.033887
55-
'28': 0.024777
56-
'27': 0.017248
57-
'26': 0.011419
58-
'25': 0.007182
59-
'24': 0.004285
60-
'23': 0.002422
61-
'22': 0.001295
62-
'21': 0.000654
63-
'20': 0.000311
64-
'19': 0.000139
65-
'18': 5.8e-05
66-
'17': 2.3e-05
67-
'16': 8e-06
68-
'15': 3e-06
69-
'14': 1e-06
70-
'13': 0
71-
'12': 0
32+
RB efficiency: 0.899977
33+
EB efficiency: 0.290308
34+
Overall efficiency: 0.331256
35+
Missing probability: 0.000028
36+
```
37+
38+
```bash
39+
jq 'to_entries | sort_by(.key | tonumber) | from_entries' tmp.json
40+
```
41+
42+
```json
43+
{
44+
"8": 0,
45+
"9": 0.000001,
46+
"10": 0.000003,
47+
"11": 0.000012,
48+
"12": 0.000036,
49+
"13": 0.0001,
50+
"14": 0.000251,
51+
"15": 0.000582,
52+
"16": 0.001251,
53+
"17": 0.0025,
54+
"18": 0.004659,
55+
"19": 0.008126,
56+
"20": 0.013297,
57+
"21": 0.020463,
58+
"22": 0.02968,
59+
"23": 0.040648,
60+
"24": 0.052656,
61+
"25": 0.064622,
62+
"26": 0.07524,
63+
"27": 0.083218,
64+
"28": 0.087538,
65+
"29": 0.087673,
66+
"30": 0.083686,
67+
"31": 0.076199,
68+
"32": 0.066239,
69+
"33": 0.055015,
70+
"34": 0.043687,
71+
"35": 0.03319,
72+
"36": 0.024137,
73+
"37": 0.016812,
74+
"38": 0.011221,
75+
"39": 0.00718,
76+
"40": 0.004405,
77+
"41": 0.002593,
78+
"42": 0.001464,
79+
"43": 0.000794,
80+
"44": 0.000413,
81+
"45": 0.000206,
82+
"46": 0.000098,
83+
"47": 0.000045,
84+
"48": 0.000019,
85+
"49": 0.000008,
86+
"50": 0.000003,
87+
"51": 0.000001,
88+
"52": 0
89+
}
7290
```
7391

7492

@@ -83,7 +101,6 @@ Run a Markov simulation of Linear Leios.
83101
USAGE:
84102
markov [FLAGS]
85103

86-
FLAGS:
87104
-h, --help Prints this message.
88105
--version Prints the version.
89106
--active-slot-coefficient : Float The active slot coefficient for RBs, in
@@ -104,10 +121,13 @@ FLAGS:
104121
--p-eb-validates : Float Probability that the EB is fully
105122
validated before 3 L_header + L_vote.
106123
[Default: `0.90`]
124+
--adversary-fraction : Float Fraction of stake that is adversarial:
125+
the adversary never produces RBs or EBs
126+
and never votes. [Default: `0`]
107127
--tolerance : Float Discard states with less than this
108128
probability. [Default: `1e-8`]
109-
--rb-count : Nat Number of RBs to simulate. [Default:
110-
`100`]
129+
--rb-count : Nat Number of potential RBs to simulate.
130+
[Default: `100`]
111131
--output-file : String Path to the JSON output file for the EB
112132
distribution.
113133
```

0 commit comments

Comments
 (0)