Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Update specification of light client algorithm to align with the code #61

Merged
merged 23 commits into from
Jan 23, 2020
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a4b68ec
Add non-recursive specification of Bisection algorithm
milosevic Nov 15, 2019
4ee393c
Clean up error conditions and simplify pseudocode
milosevic Nov 28, 2019
2306108
Apply suggestions from code review
milosevic Dec 2, 2019
afda2d3
some suggestions for pseuodocode changes
Dec 6, 2019
5c58084
Improved error handling
milosevic Dec 6, 2019
069906a
Improve algorithms
milosevic Dec 11, 2019
9ddfc79
Add explanation on difference between trusted models
milosevic Dec 11, 2019
8528cdb
Merge remote-tracking branch 'remotes/origin/master' into zm_lite_cli…
milosevic Dec 11, 2019
4f7c555
Address reviewer's comments
milosevic Dec 12, 2019
ee0cc53
Addressing reviewer's comments
milosevic Dec 25, 2019
0adde9d
Separating algorithm from proofs
milosevic Dec 26, 2019
4a9eb1f
Intermediate commit (aligning spec with the code)
milosevic Dec 31, 2019
7130c2e
Removing Store from API and providing end-to-end timing guarantees
milosevic Jan 6, 2020
146e251
Address reviewer comment's. Intermediate commit
milosevic Jan 8, 2020
f26eb4e
light client dir and readmes
ebuchman Jan 22, 2020
eb9e1f9
titles
ebuchman Jan 22, 2020
e342c21
add redirects
ebuchman Jan 22, 2020
0358389
add diagram
ebuchman Jan 22, 2020
d1bd98d
detection TODO
ebuchman Jan 22, 2020
bd2f41b
fix image
ebuchman Jan 22, 2020
c35d6e7
update readme
ebuchman Jan 22, 2020
dc54206
Merge pull request #73 from tendermint/bucky/light-reorg
milosevic Jan 23, 2020
026fdde
Aligh the correctness arguments with the pseudocode changes
milosevic Jan 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 75 additions & 42 deletions spec/consensus/light-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,33 +193,34 @@ We consider the following set-up:
we will write ```totalVotingPower(V)``` for ```votingpower_in(V,V)```, which returns the total voting power in V.
milosevic marked this conversation as resolved.
Show resolved Hide resolved
We further use the function ```signers(Commit)``` that returns the set of validators that signed the Commit.

**CheckSupport.** The following function checks whether we can trust the header h2 based on header h1 following the trusting period method.
**CheckSupport.** The following function checks whether we can trust the header h2 based on header h1 following the trusting period method. Time constraint is
captured by the `hasExpired` function that depends on trusted period (`tp`) and a parameter `Delta` that denotes minimum duration of header so it is
milosevic marked this conversation as resolved.
Show resolved Hide resolved
not considered expired.

```go
func hasExpired(h) {
if h.Header.bfttime + tp - Delta < now { // Observation 1
milosevic marked this conversation as resolved.
Show resolved Hide resolved
return true
}
milosevic marked this conversation as resolved.
Show resolved Hide resolved

// basic validation (function `verify`) has already been called on h2
milosevic marked this conversation as resolved.
Show resolved Hide resolved
func CheckSupport(h1,h2,trustlevel) bool {
if h1.Header.bfttime + tp < now { // Observation 1
return false // old header was once trusted but it is expired
}
if hasExpired(h1) then return false //old header was once trusted but it is expired
milosevic marked this conversation as resolved.
Show resolved Hide resolved

vp_all := totalVotingPower(h1.Header.NextV)
// total sum of voting power of validators in h2
// total sum of voting power of validators in h1

if h2.Header.height == h1.Header.height + 1 {
// specific check for adjacent headers; everything must be
// properly signed.
// also check that h2.Header.V == h1.Header.NextV
// Plus the following check that 2/3 of the voting power
// in h1 signed h2
return (votingpower_in(signers(h2.Commit),h1.Header.NextV) >
2/3 * vp_all)
// signing validators are more than two third in h1.
}

return (votingpower_in(signers(h2.Commit),h1.Header.NextV) >
max(1/3,trustlevel) * vp_all)
// get validators in h1 that signed h2
// sum of voting powers in h1 of
// validators that signed h2
// is more than a third in h1
// specific check for adjacent headers
if h1.Header.NextV == h2.Header.V then
milosevic marked this conversation as resolved.
Show resolved Hide resolved
return hasExpired(h2)
}
milosevic marked this conversation as resolved.
Show resolved Hide resolved
}

// validators that signed h2 are more than a third of voting power in h1
if (votingpower_in(signers(h2.Commit),h1.Header.NextV) > max(1/3,trustlevel) * vp_all) {
return hasExpired(h2)
}
}
```

Expand Down Expand Up @@ -257,28 +258,60 @@ Towards Lite Client Completeness:


```go
func Bisection(h1,h2,trustlevel) bool{
if CheckSupport(h1,h2,trustlevel) {
return true
}
if h2.Header.height == h1.Header.height + 1 {
// we have adjacent headers that are not matching (failed
// the CheckSupport)
// we could submit evidence here
return false
}
pivot := (h1.Header.height + h2.Header.height) / 2
hp := Commit(pivot)
// ask a full node for header of height pivot
Store(hp)
// store header hp locally
if Bisection(h1,hp,trustlevel) {
// only check right branch if hp is trusted
// (otherwise a lot of unnecessary computation may be done)
return Bisection(hp,h2,trustlevel)
func verify(h) {
if hasExpired(h) return false

vp_all := totalVotingPower(h.Header.V) // total sum of voting power of validators in h

if votingpower_in(signers(h.Commit),h.Header.V) > 2/3 * vp_all {
return hasExpired(h)
milosevic marked this conversation as resolved.
Show resolved Hide resolved
} else {
return false
}
else {
return false
}

milosevic marked this conversation as resolved.
Show resolved Hide resolved
func Bisection(h1,h2,trustlevel) bool{
th := h1 // th is trusted header
while th.Header.Height <= h2.Header.height do {
// try to move trusted header forward with stored headers
milosevic marked this conversation as resolved.
Show resolved Hide resolved
// we assume here that iteration will be done in order of header heights
ih := th
for all stored headers h s.t ih.Header.Height < h.Header.height < h2.Header.height do {
if CheckSupport(th,h,trustlevel) {
milosevic marked this conversation as resolved.
Show resolved Hide resolved
milosevic marked this conversation as resolved.
Show resolved Hide resolved
th = h
milosevic marked this conversation as resolved.
Show resolved Hide resolved
} else if h.Header.height == th.Header.height + 1 {
return false // fail to verify succesive headers!
} else break // for
}

if CheckSupport(th,h2,trustlevel) {
return hasExpired(h2)
}
milosevic marked this conversation as resolved.
Show resolved Hide resolved

if h2.Header.height == th.Header.height + 1 {
// we have adjacent headers that are not matching (failed the CheckSupport)
// we could submit evidence here
return false
}
milosevic marked this conversation as resolved.
Show resolved Hide resolved

// try to move th
endHeight = h2.Header.height
milosevic marked this conversation as resolved.
Show resolved Hide resolved
foundPivot = false
while(!foundPivot) {
pivot := (th.Header.height + endHeight) / 2
milosevic marked this conversation as resolved.
Show resolved Hide resolved
hp := Commit(pivot)
if !verify(hp) return false
Store(hp)
milosevic marked this conversation as resolved.
Show resolved Hide resolved

if CheckSupport(th,hd,trustlevel) {
milosevic marked this conversation as resolved.
Show resolved Hide resolved
th = hd
milosevic marked this conversation as resolved.
Show resolved Hide resolved
foundPivot = true
} else if pivot.Header.height == th.Header.height + 1 {
return false // fail to verify succesive headers!
}

endHeight = pivot
}
milosevic marked this conversation as resolved.
Show resolved Hide resolved
milosevic marked this conversation as resolved.
Show resolved Hide resolved
}
}
```
Expand Down