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

Commit

Permalink
problem: bad block reporting is defunct
Browse files Browse the repository at this point in the history
solution: remove all references of it (reporting, that is, not bad blocks in general)

Fixes #624
  • Loading branch information
whilei authored and tzdybal committed Jul 10, 2018
1 parent c7cb77e commit b829185
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 99 deletions.
7 changes: 0 additions & 7 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/ethereumproject/go-ethereum/common"
"github.com/ethereumproject/go-ethereum/console"
"github.com/ethereumproject/go-ethereum/core"
"github.com/ethereumproject/go-ethereum/eth"
"github.com/ethereumproject/go-ethereum/logger"
"github.com/ethereumproject/go-ethereum/metrics"
)
Expand Down Expand Up @@ -283,12 +282,6 @@ func makeCLIApp() (app *cli.App) {
go metrics.CollectToFile(s)
}

// This should be the only place where reporting is enabled
// because it is not intended to run while testing.
// In addition to this check, bad block reports are sent only
// for chains with the main network genesis block and network id 1.
eth.EnableBadBlockReporting = true

// (whilei): I use `log` instead of `glog` because git diff tells me:
// > The output of this command is supposed to be machine-readable.
gasLimit := ctx.GlobalString(aliasableName(TargetGasLimitFlag.Name, ctx))
Expand Down
75 changes: 0 additions & 75 deletions eth/bad_block.go

This file was deleted.

20 changes: 3 additions & 17 deletions eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ type ProtocolManager struct {
// wait group is used for graceful shutdowns during downloading
// and processing
wg sync.WaitGroup

badBlockReportingEnabled bool
}

// NewProtocolManager returns a new ethereum sub protocol manager. The Ethereum sub protocol manages peers capable
Expand Down Expand Up @@ -176,27 +174,15 @@ func NewProtocolManager(config *core.ChainConfig, mode downloader.SyncMode, netw
glog.V(logger.Warn).Warnf("Discarded bad propagated block", "number", blocks[0].Number(), "hash", blocks[0].Hash().Hex()[:9])
glog.D(logger.Warn).Warnf("Discarded bad propagated block", "number", blocks[0].Number(), "hash", blocks[0].Hash().Hex()[:9])
}
atomic.StoreUint32(&manager.acceptsTxs, 1) // Mark initial sync done on any fetcher import
return manager.insertChain(blocks)
// Mark initial sync done on any fetcher import
atomic.StoreUint32(&manager.acceptsTxs, 1)
return manager.blockchain.InsertChain(blocks)
}
manager.fetcher = fetcher.New(mux, blockchain.GetBlock, validator, manager.BroadcastBlock, heighter, inserter, manager.removePeer)

if blockchain.Genesis().Hash().Hex() == defaultGenesisHash && networkId == 1 {
manager.badBlockReportingEnabled = false
}

return manager, nil
}

func (pm *ProtocolManager) insertChain(blocks types.Blocks) *core.ChainInsertResult {
res := pm.blockchain.InsertChain(blocks)
err := res.Error
if err != nil && pm.badBlockReportingEnabled && core.IsValidateError(err) {
go sendBadBlockReport(blocks[res.Index], err)
}
return res
}

func (pm *ProtocolManager) removePeer(id string) {
// Short circuit if the peer was already removed
peer := pm.peers.Peer(id)
Expand Down

0 comments on commit b829185

Please sign in to comment.