-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADR] Light Client Architecture #185
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
eab42ec
initial draft of light client concurrency adr
brapse e1b0f78
Update
brapse 7430c06
typo
brapse d00dbf5
wip
brapse 87971c9
Update with all our changes
brapse 06ae71b
Apply suggestions from code review
brapse 9ef6711
Apply suggestions from code review
brapse 99de118
Apply suggestions from code review
brapse 793c5ce
Update docs/architecture/adr-006-light-client-refactor.md
brapse 7724071
Update docs/architecture/adr-006-light-client-refactor.md
brapse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# ADR 006: Light Client Refactor | ||
|
||
## Changelog | ||
- 2020-03-15: Initial draft | ||
- 2020-03-23: New decomposition | ||
|
||
## Context | ||
|
||
The light client protocol provides a method for verifying application | ||
state without the execution of all preceding transactions. The | ||
protocol for the light client is described in | ||
[English](https://github.com/tendermint/spec/tree/bucky/light-reorg/spec/consensus/light) | ||
while the rust implementation is described in | ||
[ADR-002](adr-002-light-client-adr-index.md). This ADR outlines the | ||
next iteration of the light client implementation in rust in which | ||
multiple modules (Peer Exchange, Requester, Verifier, etc.) operate | ||
concurrently. | ||
|
||
The basis for this work comes from the learnings of the [Reactor | ||
Experiments](https://github.com/informalsystems/reactor-experiments) as | ||
well as the [Blockchain Reactor | ||
Refactor](https://github.com/tendermint/tendermint/blob/master/docs/architecture/adr-043-blockchain-riri-org.md). The key take aways from that work are: | ||
|
||
1. Separate concerns into independently verifiable (by humans as well as | ||
computers) components. | ||
2. Deterministic functions wherever possible | ||
3. Use events to index parameters of component function executions to | ||
maintain alignment between specs and implementations. | ||
|
||
## Decision | ||
|
||
Model the Scheduler ,Verifier, Detector and IO as separate | ||
independently verifiable components. Communication between components is | ||
done by a demuxer component which ownes state and dispatches events | ||
between business logic executing components. Business logic is executed | ||
as a synchronous deterministic function. The composition of components | ||
can also be executed as a deterministic function. | ||
|
||
![Decomposition Diagram](assets/light-client-decomposition.png) | ||
|
||
### State | ||
The light client maintains state about commit/header/validators abbreviated as LightBlocks. It also has state pertaining to peers and evidence. | ||
|
||
![State Diagram](assets/light-client-state.png) | ||
|
||
### Verification Flow | ||
The flow of events and mutations on state necessary for verification. | ||
|
||
![State Diagram](assets/light-client-verification-flow.png) | ||
|
||
### Detection Flow | ||
The flow of events and mutations on state necessary for fork detection. | ||
|
||
![State Diagram](assets/light-client-detection-flow.png) | ||
|
||
### Events & State | ||
There has been a notable change in thinking here. The previous version | ||
of this ADR was built on the tenet of `communicate through events and | ||
not through state`. The motivation being to serialize mutations | ||
to state using event loops for deterministic simulation. The problem | ||
with this approach is that it required components to replicate state. | ||
For instance if the detector and the verifier both needed a store of | ||
light blocks, we would need to: | ||
|
||
* Replicate that state in memory | ||
* Produce flows of events to populate both representations | ||
* Deal with inconsistencies between representations. | ||
|
||
The new approach shares state by `lending` read only access to state | ||
for duration of the synchronous and deterministic execution of the sub | ||
component (ie. verifier, detector). The result of the execution is an | ||
event which then the owner can use to mutate the state accordingly. | ||
This way state mutation are serialized (deterministic) even if they are | ||
temporarily shared by separate components. | ||
|
||
### Concurrency | ||
|
||
No concurrency for now. We have some ideas of how to handle concurrency | ||
within this architecture that will be handled a separate ADR. | ||
|
||
## Status | ||
|
||
Proposed | ||
|
||
## Consequences | ||
|
||
### Positive | ||
- Better Isolation of Concerns | ||
- Deterministic Testing of the composition of components. | ||
- No async functions | ||
|
||
### Negative | ||
|
||
### Neutral | ||
|
||
## References | ||
|
||
* [Light Client Spec](https://github.com/tendermint/spec/tree/bucky/light-reorg/spec/consensus/light) | ||
* [Blockchain Reactor Refactor](https://github.com/tendermint/tendermint/blob/master/docs/architecture/adr-043-blockchain-riri-org.md) | ||
* [Reactor Experiments](https://github.com/informalsystems/reactor-experiments) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LightBlocks will need to maintain ValidatorSet and NextValidatorSet. NextValidatorSet is used for bisection using the trustingperiod, where we check the NextValidatorSet of an old block agains the commit/validatorSet of the new block,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity: is there something wrong with using ValidatorSet (not NextValidatorSet)? (other than validator set might have changed between ValidatorSet and NextValidatorSet)