<p><b>@sqrrm</b> approved this pull request.</p>

<p>utACK</p>
<p>It might be worth simplifying the vote reveal publishing but not necessary.</p>
<p>I think this PR will also make sure to not burn any BSQ associated with a vote reveal, even if it's published before the vote reveal phase, but the vote calculation will still be correct.</p><hr>

<p>In <a href="https://github.com/bisq-network/bisq/pull/2195#discussion_r245284937">core/src/main/java/bisq/core/dao/governance/votereveal/VoteRevealService.java</a>:</p>
<pre style='color:#555'>> @@ -172,7 +175,13 @@ public void onParseBlockChainComplete() {
     // the blind vote was created in case we have not done it already.
     // The voter need to be at least once online in the reveal phase when he has a blind vote created,
     // otherwise his vote becomes invalid and his locked stake will get unlocked
-    private void maybeRevealVotes(int chainHeight) {
+    private void maybeRevealVotes() {
+        // We must not use daoStateService.getChainHeight() because that gets updated with each parsed block but we
+        // only want to publish the vote reveal tx if our current real chain height is matching the cycle and phase and
+        // not at any intermediate height during parsing all blocks. The bsqNode knows the latest height from either
+        // Bitcoin Core or from the seed node.
+        int chainHeight = bsqNode.getChainTipHeight();
</pre>
<p>I have a feeling that we might want to wait to publish until we've parsed the chain up until chainTipHeight instead of publishing before we're done parsing. I don't have a concrete example, but publishing before knowing the actual current state seems like it could lead to more trouble. Maybe it would invalidate some BSQ, or maybe it would just burn some to fees.</p>

<hr>

<p>In <a href="https://github.com/bisq-network/bisq/pull/2195#discussion_r245475035">core/src/main/java/bisq/core/dao/governance/votereveal/VoteRevealService.java</a>:</p>
<pre style='color:#555'>> +                        // BSQ because the blind vote tx is already in the snapshot and does not get parsed
+                        // again. It would require a reset of the snapshot and parse all blocks again.
+                        // As this is an exceptional case we prefer to have a simple solution instead and just
+                        // publish the vote reveal tx but are aware that is is invalid.
+                        log.warn("We missed the vote reveal phase but publish now the tx to unlock our locked " +
+                                "BSQ from the blind vote tx. BlindVoteTxId={}", myVote.getTxId());
+
+                        boolean isAfterVoteRevealPhase = periodService.getPhaseForHeight(chainHeight).ordinal() > DaoPhase.Phase.VOTE_REVEAL.ordinal();
+
+                        // We missed the reveal phase but we are in the correct cycle
+                        boolean missedPhaseSameCycle = isAfterVoteRevealPhase && isBlindVoteTxInCorrectPhaseAndCycle;
+
+                        // If we missed the cycle we don't care about the phase anymore.
+                        boolean isBlindVoteTxInPastCycle = periodService.isTxInPastCycle(myVote.getTxId(), chainHeight);
+
+                        if (missedPhaseSameCycle || isBlindVoteTxInPastCycle) {
</pre>
<p>It seems all paths lead here except for when the time between the vote is cast and the reveal phase. Wouldn't it be easier to check at which block height the vote reveal should be sent and do a simple check if the block height is more than the reveal block height to send the vote reveal?</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/bisq-network/bisq/pull/2195#pullrequestreview-189350720">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AkpZtoFHnocRG0rGYMv3JhP45kuWWDFBks5vAJargaJpZM4ZoUDn">mute the thread</a>.<img src="https://github.com/notifications/beacon/AkpZtppLziJipcFq22OzuOyI_rtikOghks5vAJargaJpZM4ZoUDn.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/bisq-network/bisq","title":"bisq-network/bisq","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/bisq-network/bisq"}},"updates":{"snippets":[{"icon":"PERSON","message":"@sqrrm approved #2195"}],"action":{"name":"View Pull Request","url":"https://github.com/bisq-network/bisq/pull/2195#pullrequestreview-189350720"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/bisq-network/bisq/pull/2195#pullrequestreview-189350720",
"url": "https://github.com/bisq-network/bisq/pull/2195#pullrequestreview-189350720",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>