Light client: bisection, store, requester#100
Conversation
- implement `can_trust` according to the latest spec CanTrustBisection (wip) - add a `Requester` and a `Store` trait - sue refs in parameters (as they are used in several places and we don't want to Copy)
- reduce params to clippy threshold (7); still a lot ... - rename vars for better readability
- rename expired to is_within_trust_period to be closer to the spec - use TrusteState trait in check_support params - use TrusteState in lite tests
xla
left a comment
There was a problem hiding this comment.
Had a first pass with a bunch of style and doc improvements. We should probably rename types.rs given that it only holds traits.
@liamsi You mentioned that it could use more tests. Could you enumerate what cases/flows you'd like to cover?
tendermint/src/lite/verifier.rs
Outdated
| )?; | ||
| store.add(&pivot_header)?; | ||
| let pivot_trusted = TS::new(pivot_header, pivot_next_vals); | ||
| can_trust( |
There was a problem hiding this comment.
As we see calls to the same function with slightly adjusted parameters this function body could benefit from inline comments expanding of what the order of events is. This will lessen the cognitive burden on the reader.
There was a problem hiding this comment.
Added some inline comments. Is it more understandable now?
I like
Unit tests for |
ebuchman
left a comment
There was a problem hiding this comment.
Great start, thanks Ismail, but it seems there are a few bugs, some of which are reflected in the spec, and we need to be clearer about validator sets.
I'll leave some more comments on the spec.
* MockHeader and test_is_within_trust_period * remove Validator trait; make ValidatorSet associated to Commit (#105) * remove Validator trait; make ValidatorSet associated to Commit * remove stale comment
* Review comments: - update some comments / documentation - verify vals (not next vals) - store header and vals in trusted state * One offs & renaming related to trusted state
- an_trust -> can_trust_bisection - remove a redundant check for trust period - remove redundant adding state to the store (added TODO)
| // and stores the now trusted header again. | ||
| // Figure out if we want to store it here or in can_trust_bisection! | ||
| // My understanding is: with the current impl, we either bubbled up an | ||
| // error, or, successfully added sh2 (and its nex vals) to the trusted store here. |
There was a problem hiding this comment.
* use ? instead of return Err(err) * remove unused errors * move a validation and add TODOs about them * check_support returns early for sequential case * drop let _ = * add comment to voting_power_in about signers
Comments addressed or tracked for follow up
Needs tests with concrete impls of store and requester. (e.g. simple in memory store in form of a map and a mocked rpc client).
ref: #96