-
Notifications
You must be signed in to change notification settings - Fork 205
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
Pseudo slashing for invalid signers #4269
Pseudo slashing for invalid signers #4269
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## feat/optimise-consensus-sigcheck #4269 +/- ##
===================================================================
Coverage ? 71.21%
===================================================================
Files ? 663
Lines ? 86210
Branches ? 0
===================================================================
Hits ? 61392
Misses ? 20302
Partials ? 4516 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
- remove reference to temp pubsub library - restore p2p message changes
…core - fix unit tests
…for-invalid-signers
…onsensus-sig-into-pseudo-slashing
…sig-into-pseudo-slashing Merge optimize consensus sig into pseudo slashing
…onsensus-sig-into-pseudo-slashing
…sig-into-pseudo-slashing Merge optimize consensus sig into pseudo slashing
|
||
return false | ||
} | ||
|
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.
I will also add here the following checks, just to avoid some edge case situations, exactly as they are used in the receivedFinalInfo method:
if sr.IsSelfLeaderInCurrentRound() {
return false
}
if !sr.IsConsensusDataEqual(cnsDta.BlockHeaderHash) {
return false
}
if !sr.CanProcessReceivedMessage(cnsDta, sr.RoundHandler().Index(), sr.Current()) {
return false
}
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.
done
log.Debug("doEndRoundJobByLeader.getFullMessagesForInvalidSigners", "error", err.Error()) | ||
return false | ||
} | ||
|
||
bitmap, sig, err = sr.computeAggSigOnValidNodes() | ||
if err != nil { | ||
log.Debug("doEndRoundJobByLeader.computeAggSigOnValidNodes", "error", err.Error()) |
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.
Also in the case of insufficient threshold of valid signatures I think we should call sr.createAndBroadcastInvalidSigners(invalidSigners). I think this method should be called mandatory if we have invalidSigners set, no matter if we will exit from the current method earlier.
One suggestion is to replace L313-L317 with the code below and remove L365-L367 and L300-L301 as method getFullMessagesForInvalidSigners could return only two parameters, not needed the middle one.
invalidSigners, err := sr.getFullMessagesForInvalidSigners(invalidPubKeys)
if err != nil {
log.Debug("doEndRoundJobByLeader.getFullMessagesForInvalidSigners", "error", err.Error())
return false
}
if len(invalidSigners) > 0 {
sr.createAndBroadcastInvalidSigners(invalidSigners)
}
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.
done
@@ -337,7 +438,7 @@ func (sr *subroundEndRound) verifyNodesOnAggSigVerificationFail() error { | |||
|
|||
err = sr.SetJobDone(pk, SrSignature, false) | |||
if err != nil { | |||
return err | |||
return nil, err |
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.
L445 should be like this I think, as we should punish the validator who sent this, not just to revert things to his last honesty level:
decreaseFactor := -spos.ValidatorPeerHonestyIncreaseFactor + spos.ValidatorPeerHonestyDecreaseFactor
Exactly as we do in subRoundSignature -> receivedSignature method, for nodes who are not in consensus but they are sending signatures. Anyway the invalid signatures are much worse than valid ones which are sent when is not necessary:
if !sr.IsNodeInConsensusGroup(node) {
sr.PeerHonestyHandler().ChangeScore(
node,
spos.GetConsensusTopicID(sr.ShardCoordinator()),
spos.ValidatorPeerHonestyDecreaseFactor,
)
return false
}
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.
done
@@ -63,6 +67,7 @@ func (cns *ConsensusState) ResetConsensusState() { | |||
cns.Data = nil | |||
|
|||
cns.initReceivedHeaders() | |||
cns.initReceivedMessagesWithSig() |
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.
...WithInvalidSigners ?
@@ -94,6 +105,22 @@ func (cns *ConsensusState) GetReceivedHeaders() []data.HeaderHandler { | |||
return receivedHeaders | |||
} | |||
|
|||
// AddMessageWithSignature will add the p2p message to received list of messages | |||
func (cns *ConsensusState) AddMessageWithSignature(key string, message p2p.MessageP2P) { |
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.
...WithInvalidSigners ?
} | ||
|
||
// GetMessageWithSignature will get the p2p message based on key | ||
func (cns *ConsensusState) GetMessageWithSignature(key string) (p2p.MessageP2P, bool) { |
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.
...WithInvalidSigners ?
consensus/spos/interface.go
Outdated
@@ -53,6 +53,8 @@ type ConsensusCoreHandler interface { | |||
PrivateKey() crypto.PrivateKey | |||
// SingleSigner returns the single signer stored in the ConsensusStore used for randomness and leader's signature generation | |||
SingleSigner() crypto.SingleSigner | |||
// KeyGenerator returns the key generator stored in the ConsensusStore |
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.
ConsensusCore instead ConsensusStore in the whole file and also in some other files (2 files)
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.
done
consensus/spos/interface.go
Outdated
@@ -63,6 +65,8 @@ type ConsensusCoreHandler interface { | |||
NodeRedundancyHandler() consensus.NodeRedundancyHandler | |||
// ScheduledProcessor returns the scheduled txs processor | |||
ScheduledProcessor() consensus.ScheduledProcessor | |||
// MessageSignerHandler |
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.
Finalize this comment
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.
done
@@ -191,6 +193,11 @@ func (ccm *ConsensusCoreMock) SingleSigner() crypto.SingleSigner { | |||
return ccm.blsSingleSigner | |||
} | |||
|
|||
// KeyGenerator - |
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.
L191: ConsensusCore instead ConsensusStore and also in some other files (2 more files)
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.
done
consensus/spos/interface.go
Outdated
@@ -65,7 +65,7 @@ type ConsensusCoreHandler interface { | |||
NodeRedundancyHandler() consensus.NodeRedundancyHandler | |||
// ScheduledProcessor returns the scheduled txs processor | |||
ScheduledProcessor() consensus.ScheduledProcessor | |||
// MessageSignerHandler | |||
// MessageSignerHandler return the p2p signing handler |
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.
returns
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.
done
@@ -442,7 +456,7 @@ func (sr *subroundEndRound) verifyNodesOnAggSigVerificationFail() ([]string, err | |||
} | |||
|
|||
// use increase factor since it was added optimistically, and it proved to be wrong | |||
decreaseFactor := -spos.ValidatorPeerHonestyIncreaseFactor | |||
decreaseFactor := -spos.ValidatorPeerHonestyIncreaseFactor + spos.ValidatorPeerHonestyDecreaseFactor |
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.
👍
Pseudo slashing for invalid signers:
invalidSigners