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.

93 lines
4.4 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 three components:
  11. - Commit Verification - verify signed headers and associated validator set changes from a single full node
  12. - Fork Detection - verify commits across multiple full nodes and detect conflicts (ie. the existence of forks)
  13. - Fork Accountability - given a fork, which validators are responsible for it.
  14. ## Commit Verification
  15. The [English specification](verification/verification_001_published.md) describes the light client
  16. commit verification problem in terms of the temporal properties
  17. [LCV-DIST-SAFE.1](https://github.com/informalsystems/tendermint-rs/blob/master/docs/spec/lightclient/verification/verification_001_published.md#lcv-dist-safe1) and
  18. [LCV-DIST-LIVE.1](https://github.com/informalsystems/tendermint-rs/blob/master/docs/spec/lightclient/verification/verification_001_published.md#lcv-dist-live1).
  19. Commit verification is assumed to operate within the Tendermint Failure Model, where +2/3 of validators are correct for some time period and
  20. validator sets can change arbitrarily at each height.
  21. A light client protocol is also provided, including all checks that
  22. need to be performed on headers, commits, and validator sets
  23. to satisfy the temporal properties - so a light client can continuously
  24. synchronize with a blockchain. Clients can skip possibly
  25. many intermediate headers by exploiting overlap in trusted and untrusted validator sets.
  26. When there is not enough overlap, a bisection routine can be used to find a
  27. minimal set of headers that do provide the required overlap.
  28. The [TLA+ specification](verification/Lightclient_A_1.tla) is a formal description of the
  29. commit verification protocol executed by a client, including the safety and
  30. liveness properties, which can be model checked with Apalache.
  31. The `MC*.tla` files contain concrete parameters for the
  32. [TLA+ specification](verification/Lightclient_A_1.tla), in order to do model checking.
  33. For instance, [MC4_3_faulty.tla](verification/MC4_3_faulty.tla) contains the following parameters
  34. for the nodes, heights, the trusting period, and correctness of the primary node:
  35. ```tla
  36. AllNodes == {"n1", "n2", "n3", "n4"}
  37. TRUSTED_HEIGHT == 1
  38. TARGET_HEIGHT == 3
  39. TRUSTING_PERIOD == 1400 \* two weeks, one day is 100 time units :-)
  40. IS_PRIMARY_CORRECT == FALSE
  41. ```
  42. 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:
  43. ```sh
  44. $DIR/apalache-tests/scripts/mk-run.py --memlimit 28 001bmc-apalache.csv $DIR/apalache . out
  45. ./out/run-all.sh
  46. ```
  47. After the experiments have finished, you can collect the logs by executing the following command:
  48. ```sh
  49. cd ./out
  50. $DIR/apalache-tests/scripts/parse-logs.py --human .
  51. ```
  52. The following table summarizes the experimental results. The TLA+ properties can be found in the
  53. [TLA+ specification](verification/Lightclient_A_1.tla).
  54. The experiments were run in an AWS instance equipped with 32GB
  55. RAM and a 4-core Intel® Xeon® CPU E5-2686 v4 @ 2.30GHz CPU.
  56. We write “✗=k” when a bug is reported at depth k, and “✓<=k” when
  57. no bug is reported up to depth k.
  58. ![Experimental results](experiments.png)
  59. ## Attack Detection
  60. This is a work-in-progress draft.
  61. The [English specification](detection/detection_001_reviewed.md)
  62. defines blockchain forks and light client attacks, and describes
  63. the problem of a light client detecting them from communication with a network
  64. of full nodes, where at least one is correct.
  65. There is no TLA+ yet.
  66. ## Fork Accountability
  67. There is no English specification yet. TODO: Jovan's work?
  68. TODO: there is a WIP [TLA+
  69. specification](https://github.com/informalsystems/verification/pull/13) in the
  70. verification repo that should be moved over here.