-
Notifications
You must be signed in to change notification settings - Fork 166
Conversation
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'
This reverts commit cd659dd.
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: add it back
solution: remove that part of test, matches other Unsubscribe tests now
solution: add back :(
=== 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
which means that a client beyond subsequent forks will attempt to sync with nodes that have not proceeded beyond forks which our client assumes, causing invalid peers and more-than-necessary attempts to sync incompatible chains solution: included requiredHash's for hard forks which have already occurred
solution: relegate log verbosity to debug and info - ethereum/go-ethereum#2380 (comment) - ethereum/go-ethereum#890 (comment)
solution: add them, compile assets
solution: add ephemeral people-name aliases for each peer
solution: check for dl syncing as condition for prefix
defer peerSub.Unsubscribe() | ||
defer func() { | ||
cerr := s.commit(true) | ||
if err == nil { |
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.
Not sure I love this, b/c an error can be silently dropped.
👓 PTAL.
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.
And there are a lot of different kind of errors that it could be, including a commit error. Which seems important.
return | ||
} | ||
// Quickly validate the header and propagate the block if it passes | ||
switch err := f.validateBlock(block, parent); err { | ||
switch err := f.verifyHeader(block.Header()); err { |
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.
Just a quick note that in case you were wondering about the where the hell the parent went from this signature -- the validator fn passed in from the handler sets this per the blockchain validator, moving the responsibility for parent-aware validation logic back to the chain validator itself.
validator := func(header *types.Header) error {
return manager.blockchain.Validator().ValidateHeader(header, manager.blockchain.GetHeader(header.ParentHash), true)
}
eth/handler.go#168
) | ||
|
||
var ( | ||
forkChallengeTimeout = 15 * time.Second // Time allowance for a node to reply to the DAO handshake challenge |
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 is not a new idea (it used to just be hardcoded in the early handler handle()
fn requiredHash check piece, just now set to more visible global var. However, it used to be 5 seconds. And you're right, 15 seconds does seem a little high. Open idea.
if err != nil && pm.badBlockReportingEnabled && core.IsValidateError(err) { | ||
go sendBadBlockReport(blocks[i], err) | ||
go sendBadBlockReport(blocks[res.Index], err) |
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.
Open idea on this. Do we actually ever use or need this? If not, we can get rid of this whole function.
) | ||
if next <= current { | ||
infos, _ := json.MarshalIndent(p.Peer.Info(), "", " ") | ||
glog.V(logger.Warn).Infof("%v: GetBlockHeaders skip overflow attack (current %v, skip %v, next %v)\nMalicious peer infos: %s", p, current, query.Skip, next, infos) |
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.
👁 Here's worth noticing.
|
||
// peerSet represents the collection of active peers currently participating in | ||
// the Ethereum sub-protocol. | ||
type peerSet struct { |
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.
peerSet
stuff just moved to own file.
eth/sync.go
Outdated
break | ||
case <-forceSync.C: | ||
// Force a sync even if not enough peers are present | ||
go pm.synchronise(pm.peers.BestPeer()) |
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.
It is harmless to call this, even though the downloader might already by syncing. Not sure if it warrants or should have a conditional on if !pm.downloader.Synchronising()
or not.
And but the forceSync
thing is note worthy too.
eth/sync.go
Outdated
// bad block) rolled back a fast sync node below the sync point. In this case | ||
// however it's safe to reenable fast sync. | ||
atomic.StoreUint32(&pm.fastSync, 1) | ||
mode = downloader.FastSync |
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.
Here's a new behavior; if you run geth --fast
and don't progress thru downloading full blocks before restarting, then if you run just plain geth
, fast sync will resume even if you don't pass the flag. This got me. ⚡️ 👀
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.
Strange behaviour. So in such case to reastart geth with full sync I need to delete db?
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.
As-is, yes. Or just continue syncing until you reach a pivot point, then it will still automatically switch to full sync and then, like usual, always full sync from there on out.
I agree that it's kind of strange, but maybe that's because we've become so used to being very careful about the --fast
flag.
And it is kind of a nice thing to have; for example last week I accidentally made a friend have to restart syncing from 0 because my command instructions for him left the --fast
off and he started accidentally full syncing around block 3mm.
Overall, I guess there would be fewer cases when someone wants to start full syncing from a random block in the middle of the chain, compared to when someone starts with --fast
and then forgets to use the flag on a restart later.
We could consider adding a --full
flag later, maybe? 😜
for intervaled status logs solution: condtional on mode
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.
Overall LGTM;
with some minor issues
@r8d8 and @tzdybal These ones in particular, please double double check ;)
Mostly I want to be extra sure that state is definitely persisted. At the pivot, during fast, all the times. 👓 Anything with the word
|
And @r8d8 did you have other comments or issues besides #619 (review)? |
solution: add 'gitlike' to avaible list, and refactor parser
I think we should exclude the #612 related code from this PR - it's not strictly related, and it's still under discussion. |
Reviewed 3 of 10 files at r1, 11 of 145 files at r3, 43 of 156 files at r5, 2 of 2 files at r6, 2 of 2 files at r7, 1 of 1 files at r8, 2 of 2 files at r9. cmd/geth/main.go, line 257 at r9 (raw file):
Why it's removed? core/blockchain.go, line 1503 at r9 (raw file):
Lol, so it was changed with simple find and replace, not a refactoring tool :D core/state/sync.go, line 30 at r7 (raw file): Previously, whilei (ia) wrote…
This seems like a result of series of simple, safe, refactorings (rename: eth/handler.go, line 54 at r7 (raw file): Previously, whilei (ia) wrote…
15 seconds seems a bit crazy for me, even for nodes with crazy slow network and IO. eth/handler.go, line 195 at r7 (raw file): Previously, whilei (ia) wrote…
I'm opting for removing this. It's not needed, the target URL is dead (at least I cant resolve DNS for it). eth/handler.go, line 757 at r9 (raw file):
Safe to remove this commented out line? eth/sync.go, line 152 at r7 (raw file): Previously, whilei (ia) wrote…
IMHO we should add eth/sync.go, line 212 at r9 (raw file):
IMHO this is wrong use of atomic variable. This should be corrected to:
eth/sync.go, line 214 at r9 (raw file):
say twice, say twice? Line 206 in e18e163
eth/downloader/downloader.go, line 393 at r7 (raw file): Previously, whilei (ia) wrote…
👍 eth/downloader/downloader.go, line 1029 at r7 (raw file): Previously, whilei (ia) wrote…
👍 refactoring required (may be in separate PR) eth/downloader/statesync.go, line 284 at r7 (raw file): Previously, whilei (ia) wrote…
IMHO only commit error can be dropped. Do we really need to commit, even if Comments from Reviewable |
Made my comments. I think we can make fixes after merging, in separate PR, if you prefer that. |
cmd/geth/main.go, line 257 at r9 (raw file): Previously, tzdybal (Tomasz Zdybał) wrote…
I just herded the log line to the place where the other configuration log line ares.
Comments from Reviewable |
core/blockchain.go, line 1503 at r9 (raw file): Previously, tzdybal (Tomasz Zdybał) wrote…
Not to worry, there was a tool. I was just moving fast and didn't take the time to exclude all proper comments (turns out Comments from Reviewable |
eth/handler.go, line 54 at r7 (raw file): Previously, tzdybal (Tomasz Zdybał) wrote…
Agreed. IMO this is directly related to the I'm going to leave this as-is for now, and then we'll just integrate a change or leave-be with that PR #612. Comments from Reviewable |
eth/handler.go, line 195 at r7 (raw file): Previously, tzdybal (Tomasz Zdybał) wrote…
Great. I will make a separate PR ;) Comments from Reviewable |
solution: check if dler is already syncing. just log debug if busy
solution: use CompareAndSwap instead of load and store
A huge amount of these changes are integrations "merged" by hand from ethereum/go-ethereum. Unfortunately, cherry-picking and merging (which would have credited original authors appropriately), was impossible because the code bases have diverged significantly.
So, thanks to the fine folks that did the brunt of the heavy lifting. Included by not limited to karalabe, fjl, arachnid,... I'll do my best to document and cite primary sources as much as possible.
Rel at least #603, #604, #605.
A rough reference for sources cited:
eth/dwonloader: moving pivot and capped memory usage
eth/downloader: termiante state sync cleanly
eth/downloader: separate state sync from queue
eth/downloader: wait for all fetcher goroutines to exit before terminating
eth/downloader: flush state sync data before exit
eth/downloader: save and load trie sync progress
rawdb
).eth/downloader: don't require state for ancestor lookups
eth/downloader: improve deliverNodeData
eth: propagate blocks and transactions async
eth, les: allow exceeding maxPeers for trusted peers
core, trie: intermediate mempool between trie and database
eth/fetcher: check the origin of filter tasks
eth: use maxpeers from p2p layer instead of extra config
eth: don't import propagated blocks during fastsync
eth/fetcher: reuse variables for hash and number
And a few other other changes I had made earlier that were off-topic, but not worth throwing into their own PRs, IMO.
52a948f: same as https://github.com/ethereum/go-ethereum/pull/15470/filesc2806e6: only nice to have for code style