-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: broadcast vote power #4683
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -534,12 +534,14 @@ func (node *Node) validateNodeMessage(ctx context.Context, payload []byte) ( | |
return payload[p2pNodeMsgPrefixSize:], msgType, nil | ||
} | ||
|
||
type ignore = bool | ||
|
||
// validateShardBoundMessage validate consensus message | ||
// validate shardID | ||
// validate public key size | ||
// verify message signature | ||
func validateShardBoundMessage(consensus *consensus.Consensus, peer libp2p_peer.ID, nodeConfig *nodeconfig.ConfigType, payload []byte, | ||
) (*msg_pb.Message, *bls.SerializedPublicKey, bool, error) { | ||
) (*msg_pb.Message, *bls.SerializedPublicKey, ignore, error) { | ||
var ( | ||
m msg_pb.Message | ||
//consensus = registry.GetConsensus() | ||
|
@@ -591,11 +593,16 @@ func validateShardBoundMessage(consensus *consensus.Consensus, peer libp2p_peer. | |
} | ||
} | ||
|
||
maybeCon, maybeVC := m.GetConsensus(), m.GetViewchange() | ||
senderKey := []byte{} | ||
senderBitmap := []byte{} | ||
var ( | ||
maybeCon = m.GetConsensus() | ||
maybeVC = m.GetViewchange() | ||
maybeSP = m.GetLastSignPower() | ||
senderKey []byte | ||
senderBitmap []byte | ||
) | ||
|
||
if maybeCon != nil { | ||
switch { | ||
case maybeCon != nil: | ||
if maybeCon.ShardId != consensus.ShardID { | ||
nodeConsensusMessageCounterVec.With(prometheus.Labels{"type": "invalid_shard"}).Inc() | ||
return nil, nil, true, errors.WithStack(errWrongShardID) | ||
|
@@ -609,7 +616,7 @@ func validateShardBoundMessage(consensus *consensus.Consensus, peer libp2p_peer. | |
if maybeCon.ViewId+5 < consensus.GetCurBlockViewID() { | ||
return nil, nil, true, errors.WithStack(errViewIDTooOld) | ||
} | ||
} else if maybeVC != nil { | ||
case maybeVC != nil: | ||
if maybeVC.ShardId != consensus.ShardID { | ||
nodeConsensusMessageCounterVec.With(prometheus.Labels{"type": "invalid_shard"}).Inc() | ||
return nil, nil, true, errors.WithStack(errWrongShardID) | ||
|
@@ -619,7 +626,14 @@ func validateShardBoundMessage(consensus *consensus.Consensus, peer libp2p_peer. | |
if maybeVC.ViewId+5 < consensus.GetViewChangingID() { | ||
return nil, nil, true, errors.WithStack(errViewIDTooOld) | ||
} | ||
} else { | ||
case maybeSP != nil: | ||
if maybeSP.ShardId != consensus.ShardID { | ||
nodeConsensusMessageCounterVec.With(prometheus.Labels{"type": "invalid_shard"}).Inc() | ||
return nil, nil, true, errors.WithStack(errWrongShardID) | ||
} | ||
senderKey = maybeSP.SenderPubkey | ||
consensus.SetLastKnownSignPower(maybeSP.Commit) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to capture all 3 VP : during an outage, most likely we won't even hit the commit phase, and during that time only view change VP will be seen. |
||
default: | ||
nodeConsensusMessageCounterVec.With(prometheus.Labels{"type": "invalid"}).Inc() | ||
return nil, nil, true, errors.WithStack(errNoSenderPubKey) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please update the log message here