lite2: make maxClockDrift an option (#4616)

Closes #4607
This commit is contained in:
Anton Kaliaev
2020-03-31 16:33:33 +04:00
committed by GitHub
parent 5c380cdacb
commit 6c88d2ba1f
5 changed files with 66 additions and 19 deletions

View File

@@ -4,6 +4,7 @@
* 13-02-2020: Initial draft
* 26-02-2020: Cross-checking the first header
* 28-02-2020: Bisection algorithm details
* 31-03-2020: Verify signature got changed
## Context
@@ -100,6 +101,10 @@ type Store interface {
FirstSignedHeaderHeight() (int64, error)
SignedHeaderAfter(height int64) (*types.SignedHeader, error)
Prune(size uint16) error
Size() uint16
}
```
@@ -110,12 +115,13 @@ database, used in Tendermint). In the future, remote adapters are possible
```go
func Verify(
chainID string,
h1 *types.SignedHeader,
h1NextVals *types.ValidatorSet,
h2 *types.SignedHeader,
h2Vals *types.ValidatorSet,
trustedHeader *types.SignedHeader, // height=X
trustedVals *types.ValidatorSet, // height=X or height=X+1
untrustedHeader *types.SignedHeader, // height=Y
untrustedVals *types.ValidatorSet, // height=Y
trustingPeriod time.Duration,
now time.Time,
maxClockDrift time.Duration,
trustLevel tmmath.Fraction) error {
```
@@ -124,6 +130,9 @@ 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.
While `Verify` function is certainly handy, `VerifyAdjacent` and
`VerifyNonAdjacent` should be used most often to avoid logic errors.
### Bisection algorithm details
Non-recursive bisection algorithm was implemented despite the spec containing