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.

206 lines
9.2 KiB

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