GovernorChanges.spec 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import "helpers.spec"
  2. import "methods/IGovernor.spec"
  3. import "Governor.helpers.spec"
  4. import "GovernorInvariants.spec"
  5. use invariant proposalStateConsistency
  6. /*
  7. โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  8. โ”‚ Rule: Proposal can be switched state only by specific functions โ”‚
  9. โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  10. */
  11. rule changes(uint256 pId, env e, method f, calldataarg args)
  12. filtered { f -> !skip(f) }
  13. {
  14. require clockSanity(e);
  15. requireInvariant proposalStateConsistency(pId);
  16. address user;
  17. bool existBefore = proposalCreated(pId);
  18. bool isExecutedBefore = isExecuted(pId);
  19. bool isCanceledBefore = isCanceled(pId);
  20. bool isQueuedBefore = isQueued(pId);
  21. bool hasVotedBefore = hasVoted(pId, user);
  22. uint256 votesAgainstBefore = getAgainstVotes(pId);
  23. uint256 votesForBefore = getForVotes(pId);
  24. uint256 votesAbstainBefore = getAbstainVotes(pId);
  25. f(e, args);
  26. bool existAfter = proposalCreated(pId);
  27. bool isExecutedAfter = isExecuted(pId);
  28. bool isCanceledAfter = isCanceled(pId);
  29. bool isQueuedAfter = isQueued(pId);
  30. bool hasVotedAfter = hasVoted(pId, user);
  31. uint256 votesAgainstAfter = getAgainstVotes(pId);
  32. uint256 votesForAfter = getForVotes(pId);
  33. uint256 votesAbstainAfter = getAbstainVotes(pId);
  34. // propose, execute, cancel
  35. assert existAfter != existBefore => (!existBefore && f.selector == propose(address[],uint256[],bytes[],string).selector);
  36. assert isExecutedAfter != isExecutedBefore => (!isExecutedBefore && f.selector == execute(address[],uint256[],bytes[],bytes32).selector);
  37. assert isCanceledAfter != isCanceledBefore => (!isCanceledBefore && f.selector == cancel(address[],uint256[],bytes[],bytes32).selector);
  38. // queue is cleared on cancel
  39. assert isQueuedAfter != isQueuedBefore => (
  40. (!isQueuedBefore && f.selector == queue(address[],uint256[],bytes[],bytes32).selector) ||
  41. (isQueuedBefore && f.selector == cancel(address[],uint256[],bytes[],bytes32).selector)
  42. );
  43. // votes
  44. assert hasVotedAfter != hasVotedBefore => (!hasVotedBefore && votingAll(f));
  45. assert votesAgainstAfter != votesAgainstBefore => (votesAgainstAfter > votesAgainstBefore && votingAll(f));
  46. assert votesForAfter != votesForBefore => (votesForAfter > votesForBefore && votingAll(f));
  47. assert votesAbstainAfter != votesAbstainBefore => (votesAbstainAfter > votesAbstainBefore && votingAll(f));
  48. }