Skip to content

Commit

Permalink
[cherry-pick] les: fix GetProofsV2 bug (ethereum#21896) (ethereum#1265)
Browse files Browse the repository at this point in the history
### Description

Cherry pick a PR from upstream (upstream PR 21896) which fixes a possible panic in the LES server

### Tested

Manually confirmed that the panic can happen without this patch, and that this patch fixes it.

### Backwards compatibility

No backwards compatibility concerns.
  • Loading branch information
Or Neeman authored Dec 14, 2020
1 parent baa3cae commit 85c142a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions les/server_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
var (
lastBHash common.Hash
root common.Hash
header *types.Header
)
reqCnt := len(req.Reqs)
if accept(req.ReqID, uint64(reqCnt), MaxProofsFetch) {
Expand All @@ -601,10 +602,6 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
return
}
// Look up the root hash belonging to the request
var (
header *types.Header
trie state.Trie
)
if request.BHash != lastBHash {
root, lastBHash = common.Hash{}, request.BHash

Expand All @@ -631,6 +628,7 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
// Open the account or storage trie for the request
statedb := h.blockchain.StateCache()

var trie state.Trie
switch len(request.AccKey) {
case 0:
// No account key specified, open an account trie
Expand Down

0 comments on commit 85c142a

Please sign in to comment.