diff --git a/consensus/XDPoS/engines/engine_v1/engine.go b/consensus/XDPoS/engines/engine_v1/engine.go index 731a863e8a..493054c8d2 100644 --- a/consensus/XDPoS/engines/engine_v1/engine.go +++ b/consensus/XDPoS/engines/engine_v1/engine.go @@ -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 diff --git a/consensus/XDPoS/engines/engine_v2/engine.go b/consensus/XDPoS/engines/engine_v2/engine.go index 1ed03b3633..179e4c0023 100644 --- a/consensus/XDPoS/engines/engine_v2/engine.go +++ b/consensus/XDPoS/engines/engine_v2/engine.go @@ -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 } diff --git a/consensus/XDPoS/engines/engine_v2/utils.go b/consensus/XDPoS/engines/engine_v2/utils.go index be99cad26a..336b9f9494 100644 --- a/consensus/XDPoS/engines/engine_v2/utils.go +++ b/consensus/XDPoS/engines/engine_v2/utils.go @@ -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 +} diff --git a/params/config.go b/params/config.go index 73f04cc114..81e56e59b5 100644 --- a/params/config.go +++ b/params/config.go @@ -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, diff --git a/params/version.go b/params/version.go index 70070f932a..435b48e311 100644 --- a/params/version.go +++ b/params/version.go @@ -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.