47 releases (21 breaking)

new 0.36.0 Apr 25, 2024
0.35.0 Mar 14, 2024
0.34.1 Feb 22, 2024
0.34.0 Oct 2, 2023
0.15.0 Jul 20, 2020

#650 in Magic Beans

Download history 1343/week @ 2024-01-03 1941/week @ 2024-01-10 2328/week @ 2024-01-17 2635/week @ 2024-01-24 1792/week @ 2024-01-31 1356/week @ 2024-02-07 1817/week @ 2024-02-14 2104/week @ 2024-02-21 1851/week @ 2024-02-28 2253/week @ 2024-03-06 2043/week @ 2024-03-13 1825/week @ 2024-03-20 1173/week @ 2024-03-27 2101/week @ 2024-04-03 2352/week @ 2024-04-10 1355/week @ 2024-04-17

7,201 downloads per month
Used in 7 crates (4 directly)

Apache-2.0

1.5MB
22K SLoC

Crate Docs

See the repo root for build status, license, rust version, etc.

Light-Client

Implementation of the Light Client Verification and [Attack Detection][light-client-detection] protocols.

Documentation

See documentation on docs.rs.

Testing

The Tendermint Light Client is primarily tested through unit tests.

Core Verification

The logic for the core verification of light blocks is entirely self-contained in the predicates module. This code is exercised through unit tests which test each predicate in isolation by giving it a set of data along with the expected outcome of each check.

The following command can be used to run only these tests:

cargo test -p tendermint-light-client predicates

Model-based tests

We started to employ model-based testing (MBT), which is currently limited to the core verification. In MBT, the testing procedure is based on the Light Client formal model, and the tests themselves are simple assertions in the modeling language TLA+. The current set of TLA+ tests is translated automatically into the set of JSON fixtures.

The following command can be used to run only these tests:

$ cargo test -p tendermint-light-client --test model_based -- --nocapture

Please refer to the MBT Guide, and the MBT Abstract for further information.

Bisection

Similarly to the core verification logic, the algorithm for performing bisecting verification is exercised via a set of JSON fixtures which encode an initial trusted state, a target block to verify, a set of intermediary blocks, and the expected result of the bisection algorithm.

These tests target the light_client module, and can be found in the tests/light_client.rs file.

To run the tests:

$ cargo test -p tendermint-light-client --test light_client bisection

Attack Detection

Please see the light-client-detector crate.

Voting Power Calculator

The voting power calculator is exercised through unit tests which rely on JSON fixtures to provide the calculator with various types of light blocks together with the expected result of the computation.

The following command can be used to run only these tests:

$ cargo test -p tendermint-light-client voting_power

Integration Tests

This project also includes simple integration test which spawns a light client instance against a single Tendermint full node which acts both as a primary peer and as its own witness.

Because this test requires a running Tendermint node, it is ignored by default. To run this test locally:

# In one terminal
$ mkdir -p /tmp/tendermint
$ docker run -it --rm -v "/tmp/tendermint:/tendermint" tendermint/tendermint init
$ docker run -it --rm -v "/tmp/tendermint:/tendermint" -p 26657:26657 tendermint/tendermint node --proxy_app=kvstore

# In another terminal
$ cargo test -p tendermint-light-client --test integration -- --ignored --nocapture

Other tests

A few core datastructures, such as the PeerList implementation, come with unit tests located in the same module as the implementation.

To run these tests together with all tests described above:

$ cargo test -p tendermint-light-client --all-features

Dependencies

~12–29MB
~450K SLoC