From e601af0ffde3da7f5f37bc174107e521ac290d8a Mon Sep 17 00:00:00 2001 From: Antony Denyer Date: Wed, 23 Nov 2022 12:20:04 +0000 Subject: [PATCH] Fix block period changing down - the block proposal is responsible for changing the block period --- consensus/istanbul/ibft/engine/engine.go | 2 +- consensus/istanbul/qbft/engine/engine.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/consensus/istanbul/ibft/engine/engine.go b/consensus/istanbul/ibft/engine/engine.go index 369fd8eefa..305cdf19ab 100644 --- a/consensus/istanbul/ibft/engine/engine.go +++ b/consensus/istanbul/ibft/engine/engine.go @@ -157,7 +157,7 @@ func (e *Engine) verifyCascadingFields(chain consensus.ChainHeaderReader, header } // Ensure that the block's timestamp isn't too close to it's parent - if parent.Time+e.cfg.GetConfig(parent.Number).BlockPeriod > header.Time { + if parent.Time+e.cfg.GetConfig(header.Number).BlockPeriod > header.Time { return istanbulcommon.ErrInvalidTimestamp } diff --git a/consensus/istanbul/qbft/engine/engine.go b/consensus/istanbul/qbft/engine/engine.go index a7135db01c..137b790c98 100644 --- a/consensus/istanbul/qbft/engine/engine.go +++ b/consensus/istanbul/qbft/engine/engine.go @@ -209,7 +209,9 @@ func (e *Engine) verifyCascadingFields(chain consensus.ChainHeaderReader, header } // Ensure that the block's timestamp isn't too close to it's parent - if parent.Time+e.cfg.GetConfig(parent.Number).BlockPeriod > header.Time { + // When the BlockPeriod is reduced it is reduced for the proposal. + // e.g when blockperiod is 1 from block 10 the block period between 9 and 10 is 1 + if parent.Time+e.cfg.GetConfig(header.Number).BlockPeriod > header.Time { return istanbulcommon.ErrInvalidTimestamp }