Merge pull request #1738 from chaosma/consensus-fix

update consensus and committee informatin for at end of every epoch
pull/1744/head
chaosma 5 years ago committed by GitHub
commit b4ef3ec57a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      api/service/syncing/syncing.go
  2. 7
      node/node_syncing.go

@ -15,6 +15,7 @@ import (
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
"github.com/harmony-one/harmony/api/service/syncing/downloader" "github.com/harmony-one/harmony/api/service/syncing/downloader"
pb "github.com/harmony-one/harmony/api/service/syncing/downloader/proto" pb "github.com/harmony-one/harmony/api/service/syncing/downloader/proto"
"github.com/harmony-one/harmony/consensus"
"github.com/harmony-one/harmony/core" "github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/internal/ctxerror" "github.com/harmony-one/harmony/internal/ctxerror"
@ -741,7 +742,7 @@ func (ss *StateSync) IsOutOfSync(bc *core.BlockChain) bool {
} }
// SyncLoop will keep syncing with peers until catches up // SyncLoop will keep syncing with peers until catches up
func (ss *StateSync) SyncLoop(bc *core.BlockChain, worker *worker.Worker, isBeacon bool) { func (ss *StateSync) SyncLoop(bc *core.BlockChain, worker *worker.Worker, isBeacon bool, consensus *consensus.Consensus) {
if !isBeacon { if !isBeacon {
ss.RegisterNodeInfo() ss.RegisterNodeInfo()
} }
@ -754,6 +755,7 @@ Loop:
case <-ticker.C: case <-ticker.C:
otherHeight := ss.getMaxPeerHeight(isBeacon) otherHeight := ss.getMaxPeerHeight(isBeacon)
currentHeight := bc.CurrentBlock().NumberU64() currentHeight := bc.CurrentBlock().NumberU64()
if currentHeight >= otherHeight { if currentHeight >= otherHeight {
utils.Logger().Info().Msgf("[SYNC] Node is now IN SYNC! (isBeacon: %t, ShardID: %d, otherHeight: %d, currentHeight: %d)", isBeacon, bc.ShardID(), otherHeight, currentHeight) utils.Logger().Info().Msgf("[SYNC] Node is now IN SYNC! (isBeacon: %t, ShardID: %d, otherHeight: %d, currentHeight: %d)", isBeacon, bc.ShardID(), otherHeight, currentHeight)
break Loop break Loop
@ -767,6 +769,9 @@ Loop:
} }
ss.ProcessStateSync(startHash[:], size, bc, worker) ss.ProcessStateSync(startHash[:], size, bc, worker)
ss.purgeOldBlocksFromCache() ss.purgeOldBlocksFromCache()
if consensus != nil {
consensus.UpdateConsensusInformation()
}
} }
} }
ss.purgeAllBlocksFromCache() ss.purgeAllBlocksFromCache()

@ -192,7 +192,7 @@ func (node *Node) DoBeaconSyncing() {
continue continue
} }
} }
node.beaconSync.SyncLoop(node.Beaconchain(), node.BeaconWorker, true) node.beaconSync.SyncLoop(node.Beaconchain(), node.BeaconWorker, true, nil)
time.Sleep(BeaconSyncFrequency * time.Second) time.Sleep(BeaconSyncFrequency * time.Second)
} }
} }
@ -234,10 +234,7 @@ SyncingLoop:
if willJoinConsensus { if willJoinConsensus {
node.Consensus.BlocksNotSynchronized() node.Consensus.BlocksNotSynchronized()
} }
node.stateSync.SyncLoop(bc, worker, false) node.stateSync.SyncLoop(bc, worker, false, node.Consensus)
if node.NodeConfig.Role() == nodeconfig.ExplorerNode {
node.Consensus.UpdateConsensusInformation()
}
if willJoinConsensus { if willJoinConsensus {
node.stateMutex.Lock() node.stateMutex.Lock()
node.State = NodeReadyForConsensus node.State = NodeReadyForConsensus

Loading…
Cancel
Save