-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
What is the alternative for Claimable in v2.0.0? #1488
Comments
UPDATE: The alternative above is not even feasible because:
The second reason is much more critical of course, because it means that I cannot even fix I have looked into your However:
Should I just implement a designated |
UPDATE 2: I believe that it would have been better if you had left the If I understand correctly, then the only alternative at this point is to implement my own custom contract using the Step 1 - added in file
Step 2 - added file
|
Hey there @barakman! Thank you for bringing this up. The reason why the What I'm wondering is why you need |
@nventuro: Hi. I understand your motivation in changing the access-level of the However, since the To elaborate a little more about this, some of our For this purpose, we transfer the ownership of each relevant contract from ourselves (i.e., the deploying account) to a And in order to ensure that we never accidentally transfer the ownership of a contract to the wrong address, we use the Thanks. |
Hey @barakman, I'm glad you're with us on the The main reason behind As you noticed, our current access-control solution are the
I'd argue however that all |
@nventuro: Hi. Yes, your argument is accurate - if I transfer ownership of a contract to the wrong account (presumably a non-existing one, due to a typo for example), then I will need to redeploy the contract, and possibly a few other (related) contracts along with it. This redeployment is equivalent to a Fork of our system, and we consider it pretty disastrous. Thanks |
As a general rule, if such a deployment may cause issues in your system, I'd advise you to take a look at the whole architecture: ideally, your contracts should be worthless and not meaningful until you start using them (presumably, after checking deployment was successful). That said, if (temporarily) transferring ownership to a non-existent account doesn't bother you, |
While I am a fan of RBAC for large projects, for small contracts it is way overkill and adds a ton of unnecessary complexity (i.e., risk). I encourage keeping Ownable/Claimable around while also pursuing a RBAC system. The landing page for my personal blog doesn't need RBAC, while by 100 engineer company certainly does. IMO, Ownable/Claimable fill a different niche from an RBAC system and should not be deleted. |
@MicahZoltu indeed, we think Regarding |
@MicahZoltu How would you feel if the replacement for the old |
@nventuro I never use Ownable without Claimable, because Ownable alone makes it too easy to accidentally fat-finger-send-to-dev-null. @frangio If the target audience for Ownable/Claimable is "simple contracts", it feels like requiring a transitive owner is the opposite direction from what we want. Now I have to author a second contract with passthrough functions to each of the The thing that makes Claimable nice (compared to something like RBAC) is that it is a relatively simple protection (dozens of lines of already-audited code) against catastrophic failure (sending contract to /dev/null). It requires almost zero additional operational/infrastructure work over Ownable, while a full RBAC system or proxy contract requires notably more effort to maintain/manage. |
Hmm, I could get behind those arguments. I take it though that by /dev/null you mean 'any random address' and not just the zero address, right? Arguably, as soon as you transfer ownership to another account it will be able to claim it, so you'd be relying on a) no-one having the private keys, or b) they not being fast enough. |
Yeah, zero address is a common target as it is the default value for all local variables/parameters and easy to accidentally send to if you screw up your transaction creation. However, fat-fingering is another common source of error that can lead to the contract going to an address that no one controls. I'm not worried about accidentally transferring to an address that someone does have the keys to. While that is possible, it isn't the vector I'm worried about. |
What if we embedded the old Granted, we can't simply change how |
I would be fine with My vote would be Ownable + Claimable, but would not fight against a single Ownable contract with a |
Is this one due to be released any time soon? Following an (extremely thorough) audit, my workaround for fetching The auditer further recommends to add it explicitly to our system. We would highly prefer to avoid it, and to continue using your widely-used and thoroughly-verified Is there any chance that you reinstate them in the coming release? Thanks again :) |
@barakman We can't guarantee to release this soon. Given that, I'd recommend to implement |
@frangio: |
A statement I wholeheartedly agree with :) @barakman We'll be exploring options soon (specially considering this shouldn't be such a big change), but I'm not sure yet regarding a release date, sorry. |
I've already come to realize that even if you do reinstate And since we've decided to stick with solc v0.4.x for the time being, it will probably yield some other "collisions" in our project. So I have resolved the audit-warning by downloading This way, the following is achieved:
Of course, if I am wrong in my initial assumption, and you do reinstate Thanks for your help :) |
Next version compatible implementation: pragma solidity ^0.5.0;
import "github.com/openzeppelin/openzeppelin-contracts/contracts/ownership/Ownable.sol";
contract Claimable is Ownable {
address public pendingOwner;
modifier onlyPendingOwner() {
require(_msgSender() == pendingOwner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
pendingOwner = newOwner;
}
function claimOwnership() public onlyPendingOwner {
_transferOwnership(pendingOwner);
delete pendingOwner;
}
} @nventuro do you think this worth Pull Request? |
^^ @nventuro? @frangio? @MicahZoltu? |
|
Oh, actually there should be a function cancelOwnershipTransfer() public onlyOwner {
delete pendingOwner;
} You could transfer ownership to yourself (owner), but that feels dirty when your goal is to cancel an ownership transfer. Also, there may be value in firing events for |
@MicahZoltu it seems more like |
Ah, good point. You could do Funnily enough, I believe this exact feedback is what I got from OpenZeppelin in a contract review that had |
Updated implementation:
|
Is there value in having a separate event for |
This comment makes sense because function Once this function requires this condition (which it should IMO), emitting event In either case, there is nothing "magical" about 0 here (i.e., it is not used as a magic number). Alternatively, instead of adding |
Currently, the value of Adding We could add a method for |
A zero address is the default value of all uninitialized Hence Hence |
Ehhh, I would accept the argument that |
That one is dictated by the Solidity language standard. So no, |
Not exactly a bug, for for those who have been using
Claimable
in earlier versions of OZ (for the purpose oftransferOwnership
followed byclaimOwnership
) - what are the options in v2.0.0?Relying solely on
Ownable.transferOwnership
lacks a safety mechanism for accidentally transferring the ownership to an incorrect address.At present, the only alternative that I see is copying
Claimable.sol
from v.12.0 to my repo, fixing theimport "./Ownable.sol"
statement, and inheriting my contracts fromClaimable
instead ofOwnable
.This is far from being a clean solution.
Are there any alternatives?
I've been reading something about roles (issue 1274, issue 1146, issue 1291).
Is that possibly related?
Thanks
The text was updated successfully, but these errors were encountered: