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.

157 lines
7.2 KiB

  1. # Proposer-Based Timestamps (PBTS)
  2. This section describes a version of the Tendermint consensus protocol
  3. that uses proposer-based timestamps.
  4. ## Context
  5. Tendermint provides a deterministic, Byzantine fault-tolerant, source of time,
  6. defined by the `Time` field present in the headers of committed blocks.
  7. In the current consensus implementation, the timestamp of a block is
  8. computed by the [`BFTTime`][bfttime] algorithm:
  9. - Validators include a timestamp in the `Precommit` messages they broadcast.
  10. Timestamps are retrieved from the validators' local clocks,
  11. with the only restriction that they must be **monotonic**:
  12. - The timestamp of a `Precommit` message voting for a block
  13. cannot be earlier than the `Time` field of that block;
  14. - The timestamp of a block is deterministically computed from the timestamps of
  15. a set of `Precommit` messages that certify the commit of the previous block.
  16. This certificate, a set of `Precommit` messages from a round of the previous height,
  17. is selected by the block's proposer and stored in the `Commit` field of the block:
  18. - The block timestamp is the *median* of the timestamps of the `Precommit` messages
  19. included in the `Commit` field, weighted by their voting power.
  20. Block timestamps are **monotonic** because
  21. timestamps of valid `Precommit` messages are monotonic;
  22. Assuming that the voting power controlled by Byzantine validators is bounded by `f`,
  23. the cumulative voting power of any valid `Commit` set must be at least `2f+1`.
  24. As a result, the timestamp computed by `BFTTime` is not influenced by Byzantine validators,
  25. as the weighted median of `Commit` timestamps comes from the clock of a non-faulty validator.
  26. Tendermint does not make any assumptions regarding the clocks of (correct) validators,
  27. as block timestamps have no impact in the consensus protocol.
  28. However, the `Time` field of committed blocks is used by other components of Tendermint,
  29. such as IBC, the evidence, staking, and slashing modules.
  30. And it is used based on the common belief that block timestamps
  31. should bear some resemblance to real time, which is **not guaranteed**.
  32. A more comprehensive discussion of the limitations of `BFTTime`
  33. can be found in the [first draft][main_v1] of this proposal.
  34. Of particular interest is to possibility of having validators equipped with "faulty" clocks,
  35. not fairly accurate with real time, that control more than `f` voting power,
  36. plus the proposer's flexibility when selecting a `Commit` set,
  37. and thus determining the timestamp for a block.
  38. ## Proposal
  39. In the proposed solution, the timestamp of a block is assigned by its
  40. proposer, according with its local clock.
  41. In other words, the proposer of a block also *proposes* a timestamp for the block.
  42. Validators can accept or reject a proposed block.
  43. A block is only accepted if its timestamp is acceptable.
  44. A proposed timestamp is acceptable if it is *received* within a certain time window,
  45. determined by synchronous parameters.
  46. PBTS therefore augments the system model considered by Tendermint with *synchronous assumptions*:
  47. - **Synchronized clocks**: simultaneous clock reads at any two correct validators
  48. differ by at most `PRECISION`;
  49. - **Bounded message delays**: the end-to-end delay for delivering a message to all correct validators
  50. is bounded by `MSGDELAY`.
  51. This assumption is restricted to `Proposal` messages, broadcast by proposers.
  52. `PRECISION` and `MSGDELAY` are consensus parameters, shared by all validators,
  53. that define whether the timestamp of a block is acceptable.
  54. Let `t` be the time, read from its local clock, at which a validator
  55. receives, for the first time, a proposal with timestamp `ts`:
  56. - **[Time-Validity]** The proposed timestamp `ts` received at local time `t`
  57. is accepted if it satisfies the **timely** predicate:
  58. > `ts - PRECISION <= t <= ts + MSGDELAY + PRECISION`
  59. The left inequality of the *timely* predicate establishes that proposed timestamps
  60. should be in the past, when adjusted by the clocks `PRECISION`.
  61. The right inequality of the *timely* predicate establishes that proposed timestamps
  62. should not be too much in the past, more precisely, not more than `MSGDELAY` in the past,
  63. when adjusted by the clocks `PRECISION`.
  64. A more detailed and formalized description is available in the
  65. [System Model and Properties][sysmodel] document
  66. ## Implementation
  67. The implementation of PBTS requires some changes in Tendermint consensus algorithm,
  68. summarized below:
  69. - A proposer timestamps a block with the current time, read from its local clock.
  70. The block's timestamp represents the time at which it was assembled
  71. (after the `getValue()` call in line 18 of the [arXiv][arXiv] algorithm):
  72. - Block timestamps are definitive, meaning that the original timestamp
  73. is retained when a block is re-proposed (line 16);
  74. - To preserve monotonicity, a proposer might need to wait until its clock
  75. reads a time greater than the timestamp of the previous block;
  76. - A validator only prevotes for *timely* blocks,
  77. that is, blocks whose timestamps are considered *timely* (compared to the original Tendermint consensus, a check is added to line 23).
  78. If the block proposed in a round is considered *untimely*,
  79. the validator prevotes `nil` (line 26):
  80. - Validators register the time at which they received `Proposal` messages,
  81. in order to evaluate the *timely* predicate;
  82. - Blocks that are re-proposed because they received `2f+1 Prevotes`
  83. in a previous round (line 28) are not subject to the *timely* predicate,
  84. as they have already been evaluated as *timely* at a previous round.
  85. The more complex change proposed regards blocks that can be re-proposed in multiple rounds.
  86. The current solution improves the [first version of the specification][algorithm_v1] (that never had been implemented)
  87. by simplifying the way this situation is handled,
  88. from a recursive reasoning regarding valid blocks that are re-proposed.
  89. The full solution is detailed and formalized in the [Protocol Specification][algorithm] document.
  90. ## Further details
  91. - [System Model and Properties][sysmodel]
  92. - [Protocol Specification][algorithm]
  93. - [TLA+ Specification][proposertla] (first draft, not updated)
  94. ### Open issues
  95. - [PBTS: evidence #355][issue355]: not really clear the context, probably not going to be solved.
  96. - [PBTS: should synchrony parameters be adaptive? #371][issue371]
  97. - [PBTS: Treat proposal and block parts explicitly in the spec #372][issue372]
  98. - [PBTS: margins for proposal times assigned by Byzantine proposers #377][issue377]
  99. ### Closed issues
  100. - [Proposer time - fix message filter condition #353][issue353]
  101. - [PBTS: association between timely predicate and timeout_commit #370][issue370]
  102. [main_v1]: ./v1/pbts_001_draft.md
  103. [algorithm]: ./pbts-algorithm_002_draft.md
  104. [algorithm_v1]: ./v1/pbts-algorithm_001_draft.md
  105. [sysmodel]: ./pbts-sysmodel_002_draft.md
  106. [sysmodel_v1]: ./v1/pbts-sysmodel_001_draft.md
  107. [proposertla]: ./tla/TendermintPBT_001_draft.tla
  108. [bfttime]: https://github.com/tendermint/tendermint/blob/master/spec/consensus/bft-time.md
  109. [arXiv]: https://arxiv.org/pdf/1807.04938.pdf
  110. [issue353]: https://github.com/tendermint/spec/issues/353
  111. [issue355]: https://github.com/tendermint/spec/issues/355
  112. [issue370]: https://github.com/tendermint/spec/issues/370
  113. [issue371]: https://github.com/tendermint/spec/issues/371
  114. [issue372]: https://github.com/tendermint/spec/issues/372
  115. [issue377]: https://github.com/tendermint/spec/issues/377