-
Notifications
You must be signed in to change notification settings - Fork 156
/
Copy pathepoch.tex
71 lines (67 loc) · 3.3 KB
/
epoch.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
\section{Rewards and the Epoch Boundary}
\label{sec:epoch}
\newcommand{\UTxOEpState}{\type{UTxOEpState}}
\newcommand{\Acnt}{\type{Acnt}}
\newcommand{\PlReapState}{\type{PlReapState}}
\newcommand{\NewPParamEnv}{\type{NewPParamEnv}}
\newcommand{\Snapshots}{\type{Snapshots}}
\newcommand{\SnapshotEnv}{\type{SnapshotEnv}}
\newcommand{\SnapshotState}{\type{SnapshotState}}
\newcommand{\NewPParamState}{\type{NewPParamState}}
\newcommand{\EpochState}{\type{EpochState}}
\newcommand{\BlocksMade}{\type{BlocksMade}}
\newcommand{\Snapshot}{\type{Snapshot}}
\newcommand{\RewardUpdate}{\type{RewardUpdate}}
\newcommand{\obligation}[4]{\fun{obligation}~ \var{#1}~ \var{#2}~ \var{#3}~ \var{#4}}
\newcommand{\reward}[7]{\fun{reward}
~ \var{#1}~ \var{#2}~ \var{#3}~ \var{#4}~ \var{#5}~ \var{#6}~ \var{#7}}
\newcommand{\rewardOnePool}[9]{\fun{rewardOnePool}
~\var{#1}~\var{#2}~\var{#3}~\var{#4}~\var{#5}~\var{#6}~\var{#7}~\var{#8}~\var{#9}}
\newcommand{\isActive}[4]{\fun{isActive}~ \var{#1}~ \var{#2}~ \var{#3}~ \var{#4}}
\newcommand{\activeStake}[5]{\fun{activeStake}~ \var{#1}~ \var{#2}~ \var{#3}~ \var{#4}~ \var{#5}}
\newcommand{\poolRefunds}[3]{\fun{poolRefunds}~ \var{#1}~ \var{#2}~ \var{#3}}
\newcommand{\poolStake}[3]{\fun{poolStake}~ \var{#1}~ \var{#2}~ \var{#3}}
\newcommand{\stakeDistr}[3]{\fun{stakeDistr}~ \var{#1}~ \var{#2}~ \var{#3}}
\newcommand{\lReward}[4]{\fun{r_{operator}}~ \var{#1}~ \var{#2}~ \var{#3}~ {#4}}
\newcommand{\mReward}[4]{\fun{r_{member}}~ \var{#1}~ \var{#2}~ \var{#3}~ {#4}}
\newcommand{\poolReward}[5]{\fun{poolReward}~\var{#1}~{#2}~\var{#3}~\var{#4}~\var{#5}}
\newcommand{\createRUpd}[2]{\fun{createRUpd}~\var{#1}~\var{#2}}
In order to handle rewards and staking, we must change the stake distribution
calculation function to add up only the Ada in the UTxO
before performing any calculations. In Figure~\ref{fig:functions:stake-distribution}
below, we do so using the function $\fun{utxoAda}$, which returns the amount of Ada
in an address.
%%
%% Figure Functions for Stake Distribution
%%
\begin{figure}[htb]
\emph{Helper functions}
%
\begin{align*}
& \fun{utxoAda} \in \UTxO \to \Addr \to \Coin \\
& \fun{utxoAda}~{\var{utxo}}~\var{addr} ~=~\sum_{\var{out} \in \range \var{utxo}, \fun{getAddr}~\var{out} = \var{addr}} \fun{getCoin}~\var{out}
\end{align*}
%
\emph{Stake Distribution (using functions and maps as relations)}
%
\begin{align*}
& \fun{stakeDistr} \in \UTxO \to \DState \to \PState \to \Snapshot \\
& \fun{stakeDistr}~{utxo}~{dstate}~{pstate} = \\
& ~~~~ \big((\dom{\var{activeDelegs}})
\restrictdom\left(\fun{aggregate_{+}}~\var{stakeRelation}\right),
~\var{delegations},~\var{poolParams}\big)\\
& \where \\
& ~~~~ (~\var{rewards},~\var{delegations},~\var{ptrs},~\wcard,~\wcard,~\wcard)
= \var{dstate} \\
& ~~~~ (~\var{poolParams},~\wcard,~\wcard) = \var{pstate} \\
& ~~~~ \var{stakeRelation} = \left(
\left(\fun{stakeCred_b}^{-1}\cup\left(\fun{addrPtr}\circ\var{ptr}\right)^{-1}\right)
\circ\left(\hldiff{\fun{utxoAda}}~{\var{utxo}}\right)
\right)
\cup \var{rewards} \\
& ~~~~ \var{activeDelegs} =
(\dom{rewards}) \restrictdom \var{delegations} \restrictrange (\dom{poolParams})
\end{align*}
\caption{Stake Distribution Function}
\label{fig:functions:stake-distribution}
\end{figure}