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

Commit

Permalink
Merge pull request #633 from ethereumproject/rm/bad-block-reporting
Browse files Browse the repository at this point in the history
problem: bad block reporting is defunct
  • Loading branch information
whilei authored Jun 14, 2018
2 parents 5613579 + 78551c9 commit b1941bf
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 b1941bf

Please sign in to comment.