Przeglądaj źródła

[research/lotterysim] edit cascade report

ertosns 3 lat temu
rodzic
commit
7b1bb391be

+ 3 - 2
script/research/lotterysim/acc_vs_staked_ratio.py

@@ -7,7 +7,7 @@ os.system("rm log/f_output.hist; rm log/f_feedback.hist")
 
 RUNNING_TIME = int(input("running time:"))
 ERC20DRK=2.1*10**9
-NODES=100
+NODES=1000
 plot = []
 EXPS=10
 for nodes in numpy.linspace(1,NODES, 10):
@@ -18,7 +18,8 @@ for nodes in numpy.linspace(1,NODES, 10):
         darkies += [ Darkie(random.gauss(egalitarian, egalitarian*0.1), strategy=random_strategy(EPOCH_LENGTH)) for id in range(int(nodes)) ]
         #darkies += [Darkie() for _ in range(NODES*2)]
         airdrop = ERC20DRK
-        dt = DarkfiTable(airdrop, RUNNING_TIME, CONTROLLER_TYPE_DISCRETE, kp=0.005999999999989028, ki=-0.005999999985257798, kd=0.01299999999999478,  r_kp=-2.53, r_ki=29.5, r_kd=53.77)
+        #dt = DarkfiTable(airdrop, RUNNING_TIME, CONTROLLER_TYPE_DISCRETE, kp=0.005999999999989028, ki=-0.005999999985257798, kd=0.01299999999999478,  r_kp=-2.53, r_ki=29.5, r_kd=53.77)
+        dt = DarkfiTable(airdrop, RUNNING_TIME, CONTROLLER_TYPE_DISCRETE, kp=-0.0104, ki=-0.0366, kd=0.0384,  r_kp=-2.53, r_ki=29.5, r_kd=53.77)
         for darkie in darkies:
             dt.add_darkie(darkie)
         acc, apy, reward, staked_ratio, apr = dt.background(rand_running_time=False)

+ 6 - 2
script/research/lotterysim/core/darkie.py

@@ -31,6 +31,8 @@ class Darkie():
 
     def apr_scaled_to_runningtime(self):
         initial_stake = self.vesting_wrapped_initial_stake()
+        if initial_stake==0:
+            initial_stake = self.initial_stake[0]
         #print('stake: {}, initial_stake: {}'.format(self.stake, initial_stake))
         assert self.stake >= initial_stake, 'stake: {}, initial_stake: {}, slot: {}, current: {}, previous: {} vesting'.format(self.stake, initial_stake, self.slot, self.current_vesting(), self.prev_vesting())
         return Num(self.stake - initial_stake) / Num(initial_stake) *  Num(ONE_YEAR/(self.slot/EPOCH_LENGTH)) if self.slot> 0 and self.initial_stake[0]>0 else 0
@@ -83,13 +85,15 @@ class Darkie():
         '''
         current corresponding slot vesting
         '''
-        return self.vesting[int(self.slot/VESTING_PERIOD)]
+        vesting_idx = int(self.slot/VESTING_PERIOD)
+        return self.vesting[vesting_idx] if vesting_idx < len(self.vesting) else 0
 
     def prev_vesting(self):
         '''
         previous corresponding slot vesting
         '''
-        return self.vesting[int((self.slot-1)/VESTING_PERIOD)] if self.slot>0 else self.current_vesting()
+        prev_vesting_idx = int((self.slot-1)/VESTING_PERIOD)
+        return (self.vesting[prev_vesting_idx] if self.slot>0 else self.current_vesting()) if prev_vesting_idx < len(self.vesting) else 0
 
     def vesting_differential(self):
         vesting_value =  self.current_vesting() - self.prev_vesting()

BIN
script/research/lotterysim/img/stake.png


BIN
script/research/lotterysim/reports/acc_stake_1000nodes_10kslots_with_cascade.png


BIN
script/research/lotterysim/reports/acc_stake_100nodes_10kslots_with_cascade.png


+ 1 - 1
script/research/lotterysim/reports/cascade.aux

@@ -11,7 +11,7 @@
 \@writefile{toc}{\contentsline {subsection}{\numberline {4.1}experiments}{4}{}\protected@file@percent }
 \@writefile{toc}{\contentsline {subsection}{\numberline {4.2}simulation parameters}{4}{}\protected@file@percent }
 \@writefile{lof}{\contentsline {figure}{\numberline {3}{\ignorespaces apr sorted from left to right in range [0-1.2]\% and 0.2\% on average with 100\% staked ratio}}{5}{}\protected@file@percent }
-\@writefile{lof}{\contentsline {figure}{\numberline {4}{\ignorespaces apr sorted from left to right in range [1-9]\% and 4.2\% avg apr.}}{6}{}\protected@file@percent }
+\@writefile{lof}{\contentsline {figure}{\numberline {4}{\ignorespaces apr sorted from left to right in range [1-50]\% and 13.8\% avg apr.}}{6}{}\protected@file@percent }
 \@writefile{lof}{\contentsline {figure}{\numberline {5}{\ignorespaces cascade PID diagram}}{7}{}\protected@file@percent }
 \@writefile{lof}{\contentsline {figure}{\numberline {6}{\ignorespaces with accuracy set point to primary controller}}{8}{}\protected@file@percent }
 \@writefile{lof}{\contentsline {figure}{\numberline {7}{\ignorespaces relation between staked DRK ratio and accuracy of secondary controller, with accuracy as set point to primary controller}}{9}{}\protected@file@percent }

+ 52 - 32
script/research/lotterysim/reports/cascade.log

@@ -1,4 +1,4 @@
-This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2022/dev/Debian) (preloaded format=pdflatex 2023.4.15)  17 APR 2023 21:47
+This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2022/dev/Debian) (preloaded format=pdflatex 2023.6.2)  22 JUN 2023 02:56
 entering extended mode
  restricted \write18 enabled.
  %&-line parsing enabled.
@@ -492,73 +492,93 @@ Overfull \hbox (117.52686pt too wide) in paragraph at lines 56--58
 
 LaTeX Warning: `!h' float specifier changed to `!ht'.
 
+! Missing $ inserted.
+<inserted text> 
+                $
+l.63 
+     
+? 
+! Missing } inserted.
+<inserted text> 
+                }
+l.63 
+     
+? 
+! Extra }, or forgotten \endgroup.
+\par ...m \@noitemerr {\@@par }\fi \else {\@@par }
+                                                  \fi 
+l.63 
+     
+? 
 [1
 
 {/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] [2 <./hodler_acc_vs_sr.png
 >] [3]
-<fullstake_apr.png, id=25, 462.528pt x 346.896pt>
+<fullstake_apr.png, id=26, 462.528pt x 346.896pt>
 File: fullstake_apr.png Graphic file (type png)
 <use fullstake_apr.png>
-Package pdftex.def Info: fullstake_apr.png  used on input line 121.
+Package pdftex.def Info: fullstake_apr.png  used on input line 120.
 (pdftex.def)             Requested size: 462.52686pt x 346.89514pt.
 
-Overfull \hbox (117.52686pt too wide) in paragraph at lines 121--122
+Overfull \hbox (117.52686pt too wide) in paragraph at lines 120--121
 [][] 
  []
 
-<halfstake_apr.png, id=26, 462.528pt x 346.896pt>
+<halfstake_apr.png, id=27, 462.528pt x 346.896pt>
 File: halfstake_apr.png Graphic file (type png)
 <use halfstake_apr.png>
-Package pdftex.def Info: halfstake_apr.png  used on input line 126.
+Package pdftex.def Info: halfstake_apr.png  used on input line 125.
 (pdftex.def)             Requested size: 462.52686pt x 346.89514pt.
 
-Overfull \hbox (117.52686pt too wide) in paragraph at lines 126--127
+Overfull \hbox (117.52686pt too wide) in paragraph at lines 125--126
 [][] 
  []
 
 [4] [5 <./fullstake_apr.png>] [6 <./halfstake_apr.png>] [7]
-<acc_setpoint_quarterstake.png, id=42, 462.528pt x 346.896pt>
+<acc_setpoint_quarterstake.png, id=43, 462.528pt x 346.896pt>
 File: acc_setpoint_quarterstake.png Graphic file (type png)
 <use acc_setpoint_quarterstake.png>
-Package pdftex.def Info: acc_setpoint_quarterstake.png  used on input line 182.
+Package pdftex.def Info: acc_setpoint_quarterstake.png  used on input line 181.
 
 (pdftex.def)             Requested size: 462.52686pt x 346.89514pt.
 
-Overfull \hbox (117.52686pt too wide) in paragraph at lines 182--183
+Overfull \hbox (117.52686pt too wide) in paragraph at lines 181--182
 [][] 
  []
 
-<acc_setpoint_vs_sr.png, id=43, 462.528pt x 346.896pt>
-File: acc_setpoint_vs_sr.png Graphic file (type png)
-<use acc_setpoint_vs_sr.png>
-Package pdftex.def Info: acc_setpoint_vs_sr.png  used on input line 190.
+<acc_stake_1000nodes_10kslots_with_cascade.png, id=44, 462.528pt x 346.896pt>
+File: acc_stake_1000nodes_10kslots_with_cascade.png Graphic file (type png)
+<use acc_stake_1000nodes_10kslots_with_cascade.png>
+Package pdftex.def Info: acc_stake_1000nodes_10kslots_with_cascade.png  used on
+ input line 189.
 (pdftex.def)             Requested size: 462.52686pt x 346.89514pt.
 
-Overfull \hbox (117.52686pt too wide) in paragraph at lines 190--191
+Overfull \hbox (117.52686pt too wide) in paragraph at lines 189--190
 [][] 
  []
 
-[8 <./acc_setpoint_quarterstake.png>] [9 <./acc_setpoint_vs_sr.png>] [10]
-(./cascade.aux) ) 
+[8 <./acc_setpoint_quarterstake.png>] [9 <./acc_stake_1000nodes_10kslots_with_c
+ascade.png>] [10] (./cascade.aux) ) 
 Here is how much of TeX's memory you used:
- 13365 strings out of 478287
- 274321 string characters out of 5849289
- 539050 words of memory out of 5000000
- 31323 multiletter control sequences out of 15000+600000
+ 13365 strings out of 480171
+ 274482 string characters out of 5894490
+ 534248 words of memory out of 5000000
+ 31079 multiletter control sequences out of 15000+600000
  474642 words of font info for 47 fonts, out of 8000000 for 9000
- 1141 hyphenation exceptions out of 8191
+ 59 hyphenation exceptions out of 8191
  100i,8n,104p,461b,754s stack positions out of 5000i,500n,10000p,200000b,80000s
-</usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/
-cmbx12.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10
-.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi7.pfb></
-usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/sha
-re/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr12.pfb></usr/share/texl
-ive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr17.pfb></usr/share/texlive/tex
-mf-dist/fonts/type1/public/amsfonts/cm/cmsy10.pfb>
-Output written on cascade.pdf (10 pages, 180008 bytes).
+</usr/share/texlive/texmf-dist/fonts/type1/p
+ublic/amsfonts/cm/cmbx12.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/
+amsfonts/cm/cmmi10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfon
+ts/cm/cmmi7.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/c
+mr10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr12.pf
+b></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr17.pfb></usr
+/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr7.pfb></usr/share/t
+exlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy10.pfb>
+Output written on cascade.pdf (10 pages, 188489 bytes).
 PDF statistics:
- 86 PDF objects out of 1000 (max. 8388607)
- 49 compressed objects within 1 object stream
+ 91 PDF objects out of 1000 (max. 8388607)
+ 52 compressed objects within 1 object stream
  0 named destinations out of 1000 (max. 500000)
  38 words of extra memory for PDF output out of 10000 (max. 10000000)
 

BIN
script/research/lotterysim/reports/cascade.pdf


+ 8 - 9
script/research/lotterysim/reports/cascade.tex

@@ -33,7 +33,7 @@ DRK tokens in stake, in fact the relation is logarithmic.
 
 \item In our case f is targetting single leader per slot. An emulation of
 the leader election mechanism with PID controllers shows that f is
-oscillating around ~0.65 (depending on ration of tokens in stake). then P(C=lead)~=0.35
+oscillating around ~0.65 (depending on ration of tokens in stake). then P(C=lead)~=0.65
 
 
 \item Given the linear independence property of the target function T, the
@@ -41,9 +41,9 @@ probability of a node winning leadership at any slot with S staked tokens
 is the same as the probability of N nodes winning leadership at same slot,
 with same stake S for any S, N values.
 
-\item If the probability of stakeholder owning 0.1\% of the tokens is 0.03,
-then the probability of a pool consisting of stakeholders owning 0.1%
-of tokens is also 0.03.
+\item If the probability of stakeholder owning 10\% of the tokens is 0.035,
+then the probability of a pool consisting of stakeholders owning 10%
+of tokens is also 0.035.
 
 \item The probability of a pool of N\% stake to win the leadership at any slot is: $$ \frac{N}{100}*P(C=lead)$$
 
@@ -59,8 +59,7 @@ of tokens is also 0.03.
 
 
 \item Assume $P(C=lead)=33\%$, then if only 10\% of the total network token
-is staked the probability of having a single leader per slot is 0.03,
-or accuracy of 3\%.
+is staked the probability of having a single leader per slot is $\frac{10}{100}P(C=lead)=0.035, or accuracy of 3\%.
 
 
 \item From the graph above, and as a consequence of the linear independence
@@ -124,7 +123,7 @@ in stake.
 \item while with 68\% staked ratio reward goes up to 82.5 on average with 13.8\% apr and same accuracy as previous experiment 35.7\%
   \begin{figure}
     \includegraphics{halfstake_apr.png}
-    \caption{apr sorted from left to right in range [1-9]\% and 4.2\% avg apr.}
+    \caption{apr sorted from left to right in range [1-50]\% and 13.8\% avg apr.}
   \end{figure}
 
   \subsection {oracle for staked ratio discovery}
@@ -176,7 +175,7 @@ in stake.
   \item stakeholders starategy is distributed equally between HODLER: stake it all,  logarithmic and sigmoid strategy that have logarithmic, and segmoid relation respectively to APR. similar to previous experiment except there is no linear strategy since APR is much lower.
 
 
-\item from figure 1, 25\% staked DRK ratio result in approximately 11\% secondary controller accuracy, while with cascade control it gains 3X leverage. 24.6\% staked ratio results in 31.1\% accuracy with average reward 1.6 DRK, and 0.2\% APR (see figure 6)
+\item from figure 1, 25\% staked DRK ratio result in approximately 11\% secondary controller accuracy, while with cascade control it gains 3X leverage at lower staked ratio. 10\% staked ratio results in 30\% accuracy with average reward 1.6 DRK, and 0.2\% APR (see figure 6)
 \end{description}
 \begin{figure}
     \includegraphics{acc_setpoint_quarterstake.png}
@@ -187,7 +186,7 @@ in stake.
 \item figure 7 shows the relation between staked DRK tokens ratio, and accuracy
 \end{description}
 \begin{figure}
-  \includegraphics{acc_setpoint_vs_sr.png}
+  \includegraphics{acc_stake_1000nodes_10kslots_with_cascade.png}
   \caption{relation between staked DRK ratio and accuracy of secondary controller, with accuracy as set point to primary controller}
 \end{figure}
 

+ 1 - 1
src/contract/test-harness/src/consensus_proposal.rs

@@ -65,7 +65,7 @@ impl TestHarness {
         let (params, proofs, output_keypair, signature_secret_key) = (
             proposal_call_debris.params,
             proposal_call_debris.proofs,
-            proposal_call_debris.keypair,
+            proposal_c5all_debris.keypair,
             proposal_call_debris.signature_secret,
         );