Skip to content
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

ligth sync: download difflayer #2

Merged
merged 4 commits into from
Sep 2, 2021

Conversation

kyrie-yl
Copy link

@kyrie-yl kyrie-yl commented Sep 2, 2021

Signed-off-by: kyrie-yl lei.y@binance.com

@@ -290,6 +297,10 @@ func (d *Downloader) Progress() ethereum.SyncProgress {
}
}

func (d *Downloader) SetBodyFetchHook(hook func(SyncMode, string, []*types.Header)) {
Copy link
Owner

Choose a reason for hiding this comment

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

方法不要暴露,=> setBodyFetchHook

receiptFetchHook func([]*types.Header) // Method to call upon starting a receipt fetch
chainInsertHook func([]*fetchResult) // Method to call upon inserting a chain of blocks (possibly in multiple invocations)
syncInitHook func(uint64, uint64) // Method to call upon initiating a new sync run
bodyFetchHook func(SyncMode, string, []*types.Header) // Method to call upon starting a block body fetch
Copy link
Owner

Choose a reason for hiding this comment

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

this will break a lot of testcase

eth/peerset.go Outdated
@@ -66,6 +68,24 @@ type peerSet struct {
closed bool
}

func DiffBodiesFetchOption(peers *peerSet) downloader.DownloadOption {
Copy link
Owner

Choose a reason for hiding this comment

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

it is not good to defineDiffBodiesFetchOption in peerSet.go

eth/peer.go Outdated
@@ -38,7 +38,7 @@ type ethPeerInfo struct {
type ethPeer struct {
*eth.Peer
snapExt *snapPeer // Satellite `snap` connection
diffExt *diffPeer
DiffExt *diffPeer
Copy link
Owner

Choose a reason for hiding this comment

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

why upper?

kyrie-yl added 3 commits September 2, 2021 19:58
Signed-off-by: kyrie-yl <lei.y@binance.com>
Signed-off-by: kyrie-yl <lei.y@binance.com>
Signed-off-by: kyrie-yl <lei.y@binance.com>
func DiffBodiesFetchOption(peers IPeerSet) DownloadOption {
return func(dl *Downloader) *Downloader {
var hook = func(headers []*types.Header, options ...interface{}) {
if len(options) < 2 {
Copy link
Owner

Choose a reason for hiding this comment

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

options ==> args

eth/peerset.go Outdated
@@ -18,6 +18,7 @@ package eth

import (
"errors"
"github.com/ethereum/go-ethereum/eth/downloader"
Copy link
Owner

Choose a reason for hiding this comment

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

import order

Signed-off-by: kyrie-yl <lei.y@binance.com>
@unclezoro unclezoro merged commit f9bb1c5 into unclezoro:light_sync Sep 2, 2021
unclezoro pushed a commit that referenced this pull request Sep 2, 2021
* ligth sync: download difflayer

Signed-off-by: kyrie-yl <lei.y@binance.com>

* download diff layer: fix according to the comments

Signed-off-by: kyrie-yl <lei.y@binance.com>

* download diff layer: update

Signed-off-by: kyrie-yl <lei.y@binance.com>

* download diff layer: fix accroding comments

Signed-off-by: kyrie-yl <lei.y@binance.com>

Co-authored-by: kyrie-yl <lei.y@binance.com>
unclezoro pushed a commit that referenced this pull request Sep 7, 2021
* ligth sync: download difflayer

Signed-off-by: kyrie-yl <lei.y@binance.com>

* download diff layer: fix according to the comments

Signed-off-by: kyrie-yl <lei.y@binance.com>

* download diff layer: update

Signed-off-by: kyrie-yl <lei.y@binance.com>

* download diff layer: fix accroding comments

Signed-off-by: kyrie-yl <lei.y@binance.com>

Co-authored-by: kyrie-yl <lei.y@binance.com>
unclezoro added a commit that referenced this pull request Oct 12, 2021
* implement block process part of light sync

* add difflayer protocol

* handle difflayer and refine light processor

* add testcase for diff protocol

* make it faster

* allow validator to light sync

* change into diff sync

* ligth sync: download difflayer (#2)

* ligth sync: download difflayer

Signed-off-by: kyrie-yl <lei.y@binance.com>

* download diff layer: fix according to the comments

Signed-off-by: kyrie-yl <lei.y@binance.com>

* download diff layer: update

Signed-off-by: kyrie-yl <lei.y@binance.com>

* download diff layer: fix accroding comments

Signed-off-by: kyrie-yl <lei.y@binance.com>

Co-authored-by: kyrie-yl <lei.y@binance.com>

* update light sync to diff sync

* raise the max diff limit

* add switcher of snap protocol

* fix test case

* make commit concurrently

* remove peer for diff cache when peer closed

* consensus tuning

* add test code

* remove extra message

* fix testcase and lint

make diff block configable

wait code write

fix testcase

resolve comments

resolve comment

* resolve comments

* resolve comments

* resolve comment

* fix mistake

Co-authored-by: kyrie-yl <83150977+kyrie-yl@users.noreply.github.com>
Co-authored-by: kyrie-yl <lei.y@binance.com>
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.

2 participants