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.

167 lines
6.5 KiB

  1. # Proposer-Based Time - Part II
  2. This specification is **OUTDATED**. Please refer to the [new version][v2].
  3. ## Updated Consensus Algorithm
  4. ### Outline
  5. The algorithm in the [arXiv paper][arXiv] evaluates rules of the received messages without making explicit how these messages are received. In our solution, we will make some message filtering explicit. We will assume that there are message reception steps (where messages are received and possibly stored locally for later evaluation of rules) and processing steps (the latter roughly as described in a way similar to the pseudo code of the arXiv paper).
  6. In contrast to the original algorithm the field `proposal` in the `PROPOSE` message is a pair `(v, time)`, of the proposed consensus value `v` and the proposed time `time`.
  7. #### **[PBTS-RECEPTION-STEP.0]**
  8. In the reception step at process `p` at local time `now_p`, upon receiving a message `m`:
  9. - if the message `m` is of type `PROPOSE` and satisfies `now_p - PRECISION < m.time < now_p + PRECISION + MSGDELAY`, then mark the message as `timely`
  10. > if `m` does not satisfy the constraint consider it `untimely`
  11. #### **[PBTS-PROCESSING-STEP.0]**
  12. In the processing step, based on the messages stored, the rules of the algorithms are
  13. executed. Note that the processing step only operates on messages
  14. for the current height. The consensus algorithm rules are defined by the following updates to arXiv paper.
  15. #### New `StartRound`
  16. There are two additions
  17. - in case the proposer's local time is smaller than the time of the previous block, the proposer waits until this is not the case anymore (to ensure the block time is monotonically increasing)
  18. - the proposer sends its time `now_p` as part of its proposal
  19. We update the timeout for the `PROPOSE` step according to the following reasoning:
  20. - If a correct proposer needs to wait to make sure its proposed time is larger than the `blockTime` of the previous block, then it sends by realtime `blockTime + ACCURACY` (By this time, its local clock must exceed `blockTime`)
  21. - the receiver will receive a `PROPOSE` message by `blockTime + ACCURACY + MSGDELAY`
  22. - the receiver's local clock will be `<= blockTime + 2 * ACCURACY + MSGDELAY`
  23. - thus when the receiver `p` enters this round it can set its timeout to a value `waitingTime => blockTime + 2 * ACCURACY + MSGDELAY - now_p`
  24. So we should set the timeout to `max(timeoutPropose(round_p), waitingTime)`.
  25. > If, in the future, a block delay parameter `BLOCKDELAY` is introduced, this means
  26. that the proposer should wait for `now_p > blockTime + BLOCKDELAY` before sending a `PROPOSE` message.
  27. Also, `BLOCKDELAY` needs to be added to `waitingTime`.
  28. #### **[PBTS-ALG-STARTROUND.0]**
  29. ```go
  30. function StartRound(round) {
  31. blockTime ← block time of block h_p - 1
  32. waitingTime ← blockTime + 2 * ACCURACY + MSGDELAY - now_p
  33. round_p ← round
  34. step_p ← propose
  35. if proposer(h_p, round_p) = p {
  36. wait until now_p > blockTime // new wait condition
  37. if validValue_p != nil {
  38. proposal ← (validValue_p, now_p) // added "now_p"
  39. }
  40. else {
  41. proposal ← (getValue(), now_p) // added "now_p"
  42. }
  43. broadcast ⟨PROPOSAL, h_p, round_p, proposal, validRound_p⟩
  44. }
  45. else {
  46. schedule OnTimeoutPropose(h_p,round_p) to be executed after max(timeoutPropose(round_p), waitingTime)
  47. }
  48. }
  49. ```
  50. #### New Rule Replacing Lines 22 - 27
  51. - a validator prevotes for the consensus value `v` **and** the time `t`
  52. - the code changes as the `PROPOSAL` message carries time (while `lockedValue` does not)
  53. #### **[PBTS-ALG-UPON-PROP.0]**
  54. ```go
  55. upon timely(⟨PROPOSAL, h_p, round_p, (v,t), −1⟩) from proposer(h_p, round_p) while step_p = propose do {
  56. if valid(v) ∧ (lockedRound_p = −1 ∨ lockedValue_p = v) {
  57. broadcast ⟨PREVOTE, h_p, round_p, id(v,t)⟩
  58. }
  59. else {
  60. broadcast ⟨PREVOTE, h_p, round_p, nil⟩
  61. }
  62. step_p ← prevote
  63. }
  64. ```
  65. #### New Rule Replacing Lines 28 - 33
  66. In case consensus is not reached in round 1, in `StartRound` the proposer of future rounds may propose the same value but with a different time.
  67. Thus, the time `tprop` in the `PROPOSAL` message need not match the time `tvote` in the (old) `PREVOTE` messages.
  68. A validator may send `PREVOTE` for the current round as long as the value `v` matches.
  69. This gives the following rule:
  70. #### **[PBTS-ALG-OLD-PREVOTE.0]**
  71. ```go
  72. upon timely(⟨PROPOSAL, h_p, round_p, (v, tprop), vr⟩) from proposer(h_p, round_p) AND 2f + 1 ⟨PREVOTE, h_p, vr, id((v, tvote)⟩
  73. while step_p = propose ∧ (vr ≥ 0 ∧ vr < round_p) do {
  74. if valid(v) ∧ (lockedRound_p ≤ vr ∨ lockedValue_p = v) {
  75. broadcast ⟨PREVOTE, h_p, roundp, id(v, tprop)⟩
  76. }
  77. else {
  78. broadcast ⟨PREVOTE, hp, roundp, nil⟩
  79. }
  80. step_p ← prevote
  81. }
  82. ```
  83. #### New Rule Replacing Lines 36 - 43
  84. - As above, in the following `(v,t)` is part of the message rather than `v`
  85. - the stored values (i.e., `lockedValue`, `validValue`) do not contain the time
  86. #### **[PBTS-ALG-NEW-PREVOTE.0]**
  87. ```go
  88. upon timely(⟨PROPOSAL, h_p, round_p, (v,t), ∗⟩) from proposer(h_p, round_p) AND 2f + 1 ⟨PREVOTE, h_p, round_p, id(v,t)⟩ while valid(v) ∧ step_p ≥ prevote for the first time do {
  89. if step_p = prevote {
  90. lockedValue_p ← v
  91. lockedRound_p ← round_p
  92. broadcast ⟨PRECOMMIT, h_p, round_p, id(v,t))⟩
  93. step_p ← precommit
  94. }
  95. validValue_p ← v
  96. validRound_p ← round_p
  97. }
  98. ```
  99. #### New Rule Replacing Lines 49 - 54
  100. - we decide on `v` as well as on the time from the proposal message
  101. - here we do not care whether the proposal was received timely.
  102. > In particular we need to take care of the case where the proposer is untimely to one correct validator only. We need to ensure that this validator decides if all decide.
  103. #### **[PBTS-ALG-DECIDE.0]**
  104. ```go
  105. upon ⟨PROPOSAL, h_p, r, (v,t), ∗⟩ from proposer(h_p, r) AND 2f + 1 ⟨PRECOMMIT, h_p, r, id(v,t)⟩ while decisionp[h_p] = nil do {
  106. if valid(v) {
  107. decision_p [h_p] = (v,t) // decide on time too
  108. h_p ← h_p + 1
  109. reset lockedRound_p , lockedValue_p, validRound_p and validValue_p to initial values and empty message log
  110. StartRound(0)
  111. }
  112. }
  113. ```
  114. **All other rules remains unchanged.**
  115. Back to [main document][main].
  116. [main]: ./pbts_001_draft.md
  117. [arXiv]: https://arxiv.org/abs/1807.04938
  118. [tlatender]: https://github.com/tendermint/spec/blob/master/rust-spec/tendermint-accountability/README.md
  119. [bfttime]: https://github.com/tendermint/spec/blob/439a5bcacb5ef6ef1118566d7b0cd68fff3553d4/spec/consensus/bft-time.md
  120. [lcspec]: https://github.com/tendermint/spec/blob/439a5bcacb5ef6ef1118566d7b0cd68fff3553d4/rust-spec/lightclient/README.md
  121. [v2]: ./pbts-algorithm_002_draft.md