diff --git a/consensus/consensus_service.go b/consensus/consensus_service.go index d436ef5d5..1913460eb 100644 --- a/consensus/consensus_service.go +++ b/consensus/consensus_service.go @@ -1,6 +1,7 @@ package consensus import ( + "fmt" "math/big" "sync/atomic" "time" @@ -81,14 +82,17 @@ func (consensus *Consensus) UpdatePublicKeys(pubKeys, allowlist []bls_cosi.Publi func (consensus *Consensus) updatePublicKeys(pubKeys, allowlist []bls_cosi.PublicKeyWrapper) int64 { consensus.Decider.UpdateParticipants(pubKeys, allowlist) + consensus.getLogger().Info().Msg("My Committee updated") + for i := range pubKeys { + consensus.getLogger().Info(). + Int("index", i). + Str("BLSPubKey", pubKeys[i].Bytes.Hex()). + Msg("Member") + } + allKeys := consensus.Decider.Participants() - consensus.pubKeyLock.Unlock() if len(allKeys) != 0 { - first := consensus.Decider.FirstParticipant( - shard.Schedule.InstanceForEpoch(consensus.Blockchain.CurrentHeader().Epoch())) - consensus.pubKeyLock.Lock() - consensus.LeaderPubKey = first - consensus.pubKeyLock.Unlock() + consensus.LeaderPubKey = &allKeys[0] consensus.getLogger().Info(). Str("info", consensus.LeaderPubKey.Bytes.Hex()).Msg("My Leader") } else { diff --git a/consensus/consensus_v2.go b/consensus/consensus_v2.go index 8a3d4110b..3ec460ef5 100644 --- a/consensus/consensus_v2.go +++ b/consensus/consensus_v2.go @@ -664,7 +664,6 @@ func (consensus *Consensus) tryCatchup() error { consensus.getLogger().Error().Err(err).Msg("[TryCatchup] Failed to add block to chain") return err } - //fmt.Println("tryCatchup ", utils.GetPort(), blk.NumberU64()) select { // TODO: Remove this when removing dns sync and stream sync is fully up case consensus.VerifiedNewBlock <- blk: diff --git a/consensus/leader.go b/consensus/leader.go index b34757ae6..548ec98c0 100644 --- a/consensus/leader.go +++ b/consensus/leader.go @@ -322,5 +322,4 @@ func (consensus *Consensus) onCommit(recvMsg *FBFTMessage) { consensus.msgSender.StopRetry(msg_pb.MessageType_PREPARED) } - //fmt.Println("onCommit99: ", utils.GetPort(), recvMsg.BlockNum) } diff --git a/consensus/view_change.go b/consensus/view_change.go index 226db683c..377a7098f 100644 --- a/consensus/view_change.go +++ b/consensus/view_change.go @@ -1,7 +1,6 @@ package consensus import ( - "fmt" "math/big" "time" @@ -142,7 +141,6 @@ func (consensus *Consensus) getNextViewID() (uint64, time.Duration) { Uint64("stuckBlockViewID", stuckBlockViewID). Msg("[getNextViewID]") - fmt.Println("end getNextViewID: ", nextViewID, viewChangeDuration) // duration is always the fixed view change duration for synchronous view change return nextViewID, viewChangeDuration } @@ -215,7 +213,6 @@ func (consensus *Consensus) getNextLeaderKey(viewID uint64) *bls.PublicKeyWrappe lastLeaderPubKey, gap) } - fmt.Println("wasfoundNext", consensus.Blockchain.Config().IsAllowlistEpoch(epoch), wasFound, next.Bytes.Hex(), lastLeaderPubKey.Bytes.Hex()) if !wasFound { consensus.getLogger().Warn(). Str("key", consensus.LeaderPubKey.Bytes.Hex()). @@ -237,7 +234,6 @@ func createTimeout() map[TimeoutType]*utils.Timeout { // startViewChange start the view change process func (consensus *Consensus) startViewChange() { - fmt.Printf("[startViewChange]: %d %s \n", utils.GetPort(), consensus.LeaderPubKey.Bytes.Hex()) if consensus.disableViewChange || consensus.IsBackup() { return } @@ -246,7 +242,6 @@ func (consensus *Consensus) startViewChange() { consensus.consensusTimeout[timeoutBootstrap].Stop() consensus.current.SetMode(ViewChanging) nextViewID, duration := consensus.getNextViewID() - //fmt.Println("startViewChange", nextViewID) consensus.SetViewChangingID(nextViewID) // TODO: set the Leader PubKey to the next leader for view change // this is dangerous as the leader change is not succeeded yet @@ -287,9 +282,7 @@ func (consensus *Consensus) startViewChange() { if !consensus.isValidatorInCommittee(key.Pub.Bytes) { continue } - // Тут уже другой leader msgToSend := consensus.constructViewChangeMessage(&key) - fmt.Println("Message to send leader222: ", consensus.LeaderPubKey.Bytes.Hex()) if err := consensus.msgSender.SendWithRetry( consensus.BlockNum(), msg_pb.MessageType_VIEWCHANGE,