Skip to content

Commit 96f7f94

Browse files
foriequal0mergify[bot]
authored andcommitted
Fix possible regression issue caused by ProposeWaitEmptyBlockTimer
Possible scenario: * Schedule timeout for `ProposeWaitEmptyBlockTimer` on height: n * On timeout, timer loop queues a call to `Tendermint::on_timeout` on the timer worker * Blocks are imported at the same time with the timeout. * Block importer holds lock for Tendermint, calls `new_blocks` * The worker checks whether it is cancelled, but it is not cancelled yet. * The worker waits for the lock. * several `move_to_height`, `move_to_step` are called by new_blocks * height is not n anymore. * `move_to_step` clears timer, but the check is already passed and the worker waits for the lock. * It finally releases the lock. * The waiting worker calls Tendermint::on_timeout and the timeout for `ProposeWaitEmptyBlockTimer` calls `move_to_step(Prevote)` * The timeout was set for the height n, but the code in the timeout reads changed height.
1 parent e096a50 commit 96f7f94

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

core/src/consensus/tendermint/worker.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1232,8 +1232,15 @@ impl Worker {
12321232
TendermintState::ProposeWaitEmptyBlockTimer {
12331233
block,
12341234
} => {
1235-
cdebug!(ENGINE, "Empty proposal timer is finished, go to the prevote step and broadcast the block");
1236-
self.submit_proposal_block(block.as_ref());
1235+
if self.height == block.header().number() {
1236+
cdebug!(
1237+
ENGINE,
1238+
"Empty proposal timer is finished, go to the prevote step and broadcast the block"
1239+
);
1240+
self.submit_proposal_block(block.as_ref());
1241+
} else {
1242+
cwarn!(ENGINE, "Empty proposal timer was for previous height.");
1243+
}
12371244
}
12381245
_ => {
12391246
cwarn!(ENGINE, "Empty proposal timer was not cleared.");

0 commit comments

Comments
 (0)