-
Notifications
You must be signed in to change notification settings - Fork 20.4k
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
les: fix light fetcher database race #16103
Conversation
On mobile, so maybe I missed something, but it looks wrong. You check if header is nil... And then use header.Number in the error message. That'll blow up. |
les/fetcher.go
Outdated
@@ -562,6 +562,10 @@ func (f *lightFetcher) checkAnnouncedHeaders(fp *fetcherPeerInfo, headers []*typ | |||
// we ran out of recently delivered headers but have not reached a node known by this peer yet, continue matching | |||
td = f.chain.GetTd(header.ParentHash, header.Number.Uint64()-1) | |||
header = f.chain.GetHeader(header.ParentHash, header.Number.Uint64()-1) | |||
if header == nil || td == nil { | |||
log.Error("Missing parent of validated header", "hash", header.ParentHash, "number", header.Number.Uint64()-1) |
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 will cause error if header
is indeed 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.
Right, this one was a really stupid mistake.
les/fetcher.go
Outdated
@@ -46,7 +46,7 @@ type lightFetcher struct { | |||
peers map[*peer]*fetcherPeerInfo | |||
lastUpdateStats *updateStatsEntry | |||
|
|||
lock sync.Mutex // qwerqwerqwe | |||
lock sync.Mutex |
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.
Couldn't you replace qwerqwerqwe
with some documentation about specifically what asset this lock protects?
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.
done
b3baaa9
to
651ee08
Compare
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.
LGTM
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.
good
* les: fix light fetcher database race * les: lightFetcher comments
* les: fix light fetcher database race * les: lightFetcher comments
This PR fixes #16101 by avoiding a potential chain db data race that can cause checkAnnouncedHeaders being called with a nil header. There is also another check for missing parent of validated header (with an error log message) which in theory should not happen but still it would be nice to know about if it happens anyway in some weird corner case.