AccessControl.spec 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. methods {
  2. grantRole(bytes32, address)
  3. revokeRole(bytes32, address)
  4. _checkRole(bytes32)
  5. safeTransferFrom(address, address, uint256, uint256, bytes)
  6. safeBatchTransferFrom(address, address, uint256[], uint256[], bytes)
  7. getRoleAdmin(bytes32) returns(bytes32) envfree
  8. hasRole(bytes32, address) returns(bool) envfree
  9. }
  10. // STATUS - verified
  11. // If `onlyRole` modifier reverts then `grantRole()` reverts
  12. rule onlyRoleModifierCheckGrant(env e){
  13. bytes32 role; address account;
  14. _checkRole@withrevert(e, getRoleAdmin(role));
  15. bool checkRevert = lastReverted;
  16. grantRole@withrevert(e, role, account);
  17. bool grantRevert = lastReverted;
  18. assert checkRevert => grantRevert, "modifier goes bananas";
  19. }
  20. // STATUS - verified
  21. // check onlyRole modifier for revokeRole()
  22. rule onlyRoleModifierCheckRevoke(env e){
  23. bytes32 role; address account;
  24. _checkRole@withrevert(e, getRoleAdmin(role));
  25. bool checkRevert = lastReverted;
  26. revokeRole@withrevert(e, role, account);
  27. bool revokeRevert = lastReverted;
  28. assert checkRevert => revokeRevert, "modifier goes bananas";
  29. }
  30. // STATUS - verified
  31. // grantRole() does not affect another accounts
  32. rule grantRoleEffect(env e){
  33. bytes32 role; address account;
  34. bytes32 anotherRole; address nonEffectedAcc;
  35. require account != nonEffectedAcc;
  36. bool hasRoleBefore = hasRole(anotherRole, nonEffectedAcc);
  37. grantRole(e, role, account);
  38. bool hasRoleAfter = hasRole(anotherRole, nonEffectedAcc);
  39. assert hasRoleBefore == hasRoleAfter, "modifier goes bananas";
  40. }
  41. // STATUS - verified
  42. // revokeRole() does not affect another accounts
  43. rule revokeRoleEffect(env e){
  44. bytes32 role; address account;
  45. bytes32 anotherRole; address nonEffectedAcc;
  46. require account != nonEffectedAcc;
  47. bool hasRoleBefore = hasRole(anotherRole, nonEffectedAcc);
  48. revokeRole(e, role, account);
  49. bool hasRoleAfter = hasRole(anotherRole, nonEffectedAcc);
  50. assert hasRoleBefore == hasRoleAfter, "modifier goes bananas";
  51. }