From bb17e26d71f08854658d4148397acab3917d294c Mon Sep 17 00:00:00 2001 From: Andrej Mitrovic Date: Fri, 13 Nov 2020 17:41:49 +0900 Subject: [PATCH] Stop nominating immediately after externalize The super call to `onAcceptedBlock()` can actually cause a context switch, which means the call to `stopNominationRound()` may be delayed. --- source/agora/node/Validator.d | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/agora/node/Validator.d b/source/agora/node/Validator.d index 9f70797689c..e2b8114cffe 100644 --- a/source/agora/node/Validator.d +++ b/source/agora/node/Validator.d @@ -352,13 +352,13 @@ public class Validator : FullNode, API protected final override void onAcceptedBlock (const ref Block block, bool validators_changed) @safe { - super.onAcceptedBlock(block, validators_changed); + assert(block.header.height >= this.last_shuffle_height); // block received either via externalize or getBlocksFrom(), - // we need to cancel any existing nominating rounds + // we need to cancel any existing nominating rounds. + // note: must be called before any context switch this.nominator.stopNominationRound(block.header.height); - - assert(block.header.height >= this.last_shuffle_height); + super.onAcceptedBlock(block, validators_changed); const need_shuffle = block.header.height >= (this.last_shuffle_height + this.params.QuorumShuffleInterval);