-
Notifications
You must be signed in to change notification settings - Fork 156
/
Copy pathproperties.tex
618 lines (513 loc) · 28.4 KB
/
properties.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
\section{Formal Properties}
\label{sec:properties}
This appendix collects the main formal properties that the new ledger rules are expected to satisfy.
Note here that in every property in this section we consider a only phase-1 valid
transactions, ie. ones that can indeed get processed.
\begin{enumerate}[label=P{\arabic*}:\ ]
\item
\emph{Consistency with Shelley.}
\begin{itemize}
\item properties 15.6 - 15.16 (except 15.8 and 15.13) hold specifically in the $\fun{txValTag}~tx~=~\True$ case, because
the calculations refer to the UTxO as if it was updated by a scripts-validating transaction
\item other properties hold as-is
\end{itemize}
\item
\emph{Consistency with Multi-Asset.}
\begin{itemize}
\item properties 8.1 and 8.2 hold specifically in the $\fun{txValTag}~tx~=~\True$ case, because
the calculations refer to the UTxO as if it was updated by a scripts-validating transaction
\item other properties hold as-is
\end{itemize}
\end{enumerate}
\begin{definition}
For a state $s$ that is used in any subtransaction of
$\mathsf{CHAIN}$, we define $\Utxo(s) \in \UTxO$ to be the $\UTxO$
contained in $s$, or an empty map if it does not exist. This is
similar to the definition of $\Val$ in the Shelley specification.
Similarly, we also define $\field_{v}~(s)$ for the field $v$ that is part of
the ledger state $s$, referenced by the typical variable name (eg. $\var{fees}$
for the fee pot on the ledger).
\end{definition}
We also define a helper function $\varphi$ as follows:
\[\varphi(x, tx) :=
\begin{cases}
x & \fun{txValTag}~tx = \True \\
0 & \fun{txValTag}~tx = \False
\end{cases}\]
This function is useful to distinguish between the two
cases where a transaction can mint tokens or not, depending on whether
its scripts validate.
\begin{property}[General Accounting]
\label{prop:pov}
The \emph{general accounting} property in Alonzo encompasses two parts
\begin{itemize}
\item preservation of value property expressed via the $\fun{produced}$ and $\fun{consumed}$
calculations, applicable for transactions with $\fun{txValTag}~tx~=~\True$, which
is specified as in the ShelleyMA POV.
\item the preservation of value for $\fun{txValTag}~tx~=~\False$, when
only the collateral fees are collected into the fee pot.
\end{itemize}
Both of these are expressed in the following lemma.
\begin{lemma}
For all environments $e$, transactions $tx$ and states $s, s'$, if
\begin{equation*}
e\vdash s\trans{utxos}{tx}s'
\end{equation*}
then
\begin{equation*}
\Val(s) + \varphi(\fun{mint}~(\fun{txbody}~tx), tx) = \Val(s')
\end{equation*}
\end{lemma}
\begin{proof}
In the case that $\fun{txValTag}~tx = \True$ holds, the proof is
identical to the proof of Lemma 9.1 of the multi-asset
specification. Otherwise, the transition must have been done via the
$\mathsf{Scripts-No}$ rule, which removes
$\fun{collateral}~(\fun{txbody}~tx)$ from the UTxO, and increases the fee pot by the amount of the sum of Ada in the
collateral UTxO entries. The value contained in $s$ is not changed.
Note that in the $\fun{feesOK}$ function, there is a check that verifies
that, in the case that there are phase-2 scripts, there are no non-Ada tokens in the UTxOs
which the collateral inputs reference, so non-Ada tokens do not get minted, burned, or transferred
in this case.
\end{proof}
\end{property}
\begin{property}[Extended UTxO Validation]
\label{prop:fees-only}
If a phase-1 valid transaction extends the UTxO, all its scripts validate
(i.e. $\fun{txValTag}~tx = \True$).
If a transaction is accepted and marked as paying collateral only
(i.e. $\fun{txValTag}~tx = \False$), then the only change to the ledger
when processing the transaction is that the collateral inputs
are moved to the fee pot. In particular, it does not extend the UTxO.
\begin{lemma}
For all environments $e$, transactions $tx$ and states $s, s'$, if and
\begin{equation*}
e\vdash s\trans{ledger}{tx}s'
\end{equation*}
then
\[\Utxo(s') \nsubseteq \Utxo(s)~\Rightarrow~\fun{txValTag}~tx = \True \]
Also,
\[\fun{txvaltag}~tx = \False~ \Rightarrow~\]
\begin{itemize}
\item $ \field_{v}~(s') = \field_{v}~(s) \text{ for all } v~\neq~{fees}, ~v~\neq~{utxo}$
\item $\field_{fees}~(s') = \field~\var{fees}~(s) + \fun{coin}~(\Val~(\fun{collateral}~{tx} \subtractdom \Utxo(s)))$
\item $\Utxo(s') = \fun{collateral}~{tx} \subtractdom \Utxo(s)$
\end{itemize}
\end{lemma}
\begin{proof}
A ledger UTxO update is specified explicitly only by the $\mathsf{UTXOS}$ transition,
and propagated (ie. applied as-specified) to a chain-state update via the
$\mathsf{UTXO}$ and $\mathsf{UTXOW}$ transitions.
The only case in which the $\mathsf{UTXOS}$ transition adds entries to the UTxO
map is in the $\mathsf{Scripts-No}$ rule, when $\fun{txValTag}~tx = \True$.
Adding entries to the UTxO map implies exactly that the updated map is not a
submap of the original, so we get that
\[\Utxo(s') \nsubseteq \Utxo(s)~\Rightarrow~\fun{txValTag}~tx = \True \]
In the case that $\fun{txValTag}~tx = \False$, $\mathsf{LEDGER}$ calls the rule
that does not update $\DPState$ at all, only the $\UTxOState$. This state update is specified
in the $\mathsf{UTXOS}$ transition (and applied via the $\mathsf{UTXO}$ and $\mathsf{UTXOW}$ transitions).
The only parts of the state that are updated are
\begin{itemize}
\item the fee pot, which is increased by the amount of the sum of Ada in the
collateral UTxO entries, and
\item the UTxO, where the collateral entries
are removed.
\end{itemize}
\end{proof}
\end {property}
\begin{property}[Validating when No NN Scripts]
\label{prop:is-valid}
Whenever a valid transaction does not have any phase-2 scripts, its
$\fun{txValTag} = \True$.
\begin{lemma}
For all environments $e$, transactions $tx$ and states $s, s'$ such that
\begin{equation*}
e\vdash s\trans{ledger}{tx}s',
\end{equation*}
If $\range (\fun{txscripts}~tx) \cap \ScriptPhTwo = \emptyset$
then $\fun{txValTag} = \True$.
\end{lemma}
\begin{proof}
With the same argument as previously, we only need to discuss the
equivalent claim for the $\mathsf{UTXOS}$ transition. Under these
assumptions, $\var{sLst}$ is an empty
list. Thus $\fun{evalScripts}~sLst = \True$, and the transition rule
had to be $\mathsf{Scripts{-}Yes}$.
\end{proof}
\end{property}
\begin{property}[Paying fees]
\label{prop:pay-fees}
In the case that all phase-2 scripts in a transaction validate, the transaction pays
at least the minimum transaction fee amount into the fee pot. In the case that
some do not validate, it must pay at least the percentage of the minimum fee
the collateral is required to cover.
\begin{lemma}
For all environments $e$, transactions $tx$ and states $s, s'$ such that
\begin{equation*}
e\vdash s\trans{ledger}{tx}s'
\end{equation*}
The following holds : \\
$\field_{fees}~(s')~\geq~\field_{fees}~(s)~+
\begin{cases}
\fun{minfee}~{tx} & \fun{txValTag} = \True \\
\fun{quot}~(\fun{collateralPercent}~(\field_{pp}~(s)))~*~(\fun{minfee}~{tx})~100 & \fun{txValTag} = \False\\
\end{cases}$.
\end{lemma}
\begin{proof}
The fee pot is updated by the $\mathsf{Scripts{-}Yes}$ and the $\mathsf{Scripts{-}No}$
rules, one of which is necessarily called by a valid transaction via the sequence
of transitions called in the order $\mathsf{LEDGER}, \mathsf{UTXOW}, \mathsf{UTXO}, \mathsf{UTXOS}$.
The $\mathsf{Scripts{-}Yes}$ rule (i.e. $\fun{txValTag} = \True$)
transfers the amount of Lovelace in the $\fun{txfee}$ field of the
transaction to the fee pot, which is checked to be at least the $\fun{minfee}$
by $\fun{feesOK}$ in the $\mathsf{UTXO}$ transition. So, we get
\[\field_{fees}~(s')~=~\field_{fees}~(s)~+~\fun{txfee}~{tx}~\geq~\field_{fees}~(s)~+~\fun{minfee}~{tx}\]
The $\mathsf{Scripts{-}No}$ rule (i.e. $\fun{txValTag} = \False$) removes the
$\fun{collateral}$ inputs from the
UTxO, and adds the balance of these realized inputs to the fee pot.
\[\field_{fees}~(s')~=~field_{fees}~(s)~+~\fun{ubalance}~(\fun{collateral}~{txb} \restrictdom \var{utxo})\]
We can conclude that $\fun{txrdmrs}$ is non-empty whenever $\fun{txValTag} = \False$
from the following observations :
\begin{itemize}
\item $\fun{txValTag} = \False$ whenever $\fun{evalScripts}$ fails.
\item $\fun{evalScripts}$ is a $\wedge$-fold over a list of scripts and
their inputs, containing all scripts that need to be run to validate this transaction
\item All phase-1 scripts must succeed, as this is checked in phase-1 validation (UTXOW
rule check). Therefore,
$\fun{evalScripts}$ encounters a failing script which is phase-2.
\item All phase-2 scripts necessarily have an associated redeemer attached to the
transaction (UTXOW rule check)
\end{itemize}
See Property~\ref{prop:fixed-inputs} for more details on what inputs $\fun{evalScripts}$ has,
and what we can say about the outcome of its computation with respect to its inputs.
The $\fun{feesOK}$ check enforces that if a transaction has a non-empty
$\fun{txrdmrs}$ field, the balance of the realized collateral inputs
(which $\field_{fees}~(s)$ is increased by as part of processing $tx$) is
\[\fun{ubalance}~(\fun{collateral}~{txb} \restrictdom \var{utxo})~\geq~\fun{quot}~(\txfee~{txb} * (\fun{collateralPercent}~pp))~100\]
which, since $\txfee~{txb}~\geq~\fun{minfee}~{txb}$, gives
\[ \geq~\fun{quot}~(\fun{minfee}~{txb} * (\fun{collateralPercent}~pp))~100)) \]
where $\fun{txbody}~{tx}~=~{txb}$. This shows that the total collateral that gets
moved into the fee pot from the UTxO by the $\mathsf{Scripts{-}No}$ rule is at
least the minimum transaction fee scaled by the collateral percent parameter.
\[\field_{fees}~(s')~\geq~\field_{fees}~(s)~+~\fun{quot}~(\fun{minfee}~{txb} * (\fun{collateralPercent}~pp))~100))\]
\end{proof}
An immediate corollary to this property is that when the $\fun{collateralPercent}$ is set to 100 or more,
the transaction always pays at least the minimum fee. This, in turn, implies that it
pays at least the fee that it has stated in the $\fun{txfee}$ field.
\begin{corollary}
For all environments $e$, transactions $tx$ and states $s, s'$ such that
\begin{equation*}
e\vdash s\trans{ledger}{tx}s'~~\wedge~~\fun{collateralPercent}~(\field_{pp}~(s)) \geq 100
\end{equation*}
The following holds :
\[\field_{fees}~(s')~\geq~\field_{fees}~(s)~+~\fun{minfee}~{tx} \]
\end{corollary}
\begin{proof}
In both two cases in the lemma above, the $\field_{fees}$ field in the ledger state
is increased by at least $\fun{minfee}~{tx}$ :
\begin{itemize}
\item when $\fun{txValTag} = \True$, the lemma states already that
\[\field_{fees}~(s')~\geq~\field_{fees}~(s)~+~\fun{minfee}~{tx}\]
\item when $\fun{txValTag} = \False$, we have
$ \field_{fees}~(s')~\geq~\field_{fees}~(s)~+~\fun{quot}~(\fun{minfee}~{txb} * (\fun{collateralPercent}~pp))~100$ \\
$~~~\geq~\field_{fees}~(s)~+~\fun{quot}~(\fun{minfee}~{tx}~*~100)~100$ \\
$~~~=~\field_{fees}~(s)~+~\fun{minfee}~{tx}$
\end{itemize}
\end{proof}
\end{property}
\begin{property}[Correct tag]
\label{prop:correct-tag}
The $\fun{txValTag}~tx$ tag of a phase-1 valid transaction must match the result of the $\fun{evalScripts}$
function for that transaction.
\begin{lemma}
For all environments $e$, transactions $tx$ and states $s, s'$ such that
\begin{equation*}
e\vdash s\trans{utxos}{tx}s',
\end{equation*}
The following holds :
\[\fun{txValTag}~tx ~=~ \fun{evalScripts}~{tx}~{sLst} \]
where
\[ \var{sLst} \leteq \fun{collectTwoPhaseScriptInputs}~\mathsf{EI}~\mathsf{SysSt} ~\field_{pp}(s)~\var{tx}~ \Utxo(s) \]
\end{lemma}
\begin{proof}
Inspecting the $\mathsf{Scripts{-}Yes}$ and the $\mathsf{Scripts{-}No}$ rules of the $\mathsf{UTXOS}$ transition,
we see that both the $\fun{txValTag}$ and the result of $\fun{evalScripts}$
are $\True$ in the former, and $\False$ in the latter.
\end{proof}
\end{property}
\begin{property}[Replay protection]
\label{prop:replay}
A transaction always removes at least one UTxO entry from the ledger, which provides
replay protection.
\begin{lemma}
For all environments $e$, transactions $tx$ and states $s, s'$ such that
\begin{equation*}
e\vdash s\trans{ledger}{tx}s',
\end{equation*}
The following holds : $\Utxo~(s)~\nsubseteq~\Utxo~(s')$.
\end{lemma}
\begin{proof}
The UTxO is updated by the $\mathsf{Scripts{-}Yes}$ and the $\mathsf{Scripts{-}No}$
rules, on of which is necessarily called by a valid transaction. Both of these
rules remove UTxOs corresponding to a set of inputs.
In both cases, there is a check that the removed inputs set is non-empty.
The $\mathsf{Scripts{-}Yes}$ rule of the $\mathsf{UTXOS}$ transition
removes the UTxOs associated with the input set $\fun{txinputs}~{tx}$ from the ledger.
The $\fun{txinputs}~{tx}$ set must be non-empty because there is a check in the
$\mathsf{UTXO}$ rule (which calls $\mathsf{UTXOS}$) that ensure this is true.
For the $\mathsf{Scripts{-}No}$ rule of the $\mathsf{UTXOS}$ transition
removes the UTxOs associated with the input set $\fun{collateral}~{tx}$ from the ledger.
The $\fun{collateral}~{tx}$ set must be non-empty because
the $\fun{feesOK}$ function (called by the same rule that calls $\mathsf{UTXO},
\mathsf{UTXOS}$) ensures that in the case that the $tx$ contains phase-2 scripts,
$\fun{collateral}~{tx}$ must be non-empty.
Note that by property~\ref{prop:is-valid}, phase-2 scripts must always be present
if $\fun{txValTag}~tx = \False$ (that is, whenever $\mathsf{Scripts{-}No}$ rule is used).
\end{proof}
\end{property}
\begin{property}[UTxO-changing transitions]
\label{prop:utxo-change}
The $\mathsf{UTXOS}$ transition fully specifies the change in the ledger $\UTxO$
for each transaction.
\begin{lemma}
For all environments $e$, transitions $\mathsf{TRNS}$, transactions $tx$ and states $s, s'$ such that
\begin{equation*}
e\vdash s\trans{trns}{tx}s'
\end{equation*}
The following holds :
\begin{equation*}
\Utxo(s) \neq \Utxo(s')~\Rightarrow~e'\vdash u\trans{utxos}{tx}u'
\end{equation*}
where $\Utxo(s) = \Utxo(u)~\wedge~\Utxo(s') = \Utxo(u')$ for some environment $e'$,
and states $u, u'$.
\end{lemma}
\begin{proof}
By inspecting each transition in this specification, as well as those inherited from the
Shelley one, we see that a non-trivial update from the UTxO of $s$ to that of $s'$
must be done by $\mathsf{UTXOS}$. Every other transition that changes the UTxO and
has a signal of type $\Tx$ only applies the $\mathsf{UTXOS}$.
\end{proof}
\end{property}
\begin{property}[Deterministic script evaluation]
\label{prop:fixed-inputs}
The deterministic script evaluation property, also stated as
"script interpreter arguments are fixed", is a property of the Alonzo ledger
that guarantees that the outcome of phase-2 script validation in a (phase-1 valid) transaction
depends only on the contents of that transaction, and not on when, by who, or in what
block that transaction was submitted.
For this property, we make some assumptions about things that are outside the scope of this specification :
\begin{itemize}
\item The Plutus script
interpreter is a pure function that receives only the arguments provided by the ledger when it is
invoked by calling the $\fun{runPLCScript}$ function. We assume that this is
also true in an implementation. In particular, the interpreter does not
obtain any system randomness, etc.
\item We do not need to check here that the hashes that are the keys of the
$\fun{txscripts}$ and $\fun{txdats}$ fields match the computed hashes of the scripts and
datum objects they index. This is because these hashes must be computed as part of
the deserialization of a transaction (see the CDDL specification),
instead of being transmitted as part of the transaction and then checked. We
assume these hashes are correct.
\item We assume that the consensus
function $\fun{epochInfoSlotToUTCTime}$ for converting a slot interval into a
system time interval is deterministic.
\item We assume that the two global
constants, $\EpochInfo$ and $\SystemStart$, which it also takes as parameters,
cannot change within the span of any interval for which $\fun{epochInfoSlotToUTCTime}$
is able to convert both endpoints to system time.
\end{itemize}
The assumptions above are implicit in the functional style of definitions in this
specification, but they are worth pointing out for implementation.
With these assumptions in mind, we can say that
script evaluation is deterministic.
We split this result into a lemma and its corollary :
\begin{itemize}
\item First, we demonstrate that all the scripts and their arguments that are
collected for phase-2 validation are the same for two phase-1 valid transactions with the same body,
independent of the (necessarily valid) ledger state to which they are being applied
\item Second, we derive the corollary that under the same validity assumptions,
phase-2 validation results in the same outcome for both transactions
\end{itemize}
\begin{lemma}
\label{lem:inputs}
For all environments $e, e'$, transactions $tx, tx'$ and states $s, s', u, u'$ such that
$e$ and $s$ are subsets of fields of some valid chain state $c$, and
$e'$ and $s'$ are subsets of fields of some valid chain state $c'$,
\begin{equation*}
e\vdash s\trans{ledger}{tx}s', \\
e'\vdash u\trans{ledger}{tx'}u', \\
\txbody{tx} = \txbody{tx'}
\end{equation*}
The following holds :
\[\fun{toSet}~(\fun{collectTwoPhaseScriptInputs}~\mathsf{EI}~\mathsf{SysSt} ~\field_{pp}(s)~\var{tx}~ \Utxo(s))\]
\[ = \]
\[\fun{toSet}~(\fun{collectTwoPhaseScriptInputs}~\mathsf{EI}~\mathsf{SysSt} ~\field_{pp}(u)~\var{tx'}~ \Utxo(u))\]
\end{lemma}
\begin{proof}
The $\fun{collectTwoPhaseScriptInputs}$
function (see \ref{fig:functions:script2})
constructs a list where each entry contains a Plutus script
and the arguments passed to the interpreter for its evaluation.
To show that $\fun{collectTwoPhaseScriptInputs}$ returns a list containing
the same elements for both $tx$ and $tx'$, we observe that
the set of elements from which this list is produced via $\fun{toList}$
is generated using the following functions, as well as set comprehension
and list operations.
We demonstrate that the functions used in this definition
produce the same output for $tx$ and $tx'$, as all the data they
inspect is fixed by the transaction body :
\begin{itemize}
\item $\fun{scriptsNeeded}$ : The $\PolicyID$, $\AddrRWD$, and $\DCert$ data
output by this function as the second term of the hash-purpose pair
is obtained directly from the $\fun{mint}$, $\fun{txwdrls}$,
$\fun{txcerts}$ fields of the transaction, which are all fixed by the
body of the transaction. These types of script purposes all include
the hash of the validating script.
The only other data this function inspects is the UTxO entries associated
with the $\fun{txinputs}$ (passed via the $\UTxO$ argument) to get the realized inputs.
We know that the UTxO is a field in a valid chain state for both the phase-1 valid
transactions $tx$ and
the $tx'$ ($\Utxo(s)$ and $\Utxo(u)$, respectively). This means that the $\TxId$
in each input present in either UTxO is a hash of the body of the transaction
containing the $\TxOut$ part of the UTxO entry indexed by that input. The
order of the outputs is also fixed by the body, which fixes the $\Ix$ of
the entry.
A different value in output part of the UTxO entry (or a different order of
outputs) would necessarily imply
that the hash of the body containing that output must be different.
Therefore, for all Plutus script-locked realized inputs of either transaction,
the script hash in the payment credential of the address
(and, by the same argument, the datum hash) are fixed by the inputs in body of the
transaction, despite not being explicitly contained in it. We then get that
\[ \fun{scriptsNeeded}~\Utxo(s)~(\txbody{tx}) = \fun{scriptsNeeded}~\Utxo(u)~(\txbody{tx'}) \]
\item $\fun{getDatum}$ : In the case the script purpose
is of the input type, the datum this function returns is one that
is associated with the corresponding realized input. More precisely, it is the datum whose
hash is specified in the realized input, and is looked up by hash in the $\fun{txdats}$
transaction field. If there is no datum hash in the realized input, or the script purpose
is of a non-input type, the empty list is returned.
The $\mathsf{UTXOW}$ rule checks that the transaction is carrying all datums corresponding
to its realized inputs. Since the inputs (and realized inputs) are the same
for $tx$ and $tx'$ (fixed by the body), this guarantees that
of the datum hashes in the realized inputs (and therefore, their preimages)
are the same as well.
\item $\fun{txscripts}$ : in the $\mathsf{UTXOW}$ rule, there is a check that all the
script preimages of the script hashes returned by the $\fun{scriptsNeeded}$
function must be present in this field.
\item $\fun{indexedRdmrs}$ : like $\fun{scriptsNeeded}$, this function
examines four fields fixed by the transaction body ($\fun{mint}$, $\fun{txwdrls}$,
$\fun{txcerts}$, and $\fun{txinputs}$).
It also looks at data in the $\fun{txrdmrs}$ field, which is fixed
by the transaction body via the $\fun{scriptIntegrityHash}$
hash. This is done as follows: the $\mathsf{UTXOW}$ rule verifies that this
hash-containing field matches the computed hash
of the preimage constructed from several fields of the transaction,
including $\fun{txrdmrs}$ (this calculation
is done by the $\fun{hashScriptIntegrity}$ function).
\item $\fun{language}$ : this is directly conveyed by the type of a script.
\item $\fun{costmdls}$ : The hash calculated by the $\fun{hashScriptIntegrity}$
function and compared to the hash value in the $\fun{scriptIntegrityHash}$ field
must include in the preimage the current cost models of
all script languages of scripts carried by the transaction. Recall that
if a cost model changed between when a transaction was submitted and the
time at which it was processed, the field and the calculated hash values
will not match.
\item $\fun{valContext}$ and $\fun{txInfo}$ :
The $\fun{valContext}$ function is defined in \ref{sec:txinfo} and is pure.
All fields of the $\TxInfo$
structure, with the exceptions listed below,
are straightforward translations of the corresponding transaction body fields (see \ref{sec:txinfo}) that
are given no additional arguments,
and therefore completely determined by $tx$ and $tx'$. The fields not directly
appearing in the body are :
\begin{itemize}
\item $\fun{txInfoInputs}$ : this field contains the realized inputs of
the transaction which are fixed by the transaction and the unique
UTxO entries to which the inputs correspond. As explained above,
accessing information in realized inputs for script evaluation
does not break determinism.
\item $\fun{txInfoValidRange}$ : this field contains the transaction
validity interval as system time (converted from the slot numbers, which are
used to specify the interval in the transaction body). This conversion is
done by a function defined in the consensus layer, and takes two global
constants in addition to the slot interval itself. Since the slot interval
conversion function $\fun{epochInfoSlotToUTCTime}$ necessarily
succeeds if both $tx$ and $tx'$ pass phase-1 validation, the additional
global constant arguments must be the same (by assumption). The determinism of this conversion
is one of the assumptions of this property, and thus gives the same output
for both transactions.
\item $\fun{txInfoData}$ : this field is populated with the datums (and their
hashes) in the transaction field $\fun{txdats}$, which are fixed by the body
via the $\fun{scriptIntegrityHash}$ field.
\item $\fun{txInfoId}$ : this field contains the hash of the transaction body,
which is clearly the same for transactions with the same body.
\end{itemize}
Therefore, each field of the $\TxInfo$ structure is
the same for two transactions with the same body, ie.
\[ \fun{txInfo}~\PlutusVI~\Utxo(s)~\var{tx} = \fun{txInfo}~\PlutusVI~\Utxo(u)~\var{tx'}\]
\end{itemize}
\end{proof}
We can now make the general statement about evaluation of all scripts done in
phase-2 validation : for any phase-1 valid transactions with the same body,
the outcome of phase-2 script evaluation is the same. We make the same assumptions
as in Lemma \ref{lem:inputs}.
\begin{corollary}
For all environments $e, e'$, transactions $tx, tx'$ and states $s, s', u, u'$ such that
\begin{equation*}
e\vdash s\trans{ledger}{tx}s', \\
e'\vdash u\trans{ledger}{tx'}u', \\
\txbody{tx} = \txbody{tx'}
\end{equation*}
The following holds :
\[\fun{evalScripts}~{tx}~ (\fun{collectTwoPhaseScriptInputs}~\mathsf{EI}~\mathsf{SysSt} ~\field_{pp}(s)~\var{tx}~ \Utxo(s))\]
\[ = \]
\[\fun{evalScripts}~{tx'}~ (\fun{collectTwoPhaseScriptInputs}~\mathsf{EI}~\mathsf{SysSt} ~\field_{pp}(u)~\var{tx'}~ \Utxo(u))\]
\end{corollary}
\begin{proof}
Let us consider the use of arguments of $\fun{evalScripts}$ (see Figure \ref{fig:functions:script2}).
The first argument (of type $\Tx$) is only inspected in the case that the script $sc$ (the first element
in the pair at the head of the list of script-arguments pairs is a phase-1 script. Since all phase-1 scripts
are checked in phase one of validation (see \ref{fig:rules:utxow-alonzo}) by calling $\fun{validateScript}$
on all scripts attached to the transaction. For this to apply to $sc$, we must also show
that $sc$ is a script attached to the transaction (see the second argument explanation).
Note also that the $tx$ argument passed to $\fun{evalScripts}$ at the use site (in the $\mathsf{UTXOS}$ transition)
is the same, unmodified $tx$ as is the signal for the LEDGER transition. We verify this by inspecting
the sequence of transitions through which it is propagated
($\mathsf{UTXOS}$, $\mathsf{UTXO}$, $\mathsf{UTXOW}$, and $\mathsf{LEDGER}$), and their signals.
This allows us to conclude that at every step of the iteration over the script-arguments pairs list,
the first argument to $\fun{evalScripts}$,
\begin{itemize}
\item has no impact on the outcome of script evaluation in the case the script
being validated at this step is phase-2, as it is completely ignored, and,
\item because $\fun{collectTwoPhaseScriptInputs}$ filters out all phase-1 scripts,
is, in fact, ignored always.
\end{itemize}
The second argument to $\fun{evalScripts}$, ie. the list of scripts and their arguments,
has already been shown to contain the same tuples for both transactions in the lemma above.
The order of the list does not affect the validation outcome, since the interpreter is run
on each tuple of a script and its arguments independently of all other tuples in the list.
The function $\fun{evalScripts}$ is a $\wedge$-fold over the list. Thus, we may ignore the order
of the elements in the generated list as it does not affect the evaluation outcome.
From this we may conclude that the outcome of both phase-1 and phase-2 script evaluations
at each step of $\fun{evalScripts}$ must be the same for $tx$ and $tx'$. Therefore,
the $\wedge$-fold of them done by $\fun{evalScripts}$ also produces the same outcome
for both transactions.
\end{proof}
\end{property}
\begin{enumerate}
\item
\emph{Commutativity of Translation.} Translate, then apply to Alonzo ledger is
the same as apply to MA ledger, then translate the ledger.
\item
\emph{Zero ExUnits.} If a script is run (there’s a redeemer/exunits) , it will fail with 0 units
\item
\emph{Cost Increase.} if a transaction is valid, it will remain valid if you increase the execution units
\item
\emph{Cost Lower Bound.} if a transaction contains at least one valid script, it must have at least one execution unit
\item
\emph{Tx backwards Compatibility.} Any transaction that was accepted in a previous version of the ledger rules
has exactly the same cost and effect, except that the transaction output is extended.
\item \emph{Run all scripts.} All scripts attached to a transaction are run
\item
... \todo{Anything else?}
\end{enumerate}