[blockchain] v2 riri Schedule composit data structure#3848
Merged
tac0turtle merged 9 commits intomasterfrom Aug 5, 2019
Merged
[blockchain] v2 riri Schedule composit data structure#3848tac0turtle merged 9 commits intomasterfrom
tac0turtle merged 9 commits intomasterfrom
Conversation
+ The schedule is a data structure used to determine the optimal
schedule of requests to the optimal set of peers in order to perform
fast-sync as fast and efficiently as possible.
golangcibot
reviewed
Jul 30, 2019
5 tasks
golangcibot
reviewed
Jul 30, 2019
Codecov Report
@@ Coverage Diff @@
## master #3848 +/- ##
==========================================
- Coverage 65.99% 64.94% -1.06%
==========================================
Files 237 217 -20
Lines 20388 18210 -2178
==========================================
- Hits 13456 11827 -1629
+ Misses 5879 5465 -414
+ Partials 1053 918 -135 |
Contributor
|
@ancazamfir @brapse I believe this should be merged and then we can start on the stage of this process, thoughts? |
+ The schedule is a data structure used to determine the optimal
schedule of requests to the optimal set of peers in order to perform
fast-sync as fast and efficiently as possible.
…tendermint/tendermint into brapse/blockchain-riri-schedule
tac0turtle
approved these changes
Aug 5, 2019
Contributor
tac0turtle
left a comment
There was a problem hiding this comment.
Discussed on tm call, will merge this PR ⚡️
melekes
reviewed
Aug 7, 2019
| "github.com/tendermint/tendermint/p2p" | ||
| ) | ||
|
|
||
| type Event interface{} |
| case blockStateProcessed: | ||
| return "Processed" | ||
| default: | ||
| return fmt.Sprintf("unknown blockState: %d", e) |
Contributor
There was a problem hiding this comment.
wouldn't it be better to panic in this case?
| case peerStateRemoved: | ||
| return "Removed" | ||
| default: | ||
| return fmt.Sprintf("unknown peerState: %d", e) |
|
|
||
| func (sc *schedule) addPeer(peerID p2p.ID) error { | ||
| if _, ok := sc.peers[peerID]; ok { | ||
| return fmt.Errorf("Cannot add duplicate peer %s", peerID) |
Contributor
There was a problem hiding this comment.
Suggested change
| return fmt.Errorf("Cannot add duplicate peer %s", peerID) | |
| return fmt.Errorf("cannot add duplicate peer %s", peerID) |
errors must not start with a capital letter
| func (sc *schedule) markPending(peerID p2p.ID, height int64, time time.Time) error { | ||
| peer, ok := sc.peers[peerID] | ||
| if !ok { | ||
| return fmt.Errorf("Can't find peer %s", peerID) |
Contributor
There was a problem hiding this comment.
var ErrNoPeer = fmt.Errorf("can't find peer %s", peerID)| } | ||
|
|
||
| state := sc.getStateAtHeight(height) | ||
| if state != blockStateNew { |
Contributor
There was a problem hiding this comment.
wouldn't select be more appropriate here
switch {
case state != blockStateNew:
return ...
case peer.state != peerStateReady:
...| return heights | ||
| } | ||
|
|
||
| func (sc *schedule) selectPeer(peers []*scPeer) *scPeer { |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
(This PR trumps #3821)
The blockchain reactor is responsible for fetching and applying blocks from peers in order to catch up a node. #3777 specifies a new architecture architecture which includes a scheduler component which:
This PR include an implementation of the schedule data structure. The schedule is a data structure used to determine the optimal schedule of requests to the optimal set of peers in order to perform fast-sync as fast and efficiently as possible.
Blocks transition from:
unknown -> new -> pending -> received -> processedand peers transition from:
new -> ready -> removedbased on a synchronous methods calls.
This PR aims to solve #2897 by modeling a large part of the protocol as synchronous methods which can tested/verified directly.