From 8c013e2e530d87c6f342cd9c21836dcc80745cca Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Tue, 12 Sep 2023 15:14:22 +0200 Subject: [PATCH] fix(consensus): PrepareProposal should not be called during replay --- internal/consensus/state_controller.go | 1 + internal/consensus/state_enter_propose.go | 7 +++++++ internal/consensus/types/round_state.go | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/consensus/state_controller.go b/internal/consensus/state_controller.go index 6a303d91ac..b0f4240ebe 100644 --- a/internal/consensus/state_controller.go +++ b/internal/consensus/state_controller.go @@ -87,6 +87,7 @@ func NewController(cs *State, wal *wrapWAL, statsQueue *chanQueue[msgInfo], prop scheduler: cs.roundScheduler, eventPublisher: cs.eventPublisher, proposalCreator: propler, + replayMode: cs.replayMode, }, AddProposalBlockPartType: &AddProposalBlockPartAction{ logger: cs.logger, diff --git a/internal/consensus/state_enter_propose.go b/internal/consensus/state_enter_propose.go index 5def6c122c..ee41820493 100644 --- a/internal/consensus/state_enter_propose.go +++ b/internal/consensus/state_enter_propose.go @@ -31,6 +31,7 @@ type EnterProposeAction struct { scheduler *roundScheduler eventPublisher *EventPublisher proposalCreator cstypes.ProposalCreator + replayMode bool } func (c *EnterProposeAction) Execute(ctx context.Context, stateEvent StateEvent) error { @@ -93,6 +94,12 @@ func (c *EnterProposeAction) Execute(ctx context.Context, stateEvent StateEvent) "node_proTxHash", proTxHash.String()) return nil } + // In replay mode, we don't propose blocks. + if c.replayMode { + logger.Debug("enter propose step; our turn to propose but in replay mode, not proposing") + return nil + } + logger.Debug("propose step; our turn to propose", "proposer_proTxHash", proTxHash.ShortString(), ) diff --git a/internal/consensus/types/round_state.go b/internal/consensus/types/round_state.go index a1150b2741..8c9181b9a0 100644 --- a/internal/consensus/types/round_state.go +++ b/internal/consensus/types/round_state.go @@ -97,7 +97,7 @@ type RoundState struct { // Last known round with POL for non-nil valid block. ValidRound int32 `json:"valid_round"` ValidBlock *types.Block `json:"valid_block"` // Last known block of POL mentioned above. - ValidBlockRecvTime time.Time `json:"valid_block_time"` // Receive time of ast known block of POL mentioned above. + ValidBlockRecvTime time.Time `json:"valid_block_time"` // Receive time of last known block of POL mentioned above. // Last known block parts of POL mentioned above. ValidBlockParts *types.PartSet `json:"valid_block_parts"`