-
Notifications
You must be signed in to change notification settings - Fork 2
Swap out Safe requirements for generic multisig #32
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
Open
JAG-UK
wants to merge
1
commit into
filecoin-project:main
Choose a base branch
from
JAG-UK:fix/multisig-identification
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+84
−41
Open
Changes from all commits
Commits
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
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,25 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
| pragma solidity ^0.8.36; | ||
|
|
||
| /// @notice The only thing we require of a multisig: it can list its signers. | ||
| /// @dev Safe{Wallet} and the other common multisig implementations all expose this. | ||
| interface IMultisig { | ||
| function getOwners() external view returns (address[] memory); | ||
| } | ||
|
|
||
| library IsAMultisig { | ||
| error NotAMultisig(address account); | ||
| error TooFewSigners(address account, uint256 signers); | ||
|
|
||
| /// @notice Requires that `account` is a contract behaving like a multisig with >1 signer. | ||
| /// @dev FIP-0118 mandates no specific multisig implementation, so this deliberately checks | ||
| /// behaviour, not identity: any contract answering `getOwners()` with two or more signers | ||
| /// qualifies, and EOAs (no code, so no return data) do not. | ||
| function requireMultisig(address account) internal view { | ||
| (bool ok, bytes memory ret) = account.staticcall(abi.encodeCall(IMultisig.getOwners, ())); | ||
| // 64 bytes is the shortest well-formed `address[]` encoding: head offset + length | ||
| require(ok && ret.length >= 64, NotAMultisig(account)); | ||
| address[] memory signers = abi.decode(ret, (address[])); | ||
| require(signers.length > 1, TooFewSigners(account, signers.length)); | ||
| } | ||
| } | ||
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
| pragma solidity ^0.8.36; | ||
|
|
||
| /// @notice Minimal stand-in for any multisig: it just lists its signers. | ||
| contract MockMultisig { | ||
| address[] internal signers; | ||
|
|
||
| constructor(uint256 count) { | ||
| for (uint256 i = 0; i < count; i++) { | ||
| signers.push(address(uint160(i + 1))); | ||
| } | ||
| } | ||
|
|
||
| function getOwners() external view returns (address[] memory) { | ||
| return signers; | ||
| } | ||
| } |
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.
Does
Safeimplement this method? Can we assume any multisig would implement it? Research others and see what the most-common interface is.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.
Safe definitely does: getOwners() is a public view function on OwnerManager, which Safe inherits.
Just tested with foundry just now to double check but this same 'trick' worked with the Root Key Holders msig-of-msigs which mixed raw and Safe msigs.
But as for others I don't know - what others do we need to support?
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.
Sounds like we still only support safes.
Here's a list https://www.alchemy.com/dapps/list-of/multisig-wallets-on-ethereum
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.
OK cool, so we're OK then I think.
If we were still worried and want to be as broad as possible then we could change it to only check
address.code.length > 0like you suggested in the other thread. This is a governance opinion at this point I think.