github.com/ari-anchor/sei-tendermint@v0.0.0-20230519144642-dc826b7b56bb/spec/consensus/proposer-based-timestamp/pbts-algorithm_002_draft.md (about)

     1  # PBTS: Protocol Specification
     2  
     3  ## Proposal Time
     4  
     5  PBTS computes for a proposed value `v` the proposal time `v.time`, with bounded difference to the actual real-time the proposed value was generated.
     6  The proposal time is read from the clock of the process that proposes a value for the first time, its original proposer.
     7  
     8  With PBTS, therefore, we assume that processes have access to **synchronized clocks**.
     9  The proper definition of what it means can be found in the [system model][sysmodel],
    10  but essentially we assume that two correct processes do not simultaneous read from their clocks
    11  time values that differ more than `PRECISION`, which is a system parameter.
    12  
    13  ### Proposal times are definitive
    14  
    15  When a value `v` is produced by a process, it also assigns the associated proposal time `v.time`.
    16  If the same value `v` is then re-proposed in a subsequent round of consensus,
    17  it retains its original time, assigned by its original proposer.
    18  
    19  A value `v` should re-proposed when it becomes locked by the network, i.e., when it receives `2f + 1 PREVOTES` in a round `r` of consensus.
    20  This means that processes with `2f + 1`-equivalent voting power accepted, in round `r`, both `v` and its associated time `v.time`.
    21  Since the originally proposed value and its associated time were considered valid, there is no reason for reassigning `v.time`.
    22  
    23  In the [first version][algorithm_v1] of this specification, proposals were defined as pairs `(v, time)`.
    24  In addition, the same value `v` could be proposed, in different rounds, but would be associated to distinct times each time it was reproposed.
    25  Since this possibility does not exist in this second specification, the proposal time became part of the proposed value.
    26  With this simplification, several small changes to the [arXiv][arXiv] algorithm are no longer required.
    27  
    28  ## Time Monotonicity
    29  
    30  Values decided in successive heights of consensus must have increasing times, so:
    31  
    32  - Monotonicity: for any process `p` and any two decided heights `h` and `h'`, if `h > h'` then `decision_p[h].time > decision_p[h'].time`.
    33  
    34  For ensuring time monotonicity, it is enough to ensure that a value `v` proposed by process `p` at height `h_p` has `v.time > decision_p[h_p-1].time`.
    35  So, if process `p` is the proposer of a round of height `h_p` and reads from its clock a time `now_p <= decision_p[h_p-1]`,
    36  it should postpone the generation of its proposal until `now_p > decision_p[h_p-1]`.
    37  
    38  > Although it should be considered, this scenario is unlikely during regular operation,
    39  as from `decision_p[h_p-1].time` and the start of height `h_p`, a complete consensus instance need to terminate.
    40  
    41  Notice that monotonicity is not introduced by this proposal, being already ensured by  [`BFTTime`][bfttime].
    42  In `BFTTime`, the `Timestamp` field of every `Precommit` message of height `h_p` sent by a correct process is required to be larger than `decision_p[h_p-1].time`, as one of such `Timestamp` fields becomes the time assigned to a value proposed at height `h_p`.
    43  
    44  The time monotonicity of values proposed in heights of consensus is verified by the `valid()` predicate, to which every proposed value is submitted.
    45  A value rejected by the `valid()` implementation is not accepted by any correct process.
    46  
    47  ## Timely Proposals
    48  
    49  PBTS introduces a new requirement for a process to accept a proposal: the proposal must be `timely`.
    50  It is a temporal requirement, associated with the following synchrony (that is, timing)
    51  [assumptions][sysmodel] regarding the behavior of processes and the network:
    52  
    53  - Synchronized clocks: the values simultaneously read from clocks of any two correct processes differ by at most `PRECISION`;
    54  - Bounded transmission delays: the real time interval between the sending of a proposal at a correct process, and the reception of the proposal at any correct process is upper bounded by `MSGDELAY`.
    55  
    56  #### **[PBTS-RECEPTION-STEP.1]**
    57  
    58  Let `now_p` be the time, read from the clock of process `p`, at which `p` receives the proposed value `v`.
    59  The proposal is considered `timely` by `p` when:
    60  
    61  1. `now_p >= v.time - PRECISION`
    62  1. `now_p <= v.time + MSGDELAY + PRECISION`
    63  
    64  The first condition derives from the fact that the generation and sending of `v` precedes its reception.
    65  The minimum receiving time `now_p` for `v` be considered `timely` by `p` is derived from the extreme scenario when
    66  the clock of `p` is `PRECISION` *behind* of the clock of the proposer of `v`, and the proposal's transmission delay is `0` (minimum).
    67  
    68  The second condition derives from the assumption of an upper bound for the transmission delay of a proposal.
    69  The maximum receiving time `now_p` for `v` be considered `timely` by `p` is derived from the extreme scenario when
    70  the clock of `p` is `PRECISION` *ahead* of the clock of the proposer of `v`, and the proposal's transmission delay is `MSGDELAY` (maximum).
    71  
    72  ## Updated Consensus Algorithm
    73  
    74  The following changes are proposed for the algorithm in the [arXiv paper][arXiv].
    75  
    76  #### New `StartRound`
    77  
    78  There are two additions to the `propose` round step when executed by the `proposer` of a round:
    79  
    80  1. to ensure time monotonicity, the proposer does not propose a value until its current local time becomes greater than the previously decided value's time
    81  1. when the proposer produce a new proposal it sets the proposal's time to its current local time
    82     - no changes are made to the logic when a proposer has a non-nil `validValue`, which retains its original proposal time.
    83  
    84  #### **[PBTS-ALG-STARTROUND.1]**
    85  
    86  ```go
    87  function StartRound(round) {
    88   round_p ← round
    89   step_p ← propose
    90   if proposer(h_p, round_p) = p {
    91    wait until now_p > decision_p[h_p-1].time // time monotonicity
    92    if validValue_p != nil {
    93     proposal ← validValue_p
    94    } else {
    95     proposal ← getValue()
    96     proposal.time ← now_p // proposal time
    97    }
    98     broadcast ⟨PROPOSAL, h_p, round_p, proposal, validRound_p⟩
    99   } else {
   100    schedule OnTimeoutPropose(h_p,round_p) to be executed after timeoutPropose(round_p)
   101   }
   102  }
   103  ```
   104  
   105  #### New Rule Replacing Lines 22 - 27
   106  
   107  The rule on line 22 applies to values `v` proposed for the first time, i.e., for proposals not backed by `2f + 1 PREVOTE`s for `v` in a previous round.
   108  The `PROPOSAL` message, in this case, carry `-1` in its `validRound` field.
   109  
   110  The new rule for issuing a `PREVOTE` for a proposed value `v` requires the value to be `timely`.
   111  As the `timely` predicate is evaluated in the moment that the value is received,
   112  as part of a `PROPOSAL` message, we require the `PROPOSAL` message to be `timely`.
   113  
   114  #### **[PBTS-ALG-UPON-PROP.1]**
   115  
   116  ```go
   117  upon timely(⟨PROPOSAL, h_p, round_p, v, −1⟩) from proposer(h_p, round_p) while step_p = propose do {
   118    if valid(v) ∧ (lockedRound_p = −1 ∨ lockedValue_p = v) {
   119      broadcast ⟨PREVOTE, h_p, round_p, id(v)⟩ 
   120    }
   121    else {
   122      broadcast ⟨PREVOTE, h_p, round_p, nil⟩ 
   123    }
   124    step_p ← prevote
   125  }
   126  ```
   127  
   128  #### Rules at Lines 28 - 33 remain unchanged
   129  
   130  The rule on line 28 applies to values `v` proposed again in the current round because its proposer received `2f + 1 PREVOTE`s for `v` in a previous round `vr`.
   131  This means that there was a round `r <= vr` in which `2f + 1` processes accepted `v` for the first time, and so sent `PREVOTE`s for `v`.
   132  Which, in turn, means that these processes executed the line 22 of the algorithm, and therefore judged `v` as a `timely` proposal.
   133  
   134  In other words, we don't need to verify whether `v` is a timely proposal because at least `f + 1` processes judged `v` as `timely` in a previous round,
   135  and because, since `v` was re-proposed as a `validValue` (line 16), `v.time` has not being updated from its original proposal.
   136  
   137  **All other rules remains unchanged.**
   138  
   139  Back to [main document][main].
   140  
   141  [main]: ./README.md
   142  
   143  [algorithm_v1]: ./v1/pbts-algorithm_001_draft.md
   144  
   145  [sysmodel]: ./pbts-sysmodel_002_draft.md
   146  
   147  [bfttime]: https://github.com/tendermint/tendermint/blob/master/spec/consensus/bft-time.md
   148  [arXiv]: https://arxiv.org/pdf/1807.04938.pdf