Skip to content

Commit

Permalink
problem: good-will assumption for forks with required hash
Browse files Browse the repository at this point in the history
solution: HeaderCheck check for new ErrHashEmpty error,

where that error is ignored by eth/handler.go.
This is presented as a possible alternative/+addition to @sorpaas changed in ethereumproject#313

Rel ethereumproject#309
  • Loading branch information
whilei committed Jul 24, 2017
1 parent f69b80b commit 7f45ede
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions core/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ var (

ErrHashKnownBad = errors.New("known bad hash")
ErrHashKnownFork = validateError("known fork hash mismatch")

ErrHashEmpty = errors.New("empty hash")
)

// SufficientChainConfig holds necessary data for externalizing a given blockchain configuration.
Expand Down Expand Up @@ -333,6 +335,10 @@ func (c *ChainConfig) GetFeature(num *big.Int, id string) (*ForkFeature, *Fork,
}

func (c *ChainConfig) HeaderCheck(h *types.Header) error {
if (h == &types.Header{}) {
return ErrHashEmpty
}

for _, fork := range c.Forks {
if fork.Block.Cmp(h.Number) != 0 {
continue
Expand Down
2 changes: 1 addition & 1 deletion eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func (pm *ProtocolManager) handle(p *peer) error {
}
if !fork.RequiredHash.IsEmpty() {
// Request the peer's fork block header for extra-dat
if err := p.RequestHeadersByNumber(fork.Block.Uint64(), 1, 0, false); err != nil {
if err := p.RequestHeadersByNumber(fork.Block.Uint64(), 1, 0, false); err != nil && err != core.ErrHashEmpty {
glog.V(logger.Warn).Infof("%v: error requesting headers by number ", p)
return err
}
Expand Down

0 comments on commit 7f45ede

Please sign in to comment.