Skip to content

Add light client spec#1336

Merged
ebuchman merged 1 commit intodevelopfrom
zarko/1308-add-light-client-spec
Apr 3, 2018
Merged

Add light client spec#1336
ebuchman merged 1 commit intodevelopfrom
zarko/1308-add-light-client-spec

Conversation

@milosevic
Copy link
Contributor

No description provided.

@codecov-io
Copy link

codecov-io commented Mar 19, 2018

Codecov Report

Merging #1336 into develop will decrease coverage by 0.04%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##           develop    #1336      +/-   ##
===========================================
- Coverage    61.48%   61.43%   -0.05%     
===========================================
  Files          114      114              
  Lines        10988    10988              
===========================================
- Hits          6756     6751       -5     
- Misses        3585     3587       +2     
- Partials       647      650       +3
Impacted Files Coverage Δ
rpc/client/httpclient.go 67.53% <0%> (-1.05%) ⬇️
consensus/reactor.go 72.15% <0%> (-0.42%) ⬇️
consensus/state.go 76.75% <0%> (-0.41%) ⬇️
p2p/conn/connection.go 82.33% <0%> (-0.29%) ⬇️
blockchain/pool.go 69.44% <0%> (+1.38%) ⬆️

if isValid(signedHeader) then
setValidatorSet(signedHeader)
else return error
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missed closing "```"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

```

```

We assume that Tendermint keeps track of the validator set changes and that each time a validator set is changed it is
being assigned the next sequence number. We can this number the validator set sequence number. Tendermint also remembers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can this number the validator set sequence number. is very funky, probably needs to be grammatically corrected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a typo. It should be " We call this number the validator set sequence number".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"We can call this number ..."

validator set (modified based on transactions from block H) will be in block `H+1` (and signed by the current validator
set), and then starting from the block `H+2`, it will be signed by the next validator set.

Note that the real Tendermint RPC api is slightly different (for example, response messages contains more data and function
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API should be in caps as it is an acronym.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contains -> contain.

valSetNumber int64 // sequence number of the current validator set
valSetHash []byte // hash of the current validator set
valSetTime int64 // time when the current validator set is initialised
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improved readbility:

valSet       []Validator // current validator set (last known and verified validator set)
valSetNumber int64       // sequence number of the current validator set
valSetHash   []byte      // hash of the current validator set
valSetTime   int64       // time when the current validator set is initialised

Validators []Validator
ValSetTime int64 // time the current validator set is initialised, i.e, time of the last validator change before header BlockHeight
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve formatting:

type SignedHeader struct {
	Header       Header
	Commit       Commit
	ValSetNumber int64
}

type ResultValidators struct {
	BlockHeight int64
	Validators  []Validator
	// time the current validator set is initialised, i.e, time of the last validator change before header BlockHeight
	ValSetTime int64
}

if isValid(signedHeader) then
setValidatorSet(signedHeader)
else return error
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

```

and 2) update the validator set (when the given header is valid and it is more recent than the seen headers).

```golang
Certify(signedHeader SignedHeader):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is just a description of the current working of the light client, but Certify seems to conflate too many things, validation and mutation namely, while the name does not communicate that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be seen more as a description of core mechanisms of the light client. Current implementation is quite different. I agree that this is not the best name and that updating validator set is a side effect. My idea was just to have Certify as an entry point where we show how everything works together. The same underlying mechanisms can be used in the context of IBC, pooled security architecture and the light client. Do you have a suggestion how we organise the content differently?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something that would imply mutation could be a good start e.g.: Update

@milosevic milosevic force-pushed the zarko/1308-add-light-client-spec branch from 9a20f10 to 1660411 Compare March 20, 2018 13:50
return true
else
updateValidatorSet(signedHeader.ValSetNumber)
return Certify(signedHeader)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a recursive call, correct? What happened if the subsequent call to Certify fails even so updateValidatorSet has been called already?

Copy link
Contributor Author

@milosevic milosevic Mar 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it's not a problem in updating validator set and failing to check next header. With a correct FullNode this should never happen. In general, any call to the FullNode might fail or some of subsequent check could fail. At that point Certify function should fail and light client should decide how to deal with it, for example to connect to other FullNode. I added a note at the end.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, thanks for the clarification. Not sure if it was made explicit somehwere what the guarantees are for the light client.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make guarantees explicit, this is a first step to agree on the basic mechanisms.

@milosevic milosevic force-pushed the zarko/1308-add-light-client-spec branch from 1660411 to 416f03c Compare March 21, 2018 09:00
blockchain header, and further the corresponding Merkle proofs.

For the purpose of this light client specification, we assume that the Tendermint Full Node exposes the following functions over
Tendermint RPC:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's Tendermint RPC?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type SignedHeader struct {
Header Header
Commit Commit
ValSetNumber int64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this number needed?
You return it on the signed header, but you don't return it on ResultValidator.

Copy link
Contributor Author

@milosevic milosevic Mar 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly speaking, it is not needed, but it emphasises that validator set changes are first class citizens. It also simplifies supporting applications that require to strictly track validator set changes. Light client logic also seems simpler. The cost of supporting it does not seem high. We could also add this number in ResultValidator for symmetry.

@ebuchman
Copy link
Contributor

ebuchman commented Apr 3, 2018

I think we need to fix the condition re the Unbonding period (if its longer than the unbonding period, we have to revert to social consensus, we cant trust Tendermint nodes!).

Otherwise I think it looks good.

Notation could be a bit better re mutable state but good enough to merge for now.

@ebuchman ebuchman merged commit 991017f into develop Apr 3, 2018
@ebuchman ebuchman deleted the zarko/1308-add-light-client-spec branch April 3, 2018 20:02
@ebuchman ebuchman mentioned this pull request Apr 3, 2018
4 tasks
firelizzard18 pushed a commit to AccumulateNetwork/tendermint that referenced this pull request Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants