debug beacon sync not stable issue

pull/724/head
chao 6 years ago
parent cce175b74b
commit c4cf98cbc6
  1. 3
      .gitignore
  2. 2
      api/service/syncing/syncing.go
  3. 2
      core/resharding.go
  4. 4
      node/node.go
  5. 3
      node/node_syncing.go

3
.gitignore vendored

@ -64,3 +64,6 @@ node_modules/
# go mod summary file # go mod summary file
go.sum go.sum
# bnkey
test/.bnkey

@ -618,7 +618,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, willJoinConsensus bool, isBeacon bool) { func (ss *StateSync) SyncLoop(bc *core.BlockChain, worker *worker.Worker, willJoinConsensus bool, isBeacon bool) {
for { for {
if !isBeacon && !ss.IsOutOfSync(bc) { if !ss.IsOutOfSync(bc) {
utils.GetLogInstance().Info("[SYNC] Node is now IN SYNC!") utils.GetLogInstance().Info("[SYNC] Node is now IN SYNC!")
return return
} }

@ -24,7 +24,7 @@ const (
// GenesisShardNum is the number of shard at genesis // GenesisShardNum is the number of shard at genesis
GenesisShardNum = 4 GenesisShardNum = 4
// GenesisShardSize is the size of each shard at genesis // GenesisShardSize is the size of each shard at genesis
GenesisShardSize = 5 GenesisShardSize = 50
// CuckooRate is the percentage of nodes getting reshuffled in the second step of cuckoo resharding. // CuckooRate is the percentage of nodes getting reshuffled in the second step of cuckoo resharding.
CuckooRate = 0.1 CuckooRate = 0.1
) )

@ -437,13 +437,13 @@ func (node *Node) AddBeaconChainDatabase(db ethdb.Database) {
database = ethdb.NewMemDatabase() database = ethdb.NewMemDatabase()
} }
// TODO (chao) currently we use the same genesis block as normal shard // TODO (chao) currently we use the same genesis block as normal shard
chain, err := node.GenesisBlockSetup(database, 0, false) chain, err := node.GenesisBlockSetup(database, 0, true)
if err != nil { if err != nil {
utils.GetLogInstance().Error("Error when doing genesis setup") utils.GetLogInstance().Error("Error when doing genesis setup")
os.Exit(1) os.Exit(1)
} }
node.beaconChain = chain node.beaconChain = chain
node.BeaconWorker = worker.New(params.TestChainConfig, chain, node.Consensus, pki.GetAddressFromPublicKey(node.SelfPeer.ConsensusPubKey), node.Consensus.ShardID) node.BeaconWorker = worker.New(params.TestChainConfig, chain, &consensus.Consensus{}, pki.GetAddressFromPublicKey(node.SelfPeer.ConsensusPubKey), node.Consensus.ShardID)
} }
// InitBlockChainFromDB retrieves the latest blockchain and state available from the local database // InitBlockChainFromDB retrieves the latest blockchain and state available from the local database

@ -62,6 +62,7 @@ func (node *Node) DoBeaconSyncing() {
peers := node.GetBeaconSyncingPeers() peers := node.GetBeaconSyncingPeers()
if err := node.beaconSync.CreateSyncConfig(peers, true); err != nil { if err := node.beaconSync.CreateSyncConfig(peers, true); err != nil {
ctxerror.Log15(utils.GetLogInstance().Debug, err) ctxerror.Log15(utils.GetLogInstance().Debug, err)
continue
} }
} }
node.beaconSync.AddLastMileBlock(beaconBlock) node.beaconSync.AddLastMileBlock(beaconBlock)
@ -113,7 +114,7 @@ SyncingLoop:
// SupportBeaconSyncing sync with beacon chain for archival node in beacon chan or non-beacon node // SupportBeaconSyncing sync with beacon chain for archival node in beacon chan or non-beacon node
func (node *Node) SupportBeaconSyncing() { func (node *Node) SupportBeaconSyncing() {
node.DoBeaconSyncing() go node.DoBeaconSyncing()
} }
// SupportSyncing keeps sleeping until it's doing consensus or it's a leader. // SupportSyncing keeps sleeping until it's doing consensus or it's a leader.

Loading…
Cancel
Save