Skip to content

Commit

Permalink
harden invariant in ballot protocol
Browse files Browse the repository at this point in the history
for clarity and to avoid false negatives in static analyzer
  • Loading branch information
MonsieurNicolas committed Apr 1, 2022
1 parent 8e956b6 commit 97f75e8
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/scp/BallotProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,21 @@ BallotProtocol::emitCurrentStateStatement()
void
BallotProtocol::checkInvariants()
{
switch (mPhase)
{
case SCP_PHASE_PREPARE:
break;
case SCP_PHASE_CONFIRM:
case SCP_PHASE_EXTERNALIZE:
dbgAssert(mCurrentBallot);
dbgAssert(mPrepared);
dbgAssert(mCommit);
dbgAssert(mHighBallot);
break;
default:
dbgAbort();
}

if (mCurrentBallot)
{
dbgAssert(mCurrentBallot->getBallot().counter != 0);
Expand All @@ -664,21 +679,6 @@ BallotProtocol::checkInvariants()
dbgAssert(areBallotsLessAndCompatible(mHighBallot->getBallot(),
mCurrentBallot->getBallot()));
}

switch (mPhase)
{
case SCP_PHASE_PREPARE:
break;
case SCP_PHASE_CONFIRM:
dbgAssert(mCommit);
break;
case SCP_PHASE_EXTERNALIZE:
dbgAssert(mCommit);
dbgAssert(mHighBallot);
break;
default:
dbgAbort();
}
}

std::set<SCPBallot>
Expand Down

5 comments on commit 97f75e8

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

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

saw approval from marta-lokhova
at MonsieurNicolas@97f75e8

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

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

merging MonsieurNicolas/stellar-core/coverityUpdatesMarch2022 = 97f75e8 into auto

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

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

MonsieurNicolas/stellar-core/coverityUpdatesMarch2022 = 97f75e8 merged ok, testing candidate = 4c7c563

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

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

fast-forwarding master to auto = 4c7c563

Please sign in to comment.