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.

105 lines
3.6 KiB

  1. # Synopsis
  2. A TLA+ specification of a simplified Tendermint consensus, tuned for
  3. fork accountability. The simplifications are as follows:
  4. - the procotol runs for one height, that is, one-shot consensus
  5. - this specification focuses on safety, so timeouts are modelled with
  6. with non-determinism
  7. - the proposer function is non-determinstic, no fairness is assumed
  8. - the messages by the faulty processes are injected right in the initial states
  9. - every process has the voting power of 1
  10. - hashes are modelled as identity
  11. Having the above assumptions in mind, the specification follows the pseudo-code
  12. of the Tendermint paper: <https://arxiv.org/abs/1807.04938>
  13. Byzantine processes can demonstrate arbitrary behavior, including
  14. no communication. However, we have to show that under the collective evidence
  15. collected by the correct processes, at least `f+1` Byzantine processes demonstrate
  16. one of the following behaviors:
  17. - Equivocation: a Byzantine process sends two different values
  18. in the same round.
  19. - Amnesia: a Byzantine process locks a value, although it has locked
  20. another value in the past.
  21. # TLA+ modules
  22. - [TendermintAcc_004_draft](TendermintAcc_004_draft.tla) is the protocol
  23. specification,
  24. - [TendermintAccInv_004_draft](TendermintAccInv_004_draft.tla) contains an
  25. inductive invariant for establishing the protocol safety as well as the
  26. forking cases,
  27. - `MC_n<n>_f<f>`, e.g., [MC_n4_f1](MC_n4_f1.tla), contains fixed constants for
  28. model checking with the [Apalache model
  29. checker](https://github.com/informalsystems/apalache),
  30. - [TendermintAccTrace_004_draft](TendermintAccTrace_004_draft.tla) shows how
  31. to restrict the execution space to a fixed sequence of actions (e.g., to
  32. instantiate a counterexample),
  33. - [TendermintAccDebug_004_draft](TendermintAccDebug_004_draft.tla) contains
  34. the useful definitions for debugging the protocol specification with TLC and
  35. Apalache.
  36. # Reasoning about fork scenarios
  37. The theorem statements can be found in
  38. [TendermintAccInv_004_draft.tla](TendermintAccInv_004_draft.tla).
  39. First, we would like to show that `TypedInv` is an inductive invariant.
  40. Formally, the statement looks as follows:
  41. ```tla
  42. THEOREM TypedInvIsInductive ==
  43. \/ FaultyQuorum
  44. \//\ Init => TypedInv
  45. /\ TypedInv /\ [Next]_vars => TypedInv'
  46. ```
  47. When over two-thirds of processes are faulty, `TypedInv` is not inductive.
  48. However, there is no hope to repair the protocol in this case. We run
  49. [Apalache](https://github.com/informalsystems/apalache) to prove this theorem
  50. only for fixed instances of 4 to 5 validators. Apalache does not parse theorem
  51. statements at the moment, so we ran Apalache using a shell script. To find a
  52. parameterized argument, one has to use a theorem prover, e.g., TLAPS.
  53. Second, we would like to show that the invariant implies `Agreement`, that is,
  54. no fork, provided that less than one third of processes is faulty. By combining
  55. this theorem with the previous theorem, we conclude that the protocol indeed
  56. satisfies Agreement under the condition `LessThanThirdFaulty`.
  57. ```tla
  58. THEOREM AgreementWhenLessThanThirdFaulty ==
  59. LessThanThirdFaulty /\ TypedInv => Agreement
  60. ```
  61. Third, in the general case, we either have no fork, or two fork scenarios:
  62. ```tla
  63. THEOREM AgreementOrFork ==
  64. ~FaultyQuorum /\ TypedInv => Accountability
  65. ```
  66. # Model checking results
  67. Check the report on [model checking with Apalache](./results/001indinv-apalache-report.md).
  68. To run the model checking experiments, use the script:
  69. ```console
  70. ./run.sh
  71. ```
  72. This script assumes that the apalache build is available in
  73. `~/devl/apalache-unstable`.