Skip to content
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

Do not allow removeOwnerAtIndex to remove last owner, add function for removing last owner #43

Merged
merged 6 commits into from
Apr 3, 2024

Conversation

wilsoncusack
Copy link
Contributor

Adds a guard on removeOwnerAtIndex such that it will revert if the call will leave no owners on the account.

No tests yet because still considering. Removes the ability to renounce ownership, except by setting some like 0xdead owner.

@@ -82,31 +92,47 @@ contract MultiOwnable {
/// @notice Convenience function to add a new owner address.
///
/// @param owner The owner address.
function addOwnerAddress(address owner) public virtual onlyOwner {
function addOwnerAddress(address owner) external virtual onlyOwner {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other clean up I am grouping in here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this is overly restrictive. I could imagine a plugin/module that might help users manage owners. Depending on how the community agrees on module/plugin support, this call could be executed in the context of this contract.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we would do an upgrade to enable this? So we could change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wt now? DM me pls

@@ -189,12 +222,30 @@ contract MultiOwnable {
function _addOwnerAtIndex(bytes memory owner, uint256 index) internal virtual {
if (isOwnerBytes(owner)) revert AlreadyOwner(owner);

_getMultiOwnableStorage().isOwner[owner] = true;
_getMultiOwnableStorage().ownerAtIndex[index] = owner;
MultiOwnableStorage storage $ = _getMultiOwnableStorage();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wt ru guys doing

error WrongOwnerAtIndex(uint256 index, bytes owner);
/// @param expectedOwner The owner passed in the remove call.
/// @param actualOwner The actual owner at `index`.
error WrongOwnerAtIndex(uint256 index, bytes expectedOwner, bytes actualOwner);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stevieraykatz this felt nice to have to me

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed -- could help track down malicious replays

src/MultiOwnable.sol Outdated Show resolved Hide resolved
/// @dev Reverts if the owner is not registered at `index`.
/// @dev Reverts if `owner` does not match bytes found at `index`.
///
/// @param index The index of the owner to be remove.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// @param index The index of the owner to be remove.
/// @param index The index of the owner to be removed.

error WrongOwnerAtIndex(uint256 index, bytes owner);
/// @param expectedOwner The owner passed in the remove call.
/// @param actualOwner The actual owner at `index`.
error WrongOwnerAtIndex(uint256 index, bytes expectedOwner, bytes actualOwner);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed -- could help track down malicious replays

@@ -82,31 +92,47 @@ contract MultiOwnable {
/// @notice Convenience function to add a new owner address.
///
/// @param owner The owner address.
function addOwnerAddress(address owner) public virtual onlyOwner {
function addOwnerAddress(address owner) external virtual onlyOwner {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this is overly restrictive. I could imagine a plugin/module that might help users manage owners. Depending on how the community agrees on module/plugin support, this call could be executed in the context of this contract.

@wilsoncusack wilsoncusack merged commit 9c1cf9e into main Apr 3, 2024
8 checks passed
@wilsoncusack wilsoncusack changed the title enforce must always have at least one owner Do not allow removeOwnerAtIndex to remove last owner, add function for removing last owner Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants