mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
Xin 248 correct timeout message skip rule (#192)
* test on current devnet issue * change to times 3 to fit correct dist
This commit is contained in:
parent
4595bcfac1
commit
55d994690a
2 changed files with 6 additions and 4 deletions
|
|
@ -113,7 +113,9 @@ func (b *Bfter) Timeout(peer string, timeout *types.Timeout) error {
|
|||
log.Debug("Receive Timeout", "timeout", timeout)
|
||||
|
||||
gapNum := timeout.GapNumber
|
||||
if dist := int64(gapNum) - int64(b.chainHeight()); dist < -int64(b.epoch)*2 || dist > int64(b.epoch)*2 { // times 2 is to avoid cross epoch case, ex: timeout block between 901 to 1799, gapnumber is 450
|
||||
|
||||
// dist times 3, ex: timeout message's gap number is based on block and find out it's epoch switch number, then mod 900 then minus 450
|
||||
if dist := int64(gapNum) - int64(b.chainHeight()); dist < -int64(b.epoch)*3 || dist > int64(b.epoch)*3 {
|
||||
log.Debug("Discarded propagated timeout, too far away", "peer", peer, "gapNumber", gapNum, "hash", timeout.Hash, "distance", dist)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ func TestTooFarTimeout(t *testing.T) {
|
|||
verifyCounter := uint32(0)
|
||||
handlerCounter := uint32(0)
|
||||
broadcastCounter := uint32(0)
|
||||
targetTimeout := 0
|
||||
targetTimeout := 1
|
||||
|
||||
tester.bfter.consensus.verifyTimeout = func(consensus.ChainReader, *types.Timeout) (bool, error) {
|
||||
atomic.AddUint32(&verifyCounter, 1)
|
||||
|
|
@ -349,9 +349,9 @@ func TestTooFarTimeout(t *testing.T) {
|
|||
atomic.AddUint32(&broadcastCounter, 1)
|
||||
}
|
||||
|
||||
tester.bfter.chainHeight = func() uint64 { return 2400 }
|
||||
tester.bfter.chainHeight = func() uint64 { return 7175258 }
|
||||
|
||||
timeoutMsg := &types.Timeout{GapNumber: 450}
|
||||
timeoutMsg := &types.Timeout{GapNumber: 7173450}
|
||||
|
||||
err := tester.bfter.Timeout(peerID, timeoutMsg)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue