mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
I found a problem with clique: if there is only one last signer in the whole network, it can vote to set its own permission to false. After the resolution is passed, len(signers) will be equal to 0, which will cause this code to crash in this line.’(number % uint64(len(signers))) == uint64(offset)’. Crash information: panic: runtime error: integer divide by zero
This commit is contained in:
parent
ae992a5d73
commit
f6ed68e13e
1 changed files with 7 additions and 0 deletions
|
|
@ -24,6 +24,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
)
|
||||
|
|
@ -308,5 +309,11 @@ func (s *Snapshot) inturn(number uint64, signer common.Address) bool {
|
|||
for offset < len(signers) && signers[offset] != signer {
|
||||
offset++
|
||||
}
|
||||
|
||||
if len(signers) == 0 {
|
||||
log.Warn("no signer. len(signers)==0")
|
||||
return false
|
||||
}
|
||||
|
||||
return (number % uint64(len(signers))) == uint64(offset)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue