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.

205 lines
9.2 KiB

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