mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
add v1 snapshot fix
This commit is contained in:
parent
125f8a8957
commit
5733474c14
5 changed files with 29 additions and 9 deletions
|
|
@ -482,7 +482,12 @@ func (x *XDPoS_v1) snapshot(chain consensus.ChainReader, number uint64, hash com
|
|||
if s, err := loadSnapshot(x.config, x.signatures, x.db, hash); err == nil {
|
||||
log.Trace("Loaded voting snapshot form disk", "number", number, "hash", hash)
|
||||
snap = s
|
||||
break
|
||||
if len(snap.Signers) > 0 {
|
||||
break
|
||||
} else {
|
||||
log.Warn("skip this snapshot, len of snap signer is 0")
|
||||
snap = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
// If we're at block zero, make a snapshot
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ func (x *XDPoS_v2) SignHash(header *types.Header) (hash common.Hash) {
|
|||
func (x *XDPoS_v2) Initial(chain consensus.ChainReader, header *types.Header, masternodes []common.Address) error {
|
||||
log.Info("[Initial] initial v2 related parameters")
|
||||
|
||||
if x.highestQuorumCert.ProposedBlockInfo.Round != 0 { // already initialized
|
||||
if !isEmptyHash(x.highestQuorumCert.ProposedBlockInfo.Hash) { // already initialized
|
||||
log.Warn("[Initial] Already initialized")
|
||||
return nil
|
||||
}
|
||||
|
|
@ -156,12 +156,14 @@ func (x *XDPoS_v2) Initial(chain consensus.ChainReader, header *types.Header, ma
|
|||
|
||||
// Initial timeout
|
||||
log.Info("[Initial] miner wait period", "period", x.config.WaitPeriod)
|
||||
|
||||
// avoid deadlock
|
||||
go func() {
|
||||
x.waitPeriodCh <- x.config.V2.WaitPeriod
|
||||
}()
|
||||
|
||||
// Kick-off the countdown timer
|
||||
x.timeoutWorker.Reset()
|
||||
|
||||
log.Info("[Initial] finish initialisation")
|
||||
return nil
|
||||
}
|
||||
|
|
@ -434,7 +436,11 @@ func (x *XDPoS_v2) IsAuthorisedAddress(chain consensus.ChainReader, header *type
|
|||
}
|
||||
}
|
||||
|
||||
log.Warn("Not authorised address", "Address", address, "MN", masterNodes, "Hash", header.Hash())
|
||||
log.Warn("Not authorised address", "Address", address.Hex(), "Hash", header.Hash())
|
||||
for index, mn := range masterNodes {
|
||||
log.Warn("Master node list item", "mn", mn.Hex(), "index", index)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,3 +68,12 @@ func decodeMasternodesFromHeaderExtra(checkpointHeader *types.Header) []common.A
|
|||
}
|
||||
return masternodes
|
||||
}
|
||||
|
||||
func isEmptyHash(hash common.Hash) bool {
|
||||
for _, b := range hash {
|
||||
if b != 0 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ var (
|
|||
SwitchBlock: big.NewInt(900),
|
||||
}
|
||||
DevnetXDPoSV2Config = &V2{
|
||||
SwitchBlock: big.NewInt(9999999), // Temporary set it to very high
|
||||
SwitchBlock: big.NewInt(7218000),
|
||||
TimeoutWorkerDuration: 50,
|
||||
CertThreshold: 6,
|
||||
WaitPeriod: 2,
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
VersionMajor = 1 // Major version component of the current release
|
||||
VersionMinor = 4 // Minor version component of the current release
|
||||
VersionPatch = 4 // Patch version component of the current release
|
||||
VersionMeta = "stable" // Version metadata to append to the version string
|
||||
VersionMajor = 2 // Major version component of the current release
|
||||
VersionMinor = 0 // Minor version component of the current release
|
||||
VersionPatch = 0 // Patch version component of the current release
|
||||
VersionMeta = "unstable" // Version metadata to append to the version string
|
||||
)
|
||||
|
||||
// Version holds the textual version string.
|
||||
|
|
|
|||
Loading…
Reference in a new issue