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.

202 lines
9.2 KiB

  1. # Light Client Specification
  2. This directory contains work-in-progress English and TLA+ specifications for the Light Client
  3. protocol. Implementations of the light client can be found in
  4. [Rust](https://github.com/informalsystems/tendermint-rs/tree/master/light-client) and
  5. [Go](https://github.com/tendermint/tendermint/tree/master/light).
  6. Light clients are assumed to be initialized once from a trusted source
  7. with a trusted header and validator set. The light client
  8. protocol allows a client to then securely update its trusted state by requesting and
  9. verifying a minimal set of data from a network of full nodes (at least one of which is correct).
  10. The light client is decomposed into two main components:
  11. - [Commit Verification](#Commit-Verification) - verify signed headers and associated validator
  12. set changes from a single full node, called primary
  13. - [Attack Detection](#Attack-Detection) - verify commits across multiple full nodes (called secondaries) and detect conflicts (ie. the existence of a lightclient attack)
  14. In case a lightclient attack is detected, the lightclient submits evidence to a full node which is responsible for "accountability", that is, punishing attackers:
  15. - [Accountability](#Accountability) - given evidence for an attack, compute a set of validators that are responsible for it.
  16. ## Commit Verification
  17. The [English specification](verification/verification_001_published.md) describes the light client
  18. commit verification problem in terms of the temporal properties
  19. [LCV-DIST-SAFE.1](https://github.com/informalsystems/tendermint-rs/blob/master/docs/spec/lightclient/verification/verification_001_published.md#lcv-dist-safe1) and
  20. [LCV-DIST-LIVE.1](https://github.com/informalsystems/tendermint-rs/blob/master/docs/spec/lightclient/verification/verification_001_published.md#lcv-dist-live1).
  21. Commit verification is assumed to operate within the Tendermint Failure Model, where +2/3 of validators are correct for some time period and
  22. validator sets can change arbitrarily at each height.
  23. A light client protocol is also provided, including all checks that
  24. need to be performed on headers, commits, and validator sets
  25. to satisfy the temporal properties - so a light client can continuously
  26. synchronize with a blockchain. Clients can skip possibly
  27. many intermediate headers by exploiting overlap in trusted and untrusted validator sets.
  28. When there is not enough overlap, a bisection routine can be used to find a
  29. minimal set of headers that do provide the required overlap.
  30. The [TLA+ specification ver. 001](verification/Lightclient_A_1.tla)
  31. is a formal description of the
  32. commit verification protocol executed by a client, including the safety and
  33. termination, which can be model checked with Apalache.
  34. A more detailed TLA+ specification of
  35. [Light client verification ver. 003](verification/Lightclient_003_draft.tla)
  36. is currently under peer review.
  37. The `MC*.tla` files contain concrete parameters for the
  38. [TLA+ specification](verification/Lightclient_A_1.tla), in order to do model checking.
  39. For instance, [MC4_3_faulty.tla](verification/MC4_3_faulty.tla) contains the following parameters
  40. for the nodes, heights, the trusting period, the clock drifts,
  41. correctness of the primary node, and the ratio of the faulty processes:
  42. ```tla
  43. AllNodes == {"n1", "n2", "n3", "n4"}
  44. TRUSTED_HEIGHT == 1
  45. TARGET_HEIGHT == 3
  46. TRUSTING_PERIOD == 1400 \* the trusting period in some time units
  47. CLOCK_DRIFT = 10 \* how much we assume the local clock is drifting
  48. REAL_CLOCK_DRIFT = 3 \* how much the local clock is actually drifting
  49. IS_PRIMARY_CORRECT == FALSE
  50. FAULTY_RATIO == <<1, 3>> \* < 1 / 3 faulty validators
  51. ```
  52. To run a complete set of experiments, clone [apalache](https://github.com/informalsystems/apalache) and [apalache-tests](https://github.com/informalsystems/apalache-tests) into a directory `$DIR` and run the following commands:
  53. ```sh
  54. $DIR/apalache-tests/scripts/mk-run.py --memlimit 28 002bmc-apalache-ok.csv $DIR/apalache . out
  55. ./out/run-all.sh
  56. ```
  57. After the experiments have finished, you can collect the logs by executing the following command:
  58. ```sh
  59. cd ./out
  60. $DIR/apalache-tests/scripts/parse-logs.py --human .
  61. ```
  62. All lines in `results.csv` should report `Deadlock`, which means that the algorithm
  63. has terminated and no invariant violation was found.
  64. Similar to [002bmc-apalache-ok.csv](verification/002bmc-apalache-ok.csv),
  65. file [003bmc-apalache-error.csv](verification/003bmc-apalache-error.csv) specifies
  66. the set of experiments that should result in counterexamples:
  67. ```sh
  68. $DIR/apalache-tests/scripts/mk-run.py --memlimit 28 003bmc-apalache-error.csv $DIR/apalache . out
  69. ./out/run-all.sh
  70. ```
  71. All lines in `results.csv` should report `Error`.
  72. The following table summarizes the experimental results for Light client verification
  73. version 001. The TLA+ properties can be found in the
  74. [TLA+ specification](verification/Lightclient_A_1.tla).
  75. The experiments were run in an AWS instance equipped with 32GB
  76. RAM and a 4-core Intel® Xeon® CPU E5-2686 v4 @ 2.30GHz CPU.
  77. We write “✗=k” when a bug is reported at depth k, and “✓<=k” when
  78. no bug is reported up to depth k.
  79. ![Experimental results](experiments.png)
  80. The experimental results for version 003 are to be added.
  81. ## Attack Detection
  82. The [English specification](detection/detection_003_reviewed.md)
  83. defines light client attacks (and how they differ from blockchain
  84. forks), and describes the problem of a light client detecting
  85. these attacks by communicating with a network of full nodes,
  86. where at least one is correct.
  87. The specification also contains a detection protocol that checks
  88. whether the header obtained from the primary via the verification
  89. protocol matches corresponding headers provided by the secondaries.
  90. If this is not the case, the protocol analyses the verification traces
  91. of the involved full nodes
  92. and generates
  93. [evidence](detection/detection_003_reviewed.md#tmbc-lc-evidence-data1)
  94. of misbehavior that can be submitted to a full node so that
  95. the faulty validators can be punished.
  96. The [TLA+ specification](detection/LCDetector_003_draft.tla)
  97. is a formal description of the
  98. detection protocol for two peers, including the safety and
  99. termination, which can be model checked with Apalache.
  100. The `LCD_MC*.tla` files contain concrete parameters for the
  101. [TLA+ specification](detection/LCDetector_003_draft.tla),
  102. in order to run the model checker.
  103. For instance, [LCD_MC4_4_faulty.tla](detection/MC4_4_faulty.tla)
  104. contains the following parameters
  105. for the nodes, heights, the trusting period, the clock drifts,
  106. correctness of the nodes, and the ratio of the faulty processes:
  107. ```tla
  108. AllNodes == {"n1", "n2", "n3", "n4"}
  109. TRUSTED_HEIGHT == 1
  110. TARGET_HEIGHT == 3
  111. TRUSTING_PERIOD == 1400 \* the trusting period in some time units
  112. CLOCK_DRIFT = 10 \* how much we assume the local clock is drifting
  113. REAL_CLOCK_DRIFT = 3 \* how much the local clock is actually drifting
  114. IS_PRIMARY_CORRECT == FALSE
  115. IS_SECONDARY_CORRECT == FALSE
  116. FAULTY_RATIO == <<1, 3>> \* < 1 / 3 faulty validators
  117. ```
  118. To run a complete set of experiments, clone [apalache](https://github.com/informalsystems/apalache) and [apalache-tests](https://github.com/informalsystems/apalache-tests) into a directory `$DIR` and run the following commands:
  119. ```sh
  120. $DIR/apalache-tests/scripts/mk-run.py --memlimit 28 004bmc-apalache-ok.csv $DIR/apalache . out
  121. ./out/run-all.sh
  122. ```
  123. After the experiments have finished, you can collect the logs by executing the following command:
  124. ```sh
  125. cd ./out
  126. $DIR/apalache-tests/scripts/parse-logs.py --human .
  127. ```
  128. All lines in `results.csv` should report `Deadlock`, which means that the algorithm
  129. has terminated and no invariant violation was found.
  130. Similar to [004bmc-apalache-ok.csv](verification/004bmc-apalache-ok.csv),
  131. file [005bmc-apalache-error.csv](verification/005bmc-apalache-error.csv) specifies
  132. the set of experiments that should result in counterexamples:
  133. ```sh
  134. $DIR/apalache-tests/scripts/mk-run.py --memlimit 28 005bmc-apalache-error.csv $DIR/apalache . out
  135. ./out/run-all.sh
  136. ```
  137. All lines in `results.csv` should report `Error`.
  138. The detailed experimental results are to be added soon.
  139. ## Accountability
  140. The [English specification](attacks/isolate-attackers_002_reviewed.md)
  141. defines the protocol that is executed on a full node upon receiving attack [evidence](detection/detection_003_reviewed.md#tmbc-lc-evidence-data1) from a lightclient. In particular, the protocol handles three types of attacks
  142. - lunatic
  143. - equivocation
  144. - amnesia
  145. We discussed in the [last part](attacks/isolate-attackers_002_reviewed.md#Part-III---Completeness) of the English specification
  146. that the non-lunatic cases are defined by having the same validator set in the conflicting blocks. For these cases,
  147. computer-aided analysis of [Tendermint Consensus in TLA+][tendermint-accountability] shows that equivocation and amnesia capture all non-lunatic attacks.
  148. The [TLA+ specification](attacks/Isolation_001_draft.tla)
  149. is a formal description of the
  150. protocol, including the safety property, which can be model checked with Apalache.
  151. Similar to the other specifications, [MC_5_3.tla](attacks/MC_5_3.tla) contains concrete parameters to run the model checker. The specification can be checked within seconds.
  152. [tendermint-accountability]:
  153. https://github.com/tendermint/spec/blob/master/rust-spec/tendermint-accountability/README.md