forked from IntersectMBO/cardano-ledger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransactions.tex
154 lines (135 loc) · 6.18 KB
/
transactions.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
\begin{figure*}[t!]
%
\emph{Abstract types}
%
\begin{equation*}
\begin{array}{r@{~\in~}l@{\qquad=\qquad}lr}
\var{s_{v2}} & \Timelock & \text{extended script language}
\end{array}
\end{equation*}
%
\emph{Derived types}
%
\begin{equation*}
\begin{array}{r@{~\in~}l@{\qquad=\qquad}lr}
\var{txout} & \TxOut & \Addr \times \hldiff{\ValMonoid} \\
% & \text{tx outputs}
\var{s} & \Script & \hldiff{\Timelock}
% & \text{scripts}
\\
\end{array}
\end{equation*}
%
\emph{Transaction Type}
%
\begin{equation*}
\begin{array}{r@{~~}l@{~~}l@{\qquad}l}
\var{txbody} ~\in~ \TxBody ~=~
& \powerset{\TxIn} & \fun{txinputs}& \text{inputs}\\
&\times ~(\Ix \mapsto \TxOut) & \fun{txouts}& \text{outputs}\\
& \times~ \seqof{\DCert} & \fun{txcerts}& \text{certificates}\\
& \times ~\hldiff{\ValMonoid} & \hldiff{\fun{mint}} &\text{value minted}\\
& \times ~\Coin & \fun{txfee} &\text{non-script fee}\\
& \times ~\hldiff{\Slot^? \times \Slot^?} & \hldiff{\fun{txvldt}} & \text{validity interval}\\
& \times~ \Wdrl & \fun{txwdrls} &\text{reward withdrawals}\\
& \times ~\Update^? & \fun{txUpdates} & \text{update proposals}\\
& \times ~\AuxiliaryDataHash^? & \fun{txADhash} & \text{auxiliary data hash}
\end{array}
\end{equation*}
%
\begin{equation*}
\begin{array}{r@{~~}l@{~~}l@{\qquad}l}
\var{ad} ~\in~ \AuxiliaryData ~=~
& \powerset{\Script} & \fun{scripts}& \text{Optional scripts}\\
& \times ~\Metadata^? & \fun{md} & \text{metadata}
\end{array}
\end{equation*}
%
\begin{equation*}
\begin{array}{r@{~~}l@{~~}l@{\qquad}l}
\var{tx} ~\in~ \Tx ~=~
& \TxBody & \fun{txinputs}& \text{Transaction body}\\
&\times ~\TxWitness & \fun{txouts}& \text{Witnesses}\\
& \times ~\AuxiliaryData^? & \fun{txADhash} & \text{Auxiliary data}
\end{array}
\end{equation*}
%
\emph{Accessor Functions}
\begin{equation*}
\begin{array}{r@{~\in~}lr}
\fun{getValue} & \TxOut \to \ValMonoid & \text{output value} \\
\fun{getAddr} & \TxOut \to \Addr & \text{output address}
\end{array}
\end{equation*}
\caption{Type Definitions used in the UTxO transition system}
\label{fig:defs:utxo-shelley}
\end{figure*}
\section{Transactions}
\label{sec:transactions}
This section describes the changes that are made to the
transaction structure to support both timelock script and native multi-asset (MA)
functionality in the Cardano ledger.
\subsection*{New Output Type}
A key change needed to introduce MA functionality in the Mary era is changing the type of
the transaction and UTxO outputs to contain multi-asset values to accommodate
transacting with these types of assets natively, using the same ledger accounting
scheme as is used for Ada. We set up the infrastructure for this
change in transition system update common to both Allegra and Mary, ie. ShelleyMA. That is,
$\TxOut$ now contains an element of $\ValMonoid$ (which
could be a $\Coin$, $\Value$, or another type, see Section \ref{sec:coin-ma}),
rather than only $\Coin$.
\subsection*{New Script Type}
The multi-signature scripting language has been renamed to $\ScriptNI$ and
the type $\Script$ has been extended to include a new scripting language,
$\Timelock$, that is backwards compatible with the multi signature scripting
language, see Section~\ref{sec:chain}. We specify the evaluation
function for the new script type in Section~\ref{sec:timelock-lang}.
The new type of scripts can be used for all the same purposes, which means, for this
specification, as
\begin{itemize}
\item output-locking scripts,
\item certificate validation,
\item reward withdrawals, or
\item as minting scripts (see below).
\end{itemize}
\subsection*{The Mint Field}
The body of a transaction in the ShelleyMA era contains one additional
field, the $\fun{mint}$ field.
The $\fun{mint}$ field contains an element of $\ValMonoid$, which is used to specify
the assets a transaction is putting into or taking out of
circulation. Here, by "circulation", we mean specifically "the UTxO on the
ledger". Since the administrative fields cannot contain assets other than Ada,
and Ada cannot be minted (this is enforced by the UTxO rule, see Figure~\ref{fig:rules:utxo-shelley}),
they are not affected in any way by minting.
Putting assets into circulation is done with positive values in the $\Quantity$
fields $\fun{mint}$ field, and taking assets out of circulation can be done
with negative quantities.
A transaction cannot simply mint arbitrary assets. In the Mary era, restrictions on
multi-asset are imposed, for each asset with policy ID $\var{pid}$, by a script
with the hash $\var{pid}$. Whether a minting transaction adheres to the restrictions
prescribed by the preimage script is verified as part of the processing of the transaction.
The minting mechanism is detailed in Section~\ref{sec:utxo}.
Note that the $\fun{mint}$ field exists in both Allegra and Mary eras,
but can only be used in the Mary era, when multi-assets are introduced.
\subsection*{Transaction Body}
The following changes were made to $\TxBody$:
\begin{itemize}
\item a change in the type of $\TxOut$ --- instead of
$\Coin$, the transaction outputs now have type $\ValMonoid$.
\item the addition of the $\fun{mint}$ field to the transaction body
\item the time-to-live slot number (which had the accessor $\fun{txttl}$),
has been replaced with a validity interval with accessor $\fun{txvldt}$,
both endpoints of which are optional
\end{itemize}
The only change to the types related to transaction witnessing is the addition
of minting policy scripts to the underlying $\Script$ type, so we do not include the
whole $\Tx$ type here.
\subsection*{Auxiliary Data}
The auxiliary data section of the transaction consists of two parts:
$\fun{md}$ which is the same metadata type used in
Shelley, and $\fun{scripts}$, which is used to allow transactions to
contain optional scripts that are not used for witnessing. The
intended purpose of this field is to give users the ability to
transmit a script that belongs to a script address via this
auxiliary data. There are no restrictions on this field however, and users
can use it to put arbitrary scripts into the auxiliary data.