docs: adr-046 add bisection algorithm details (#4496)

* docs: adr-046 add bisection algorithm details

Closes #4329

* format fig. 1 title

* docs: adr-046 we no longer download headers in TrustedHeader

https://github.com/tendermint/tendermint/pull/4496#issuecomment-592446054
This commit is contained in:
Anton Kaliaev
2020-02-28 11:53:06 +01:00
committed by GitHub
parent c837a57ddd
commit a122a555de
2 changed files with 23 additions and 3 deletions

View File

@@ -3,6 +3,7 @@
## Changelog
* 13-02-2020: Initial draft
* 26-02-2020: Cross-checking the first header
* 28-02-2020: Bisection algorithm details
## Context
@@ -67,9 +68,13 @@ required to respond: 1. Note the very first header (`TrustOptions.Hash`) is
also cross-checked with witnesses for additional security.
Due to bisection algorithm nature, some headers might be skipped. If the light
client does not have a header for height `X` and `TrustedHeader(X)` or
`TrustedValidatorSet(X)` methods are called, it will download the header from
primary provider and perform a backwards verification.
client does not have a header for height `X` and `VerifyHeaderAtHeight(X)` or
`VerifyHeader(H#X)` methods are called, it will perform a backwards
verification from the latest header back to the header at height `X`.
`TrustedHeader`, `TrustedValidatorSet` only communicate with the trusted store.
If some header is not there, an error will be returned indicating that
verification is required.
```go
type Provider interface {
@@ -127,6 +132,21 @@ cases of adjacent and non-adjacent headers. In the former case, it compares the
hashes directly (2/3+ signed transition). Otherwise, it verifies 1/3+
(`trustLevel`) of trusted validators are still present in new validators.
### Bisection algorithm details
Non-recursive bisection algorithm was implemented despite the spec containing
the recursive version. There are two major reasons:
1) Constant memory consumption => no risk of getting OOM (Out-Of-Memory) exceptions;
2) Faster finality (see Fig. 1).
_Fig. 1: Differences between recursive and non-recursive bisections_
![Fig. 1](./img/adr-046-fig1.png)
Specification of the non-recursive bisection can be found
[here](https://github.com/tendermint/spec/blob/zm_non-recursive-verification/spec/consensus/light-client/non-recursive-verification.md).
## Status
Accepted.

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB