explain trustLevel and trustLevelAdj

also

- add trustLevelAdj param to SequentialVerification
- rename LinearVerification to SequentialVerification
This commit is contained in:
Anton Kaliaev 2019-08-26 16:13:05 +04:00
parent a79a325011
commit 91f66592f3
No known key found for this signature in database
GPG Key ID: 7B6881D965918214

View File

@ -144,12 +144,24 @@ IBC, it will be a `ibc` provider, receiving information from IBC transactions.
Once we have the information, we need to verify it.
```go
type mode int
const (
sequential mode = iota
bisecting
)
// default mode - DefaultBisectingVerification
type Verifier struct {
chainID string
options TrustOptions
lastVerifiedHeight int64
logger log.Logger
mode mode
trustLevel float
trustLevelAdj float
// Already validated, stored locally
trusted PersistentProvider
@ -171,23 +183,41 @@ Verifier should use bisection by default, but provide options to choose a
different mode OR tweak bisection.
```go
func LinearVerification() Option {
// trustLevelAdj - maximum change between two consequitive headers in terms of
// validators & their respective voting power, required to trust a new header.
func SequentialVerification(trustLevelAdj float) Option {
if trustLevelAdj > 1 || trustLevelAdj < 1/3 {
panic(fmt.Sprintf("trustLevelAdj must be within [1/3, 1], given %v, %v", trustLevel, trustLevelAdj))
}
return func(v *Verifier) {
v.mode = LINEAR
v.mode = sequential
v.trustLevelAdj = trustLevelAdj
}
}
// trustLevel - maximum change between two headers in terms of validators &
// their respective voting power, required to trust a new header (default:
// 1/3).
//
// trustLevelAdj - maximum change between two consequitive headers in terms of
// validators & their respective voting power, required to trust a new header
// (default: 2/3).
func BisectingVerification(trustLevel, trustLevelAdj float) Option {
if trustLevel > 1 || trustLevel < 1/3 || trustLevelAdj > 1 || trustLevelAdj < 1/3 {
panic(fmt.Sprintf("trustLevel, trustLevelAdj must be within [1/3, 1], given %v, %v", trustLevel, trustLevelAdj))
}
return func(v *Verifier) {
v.mode = BISECTION
v.mode = bisecting
v.trustLevel = trustLevel
v.trustLevelAdj = trustLevelAdj
}
}
var DefaultBisectingVerification = func() Option {
return BisectingVerification(1/3, 2/3)
}
```
Once we verified the header, we will need to store it somewhere.