Skip to content

[POA] Fix rewinding expired polls#769

Merged
fassadlr merged 9 commits intostratisproject:release/1.1.0.0from
fassadlr:pollsreporewind
Nov 17, 2021
Merged

[POA] Fix rewinding expired polls#769
fassadlr merged 9 commits intostratisproject:release/1.1.0.0from
fassadlr:pollsreporewind

Conversation

@fassadlr
Copy link
Contributor

No description provided.

@fassadlr fassadlr requested a review from quantumagi November 16, 2021 14:09

// Check if the current tip is before the poll expiry activation block,
// if so un-expire it.
if (poll.IsExpired && this.CurrentTip.Height < this.network.ConsensusOptions.Release1100ActivationHeight)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@quantumagi this part is important to review.

Copy link
Contributor

@quantumagi quantumagi Nov 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (poll.IsExpired && !IsPollExpiredAt(poll, this.CurrentTip, this.network))
{
  poll.IsExpired = false;
  ...
}

// Add this PollsRepository method which could also replace a similar method on VotingManager.
public static bool IsPollExpiredAt(Poll poll, ChainedHeader chainedHeader, Network network)
{
    if (chainedHeader == null)
        return false;

    return Math.Max(poll.PollStartBlockData.Height + network.ConsensusOptions.PollExpiryBlocks, network.ConsensusOptions.Release1100ActivationHeight) <= chainedHeader.Height;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@quantumagi fixed, please re-check.

@quantumagi
Copy link
Contributor

LGTM. Perhaps just the one suggested change and CI must pass.

Copy link
Contributor

@quantumagi quantumagi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fassadlr fassadlr merged commit 83313bc into stratisproject:release/1.1.0.0 Nov 17, 2021
@fassadlr fassadlr deleted the pollsreporewind branch November 24, 2021 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants