Skip to content

Commit

Permalink
Broadcast sign power
Browse files Browse the repository at this point in the history
  • Loading branch information
Frozen committed Jun 4, 2024
1 parent e88d6e2 commit d58a280
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
7 changes: 1 addition & 6 deletions consensus/consensus_service.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package consensus

import (
"fmt"
"math/big"
"sync/atomic"
"time"
Expand Down Expand Up @@ -182,20 +181,16 @@ func (consensus *Consensus) sendLastSignPower() {
}
marshaledMessage, err := consensus.signAndMarshalConsensusMessage(msg, k.Pri)
if err != nil {
panic(err)
consensus.getLogger().Err(err).
Msg("[constructNewViewMessage] failed to sign and marshal the new view message")
return
}
msgToSend := proto.ConstructConsensusMessage(marshaledMessage)
if err := consensus.msgSender.SendWithoutRetry(
//consensus.getBlockNum(),
//msg_pb.MessageType_LAST_SIGN_POWER,
[]nodeconfig.GroupID{
nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(consensus.ShardID))},
p2p.ConstructMessage(msgToSend),
); err != nil {
panic(err)
fmt.Println("Error when sending out the message", err)
consensus.getLogger().Err(err).
Msg("[LastSignPower] could not send out the ViewChange message")
}
Expand Down
9 changes: 1 addition & 8 deletions consensus/leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/harmony-one/harmony/crypto/bls"
"github.com/harmony-one/harmony/internal/common"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
"github.com/harmony-one/harmony/numeric"

"github.com/ethereum/go-ethereum/rlp"
bls_core "github.com/harmony-one/bls/ffi/go/bls"
Expand Down Expand Up @@ -131,9 +130,8 @@ func (consensus *Consensus) onPrepare(recvMsg *FBFTMessage) {
}
signerCount := consensus.decider.SignersCount(quorum.Prepare)
//// Read - End
power := consensus.decider.VoteTally(quorum.Prepare)

consensus.UpdateLeaderMetrics(float64(signerCount), float64(consensus.getBlockNum()), roundPower(power))
consensus.UpdateLeaderMetrics(float64(signerCount), float64(consensus.getBlockNum()))

// Check BLS signature for the multi-sig
prepareSig := recvMsg.Payload
Expand Down Expand Up @@ -195,11 +193,6 @@ func (consensus *Consensus) onPrepare(recvMsg *FBFTMessage) {
//// Read - End
}

func roundPower(power numeric.Dec) float64 {
round := float64(power.MulInt64(10000).RoundInt64()) / 10000
return round
}

// this method is called by leader
func (consensus *Consensus) onCommit(recvMsg *FBFTMessage) {
//// Read - Start
Expand Down
2 changes: 1 addition & 1 deletion consensus/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (consensus *Consensus) UpdateValidatorMetrics(numSig float64, blockNum floa
}

// UpdateLeaderMetrics will udpate leader metrics
func (consensus *Consensus) UpdateLeaderMetrics(numCommits float64, blockNum float64, power float64) {
func (consensus *Consensus) UpdateLeaderMetrics(numCommits float64, blockNum float64) {
consensusCounterVec.With(prometheus.Labels{"consensus": "hooray"}).Inc()
consensusGaugeVec.With(prometheus.Labels{"consensus": "block_num"}).Set(blockNum)
consensusCounterVec.With(prometheus.Labels{"consensus": "num_commits"}).Add(numCommits)
Expand Down

0 comments on commit d58a280

Please sign in to comment.