aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Holst Swende <martin@swende.se>2018-12-20 17:46:08 +0800
committerGitHub <noreply@github.com>2018-12-20 17:46:08 +0800
commit5f251a6448b3385015ab531c35071743f93cafae (patch)
treef3cb4025c93f26d43f8cf93d40539b92da6acba4
parentfe86a707d8270108e0fb77359e702689664dcb4b (diff)
downloadgo-tangerine-5f251a6448b3385015ab531c35071743f93cafae.tar
go-tangerine-5f251a6448b3385015ab531c35071743f93cafae.tar.gz
go-tangerine-5f251a6448b3385015ab531c35071743f93cafae.tar.bz2
go-tangerine-5f251a6448b3385015ab531c35071743f93cafae.tar.lz
go-tangerine-5f251a6448b3385015ab531c35071743f93cafae.tar.xz
go-tangerine-5f251a6448b3385015ab531c35071743f93cafae.tar.zst
go-tangerine-5f251a6448b3385015ab531c35071743f93cafae.zip
downloader: fix edgecase where returned index is OOB for downloader (#18335)
* downloader: fix edgecase where returned index is OOB for downloader * downloader: documentation Co-Authored-By: holiman <martin@swende.se>
-rw-r--r--eth/downloader/downloader.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index 3a177ab9d..4db689f73 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -1488,7 +1488,15 @@ func (d *Downloader) importBlockResults(results []*fetchResult) error {
blocks[i] = types.NewBlockWithHeader(result.Header).WithBody(result.Transactions, result.Uncles)
}
if index, err := d.blockchain.InsertChain(blocks); err != nil {
- log.Debug("Downloaded item processing failed", "number", results[index].Header.Number, "hash", results[index].Header.Hash(), "err", err)
+ if index < len(results) {
+ log.Debug("Downloaded item processing failed", "number", results[index].Header.Number, "hash", results[index].Header.Hash(), "err", err)
+ } else {
+ // The InsertChain method in blockchain.go will sometimes return an out-of-bounds index,
+ // when it needs to preprocess blocks to import a sidechain.
+ // The importer will put together a new list of blocks to import, which is a superset
+ // of the blocks delivered from the downloader, and the indexing will be off.
+ log.Debug("Downloaded item processing failed on sidechain import", "index", index, "err", err)
+ }
return errInvalidChain
}
return nil