Skip to content

Commit

Permalink
fix(consensus): PrepareProposal should not be called during replay (#678
Browse files Browse the repository at this point in the history
)
  • Loading branch information
lklimek authored Sep 13, 2023
1 parent ecfc56f commit 920f346
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/consensus/state_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions internal/consensus/state_enter_propose.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(),
)
Expand Down
2 changes: 1 addition & 1 deletion internal/consensus/types/round_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit 920f346

Please sign in to comment.