Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

[WIP]: Fix/sync stuck near head #606

Closed
wants to merge 19 commits into from
Closed

Conversation

whilei
Copy link
Contributor

@whilei whilei commented May 28, 2018

🚳 The documentation below is WIP, but maybe useful for first-impressions.


Maybe rel #603, #604, #605, of which 603 and 605 are definitely related to a lot of ETH issues: https://github.com/ethereum/go-ethereum/search?q=fast+pivot&unscoped_q=fast+pivot&type=Issues

In digging around these issues and hunting and pecking through blames and historys, I found ethereum/go-ethereum#15857 (comment) in which Peter's referring (I presume) to ethereum/go-ethereum@55599ee#diff-6a6ebbb3908dd266c6717cdc1c7b84ed, and this is the PR from which these changes have been pseudo-cherry-picked. I would have loved to actually cherry-pick them, but no amount of fetching nor git am patching would give me anything besides

$ git cherry-pick 62de04cf91d85b6394560ae3fe1e6bfdb0836bd2
fatal: bad object 62de04cf91d85b6394560ae3fe1e6bfdb0836bd2

or un-applyable patches. I guess this likely because the commits were made on a dev branch and somehow disappeared... 👻

But here's a rough reference of where this Frankenstein comes from:

And a few other other changes I had made earlier that were off-topic, but not worth throwing into their own PRs, IMO.


In manhandling these changes, there are a couple of things that I think warrant further refactoring in their own, later, PRs:

  • use (hash, uint64) signature for methods like blockchain.HasHeader, blockchain.GetTd, and a few others, mostly akin to the downloader.BlockChain interface. This instead of plain (hash), because it provides an extra level of certainty.
  • use a dedicated downloader.SyncProgress struct as the returnable for downloader.Progress. Returning (uint64, uint64, uint64, uint64, uint64) is just a pain in the ass.
  • consider refactoring to the downloader.peerConnection pattern instead of just plain downloader.peer.

whilei and others added 16 commits May 28, 2018 14:25
solution: if block number is lower than local with same td, use it

otherwise ok to flip coin if same
solution: use 'bc' instead of 'self'
NOTE: bc.HasHeader, bc.GetHeader, ... etc funcs SHOULD use hash, uint64 signature
b/c more safer. HOWEVER, I just made the incoming implementation use hash
because it was easier and fast and a POC, so far.
solution: fix interfaces and adapt to compromise between
incoming and existing patterns
via karalabe's un-cherry-pickable 4cf1ece5ba7c28e9ef7edabe0f53e5ae1fe37b76
solution: remove that part of test, matches other Unsubscribe tests now
=== RUN   TestDeliverHeadersHang/protocol_64_mode_LIGHT
fatal error: concurrent map iteration and map write

goroutine 984 [running]:
runtime.throw(0x459e978, 0x26)
    /usr/local/Cellar/go/1.9.2/libexec/src/runtime/panic.go:605 +0x95 fp=0xc420497c70 sp=0xc420497c50 pc=0x402dc25
runtime.mapiternext(0xc420497de8)
    /usr/local/Cellar/go/1.9.2/libexec/src/runtime/hashmap.go:778 +0x6f1 fp=0xc420497d08 sp=0xc420497c70 pc=0x400c2d1
runtime.mapiterinit(0x44f3f00, 0xc4207b3590, 0xc420497de8)
    /usr/local/Cellar/go/1.9.2/libexec/src/runtime/hashmap.go:768 +0x270 fp=0xc420497d70 sp=0xc420497d08 pc=0x400b980
github.com/ethereumproject/go-ethereum/eth/downloader.(*peerSet).medianRTT(0xc420138d00, 0x0)
    /Users/ia/gocode/src/github.com/ethereumproject/go-ethereum/eth/downloader/peer.go:566 +0x120 fp=0xc420497e58 sp=0xc420497d70 pc=0x4431fa0
github.com/ethereumproject/go-ethereum/eth/downloader.(*Downloader).qosTuner(0xc420800180)
    /Users/ia/gocode/src/github.com/ethereumproject/go-ethereum/eth/downloader/downloader.go:1624 +0x50 fp=0xc420497fd8 sp=0xc420497e58 pc=0x442e400
runtime.goexit()
    /usr/local/Cellar/go/1.9.2/libexec/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc420497fe0 sp=0xc420497fd8 pc=0x405dc01
created by github.com/ethereumproject/go-ethereum/eth/downloader.New
    /Users/ia/gocode/src/github.com/ethereumproject/go-ethereum/eth/downloader/downloader.go:250 +0xa16

goroutine 1 [chan receive]:

solution: add a peerset un/lock in test
solution: use go test fatal instead of test-killing panic
// FIXME?: Is this backwards?
if fails <= 2 {
glog.V(logger.Detail).Warnf("%s: %s delivery timeout", peer, strings.ToLower(kind))
if fails > 2 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tzdybal PTAL. IDK. WTF.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@whilei whilei force-pushed the fix/sync-stuck-near-head branch from 4593351 to 7da3be4 Compare May 29, 2018 09:24
solution: add syncstatschainheight updater
@whilei
Copy link
Contributor Author

whilei commented Jun 4, 2018

Closing via #619

@whilei whilei closed this Jun 4, 2018
@soc1c soc1c deleted the fix/sync-stuck-near-head branch June 19, 2019 12:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants