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

eth/protocols/snap: snap sync testing #22179

Merged
merged 22 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4a878d1
eth/protocols/snap: make timeout configurable
holiman Jan 18, 2021
9d8994c
eth/protocols/snap: snap sync testing
holiman May 27, 2020
935c001
eth/protocols/snap: test to trigger panic
holiman Jan 18, 2021
375588b
eth/protocols/snap: fix race condition on timeouts
holiman Jan 18, 2021
404b299
eth/protocols/snap: return error on cancelled sync
holiman Jan 18, 2021
f191848
squashme: updates + test causing panic + properly serve accounts in o…
holiman Jan 19, 2021
dc21744
eth/protocols/snap: revert failing storage response
holiman Jan 19, 2021
09d0610
eth/protocols/snap: revert on bad responses (storage, code)
holiman Jan 19, 2021
f963041
eth/protocols/snap: fix account handling stall
holiman Jan 19, 2021
cf8b96b
eth/protocols/snap: fix remaining revertal-issues
holiman Jan 19, 2021
6944299
eth/protocols/snap: timeouthandler for bytecode requests
holiman Jan 20, 2021
b86bd4b
eth/protocols/snap: debugging + fix log message
holiman Jan 20, 2021
f358473
eth/protocols/snap: fix misspelliings in docs
holiman Jan 20, 2021
ac7c967
eth/protocols/snap: fix race in bytecode handling
holiman Jan 20, 2021
a8e39d1
eth/protocols/snap: undo deduplication of storage roots
holiman Jan 20, 2021
be0ab3b
synctests: refactor + minify panic testcase
holiman Jan 20, 2021
324b8a6
eth/protocols/snap: minor polishes
karalabe Jan 24, 2021
88dc6ee
eth: minor polishes to make logs more useful
karalabe Jan 24, 2021
4aeb629
eth/protocols/snap: remove excessive logs from the test runs
karalabe Jan 24, 2021
a6a131f
eth/protocols/snap: stress tests with concurrency
karalabe Jan 24, 2021
00b8129
eth/protocols/snap: further fixes to test cancel channel handling
karalabe Jan 24, 2021
2aafa6a
eth/protocols/snap: extend test timeouts on CI
karalabe Jan 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions eth/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (d *Downloader) RegisterPeer(id string, version uint, peer Peer) error {
// Tests use short IDs, don't choke on them
logger = log.New("peer", id)
} else {
logger = log.New("peer", id[:16])
logger = log.New("peer", id[:8])
}
logger.Trace("Registering sync peer")
if err := d.peers.Register(newPeerConnection(id, version, peer, logger)); err != nil {
Expand All @@ -325,7 +325,7 @@ func (d *Downloader) UnregisterPeer(id string) error {
// Tests use short IDs, don't choke on them
logger = log.New("peer", id)
} else {
logger = log.New("peer", id[:16])
logger = log.New("peer", id[:8])
}
logger.Trace("Unregistering sync peer")
if err := d.peers.Unregister(id); err != nil {
Expand Down
16 changes: 12 additions & 4 deletions eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,24 +326,32 @@ func (h *handler) runSnapPeer(peer *snap.Peer, handler snap.Handler) error {
}

func (h *handler) removePeer(id string) {
// Create a custom logger to avoid printing the entire id
var logger log.Logger
if len(id) < 16 {
// Tests use short IDs, don't choke on them
logger = log.New("peer", id)
} else {
logger = log.New("peer", id[:8])
}
// Remove the eth peer if it exists
eth := h.peers.ethPeer(id)
if eth != nil {
log.Debug("Removing Ethereum peer", "peer", id)
logger.Debug("Removing Ethereum peer")
h.downloader.UnregisterPeer(id)
h.txFetcher.Drop(id)

if err := h.peers.unregisterEthPeer(id); err != nil {
log.Error("Peer removal failed", "peer", id, "err", err)
logger.Error("Ethereum peer removal failed", "err", err)
}
}
// Remove the snap peer if it exists
snap := h.peers.snapPeer(id)
if snap != nil {
log.Debug("Removing Snapshot peer", "peer", id)
logger.Debug("Removing Snapshot peer")
h.downloader.SnapSyncer.Unregister(id)
if err := h.peers.unregisterSnapPeer(id); err != nil {
log.Error("Peer removal failed", "peer", id, "err", err)
logger.Error("Snapshot peer removel failed", "err", err)
}
}
// Hard disconnect at the networking layer
Expand Down
5 changes: 5 additions & 0 deletions eth/protocols/snap/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ func (p *Peer) Version() uint {
return p.version
}

// Log overrides the P2P logget with the higher level one containing only the id.
func (p *Peer) Log() log.Logger {
return p.logger
}

// RequestAccountRange fetches a batch of accounts rooted in a specific account
// trie, starting with the origin.
func (p *Peer) RequestAccountRange(id uint64, root common.Hash, origin, limit common.Hash, bytes uint64) error {
Expand Down
1 change: 1 addition & 0 deletions eth/protocols/snap/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ var (
errDecode = errors.New("invalid message")
errInvalidMsgCode = errors.New("invalid message code")
errBadRequest = errors.New("bad request")
errCancelled = errors.New("sync cancelled")
)

// Packet represents a p2p message in the `snap` protocol.
Expand Down
Loading