mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-29 06:01:21 +00:00
explain trustLevel and trustLevelAdj
also - add trustLevelAdj param to SequentialVerification - rename LinearVerification to SequentialVerification
This commit is contained in:
parent
a79a325011
commit
91f66592f3
@ -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.
|
Once we have the information, we need to verify it.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
|
type mode int
|
||||||
|
|
||||||
|
const (
|
||||||
|
sequential mode = iota
|
||||||
|
bisecting
|
||||||
|
)
|
||||||
|
|
||||||
|
// default mode - DefaultBisectingVerification
|
||||||
type Verifier struct {
|
type Verifier struct {
|
||||||
chainID string
|
chainID string
|
||||||
options TrustOptions
|
options TrustOptions
|
||||||
lastVerifiedHeight int64
|
lastVerifiedHeight int64
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
|
|
||||||
|
mode mode
|
||||||
|
trustLevel float
|
||||||
|
trustLevelAdj float
|
||||||
|
|
||||||
// Already validated, stored locally
|
// Already validated, stored locally
|
||||||
trusted PersistentProvider
|
trusted PersistentProvider
|
||||||
|
|
||||||
@ -171,23 +183,41 @@ Verifier should use bisection by default, but provide options to choose a
|
|||||||
different mode OR tweak bisection.
|
different mode OR tweak bisection.
|
||||||
|
|
||||||
```go
|
```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) {
|
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 {
|
func BisectingVerification(trustLevel, trustLevelAdj float) Option {
|
||||||
if trustLevel > 1 || trustLevel < 1/3 || trustLevelAdj > 1 || trustLevelAdj < 1/3 {
|
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))
|
panic(fmt.Sprintf("trustLevel, trustLevelAdj must be within [1/3, 1], given %v, %v", trustLevel, trustLevelAdj))
|
||||||
}
|
}
|
||||||
|
|
||||||
return func(v *Verifier) {
|
return func(v *Verifier) {
|
||||||
v.mode = BISECTION
|
v.mode = bisecting
|
||||||
v.trustLevel = trustLevel
|
v.trustLevel = trustLevel
|
||||||
v.trustLevelAdj = trustLevelAdj
|
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.
|
Once we verified the header, we will need to store it somewhere.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user