From d9b8704b48749b2026844644085ca59f16ac6978 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 19 Aug 2020 19:38:50 +0300 Subject: [PATCH] consensus: check for chain's height in verifyBlock We may already be behind and this check could be irrelevant. --- pkg/consensus/consensus.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/consensus/consensus.go b/pkg/consensus/consensus.go index e685238fe..4971fd52d 100644 --- a/pkg/consensus/consensus.go +++ b/pkg/consensus/consensus.go @@ -349,6 +349,10 @@ func (s *service) getTx(h util.Uint256) block.Transaction { func (s *service) verifyBlock(b block.Block) bool { coreb := &b.(*neoBlock).Block + if s.Chain.BlockHeight() >= coreb.Index { + s.log.Warn("proposed block has already outdated") + return false + } maxBlockSize := int(s.Chain.GetMaxBlockSize()) size := io.GetVarSize(coreb) if size > maxBlockSize { @@ -379,6 +383,10 @@ func (s *service) verifyBlock(b block.Block) bool { zap.Error(err)) return false } + if s.Chain.BlockHeight() >= coreb.Index { + s.log.Warn("proposed block has already outdated") + return false + } } maxBlockSysFee := s.Chain.GetMaxBlockSystemFee()