-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[R4R]implement diff sync #376
Merged
Merged
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
bfce9eb
implement block process part of light sync
unclezoro 3d8a997
add difflayer protocol
unclezoro b782a7b
handle difflayer and refine light processor
unclezoro 172b26e
add testcase for diff protocol
unclezoro c598aae
make it faster
unclezoro d160091
allow validator to light sync
unclezoro 6f39765
change into diff sync
unclezoro a9e5a00
ligth sync: download difflayer (#2)
kyrie-yl 66ee50d
update light sync to diff sync
unclezoro ca156fc
raise the max diff limit
unclezoro 01fe925
add switcher of snap protocol
unclezoro 296f320
fix test case
unclezoro 2041edc
make commit concurrently
unclezoro 5ce6bbe
remove peer for diff cache when peer closed
unclezoro c6e62e1
consensus tuning
unclezoro 443f9a4
add test code
unclezoro 1fbecfa
remove extra message
unclezoro 92e21cc
fix testcase and lint
unclezoro 85e0fd4
resolve comments
unclezoro 0bbbcc5
resolve comments
unclezoro 0011461
resolve comment
unclezoro 844f2ab
fix mistake
unclezoro 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
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
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
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
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
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 |
---|---|---|
|
@@ -799,6 +799,10 @@ func (p *Parlia) Delay(chain consensus.ChainReader, header *types.Header) *time. | |
return nil | ||
} | ||
delay := p.delayForRamanujanFork(snap, header) | ||
// The blocking time should be no more than half of period | ||
if delay > time.Duration(p.config.Period)*time.Second/2 { | ||
delay = time.Duration(p.config.Period) * time.Second / 2 | ||
} | ||
return &delay | ||
} | ||
|
||
|
@@ -882,6 +886,18 @@ func (p *Parlia) EnoughDistance(chain consensus.ChainReader, header *types.Heade | |
return snap.enoughDistance(p.val, header) | ||
} | ||
|
||
func (p *Parlia) AllowLightProcess(chain consensus.ChainReader, currentHeader *types.Header) bool { | ||
snap, err := p.snapshot(chain, currentHeader.Number.Uint64()-1, currentHeader.ParentHash, nil) | ||
if err != nil { | ||
return true | ||
} | ||
|
||
idx := snap.indexOfVal(p.val) | ||
// validator is not allowed to diff sync | ||
return idx < 0 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. empty line There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed. |
||
} | ||
|
||
func (p *Parlia) IsLocalBlock(header *types.Header) bool { | ||
return p.val == header.Coinbase | ||
} | ||
|
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
Oops, something went wrong.
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.
This way don't need to calculate twice
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.
fixed