You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

280 lines
17 KiB

  1. \section{Proof of Tendermint consensus algorithm} \label{sec:proof}
  2. \begin{lemma} \label{lemma:majority-intersection} For all $f\geq 0$, any two
  3. sets of processes with voting power at least equal to $2f+1$ have at least one
  4. correct process in common. \end{lemma}
  5. \begin{proof} As the total voting power is equal to $n=3f+1$, we have $2(2f+1)
  6. = n+f+1$. This means that the intersection of two sets with the voting
  7. power equal to $2f+1$ contains at least $f+1$ voting power in common, \ie,
  8. at least one correct process (as the total voting power of faulty processes
  9. is $f$). The result follows directly from this. \end{proof}
  10. \begin{lemma} \label{lemma:locked-decision_value-prevote-v} If $f+1$ correct
  11. processes lock value $v$ in round $r_0$ ($lockedValue = v$ and $lockedRound =
  12. r_0$), then in all rounds $r > r_0$, they send $\Prevote$ for $id(v)$ or
  13. $\nil$. \end{lemma}
  14. \begin{proof} We prove the result by induction on $r$.
  15. \emph{Base step $r = r_0 + 1:$} Let's denote with $C$ the set of correct
  16. processes with voting power equal to $f+1$. By the rules at
  17. line~\ref{line:tab:recvProposal} and line~\ref{line:tab:acceptProposal}, the
  18. processes from the set $C$ can't accept $\Proposal$ for any value different
  19. from $v$ in round $r$, and therefore can't send a $\li{\Prevote,height_p,
  20. r,id(v')}$ message, if $v' \neq v$. Therefore, the Lemma holds for the base
  21. step.
  22. \emph{Induction step from $r_1$ to $r_1+1$:} We assume that no process from the
  23. set $C$ has sent $\Prevote$ for values different than $id(v)$ or $\nil$ until
  24. round $r_1 + 1$. We now prove that the Lemma also holds for round $r_1 + 1$. As
  25. processes from the set $C$ send $\Prevote$ for $id(v)$ or $\nil$ in rounds $r_0
  26. \le r \le r_1$, by Lemma~\ref{lemma:majority-intersection} there is no value
  27. $v' \neq v$ for which it is possible to receive $2f+1$ $\Prevote$ messages in
  28. those rounds (i). Therefore, we have for all processes from the set $C$,
  29. $lockedValue = v$ and $lockedRound \ge r_0$. Let's assume by a contradiction
  30. that a process $q$ from the set $C$ sends $\Prevote$ in round $r_1 + 1$ for
  31. value $id(v')$, where $v' \neq v$. This is possible only by
  32. line~\ref{line:tab:prevote-higher-proposal}. Note that this implies that $q$
  33. received $2f+1$ $\li{\Prevote,h_q, r,id(v')}$ messages, where $r > r_0$ and $r
  34. < r_1 +1$ (see line~\ref{line:tab:cond-prevote-higher-proposal}). A
  35. contradiction with (i) and Lemma~\ref{lemma:majority-intersection}.
  36. \end{proof}
  37. \begin{lemma} \label{lemma:agreement} Algorithm~\ref{alg:tendermint} satisfies
  38. Agreement. \end{lemma}
  39. \begin{proof} Let round $r_0$ be the first round of height $h$ such that some
  40. correct process $p$ decides $v$. We now prove that if some correct process
  41. $q$ decides $v'$ in some round $r \ge r_0$, then $v = v'$.
  42. In case $r = r_0$, $q$ has received at least $2f+1$
  43. $\li{\Precommit,h_p,r_0,id(v')}$ messages at line~\ref{line:tab:onDecideRule},
  44. while $p$ has received at least $2f+1$ $\li{\Precommit,h_p,r_0,id(v)}$
  45. messages. By Lemma~\ref{lemma:majority-intersection} two sets of messages of
  46. voting power $2f+1$ intersect in at least one correct process. As a correct
  47. process sends a single $\Precommit$ message in a round, then $v=v'$.
  48. We prove the case $r > r_0$ by contradiction. By the
  49. rule~\ref{line:tab:onDecideRule}, $p$ has received at least $2f+1$ voting-power
  50. equivalent of $\li{\Precommit,h_p,r_0,id(v)}$ messages, i.e., at least $f+1$
  51. voting-power equivalent correct processes have locked value $v$ in round $r_0$ and have
  52. sent those messages (i). Let denote this set of messages with $C$. On the
  53. other side, $q$ has received at least $2f+1$ voting power equivalent of
  54. $\li{\Precommit,h_q, r,id(v')}$ messages. As the voting power of all faulty
  55. processes is at most $f$, some correct process $c$ has sent one of those
  56. messages. By the rule at line~\ref{line:tab:recvPrevote}, $c$ has locked value
  57. $v'$ in round $r$ before sending $\li{\Precommit,h_q, r,id(v')}$. Therefore $c$
  58. has received $2f+1$ $\Prevote$ messages for $id(v')$ in round $r > r_0$ (see
  59. line~\ref{line:tab:recvPrevote}). By Lemma~\ref{lemma:majority-intersection}, a
  60. process from the set $C$ has sent $\Prevote$ message for $id(v')$ in round $r$.
  61. A contradiction with (i) and Lemma~\ref{lemma:locked-decision_value-prevote-v}.
  62. \end{proof}
  63. \begin{lemma} \label{lemma:agreement} Algorithm~\ref{alg:tendermint} satisfies
  64. Validity. \end{lemma}
  65. \begin{proof} Trivially follows from the rule at line
  66. \ref{line:tab:validDecisionValue} which ensures that only valid values can be
  67. decided. \end{proof}
  68. \begin{lemma} \label{lemma:round-synchronisation} If we assume that:
  69. \begin{enumerate}
  70. \item a correct process $p$ is the first correct process to
  71. enter a round $r>0$ at time $t > GST$ (for every correct process
  72. $c$, $round_c \le r$ at time $t$)
  73. \item the proposer of round $r$ is
  74. a correct process $q$
  75. \item for every correct process $c$,
  76. $lockedRound_c \le validRound_q$ at time $t$
  77. \item $\timeoutPropose(r)
  78. > 2\Delta + \timeoutPrecommit(r-1)$, $\timeoutPrevote(r) > 2\Delta$ and
  79. $\timeoutPrecommit(r) > 2\Delta$,
  80. \end{enumerate}
  81. then all correct processes decide in round $r$ before $t + 4\Delta +
  82. \timeoutPrecommit(r-1)$.
  83. \end{lemma}
  84. \begin{proof} As $p$ is the first correct process to enter round $r$, it
  85. executed the line~\ref{line:tab:nextRound} after $\timeoutPrecommit(r-1)$
  86. expired. Therefore, $p$ received $2f+1$ $\Precommit$ messages in the round
  87. $r-1$ before time $t$. By the \emph{Gossip communication} property, all
  88. correct processes will receive those messages the latest at time $t +
  89. \Delta$. Correct processes that are in rounds $< r-1$ at time $t$ will
  90. enter round $r-1$ (see the rule at line~\ref{line:tab:nextRound2}) and
  91. trigger $\timeoutPrecommit(r-1)$ (see rule~\ref{line:tab:startTimeoutPrecommit})
  92. by time $t+\Delta$. Therefore, all correct processes will start round $r$
  93. by time $t+\Delta+\timeoutPrecommit(r-1)$ (i).
  94. In the worst case, the process $q$ is the last correct process to enter round
  95. $r$, so $q$ starts round $r$ and sends $\Proposal$ message for some value $v$
  96. at time $t + \Delta + \timeoutPrecommit(r-1)$. Therefore, all correct processes
  97. receive the $\Proposal$ message from $q$ the latest by time $t + 2\Delta +
  98. \timeoutPrecommit(r-1)$. Therefore, if $\timeoutPropose(r) > 2\Delta +
  99. \timeoutPrecommit(r-1)$, all correct processes will receive $\Proposal$ message
  100. before $\timeoutPropose(r)$ expires.
  101. By (3) and the rules at line~\ref{line:tab:recvProposal} and
  102. \ref{line:tab:acceptProposal}, all correct processes will accept the
  103. $\Proposal$ message for value $v$ and will send a $\Prevote$ message for
  104. $id(v)$ by time $t + 2\Delta + \timeoutPrecommit(r-1)$. Note that by the
  105. \emph{Gossip communication} property, the $\Prevote$ messages needed to trigger
  106. the rule at line~\ref{line:tab:acceptProposal} are received before time $t +
  107. \Delta$.
  108. By time $t + 3\Delta + \timeoutPrecommit(r-1)$, all correct processes will receive
  109. $\Proposal$ for $v$ and $2f+1$ corresponding $\Prevote$ messages for $id(v)$.
  110. By the rule at line~\ref{line:tab:recvPrevote}, all correct processes will send
  111. a $\Precommit$ message (see line~\ref{line:tab:precommit-v}) for $id(v)$ by
  112. time $t + 3\Delta + \timeoutPrecommit(r-1)$. Therefore, by time $t + 4\Delta +
  113. \timeoutPrecommit(r-1)$, all correct processes will have received the $\Proposal$
  114. for $v$ and $2f+1$ $\Precommit$ messages for $id(v)$, so they decide at
  115. line~\ref{line:tab:decide} on $v$.
  116. This scenario holds if every correct process $q$ sends a $\Precommit$ message
  117. before $\timeoutPrevote(r)$ expires, and if $\timeoutPrecommit(r)$ does not expire
  118. before $t + 4\Delta + \timeoutPrecommit(r-1)$. Let's assume that a correct process
  119. $c_1$ is the first correct process to trigger $\timeoutPrevote(r)$ (see the rule
  120. at line~\ref{line:tab:recvAny2/3Prevote}) at time $t_1 > t$. This implies that
  121. before time $t_1$, $c_1$ received a $\Proposal$ ($step_{c_1}$ must be
  122. $\prevote$ by the rule at line~\ref{line:tab:recvAny2/3Prevote}) and a set of
  123. $2f+1$ $\Prevote$ messages. By time $t_1 + \Delta$, all correct processes will
  124. receive those messages. Note that even if some correct process was in the
  125. smaller round before time $t_1$, at time $t_1 + \Delta$ it will start round $r$
  126. after receiving those messages (see the rule at
  127. line~\ref{line:tab:skipRounds}). Therefore, all correct processes will send
  128. their $\Prevote$ message for $id(v)$ by time $t_1 + \Delta$, and all correct
  129. processes will receive those messages the by time $t_1 + 2\Delta$. Therefore,
  130. as $\timeoutPrevote(r) > 2\Delta$, this ensures that all correct processes receive
  131. $\Prevote$ messages from all correct processes before their respective local
  132. $\timeoutPrevote(r)$ expire.
  133. On the other hand, $\timeoutPrecommit(r)$ is triggered in a correct process $c_2$
  134. after it receives any set of $2f+1$ $\Precommit$ messages for the first time.
  135. Let's denote with $t_2 > t$ the earliest point in time $\timeoutPrecommit(r)$ is
  136. triggered in some correct process $c_2$. This implies that $c_2$ has received
  137. at least $f+1$ $\Precommit$ messages for $id(v)$ from correct processes, i.e.,
  138. those processes have received $\Proposal$ for $v$ and $2f+1$ $\Prevote$
  139. messages for $id(v)$ before time $t_2$. By the \emph{Gossip communication}
  140. property, all correct processes will receive those messages by time $t_2 +
  141. \Delta$, and will send $\Precommit$ messages for $id(v)$. Note that even if
  142. some correct processes were at time $t_2$ in a round smaller than $r$, by the
  143. rule at line~\ref{line:tab:skipRounds} they will enter round $r$ by time $t_2 +
  144. \Delta$. Therefore, by time $t_2 + 2\Delta$, all correct processes will
  145. receive $\Proposal$ for $v$ and $2f+1$ $\Precommit$ messages for $id(v)$. So if
  146. $\timeoutPrecommit(r) > 2\Delta$, all correct processes will decide before the
  147. timeout expires. \end{proof}
  148. \begin{lemma} \label{lemma:validValue} If a correct process $p$ locks a value
  149. $v$ at time $t_0 > GST$ in some round $r$ ($lockedValue = v$ and
  150. $lockedRound = r$) and $\timeoutPrecommit(r) > 2\Delta$, then all correct
  151. processes set $validValue$ to $v$ and $validRound$ to $r$ before starting
  152. round $r+1$. \end{lemma}
  153. \begin{proof} In order to prove this Lemma, we need to prove that if the
  154. process $p$ locks a value $v$ at time $t_0$, then no correct process will
  155. leave round $r$ before time $t_0 + \Delta$ (unless it has already set
  156. $validValue$ to $v$ and $validRound$ to $r$). It is sufficient to prove
  157. this, since by the \emph{Gossip communication} property the messages that
  158. $p$ received at time $t_0$ and that triggered rule at
  159. line~\ref{line:tab:recvPrevote} will be received by time $t_0 + \Delta$ by
  160. all correct processes, so all correct processes that are still in round $r$
  161. will set $validValue$ to $v$ and $validRound$ to $r$ (by the rule at
  162. line~\ref{line:tab:recvPrevote}). To prove this, we need to compute the
  163. earliest point in time a correct process could leave round $r$ without
  164. updating $validValue$ to $v$ and $validRound$ to $r$ (we denote this time
  165. with $t_1$). The Lemma is correct if $t_0 + \Delta < t_1$.
  166. If the process $p$ locks a value $v$ at time $t_0$, this implies that $p$
  167. received the valid $\Proposal$ message for $v$ and $2f+1$
  168. $\li{\Prevote,h,r,id(v)}$ at time $t_0$. At least $f+1$ of those messages are
  169. sent by correct processes. Let's denote this set of correct processes as $C$. By
  170. Lemma~\ref{lemma:majority-intersection} any set of $2f+1$ $\Prevote$ messages
  171. in round $r$ contains at least a single message from the set $C$.
  172. Let's denote as time $t$ the earliest point in time a correct process, $c_1$, triggered
  173. $\timeoutPrevote(r)$. This implies that $c_1$ received $2f+1$ $\Prevote$ messages
  174. (see the rule at line \ref{line:tab:recvAny2/3Prevote}), where at least one of
  175. those messages was sent by a process $c_2$ from the set $C$. Therefore, process
  176. $c_2$ had received $\Proposal$ message before time $t$. By the \emph{Gossip
  177. communication} property, all correct processes will receive $\Proposal$ and
  178. $2f+1$ $\Prevote$ messages for round $r$ by time $t+\Delta$. The latest point
  179. in time $p$ will trigger $\timeoutPrevote(r)$ is $t+\Delta$\footnote{Note that
  180. even if $p$ was in smaller round at time $t$ it will start round $r$ by time
  181. $t+\Delta$.}. So the latest point in time $p$ can lock the value $v$ in
  182. round $r$ is $t_0 = t+\Delta+\timeoutPrevote(r)$ (as at this point
  183. $\timeoutPrevote(r)$ expires, so a process sends $\Precommit$ $\nil$ and updates
  184. $step$ to $\precommit$, see line \ref{line:tab:onTimeoutPrevote}).
  185. Note that according to the Algorithm \ref{alg:tendermint}, a correct process
  186. can not send a $\Precommit$ message before receiving $2f+1$ $\Prevote$
  187. messages. Therefore, no correct process can send a $\Precommit$ message in
  188. round $r$ before time $t$. If a correct process sends a $\Precommit$ message
  189. for $\nil$, it implies that it has waited for the full duration of
  190. $\timeoutPrevote(r)$ (see line
  191. \ref{line:tab:precommit-nil-onTimeout})\footnote{The other case in which a
  192. correct process $\Precommit$ for $\nil$ is after receiving $2f+1$ $Prevote$ for
  193. $\nil$ messages, see the line \ref{line:tab:precommit-v-1}. By
  194. Lemma~\ref{lemma:majority-intersection}, this is not possible in round $r$.}.
  195. Therefore, no correct process can send $\Precommit$ for $\nil$ before time $t +
  196. \timeoutPrevote(r)$ (*).
  197. A correct process $q$ that enters round $r+1$ must wait (i) $\timeoutPrecommit(r)$
  198. (see line \ref{line:tab:nextRound}) or (ii) receiving $f+1$ messages from the
  199. round $r+1$ (see the line \ref{line:tab:skipRounds}). In the former case, $q$
  200. receives $2f+1$ $\Precommit$ messages before starting $\timeoutPrecommit(r)$. If
  201. at least a single $\Precommit$ message from a correct process (at least $f+1$
  202. voting power equivalent of those messages is sent by correct processes) is for
  203. $\nil$, then $q$ cannot start round $r+1$ before time $t_1 = t +
  204. \timeoutPrevote(r) + \timeoutPrecommit(r)$ (see (*)). Therefore in this case we have:
  205. $t_0 + \Delta < t_1$, i.e., $t+2\Delta+\timeoutPrevote(r) < t + \timeoutPrevote(r) +
  206. \timeoutPrecommit(r)$, and this is true whenever $\timeoutPrecommit(r) > 2\Delta$, so
  207. Lemma holds in this case.
  208. If in the set of $2f+1$ $\Precommit$ messages $q$ receives, there is at least a
  209. single $\Precommit$ for $id(v)$ message from a correct process $c$, then $q$
  210. can start the round $r+1$ the earliest at time $t_1 = t+\timeoutPrecommit(r)$. In
  211. this case, by the \emph{Gossip communication} property, all correct processes
  212. will receive $\Proposal$ and $2f+1$ $\Prevote$ messages (that $c$ received
  213. before time $t$) the latest at time $t+\Delta$. Therefore, $q$ will set
  214. $validValue$ to $v$ and $validRound$ to $r$ the latest at time $t+\Delta$. As
  215. $t+\Delta < t+\timeoutPrecommit(r)$, whenever $\timeoutPrecommit(r) > \Delta$, the
  216. Lemma holds also in this case.
  217. In case (ii), $q$ received at least a single message from a correct process $c$
  218. from the round $r+1$. The earliest point in time $c$ could have started round
  219. $r+1$ is $t+\timeoutPrecommit(r)$ in case it received a $\Precommit$ message for
  220. $v$ from some correct process in the set of $2f+1$ $\Precommit$ messages it
  221. received. The same reasoning as above holds also in this case, so $q$ set
  222. $validValue$ to $v$ and $validRound$ to $r$ the latest by time $t+\Delta$. As
  223. $t+\Delta < t+\timeoutPrecommit(r)$, whenever $\timeoutPrecommit(r) > \Delta$, the
  224. Lemma holds also in this case. \end{proof}
  225. \begin{lemma} \label{lemma:agreement} Algorithm~\ref{alg:tendermint} satisfies
  226. Termination. \end{lemma}
  227. \begin{proof} Lemma~\ref{lemma:round-synchronisation} defines a scenario in
  228. which all correct processes decide. We now prove that within a bounded
  229. duration after GST such a scenario will unfold. Let's assume that at time
  230. $GST$ the highest round started by a correct process is $r_0$, and that
  231. there exists a correct process $p$ such that the following holds: for every
  232. correct process $c$, $lockedRound_c \le validRound_p$. Furthermore, we
  233. assume that $p$ will be the proposer in some round $r_1 > r$ (this is
  234. ensured by the $\coord$ function).
  235. We have two cases to consider. In the first case, for all rounds $r \ge r_0$
  236. and $r < r_1$, no correct process locks a value (set $lockedRound$ to $r$). So
  237. in round $r_1$ we have the scenario from the
  238. Lemma~\ref{lemma:round-synchronisation}, so all correct processes decides in
  239. round $r_1$.
  240. In the second case, a correct process locks a value $v$ in round $r_2$, where
  241. $r_2 \ge r_0$ and $r_2 < r_1$. Let's assume that $r_2$ is the highest round
  242. before $r_1$ in which some correct process $q$ locks a value. By Lemma
  243. \ref{lemma:validValue} at the end of round $r_2$ the following holds for all
  244. correct processes $c$: $validValue_c = lockedValue_q$ and $validRound_c = r_2$.
  245. Then in round $r_1$, the conditions for the
  246. Lemma~\ref{lemma:round-synchronisation} holds, so all correct processes decide.
  247. \end{proof}