-
Notifications
You must be signed in to change notification settings - Fork 156
/
Copy pathledger.tex
195 lines (184 loc) · 4.77 KB
/
ledger.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
\section{Ledger State Transition}
\label{sec:ledger-trans}
The entire state transformation of the ledger state caused by a valid transaction
can now be given as the combination of the UTxO transition and the delegation transitions.
Figure~\ref{fig:ts-types:ledger} defines the types for this transition.
The environment for this rule consists of:
\begin{itemize}
\item The current slot.
\item The transaction index within the current block.
\item The protocol parameters.
\item The accounting state.
\end{itemize}
The ledger state consists of:
\begin{itemize}
\item The UTxO state.
\item The delegation and pool states.
\end{itemize}
\begin{figure}[htb]
\emph{Ledger environment}
\begin{equation*}
\LEnv =
\left(
\begin{array}{r@{~\in~}lr}
\var{slot} & \Slot & \text{current slot}\\
\var{txIx} & \Ix & \text{transaction index}\\
\var{pp} & \PParams & \text{protocol parameters}\\
\var{acnt} & \Acnt & \text{accounting state}
\end{array}
\right)
\end{equation*}
%
\emph{Ledger state}
\begin{equation*}
\LState =
\left(
\begin{array}{r@{~\in~}lr}
\var{utxoSt} & \UTxOState & \text{UTxO state}\\
\var{dpstate} & \DPState & \text{delegation and pool state}\\
\end{array}
\right)
\end{equation*}
%
\emph{Ledger transitions}
\begin{equation*}
\_ \vdash
\var{\_} \trans{ledger}{\_} \var{\_}
\subseteq \powerset (\LEnv \times \LState \times \Tx \times \LState)
\end{equation*}
\caption{Ledger transition-system types}
\label{fig:ts-types:ledger}
\end{figure}
Figure~\ref{fig:ts-types:ledger} defines the ledger state transition.
It has a single rule, which first calls the $\mathsf{UTXOW}$ transition,
then calls the $\mathsf{DELEGS}$ transition.
\begin{figure}
\begin{equation}
\label{eq:ledger}
\inference[ledger]
{
{
\begin{array}{c}
\var{slot} \\
\var{txIx} \\
\var{pp} \\
\var{tx}\\
\var{acnt}
\end{array}
}
\vdash
dpstate \trans{\hyperref[fig:rules:delegation-sequence]{delegs}}{
\fun{txcerts}~\var{(\txbody{tx})}} dpstate'
\\~\\
(\var{dstate}, \var{pstate}) \leteq \var{dpstate} \\
(\_, \_, \_, \_, \var{genDelegs}, \_) \leteq \var{dstate} \\
(\var{poolParams}, \_, \_) \leteq \var{pstate} \\
\\~\\
{
\begin{array}{c}
\var{slot} \\
\var{pp} \\
\var{poolParams} \\
\var{genDelegs} \\
\end{array}
}
\vdash \var{utxoSt} \trans{\hyperref[fig:rules:utxow-shelley]{utxow}}{tx} \var{utxoSt'}
}
{
\begin{array}{c}
\var{slot} \\
\var{txIx} \\
\var{pp} \\
\var{acnt}
\end{array}
\vdash
\left(
\begin{array}{ll}
\var{utxoSt} \\
\var{dpstate} \\
\end{array}
\right)
\trans{ledger}{tx}
\left(
\begin{array}{ll}
\varUpdate{utxoSt'} \\
\varUpdate{dpstate'} \\
\end{array}
\right)
}
\end{equation}
\caption{Ledger inference rule}
\label{fig:rules:ledger}
\end{figure}
\clearpage
The transition system $\mathsf{LEDGER}$ in Figure~\ref{fig:rules:ledger} is iterated
in $\mathsf{LEDGERS}$ in order to process a list of transactions.
\begin{figure}[htb]
\emph{Ledger Sequence transitions}
\begin{equation*}
\_ \vdash
\var{\_} \trans{ledgers}{\_} \var{\_}
\subseteq \powerset ((\Slot\times\PParams\times\Coin) \times \LState \times \seqof{\Tx} \times \LState)
\end{equation*}
\caption{Ledger Sequence transition-system types}
\label{fig:ts-types:ledgers}
\end{figure}
\begin{figure}[hbt]
\begin{equation}
\label{eq:ledgers-base}
\inference[Seq-ledger-base]
{ }
{
\begin{array}{r}
\var{slot}\\
\var{pp}\\
\var{acnt}
\end{array}
\vdash \var{ls} \trans{ledgers}{\epsilon} \var{ls}
}
\end{equation}
\nextdef
\begin{equation}
\label{eq:ledgers-induct}
\inference[Seq-ledger-ind]
{
{
\begin{array}{r}
\var{slot}\\
\var{pp}\\
\var{acnt}
\end{array}
}
\vdash
\var{ls}
\trans{ledgers}{\Gamma}
\var{ls'}
&
{
\begin{array}{r}
\var{slot}\\
\mathsf{len}~\Gamma\\
\var{pp}\\
\var{acnt}
\end{array}
}
\vdash
\var{ls'}
\trans{\hyperref[fig:rules:ledger]{ledger}}{\var{tx}}
\var{ls''}
}
{
\begin{array}{r}
\var{slot}\\
\var{pp}\\
\var{acnt}
\end{array}
\vdash
\var{ls}
\trans{ledgers}{\Gamma;~\var{tx}}
\varUpdate{\var{ls''}}
}
\end{equation}
\caption{Ledger sequence rules}
\label{fig:rules:ledger-sequence}
\end{figure}