From d97a093c187a8eb26b142dddcf448d8a285741f3 Mon Sep 17 00:00:00 2001 From: Cassandra Heart Date: Sat, 16 Nov 2024 23:11:19 -0600 Subject: [PATCH] remove logging in validators due to locking, allow 2.0.3 minversion --- node/config/version.go | 2 +- .../data/data_clock_consensus_engine.go | 6 +++--- node/consensus/data/message_validators.go | 21 ------------------- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/node/config/version.go b/node/config/version.go index 4e88733..391dccd 100644 --- a/node/config/version.go +++ b/node/config/version.go @@ -10,7 +10,7 @@ func GetMinimumVersionCutoff() time.Time { } func GetMinimumVersion() []byte { - return []byte{0x02, 0x00, 0x04} + return []byte{0x02, 0x00, 0x03} } func GetVersion() []byte { diff --git a/node/consensus/data/data_clock_consensus_engine.go b/node/consensus/data/data_clock_consensus_engine.go index 33b5cf1..222aab1 100644 --- a/node/consensus/data/data_clock_consensus_engine.go +++ b/node/consensus/data/data_clock_consensus_engine.go @@ -315,9 +315,9 @@ func (e *DataClockConsensusEngine) Start() <-chan error { go e.runInfoMessageHandler() e.logger.Info("subscribing to pubsub messages") - e.pubSub.RegisterValidator(e.frameFilter, e.validateFrameMessage, true) - e.pubSub.RegisterValidator(e.txFilter, e.validateTxMessage, true) - e.pubSub.RegisterValidator(e.infoFilter, e.validateInfoMessage, true) + e.pubSub.RegisterValidator(e.frameFilter, e.validateFrameMessage, false) + e.pubSub.RegisterValidator(e.txFilter, e.validateTxMessage, false) + e.pubSub.RegisterValidator(e.infoFilter, e.validateInfoMessage, false) e.pubSub.Subscribe(e.frameFilter, e.handleFrameMessage) e.pubSub.Subscribe(e.txFilter, e.handleTxMessage) e.pubSub.Subscribe(e.infoFilter, e.handleInfoMessage) diff --git a/node/consensus/data/message_validators.go b/node/consensus/data/message_validators.go index 01baf91..a3be960 100644 --- a/node/consensus/data/message_validators.go +++ b/node/consensus/data/message_validators.go @@ -5,7 +5,6 @@ import ( "time" "github.com/libp2p/go-libp2p/core/peer" - "go.uber.org/zap" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" "source.quilibrium.com/quilibrium/monorepo/go-libp2p-blossomsub/pb" @@ -16,28 +15,23 @@ import ( func (e *DataClockConsensusEngine) validateFrameMessage(peerID peer.ID, message *pb.Message) p2p.ValidationResult { msg := &protobufs.Message{} if err := proto.Unmarshal(message.Data, msg); err != nil { - e.logger.Debug("could not unmarshal message", zap.Error(err)) return p2p.ValidationResultReject } a := &anypb.Any{} if err := proto.Unmarshal(msg.Payload, a); err != nil { - e.logger.Debug("could not unmarshal payload", zap.Error(err)) return p2p.ValidationResultReject } switch a.TypeUrl { case protobufs.ClockFrameType: frame := &protobufs.ClockFrame{} if err := proto.Unmarshal(a.Value, frame); err != nil { - e.logger.Debug("could not unmarshal frame", zap.Error(err)) return p2p.ValidationResultReject } if ts := time.UnixMilli(frame.Timestamp); time.Since(ts) > time.Hour { - e.logger.Debug("frame is too old", zap.Time("timestamp", ts)) return p2p.ValidationResultIgnore } return p2p.ValidationResultAccept default: - e.logger.Debug("unknown message type", zap.String("type_url", a.TypeUrl)) return p2p.ValidationResultReject } } @@ -45,32 +39,26 @@ func (e *DataClockConsensusEngine) validateFrameMessage(peerID peer.ID, message func (e *DataClockConsensusEngine) validateTxMessage(peerID peer.ID, message *pb.Message) p2p.ValidationResult { msg := &protobufs.Message{} if err := proto.Unmarshal(message.Data, msg); err != nil { - e.logger.Debug("could not unmarshal message", zap.Error(err)) return p2p.ValidationResultReject } a := &anypb.Any{} if err := proto.Unmarshal(msg.Payload, a); err != nil { - e.logger.Debug("could not unmarshal payload", zap.Error(err)) return p2p.ValidationResultReject } switch a.TypeUrl { case protobufs.TokenRequestType: tx := &protobufs.TokenRequest{} if err := proto.Unmarshal(a.Value, tx); err != nil { - e.logger.Debug("could not unmarshal token request", zap.Error(err)) return p2p.ValidationResultReject } if mint := tx.GetMint(); mint != nil { if len(mint.Proofs) < 3 { - e.logger.Debug("mint request is missing proofs") return p2p.ValidationResultReject } if len(mint.Proofs[1]) != 4 { - e.logger.Debug("mint request has invalid modulo") return p2p.ValidationResultReject } if len(mint.Proofs[2]) != 8 { - e.logger.Debug("mint request has invalid frame number") return p2p.ValidationResultReject } head, err := e.dataTimeReel.Head() @@ -78,7 +66,6 @@ func (e *DataClockConsensusEngine) validateTxMessage(peerID peer.ID, message *pb panic(err) } if frameNumber := binary.BigEndian.Uint64(mint.Proofs[2]); frameNumber+10 < head.FrameNumber { - e.logger.Debug("mint request is too old", zap.Uint64("frame_number", frameNumber)) return p2p.ValidationResultIgnore } } @@ -89,12 +76,10 @@ func (e *DataClockConsensusEngine) validateTxMessage(peerID peer.ID, message *pb return p2p.ValidationResultAccept } if ts := time.UnixMilli(tx.Timestamp); time.Since(ts) > 10*time.Minute { - e.logger.Debug("token request is too old", zap.Time("timestamp", ts)) return p2p.ValidationResultIgnore } return p2p.ValidationResultAccept default: - e.logger.Debug("unknown message type", zap.String("type_url", a.TypeUrl)) return p2p.ValidationResultReject } } @@ -102,32 +87,26 @@ func (e *DataClockConsensusEngine) validateTxMessage(peerID peer.ID, message *pb func (e *DataClockConsensusEngine) validateInfoMessage(peerID peer.ID, message *pb.Message) p2p.ValidationResult { msg := &protobufs.Message{} if err := proto.Unmarshal(message.Data, msg); err != nil { - e.logger.Debug("could not unmarshal message", zap.Error(err)) return p2p.ValidationResultReject } a := &anypb.Any{} if err := proto.Unmarshal(msg.Payload, a); err != nil { - e.logger.Debug("could not unmarshal payload", zap.Error(err)) return p2p.ValidationResultReject } switch a.TypeUrl { case protobufs.DataPeerListAnnounceType: announce := &protobufs.DataPeerListAnnounce{} if err := proto.Unmarshal(a.Value, announce); err != nil { - e.logger.Debug("could not unmarshal network info request", zap.Error(err)) return p2p.ValidationResultReject } if announce.Peer == nil { - e.logger.Debug("peer list announce is missing peer") return p2p.ValidationResultIgnore } if ts := time.UnixMilli(announce.Peer.Timestamp); time.Since(ts) > 10*time.Minute { - e.logger.Debug("peer list announce is too old", zap.Time("timestamp", ts)) return p2p.ValidationResultIgnore } return p2p.ValidationResultAccept default: - e.logger.Debug("unknown message type", zap.String("type_url", a.TypeUrl)) return p2p.ValidationResultReject } }