-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate-mechanism.tex
1425 lines (1362 loc) · 45.5 KB
/
update-mechanism.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\newcommand{\UProp}{\ensuremath{\type{UProp}}}
\newcommand{\UPropId}{\ensuremath{\type{UpId}}}
\newcommand{\UPropSD}{\ensuremath{\type{UpSD}}}
\newcommand{\ProtVer}{\ensuremath{\type{ProtVer}}}
\newcommand{\ProtPm}{\ensuremath{\type{Ppm}}}
\newcommand{\Rpus}{\ensuremath{\type{Rpus}}}
\newcommand{\UPVEnv}{\ensuremath{\type{UPVEnv}}}
\newcommand{\UPVState}{\ensuremath{\type{UPVState}}}
\newcommand{\UPLEnv}{\ensuremath{\type{UPLEnv}}}
\newcommand{\UPLState}{\ensuremath{\type{UPLState}}}
\newcommand{\UPREnv}{\ensuremath{\type{UPREnv}}}
\newcommand{\UPRState}{\ensuremath{\type{UPRState}}}
\newcommand{\Vote}{\ensuremath{\type{Vote}}}
\newcommand{\VREnv}{\ensuremath{\type{VREnv}}}
\newcommand{\VRState}{\ensuremath{\type{VRState}}}
\newcommand{\VEnv}{\ensuremath{\type{VEnv}}}
\newcommand{\VState}{\ensuremath{\type{VState}}}
\newcommand{\BVREnv}{\ensuremath{\type{BVREnv}}}
\newcommand{\BVRState}{\ensuremath{\type{BVRState}}}
\newcommand{\ApName}{\ensuremath{\type{ApName}}}
\newcommand{\SWVer}{\ensuremath{\type{SWVer}}}
\newcommand{\ApVer}{\ensuremath{\type{ApVer}}}
\newcommand{\Metadata}{\ensuremath{\type{Mdt}}}
\newcommand{\STag}{\ensuremath{\type{STag}}}
\newcommand{\upSize}[1]{\ensuremath{\fun{upSize}~\var{#1}}}
\newcommand{\upPV}[1]{\ensuremath{\fun{upPV}~\var{#1}}}
\newcommand{\upId}[1]{\ensuremath{\fun{upId}~\var{#1}}}
\newcommand{\upSig}[1]{\ensuremath{\fun{upSig}~\var{#1}}}
\newcommand{\upSigData}[1]{\ensuremath{\fun{upSigData}~\var{#1}}}
\newcommand{\upIssuer}[1]{\ensuremath{\fun{upIssuer}~\var{#1}}}
\newcommand{\upParams}[1]{\ensuremath{\fun{upParams}~\var{#1}}}
\newcommand{\upSwVer}[1]{\ensuremath{\fun{upSwVer}~\var{#1}}}
\newcommand{\upMetadata}[1]{\ensuremath{\fun{upMdt}~\var{#1}}}
\newcommand{\vCaster}[1]{\ensuremath{\fun{vCaster}~\var{#1}}}
\newcommand{\vPropId}[1]{\ensuremath{\fun{vPropId}~\var{#1}}}
\newcommand{\vSig}[1]{\ensuremath{\fun{vSig}~\var{#1}}}
\lstset{ frame=tb,
, language=Haskell
, basicstyle=\footnotesize\ttfamily,
, keywordstyle=\color{blue!80},
, commentstyle=\itshape\color{purple!40!black},
, identifierstyle=\bfseries\color{green!40!black},
, stringstyle=\color{orange},
}
\lstMakeShortInline[columns=fixed]`
\section{Update mechanism}
\label{sec:update}
This section formalizes the update mechanism by which the protocol parameters
get updated. This formalization is a simplification of the current update
mechanism implemented in
\href{https://github.com/The-Blockchain-Company/bcc-sl/}{\texttt{bcc-sl}}, and
partially documented in:
\begin{itemize}
\item \href{https://bccdocs.com/technical/updater/}{Updater implementation}
\item \href{https://bccdocs.com/bcc/update-mechanism/}{Update mechanism}
\item
\href{https://github.com/The-Blockchain-Company/bcc-sl/blob/2a19d8ce2941b8e60f0208a5198943ec2ada1fd4/docs/block-processing/us.md}{Update system consensus rules}
\end{itemize}
The reason for formalizing a simplified version of the current implementation
is that research work on blockchain update mechanisms is needed before
introducing a more complex update logic. Since this specification is to be
implemented in a federated setting, some of the constraints put in place in the
current implementation are no longer relevant. Once the research work is ready,
this specification can be extended to incorporate the research results.
\subsection{Update proposals}
\label{sec:update-proposals}
The definitions used in the update mechanism rules are presented in
\cref{fig:defs:update-proposals}. A system tag is used to identify the system
for which the update is proposed (in practice this would be a string referring
to an operating system; e.g. `linux`, `win64`, or `mac32`). The software update
metadata ($\Metadata$) is any information required for performing an update
such as hashes of software downloads. Note that the fact that the metadata is
kept abstract in the specification does not mean that we allow any arbitrary
metadata (in the actual implementation this abstract metadata would correspond
to `Map SystemTag UpdateData`, were the `SystemTag` corresponds with $\STag$
and `UpdateData` contains the software hash for a specific platform).
\begin{figure}[htb]
\emph{Abstract types}
%
\begin{equation*}
\begin{array}{r@{~\in~}lr}
\var{up} & \UProp & \text{update proposal}\\
\var{p} & \ProtPm & \text{protocol parameter}\\
\var{upd} & \type{UpdData} & \text{update data}\\
\var{upa} & \type{UpdAttrs} & \text{update attributes}\\
\var{an} & \ApName & \text{application name}\\
\var{t} & \STag & \text{system tag}\\
\var{m} & \Metadata & \text{metadata}
\end{array}
\end{equation*}
%
\emph{Derived types}
\begin{equation*}
\begin{array}{r@{~\in~}l@{~=~}r@{~\in~}lr}
\var{s_n} & \Slot & n & \mathbb{N} & \text{slot number}\\
\var{pv} & \ProtVer & (\var{maj}, \var{min}, \var{alt})
& (\mathbb{N}, \mathbb{N}, \mathbb{N}) & \text{protocol version}\\
\var{pps} & \PPMMap & \var{pps} & \ProtPm \mapsto \Value
& \text{protocol parameters map}\\
\var{apv} & \ApVer & n & \mathbb{N}\\
\var{swv} & \SWVer
& (\var{an}, \var{av}) & \ApName \times \ApVer
& \text{software version}\\
\var{pb} & \UPropSD
&
{\left(\begin{array}{r l}
\var{pv}\\
\var{pps}\\
\var{swv}\\
\var{upd}\\
\var{upa}\\
\end{array}\right)}
& {
\left(
\begin{array}{l}
\ProtVer\\
\PPMMap\\
\type{SWVer}\\
\type{UpdData}\\
\type{UpdAttrs}\\
\end{array}
\right)
}
& \text{protocol update signed data}
\end{array}
\end{equation*}
\emph{Abstract functions}
%
\begin{equation*}
\begin{array}{r@{~\in~}lr}
\fun{upIssuer} & \UProp \to \VKey & \text{update proposal issuer (delegate)}\\
\fun{upSize} & \UProp \to \mathbb{N} & \text{update proposal size}\\
\fun{upPV} & \UProp \to \ProtVer & \text{update proposal protocol version}\\
\fun{upId} & \UProp \to \UPropId & \text{update proposal id}\\
\fun{upParams} & \UProp \to \mathbb{\PPMMap}
& \text{proposed parameters update}\\
\fun{upSwVer} & \UProp \to \SWVer & \text{software-version update proposal}\\
\fun{upSig} & \UProp \to \Sig & \text{update proposal signature}\\
\fun{upSigData} & \UProp \to \UPropSD & \text{update proposal signed data}\\
\fun{upSTags} & \UProp \to \powerset{\STag} & \text{update proposal system tags}\\
\fun{upMdt} & \UProp \to \Metadata & \text{software update metadata}
\end{array}
\end{equation*}
\caption{Update proposals definitions}
\label{fig:defs:update-proposals}
\end{figure}
The set of protocol parameters ($\ProtPm$) is assumed to contain the following
keys, some of which correspond with fields of the
\href{https://github.com/The-Blockchain-Company/bcc-sl/}{\texttt{bcc-sl}}
`BlockVersionData` structure:
\begin{itemize}
\item Maximum block size: $\var{maxBlockSize}$
\item Maximum transaction size: $\var{maxTxSize}$
\item Maximum header size: $\var{maxHeaderSize}$
\item Maximum proposal size: $\var{maxProposalSize}$
\item Transaction fee policy: $\var{txFeePolicy}$
\item Script version: $\var{scriptVersion}$
\item Update adoption threshold: $\var{upAdptThd}$. This represents the minimum
percentage of the total number of genesis keys that have to endorse a protocol
version to be able to become adopted. We use this parameter to determine the
confirmation threshold as well. There is no corresponding parameter in the
`bcc-sl` protocol parameters, however we do have a soft-fork minimum
threshold parameter (`srMinThd` in `bvdSoftforkRule`). When divided by,
$1\times 10^{15}$, it determines the minimum portion of the total stake that
is needed for the adoption of a new protocol version. On mainnet, this number
is set to $6 \times 10^{14}$, so the minimum portion becomes $0.6$. This
number can be multiplied by the total number of genesis keys to obtain how
many keys are needed to reach a majority.
\item Update proposal time-to-live: $\var{upropTTL}$. This would correspond to
the number of slots specified by `bvdUpdateImplicit`. In `bcc-sl` the
rule was that after `bvdUpdateImplicit` slots, if a proposal did not reach a
majority of the votes, then if the proposal has more votes for than against
it, then it will become implicitly accepted, or rejected otherwise. In this
specification, we re-interpret the meaning of this parameter as the proposal
time-to-live: if after the number of slots specified by `bvdUpdateImplicit`
the proposal does not reach a majority of approvals, the proposal is simply
discarded. In the mainnet configuration (`mainnet-genesis.json`) this value is
set to $10000$, which corresponds with almost half of the total number of
slots in an epoch.
\end{itemize}
The protocol parameters are formally defined in \cref{fig:prot-params-defs}.
\begin{figure}[ht]
\begin{equation*}
\begin{array}{r@{~\in~}lr}
\var{maxBlockSize} \mapsto \mathbb{N} & \PPMMap & \text{maximum block size}\\
\var{maxTxSize} \mapsto \mathbb{N} & \PPMMap & \text{maximum transaction size}\\
\var{maxHeaderSize} \mapsto \mathbb{N} & \PPMMap & \text{maximum header size}\\
\var{scriptVersion} \mapsto \mathbb{N} & \PPMMap & \text{script version}\\
\var{upAdptThd} \mapsto \mathbb{Q} & \PPMMap & \text{update proposal adoption threshold}\\
\var{upropTTL} \mapsto \mathbb{\Slot} & \PPMMap & \text{update proposal time-to-live}\\
\end{array}
\end{equation*}
\caption{Protocol-parameters definitions}
\label{fig:prot-params-defs}
\end{figure}
\subsection{Update proposals registration}
\label{sec:update-proposals-registration}
\begin{figure}[htb]
\emph{Update proposals validity environments}
\begin{equation*}
\UPVEnv =
\left(
\begin{array}{r@{~\in~}lr}
\var{pv} & \ProtVer & \text{adopted (current) protocol version}\\
\var{pps} & \PPMMap & \text{adopted protocol parameters map}\\
\var{avs} & \ApName \mapsto (\ApVer \times \Slot \times \Metadata)
& \text{application versions}\\
\end{array}
\right)
\end{equation*}
%
\emph{Update proposals validity states}
\begin{align*}
& \UPVState \\
& = \left(
\begin{array}{r@{~\in~}lr}
\var{rpus} & \UPropId \mapsto (\ProtVer \times \PPMMap)
& \text{registered protocol update proposals}\\
\var{raus} & \UPropId \mapsto (\ApName \times \ApVer \times \Metadata)
& \text{registered software update proposals}\\
\end{array}
\right)
\end{align*}
%
\emph{Update proposals validity transitions}
\begin{equation*}
\var{\_} \vdash
\var{\_} \trans{upv}{\_} \var{\_}
\subseteq \powerset (\UPVEnv \times \UPVState \times \UProp \times \UPVState)
\end{equation*}
\caption{Update proposals validity transition-system types}
\label{fig:ts-types:up-validity}
\end{figure}
The rules in Figure~\ref{fig:rules:up-validity} model the validity of a proposal:
\begin{itemize}
\item if an update proposal proposes a change in the protocol version, it must
do so in a consistent manner:
\begin{itemize}
\item The proposed version must be lexicographically bigger than the
current version.
\item The major versions of the proposed and current version must differ in
at most one.
\item If the proposed major version is equal to the current major
version, then the proposed minor version must be incremented by one.
\item If the proposed major version is larger than the current major version,
then the proposed minor version must be zero.
\item must be consistent with the current protocol parameters:
\begin{itemize}
\item the proposal size must not exceed the maximum size specified by the
current protocol parameters, (note that here we use function application
to extract the value of the different protocol parameters, and a rule
that uses a value of the map can be applied only if the function -e.g.
$\var{pps}$- is defined for that value)
\item the proposed new maximum block size should be not greater than twice
current maximum block size,
\item the maximum transaction size must be smaller than the maximum block
size (this requirement is \textbf{crucial} for having every transaction
fitting in a block, and
\item the proposed new script version can be incremented by at most 1.
\end{itemize}
\item must have a unique version among the current active proposals.
\end{itemize}
\item if an update proposal proposes to increase the application version
version ($\var{av}$) for a given application ($\var{an}$), then there should
not be an active update proposal that proposes the same update.
\end{itemize}
Note that the rules in Figure~\ref{fig:rules:up-validity} allow for an update
that does not propose changes in the protocol version, or does not propose
changes to the software version. However the update proposal must contain a change
proposal in any of these two aspects.
%
Also note that we do not allow for updating the protocol parameters without
updating the protocol version. If an update in the protocol parameters does not
cause a soft-fork we might use the alt version for that purpose.
In Rule~\ref{eq:rule:up-av-validity} we make use of the following abstract
functions:
\begin{itemize}
\item $\fun{apNameValid}$, which checks that the name is an ASCII string 12
characters or less.
\item $\fun{sTagValid}$, which checks that the name is an ASCII string of 10
characters or less.
\end{itemize}
\begin{figure}[htb]
\emph{Abstract functions}
\begin{equation*}
\begin{array}{r@{~\in~}lr}
\fun{apNameValid} & \ApName \rightarrow \mathbb{B} & \text{validity checking for application name}\\
\fun{sTagValid} & \STag \rightarrow \mathbb{B} & \text{validity checking for system tag}
\end{array}
\end{equation*}
\caption{Update proposal validity definitions}
\label{fig:defs:update-proposal-validity}
\end{figure}
\begin{figure}[htb]
\begin{equation}
\label{eq:func:pv-can-follow}
\begin{array}{r c l}
\fun{pvCanFollow}~(\var{mj_p}, \var{mi_p}, \var{a_p})~(\var{mj_n}, \var{mi_n}, \var{a_n})
& = & (\var{mj_p}, \var{mi_p}, \var{a_p}) < (\var{mj_n}, \var{mi_n}, \var{a_n})\\
& \wedge & 0 \leq \var{mj_n} - \var{mj_p} \leq 1\\
& \wedge & (\var{mj_p} = \var{mj_n} \Rightarrow \var{mi_p} + 1 = \var{mi_n}))\\
& \wedge & (\var{mj_p} + 1 = \var{mj_n} \Rightarrow \var{mi_n} = 0)
\end{array}
\end{equation}
\nextdef
\begin{equation}
\label{eq:func:can-update}
\begin{array}{l}
\fun{canUpdate}~\var{pps}~\var{pps'}\\
{\begin{array}{r c l}
& = & \var{pps'}~\var{maxBlockSize} \leq 2\cdot\var{pps}~\var{maxBlockSize}\\
& \wedge & \var{pps'}~\var{maxTxSize} < \var{pps'}~\var{maxBlockSize} \\
& \wedge
& 0 \leq
\var{pps'}~\var{scriptVersion} - \var{pps}~\var{scriptVersion}
\leq 1
\end{array}}
\end{array}
\end{equation}
\nextdef
\begin{equation}
\label{eq:func:av-can-follow}
\begin{array}{r c l}
\fun{svCanFollow}~\var{avs}~(\var{an}, \var{av}) & =
& (\var{an} \mapsto (\var{av_c}, \wcard, \wcard) \in \var{avs}
\Rightarrow \var{av} = \var{av_c} + 1)\\
& \wedge & (\var{an} \notin \dom~\var{avs} \Rightarrow \var{av} = 0 \vee \var{av} = 1)
\end{array}
\end{equation}
\caption{Update validity functions}
\end{figure}
\begin{figure}[htb]
\begin{equation}
\label{eq:rule:up-av-validity}
\inference
{
(\var{an}, \var{av}) \leteq \upSwVer{up}
& \fun{apNameValid}~\var{an}\\
& \fun{svCanFollow}~\var{avs}~(\var{an}, \var{av})
& (\var{an}, \wcard, \wcard) \notin \range~\var{raus}\\
\forall \var{t} \in \fun{upSTags}~\var{up} \cdot \fun{sTagValid}~t
}
{
{\left(
\begin{array}{l}
\var{avs}
\end{array}
\right)}
\vdash
{
\left(
\begin{array}{l}
\var{raus}
\end{array}
\right)
}
\trans{upsvv}{up}
{
\left(
\begin{array}{l}
\var{raus} \unionoverrideRight \{ \upId{up} \mapsto (\var{an}, \var{av}, \upMetadata{up})\}
\end{array}
\right)
}
}
\end{equation}
\nextdef
\begin{equation}
\label{eq:rule:up-pv-validity}
\inference
{
\var{pps'} \leteq \var{pps} \unionoverrideRight \upParams{up}
& \fun{canUpdate}~\var{pps}~\var{pps'}\\
& \var{nv} \leteq \upPV{up}
& \fun{pvCanFollow}~\var{nv}~\var{pv}\\
& \upSize{up} \leq \var{pps}~\var{maxProposalSize}
& \var{nv} \notin \dom~(\range~\var{rpus})
}
{
{\left(
\begin{array}{l}
\var{pv}\\
\var{pps}
\end{array}
\right)}
\vdash
{
\left(
\begin{array}{l}
\var{rpus}
\end{array}
\right)
}
\trans{uppvv}{\var{up}}
{
\left(
\begin{array}{l}
\var{rpus} \unionoverrideRight
\{ \upId{up} \mapsto (\var{nv}, \var{pps'}) \}
\end{array}
\right)
}
}
\end{equation}
\nextdef
\begin{equation}
\label{eq:rule:up-validity-pu-nosu}
\inference
{
{\left(
\begin{array}{l}
\var{pv}\\
\var{pps}
\end{array}
\right)}
\vdash
{
\left(
\begin{array}{l}
\var{rpus}
\end{array}
\right)
}
\trans{uppvv}{\var{up}}
{
\left(
\begin{array}{l}
\var{rpus'}
\end{array}
\right)
}
&
(\var{an}, \var{av}) \leteq \upSwVer{up} & \var{an} \mapsto (\var{av}, \_, \_) \in \var{avs}
}
{
{\left(
\begin{array}{l}
\var{pv}\\
\var{pps}\\
\var{avs}
\end{array}
\right)}
\vdash
{
\left(
\begin{array}{l}
\var{rpus}\\
\var{raus}
\end{array}
\right)
}
\trans{upv}{\var{up}}
{
\left(
\begin{array}{l}
\var{rpus'}\\
\var{raus}
\end{array}
\right)
}
}
\end{equation}
\nextdef
\begin{equation}
\label{eq:rule:up-validity-nopu-no}
\inference
{
\var{pv} = \upPV{up} & \upParams{up} = \emptyset &
{\left(
\begin{array}{l}
\var{avs}
\end{array}
\right)}
\vdash
{
\left(
\begin{array}{l}
\var{raus}
\end{array}
\right)
}
\trans{upsvv}{up}
{
\left(
\begin{array}{l}
\var{raus'}
\end{array}
\right)
}
}
{
{\left(
\begin{array}{l}
\var{pv}\\
\var{pps}\\
\var{avs}
\end{array}
\right)}
\vdash
{
\left(
\begin{array}{l}
\var{rpus}\\
\var{raus}
\end{array}
\right)
}
\trans{upv}{\var{up}}
{
\left(
\begin{array}{l}
\var{rpus}\\
\var{raus'}
\end{array}
\right)
}
}
\end{equation}
\nextdef
\begin{equation}
\label{eq:rule:up-validity-pu-su}
\inference
{
{\left(
\begin{array}{l}
\var{pv}\\
\var{pps}
\end{array}
\right)}
\vdash
{
\left(
\begin{array}{l}
\var{rpus}
\end{array}
\right)
}
\trans{uppvv}{\var{up}}
{
\left(
\begin{array}{l}
\var{rpus'}
\end{array}
\right)
}
&
{
\begin{array}{l}
\var{avs}
\end{array}
}
\vdash
{
\left(
\begin{array}{l}
\var{raus}
\end{array}
\right)
}
\trans{upsvv}{up}
{
\left(
\begin{array}{l}
\var{raus'}
\end{array}
\right)
}
}
{
{\left(
\begin{array}{l}
\var{pv}\\
\var{pps}\\
\var{avs}
\end{array}
\right)}
\vdash
{
\left(
\begin{array}{l}
\var{rpus}\\
\var{raus}
\end{array}
\right)
}
\trans{upv}{\var{up}}
{
\left(
\begin{array}{l}
\var{rpus'}\\
\var{raus'}
\end{array}
\right)
}
}
\end{equation}
\caption{Update proposals validity rules}
\label{fig:rules:up-validity}
\end{figure}
\clearpage
The rule of Figure~\ref{fig:rules:up-registration} models the registration of
an update proposal:
\begin{itemize}
\item We consider the update proposal issuers to be the delegators of the key
($\var{vk}$) that is associated with the proposal under consideration
($\var{up}$).
\item We check that the issuer of a proposal was delegated by a genesis key
(which are in the domain of $\var{dms}$).
\item the update proposal data (see the definition of $\fun{upSigdata}$) must
be signed by the proposal issuer.
\end{itemize}
\begin{figure}[htb]
\emph{Update proposals registration environments}
\begin{equation*}
\UPREnv =
\left(
\begin{array}{r@{~\in~}lr}
\var{pv} & \ProtVer & \text{adopted (current) protocol version}\\
\var{pps} & \PPMMap & \text{adopted protocol parameters map}\\
\var{avs} & \ApName \mapsto (\ApVer \times \Slot \times \Metadata)
& \text{application versions}\\
\var{dms} & \VKeyGen \mapsto \VKey & \text{delegation map}\\
\end{array}
\right)
\end{equation*}
%
\emph{Update proposals registration states}
\begin{align*}
& \UPRState = \\
& \left(
\begin{array}{r@{~\in~}lr}
\var{rpus} & \UPropId \mapsto (\ProtVer \times \PPMMap)
& \text{registered update proposals}\\
\var{raus} & \UPropId \mapsto (\ApName \times \ApVer \times \Metadata)
& \text{registered software update proposals}
\end{array}
\right)
\end{align*}
%
\emph{Update proposals registration transitions}
\begin{equation*}
\var{\_} \vdash
\var{\_} \trans{upreg}{\_} \var{\_}
\subseteq \powerset (\UPREnv \times \UPRState \times \UProp \times \UPRState)
\end{equation*}
\caption{Update proposals registration transition-system types}
\label{fig:ts-types:up-registration}
\end{figure}
\begin{figure}[htb]
\begin{equation}
\label{eq:rule:up-registration}
\inference
{
{\left(
\begin{array}{l}
\var{pv}\\
\var{pps}\\
\var{avs}
\end{array}
\right)}
\vdash
{
\left(
\begin{array}{l}
\var{rpus}\\
\var{raus}\\
\end{array}
\right)
}
\trans{\hyperref[fig:rules:up-validity]{upv}}{\var{up}}
{
\left(
\begin{array}{l}
\var{rpus'}\\
\var{raus'}\\
\end{array}
\right)
}
&
\var{dms} \restrictrange \{\var{vk}\} \neq \emptyset\\
\var{vk} \leteq \upIssuer{up} &
\mathcal{V}_{\var{vk}}\serialised{\upSigData{up}}_{(\upSig{up})}
}
{
{\left(
\begin{array}{l}
\var{pv}\\
\var{pps}\\
\var{avs}\\
\var{dms}
\end{array}
\right)}
\vdash
{
\left(
\begin{array}{l}
\var{rpus}\\
\var{raus}
\end{array}
\right)
}
\trans{upreg}{\var{up}}
{
\left(
\begin{array}{l}
\var{rpus'}\\
\var{raus'}
\end{array}
\right)
}
}
\end{equation}
\caption{Update registration rules}
\label{fig:rules:up-registration}
\end{figure}
\clearpage
\subsection{Voting on update proposals}
\label{sec:voting-on-update-proposals}
\begin{figure}[htb]
\emph{Abstract types}
%
\begin{equation*}
\begin{array}{r@{~\in~}lr}
\var{v} & \Vote & \text{vote on an update proposal}
\end{array}
\end{equation*}
%
\emph{Abstract functions}
\begin{align*}
& \fun{vCaster} \in \Vote \to \VKey & \text{caster of a vote}\\
& \fun{vPropId} \in \Vote \to \UPropId & \text{proposal id that is being voted}\\
& \fun{vSig} \in \Vote \to \Sig & \text{vote signature}
\end{align*}
\caption{Voting definitions}
\label{fig:defs:voting}
\end{figure}
\begin{figure}[htb]
\emph{Voting environments}
\begin{align*}
& \VREnv
= \left(
\begin{array}{r@{~\in~}lr}
\var{rups} & \powerset{\UPropId}
& \text{registered update proposals}\\
\var{dms} & \VKeyGen \mapsto \VKey & \text{delegation map}
\end{array}\right)
\end{align*}
%
\emph{Voting states}
\begin{align*}
& \VRState
= \left(
\begin{array}{r@{~\in~}lr}
\var{vts} & \powerset{(\UPropId \times \VKeyGen)} & \text{votes}
\end{array}\right)
\end{align*}
%
\emph{Voting transitions}
\begin{equation*}
\_ \vdash \_ \trans{addvote}{\_} \_ \in
\powerset (\VREnv \times \VRState \times \Vote \times \VRState)
\end{equation*}
\caption{Voting transition-system types}
\label{fig:ts-types:voting}
\end{figure}
In Rule~\ref{eq:rule:voting}:
\begin{itemize}
\item Only genesis keys can vote on an update proposal, although votes can be
cast by delegates of these genesis keys.
\item We count one vote per genesis key that delegated to the key that is
casting the vote.
\item The vote must refer to a registered update proposal.
\item The proposal id must be signed by the key that is casting the vote.
\item A given genesis key is only allowed to vote for a proposal once. This
provision guards against replay attacks, where a third party may replay the
vote in multiple blocks.
\end{itemize}
\begin{figure}[htb]
\begin{equation}
\label{eq:rule:voting}
\inference
{
\var{pid} \leteq \vPropId{v} & \var{vk} \leteq \vCaster{v} & \var{pid} \in \var{rups}\\
\var{vts}_{\var{pid}} \leteq
\{ (\var{pid}, \var{vk_s}) \mid \var{vk_s} \mapsto \var{vk} \in \var{dms} \} &
\var{vts}_{\var{pid}} \neq \emptyset &
\var{vts}_{\var{pid}} \nsubseteq \var{vts} \\
\mathcal{V}_{\var{vk}}\serialised{\var{pid}}_{(\vSig{v})}\\
}
{
{\left(
\begin{array}{l}
\var{rups}\\
\var{dms}
\end{array}
\right)}
\vdash
{
\left(
\begin{array}{l}
\var{vts}
\end{array}
\right)
}
\trans{addvote}{\var{v}}
{
\left(
\begin{array}{l}
\var{vts} \cup \var{vts}_{\var{pid}}\\
\end{array}
\right)
}
}
\end{equation}
\caption{Update voting rules}
\label{fig:rules:voting}
\end{figure}
\clearpage
\begin{figure}[htb]
\emph{Vote registration environments}
\begin{align*}
& \VEnv
= \left(
\begin{array}{r@{~\in~}lr}
\var{s_n} & \Slot & \text{current slot number}\\
\var{t} & \mathbb{N} & \text{confirmation threshold}\\
\var{rups} & \powerset{\UPropId}
& \text{registered update proposals}\\
\var{dms} & \VKeyGen \mapsto \VKey & \text{delegation map}
\end{array}\right)
\end{align*}
%
\emph{Vote registration states}
\begin{align*}
& \VState
= \left(
\begin{array}{r@{~\in~}lr}
\var{cps} & \UPropId \mapsto \Slot & \text{confirmed proposals}\\
\var{vts} & \powerset{(\UPropId \times \VKeyGen)} & \text{votes}
\end{array}\right)
\end{align*}
%
\emph{Vote registration transitions}
\begin{equation*}
\_ \vdash \_ \trans{UPVOTE}{\_} \_ \in
\powerset (\VEnv \times \VState \times \Vote \times \VState)
\end{equation*}
\caption{Vote registration transition-system types}
\label{fig:ts-types:vote-reg}
\end{figure}
The rules in Figure~\ref{fig:rules:up-vote-reg} model the registration of a vote:
\begin{itemize}
\item The vote gets added to the list set of votes per-proposal ($\var{vts}$),
via transition $\trans{addvote}{}$.
\item If the number of votes for the proposal $v$ refers to exceeds the
confirmation threshold and this proposal was not confirmed already, then the
proposal gets added to the set of confirmed proposals ($\var{cps}$). The
reason why we check that the proposal was not already confirmed, is that we
want to keep in $\var{cps}$ the earliest block number in which the proposal
was confirmed.
\end{itemize}
\begin{figure}[htb]
\begin{equation}
\label{eq:rule:up-no-confirmation}
\inference
{
{\left(
\begin{array}{l}
\var{rups}\\
\var{dms}
\end{array}
\right)}
\vdash
{
\left(
\begin{array}{l}
\var{vts}
\end{array}
\right)
}
\trans{\hyperref[fig:rules:voting]{addvote}}{\var{v}}
{
\left(
\begin{array}{l}
\var{vts'}
\end{array}
\right)
}\\
\var{pid} \leteq \vPropId{v}
& (\size{\{\var{pid}\} \restrictdom \var{vts'}} < t
\vee \var{pid} \in \dom~\var{cps}
)
}
{
{\left(
\begin{array}{l}
s_n\\
\var{t}\\
\var{rups}\\
\var{dms}
\end{array}
\right)}
\vdash
{
\left(
\begin{array}{l}
\var{cps}\\
\var{vts}
\end{array}
\right)
}
\trans{upvote}{\var{v}}
{
\left(
\begin{array}{l}
\var{cps}\\
\var{vts'}
\end{array}
\right)
}
}
\end{equation}
\nextdef
\begin{equation}
\label{eq:rule:up-vote-reg}
\inference
{
{\left(
\begin{array}{l}
\var{rups}\\
\var{dms}
\end{array}
\right)}
\vdash
{
\left(
\begin{array}{l}
\var{vts}
\end{array}
\right)
}
\trans{\hyperref[fig:rules:voting]{addvote}}{\var{v}}
{
\left(
\begin{array}{l}
\var{vts'}
\end{array}
\right)
}\\
\var{pid} \leteq \vPropId{v}
& t \leq \size{\{\var{pid}\} \restrictdom \var{vts'}}
& \var{pid} \notin \dom~\var{cps}
}
{
{\left(
\begin{array}{l}
\var{s_n}\\
\var{t}\\
\var{rups}\\
\var{dms}
\end{array}
\right)}
\vdash
{
\left(
\begin{array}{l}
\var{cps}\\