diff --git a/gossip/gossip/channel/channel.go b/gossip/gossip/channel/channel.go index ae1383e79f2..8502d13fd26 100644 --- a/gossip/gossip/channel/channel.go +++ b/gossip/gossip/channel/channel.go @@ -420,6 +420,10 @@ func (gc *gossipChannel) HandleMessage(msg proto.ReceivedMessage) { gc.logger.Warning("Payload is empty, got it from", msg.GetConnectionInfo().ID) return } + // Would this block go into the message store if it was verified? + if !gc.blockMsgStore.CheckValid(msg.GetGossipMessage()) { + return + } if !gc.verifyBlock(m.GossipMessage, msg.GetConnectionInfo().ID) { gc.logger.Warning("Failed verifying block", m.GetDataMsg().Payload.SeqNum) return @@ -468,6 +472,10 @@ func (gc *gossipChannel) HandleMessage(msg proto.ReceivedMessage) { gc.logger.Warning("DataUpdate message contains item with channel", gMsg.Channel, "but should be", gc.chainID) return } + // Would this block go into the message store if it was verified? + if !gc.blockMsgStore.CheckValid(msg.GetGossipMessage()) { + return + } if !gc.verifyBlock(gMsg.GossipMessage, msg.GetConnectionInfo().ID) { return } diff --git a/gossip/gossip/gossip_impl.go b/gossip/gossip/gossip_impl.go index da317819a74..1a877b4836c 100644 --- a/gossip/gossip/gossip_impl.go +++ b/gossip/gossip/gossip_impl.go @@ -437,26 +437,6 @@ func (g *gossipServiceImpl) validateMsg(msg proto.ReceivedMessage) bool { } } - if msg.GetGossipMessage().IsDataMsg() { - blockMsg := msg.GetGossipMessage().GetDataMsg() - if blockMsg.Payload == nil { - g.logger.Warning("Empty block! Discarding it") - return false - } - - // If we're configured to skip block validation, don't verify it - if g.conf.SkipBlockVerification { - return true - } - - seqNum := blockMsg.Payload.SeqNum - rawBlock := blockMsg.Payload.Data - if err := g.mcs.VerifyBlock(msg.GetGossipMessage().Channel, seqNum, rawBlock); err != nil { - g.logger.Warning("Could not verify block", blockMsg.Payload.SeqNum, ":", err) - return false - } - } - if msg.GetGossipMessage().IsStateInfoMsg() { if err := g.validateStateInfoMsg(msg.GetGossipMessage()); err != nil { g.logger.Warning("StateInfo message", msg, "is found invalid:", err)