Vulnerability: VotingMachine - tryToMoveToValidating can lock up proposals
Severity: high

Description:
After a vote was received, the proposal can move to a validating state if any of the votes pass the proposal's `precReq` value, referred to as the minimum threshold.\\n```\\ntryToMoveToValidating(\\_proposalId);\\n```\\n\\nInside the method `tryToMoveToValidating` each of the vote options are checked to see if they pass `precReq`. In case that happens, the proposal goes into the next stage, specifically `Validating`.\\n```\\n/// @notice Function to move to Validating the proposal in the case the last vote action\\n/// was done before the required votingBlocksDuration passed\\n/// @param \\_proposalId The id of the proposal\\nfunction tryToMoveToValidating(uint256 \\_proposalId) public {\\n    Proposal storage \\_proposal = proposals[\\_proposalId];\\n    require(\\_proposal.proposalStatus == ProposalStatus.Voting, "VOTING\\_STATUS\\_REQUIRED");\\n    if (\\_proposal.currentStatusInitBlock.add(\\_proposal.votingBlocksDuration) <= block.number) {\\n        for (uint256 i = 0; i <= COUNT\\_CHOICES; i++) {\\n            if (\\_proposal.votes[i] > \\_proposal.precReq) {\\n                internalMoveToValidating(\\_proposalId);\\n            }\\n        }\\n    }\\n}\\n```\\n\\nThe method `internalMoveToValidating` checks the proposal's status to be `Voting` and proceeds to moving the proposal into `Validating` state.\\n```\\n/// @notice Internal function to change proposalStatus from Voting to Validating\\n/// @param \\_proposalId The id of the proposal\\nfunction internalMoveToValidating(uint256 \\_proposalId) internal {\\n    Proposal storage \\_proposal = proposals[\\_proposalId];\\n    require(\\_proposal.proposalStatus == ProposalStatus.Voting, "ONLY\\_ON\\_VOTING\\_STATUS");\\n    \\_proposal.proposalStatus = ProposalStatus.Validating;\\n    \\_proposal.currentStatusInitBlock = block.number;\\n    emit StatusChangeToValidating(\\_proposalId);\\n}\\n```\\n\\nThe problem appears if multiple vote options go past the minimum threshold. This is because the loop does not stop after the first found option and the loop will fail when the method `internalMoveToValidating` is called a second time.\\n```\\nfor (uint256 i = 0; i <= COUNT\\_CHOICES; i++) {\\n    if (\\_proposal.votes[i] > \\_proposal.precReq) {\\n        internalMoveToValidating(\\_proposalId);\\n    }\\n}\\n```\\n\\nThe method `internalMoveToValidating` fails the second time because the first time it is called, the proposal goes into the `Validating` state and the second time it is called, the require check fails.\\n```\\nrequire(\\_proposal.proposalStatus == ProposalStatus.Voting, "ONLY\\_ON\\_VOTING\\_STATUS");\\n\\_proposal.proposalStatus = ProposalStatus.Validating;\\n```\\n\\nThis can lead to proposal lock-ups if there are enough votes to at least one option that pass the minimum threshold.

Impact:

Recommended mitigation:
After moving to the `Validating` state return successfully.\\n```\\nfunction tryToMoveToValidating(uint256 \\_proposalId) public {\\n    Proposal storage \\_proposal = proposals[\\_proposalId];\\n    require(\\_proposal.proposalStatus == ProposalStatus.Voting, "VOTING\\_STATUS\\_REQUIRED");\\n    if (\\_proposal.currentStatusInitBlock.add(\\_proposal.votingBlocksDuration) <= block.number) {\\n        for (uint256 i = 0; i <= COUNT\\_CHOICES; i++) {\\n            if (\\_proposal.votes[i] > \\_proposal.precReq) {\\n                internalMoveToValidating(\\_proposalId);\\n                return; // <- this was added\\n            }\\n        }\\n    }\\n}\\n```\\n\\nAn additional change can be done to `internalMoveToValidating` because it is called only in `tryToMoveToValidating` and the parent method already does the check.\\n```\\n/// @notice Internal function to change proposalStatus from Voting to Validating\\n/// @param \\_proposalId The id of the proposal\\nfunction internalMoveToValidating(uint256 \\_proposalId) internal {\\n    Proposal storage \\_proposal = proposals[\\_proposalId];\\n    // The line below can be removed\\n    // require(\\_proposal.proposalStatus == ProposalStatus.Voting, "ONLY\\_ON\\_VOTING\\_STATUS");\\n    \\_proposal.proposalStatus = ProposalStatus.Validating;\\n    \\_proposal.currentStatusInitBlock = block.number;\\n    emit StatusChangeToValidating(\\_proposalId);\\n}\\n```\\n