mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-12-26 00:25:17 +00:00
qol: banish the noise
This commit is contained in:
parent
196588cbe6
commit
483077e1da
@ -100,6 +100,12 @@ func (e *CeremonyDataClockConsensusEngine) handleMessage(
|
|||||||
|
|
||||||
switch any.TypeUrl {
|
switch any.TypeUrl {
|
||||||
case protobufs.ClockFrameType:
|
case protobufs.ClockFrameType:
|
||||||
|
e.peerMapMx.Lock()
|
||||||
|
if peer, ok := e.peerMap[string(message.From)]; !ok ||
|
||||||
|
bytes.Compare(peer.version, consensus.GetMinimumVersion()) < 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
e.peerMapMx.Unlock()
|
||||||
if err := e.handleClockFrameData(
|
if err := e.handleClockFrameData(
|
||||||
message.From,
|
message.From,
|
||||||
msg.Address,
|
msg.Address,
|
||||||
@ -150,22 +156,13 @@ func (e *CeremonyDataClockConsensusEngine) handleCeremonyPeerListAnnounce(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if p.PublicKey == nil || p.Signature == nil || p.Version == nil {
|
if p.PublicKey == nil || p.Signature == nil || p.Version == nil {
|
||||||
if time.Now().After(consensus.GetMinimumVersionCutoff()) {
|
|
||||||
if bytes.Equal(p.PeerId, peerID) {
|
|
||||||
e.logger.Warn(
|
|
||||||
"peer provided outdated version, penalizing app score",
|
|
||||||
zap.Binary("peer_id", p.PeerId),
|
|
||||||
)
|
|
||||||
e.pubSub.SetPeerScore(p.PeerId, -100)
|
|
||||||
}
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if p.PublicKey != nil && p.Signature != nil && p.Version != nil {
|
if p.PublicKey != nil && p.Signature != nil && p.Version != nil {
|
||||||
key, err := pcrypto.UnmarshalEd448PublicKey(p.PublicKey)
|
key, err := pcrypto.UnmarshalEd448PublicKey(p.PublicKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.logger.Error(
|
e.logger.Warn(
|
||||||
"peer announcement contained invalid pubkey",
|
"peer announcement contained invalid pubkey",
|
||||||
zap.Binary("public_key", p.PublicKey),
|
zap.Binary("public_key", p.PublicKey),
|
||||||
)
|
)
|
||||||
@ -173,7 +170,7 @@ func (e *CeremonyDataClockConsensusEngine) handleCeremonyPeerListAnnounce(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !(peer.ID(p.PeerId)).MatchesPublicKey(key) {
|
if !(peer.ID(p.PeerId)).MatchesPublicKey(key) {
|
||||||
e.logger.Error(
|
e.logger.Warn(
|
||||||
"peer announcement peer id does not match pubkey",
|
"peer announcement peer id does not match pubkey",
|
||||||
zap.Binary("peer_id", p.PeerId),
|
zap.Binary("peer_id", p.PeerId),
|
||||||
zap.Binary("public_key", p.PublicKey),
|
zap.Binary("public_key", p.PublicKey),
|
||||||
@ -186,7 +183,7 @@ func (e *CeremonyDataClockConsensusEngine) handleCeremonyPeerListAnnounce(
|
|||||||
msg = binary.BigEndian.AppendUint64(msg, uint64(p.Timestamp))
|
msg = binary.BigEndian.AppendUint64(msg, uint64(p.Timestamp))
|
||||||
b, err := key.Verify(msg, p.Signature)
|
b, err := key.Verify(msg, p.Signature)
|
||||||
if err != nil || !b {
|
if err != nil || !b {
|
||||||
e.logger.Error(
|
e.logger.Warn(
|
||||||
"peer provided invalid signature",
|
"peer provided invalid signature",
|
||||||
zap.Binary("msg", msg),
|
zap.Binary("msg", msg),
|
||||||
zap.Binary("public_key", p.PublicKey),
|
zap.Binary("public_key", p.PublicKey),
|
||||||
@ -196,8 +193,8 @@ func (e *CeremonyDataClockConsensusEngine) handleCeremonyPeerListAnnounce(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if bytes.Compare(p.Version, consensus.GetMinimumVersion()) < 0 &&
|
if bytes.Compare(p.Version, consensus.GetMinimumVersion()) < 0 &&
|
||||||
time.Now().After(consensus.GetMinimumVersionCutoff()) {
|
p.Timestamp > consensus.GetMinimumVersionCutoff().UnixMilli() {
|
||||||
e.logger.Warn(
|
e.logger.Debug(
|
||||||
"peer provided outdated version, penalizing app score",
|
"peer provided outdated version, penalizing app score",
|
||||||
zap.Binary("peer_id", p.PeerId),
|
zap.Binary("peer_id", p.PeerId),
|
||||||
)
|
)
|
||||||
|
@ -915,7 +915,8 @@ func (e *CeremonyDataClockConsensusEngine) GetMostAheadPeer() (
|
|||||||
var peer []byte = nil
|
var peer []byte = nil
|
||||||
for _, v := range e.peerMap {
|
for _, v := range e.peerMap {
|
||||||
_, ok := e.uncooperativePeersMap[string(v.peerId)]
|
_, ok := e.uncooperativePeersMap[string(v.peerId)]
|
||||||
if v.maxFrame > max && !ok {
|
if v.maxFrame > max &&
|
||||||
|
v.timestamp > consensus.GetMinimumVersionCutoff().UnixMilli() && !ok {
|
||||||
peer = v.peerId
|
peer = v.peerId
|
||||||
max = v.maxFrame
|
max = v.maxFrame
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user