-
Notifications
You must be signed in to change notification settings - Fork 12.4k
feat: Bouncer refactor, test streamlining, and vocabulary updates #1024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a3df995
fix: updates for SignatureBouncer tests and voucher construction
shrugs 40cd2a7
feat: implement isValidSignature and update language
shrugs 84c63f5
fix: linting errors
shrugs a07eca7
fix: change RBACOwnable#onlyOwner to onlyOwners
shrugs f11aa5c
checkpoint: refactor out delegate contant
shrugs 5257a81
fix: split logic into BouncerUtils and abstract awway sender, delegate
shrugs b932612
fix: update imports for other contracts
shrugs ca23fa7
feat: refactor into SignatureChecker
shrugs ce2d206
fix: abstract to isSignedBy
shrugs 1e0fd85
fix: formatting of ERC165Checker
shrugs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
fix: updates for SignatureBouncer tests and voucher construction
- Loading branch information
commit a3df995141f2416f13fd30b865e16d6f54317aa4
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| pragma solidity ^0.4.24; | ||
|
|
||
| import "./RBAC.sol"; | ||
|
|
||
|
|
||
| /** | ||
| * @title RBACOwnable | ||
| * @author Matt Condon (@shrugs) | ||
| * @dev Ownable logic using RBAC. | ||
| * @dev Use RBACOwnable if you could have many different owners and you're ok with | ||
| * @dev the security profile of any owner being able to add another owner. | ||
| * @dev Only difference from Ownable.sol is that the owners are not stored as public variables. | ||
| */ | ||
| contract RBACOwnable is RBAC { | ||
| string public constant ROLE_OWNER = "owner"; | ||
|
|
||
| constructor() | ||
| public | ||
| { | ||
| addRole(msg.sender, ROLE_OWNER); | ||
| } | ||
|
|
||
| modifier onlyOwner() { | ||
| checkRole(msg.sender, ROLE_OWNER); | ||
| _; | ||
| } | ||
|
|
||
| function addOwner(address _owner) | ||
| onlyOwner | ||
| public | ||
| { | ||
| addRole(_owner, ROLE_OWNER); | ||
| } | ||
|
|
||
| function removeOwner(address _owner) | ||
| onlyOwner | ||
| public | ||
| { | ||
| removeRole(_owner, ROLE_OWNER); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import assertRevert from '../../helpers/assertRevert'; | ||
|
|
||
| const RBACOwnable = artifacts.require('RBACOwnable'); | ||
|
|
||
| require('chai') | ||
| .use(require('chai-as-promised')) | ||
| .should(); | ||
|
|
||
| contract('RBAC', function ([_, owner, newOwner, notOwner]) { | ||
| before(async function () { | ||
| this.ownable = await RBACOwnable.new({ from: owner }); | ||
| this.roleOwner = await this.ownable.ROLE_OWNER(); | ||
| }); | ||
|
|
||
| it('should not allow notOwner to add or remove owners', async function () { | ||
| await assertRevert( | ||
| this.ownable.addOwner(newOwner, { from: notOwner }) | ||
| ); | ||
|
|
||
| await assertRevert( | ||
| this.ownable.removeOwner(owner, { from: notOwner }) | ||
| ); | ||
| }); | ||
|
|
||
| it('should allow existing owner to add and remove a newOwner', async function () { | ||
| await this.ownable.addOwner(newOwner, { from: owner }); | ||
| let hasRole = await this.ownable.hasRole(newOwner, this.roleOwner); | ||
| hasRole.should.eq(true); | ||
|
|
||
| await this.ownable.removeOwner(newOwner, { from: owner }); | ||
| hasRole = await this.ownable.hasRole(newOwner, this.roleOwner); | ||
| hasRole.should.eq(false); | ||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's Solidity's fault but if a contract has both
OwnableandRBACOwnablein its inheritance graph there is no warning about the clashing modifier names... I'm not even sure what will happen.Having both of those in the inheritance graph is probably a mistake, so in an ideal world the clashing modifiers would raise an error. Given that there is no error, I'm not sure what I prefer. π
It's also not clear to me why we're changing
BouncerintoRBACOwnable. Perhaps we can undo that so as to sidestep the issue for now...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modifiers will be overwritten just like function implementations afaik, so as long as RBAC is higher in the tree, this one takes precedence. I agree that it's confusing, but I bet it's expected behavior.
Contracts should only inherit from RBACOwnable or Ownable; I can't think of a reason a contract would inherit from both.
In any case, I still think RBACOwnable is a better primitive than ownable, and want to use it as basic access control on new features. thoughts?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about using the current
RBACOwnablefor new features: I would either change the name of the modifier, or removeOwnablealtogether.While no-one should explicitly use both, I worry about the danger of someone inadvertently doing it indirectly, e.g., by extending a
RefundableCrowdsaleand then either adding RBAC ownership on top or inheriting from another contract that uses RBAC as the ownership model.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could change it to
onlyOwnersβhow's that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I think that could work, specially considering that (how many owners there are) is the only difference between
OwnableandRBACOwnable.