diff --git a/sync/firewall/firewall.go b/sync/firewall/firewall.go index ed55bd820..cea9c9f86 100644 --- a/sync/firewall/firewall.go +++ b/sync/firewall/firewall.go @@ -217,35 +217,13 @@ func (f *Firewall) isExpiredMessage(msgData []byte) bool { return true } - // TODO: we remove on the version v1.8.0 - consensusHeightExtracted := false - var consensusHeight uint32 - consensusHeightBytes := msgData[msgLen-6:] - // Check if consensus height is set. Refer to the bundle encoding for more details. - if consensusHeightBytes[0] == 0x04 && consensusHeightBytes[1] == 0x1a { - consensusHeight = binary.BigEndian.Uint32(consensusHeightBytes[2:]) - - if consensusHeight > 2_900_000 { - consensusHeightExtracted = true - } - } - if !consensusHeightExtracted { - // Decoding the message at this level is costly, and we should avoid it. - // In future versions, this code can be removed. - // However, at the time of writing this code, we need it to prevent replay attacks. - bdl := new(bundle.Bundle) - _, err := bdl.Decode(bytes.NewReader(msgData)) - if err != nil { - return true - } - - consensusHeight = bdl.Message.ConsensusHeight() - } + consensusHeightRaw := msgData[msgLen-6:] + consensusHeight := binary.BigEndian.Uint32(consensusHeightRaw[2:]) // The message is expired, or the consensus height is behind the network's current height. - // In either case, the message is dropped and won't be propagated. if f.state.LastBlockHeight() > 0 && consensusHeight < f.state.LastBlockHeight()-1 { - f.logger.Warn("firewall: expired message", "message height", consensusHeight, "our height", f.state.LastBlockHeight()) + f.logger.Warn("firewall: expired message", "message height", consensusHeight, + "our height", f.state.LastBlockHeight()) return true }