-
Notifications
You must be signed in to change notification settings - Fork 363
Warning for mismatching mastercopy in safe proxy #3908
Conversation
CLA Assistant Lite All Contributors have signed the CLA. |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
Pull Request Test Coverage Report for Build 2514574842
💛 - Coveralls |
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.
Note : the error is shown for the valid mastercopy 1.1.1 - safe for testing rin:0x43852dB7B5ACE1e57d853789D331caeD88Af3cFF |
* refactor master copy validation to reuse safeContracts getSafeContractDeployment * change test + new testcase
I found the issue and fixed it. I also added a new testcase for this. |
This safe is using an invalid master copy contract. The web interface might not work correctly. It's | ||
recommended to use the{' '} |
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.
This safe is using an invalid master copy contract. The web interface might not work correctly. It's | |
recommended to use the{' '} | |
This Safe is created with an unsupported base contract. The web interface might not work correctly. We recommend using the{' '} |
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.
The ecosystem term for the "base" contract is an implementation contract. But in our codebase we use "singleton", I'd suggest to keep the wording aligned
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.
Thanks for the correction Mikhail. IMHO implementation contract is clear, singleton sounds like too much detail.
Let's just drop the word base
maybe?
I.e. This Safe was created with an unsupported contract
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.
This Safe was created with an unsupported contract
It may be too broad, I feel like creating a Safe with an unsupported factory contract also can be described like this
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.
Yes, and that would also warrant this banner.
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.
Looks good! There are a few linting issues re return types.
@@ -36,4 +40,50 @@ describe('Check safe version', () => { | |||
expect(hasFeature(FEATURES.SAFE_APPS, '1.1.1')).toBe(true) | |||
}) | |||
}) | |||
|
|||
describe('isValidMasterCopy', () => { |
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 think we should add some more tests so that we cover all deployed versions.
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.
Fixed the linter and prettier warnings and added tests for 1.0.0 and 1.2.0!
We're having quite a few errors on Sentry from Safes like this btw: It's from a Safe deployed on an unsupported BSC fork of the contract. It would be nice to also handle cases like that. As you can see in the Safe Info payload, the version is But otherwise I think it's ready for QA. |
Co-authored-by: Aaron Cook <[email protected]>
Dismissing because that button isn't there anymore.
@katspaugh , I would expect that such case is covered on the add safe flow as not supported mastercopy on address detection - should we report it as a separate issue ? |
I've found this specific safe, one I created a while ago using the safe UI. This safe shows the banner and I don't think it should https://safe-client.gnosis.io/v1/chains/100/safes/0x157C6adB6786fB471C9969cAc2D77e09c4e2599d EDIT: I tried a tx (owner removal) and it worked just fine |
@francovenica I checked the safes which were flagged as invalid and I think they use the L1 master copy instead of the L2 master copy: Here is a IMO correct safe using the L2 master copy on matic: "implementation":{
"value":"0x3E5c63644E683549055b9Be8653de26E0B4CD36E",
"name":"Gnosis Safe: Singleton L2 1.3.0",
"logoUri":"https://safe-transaction-assets.gnosis-safe.io/contracts/logos/0x3E5c63644E683549055b9Be8653de26E0B4CD36E.png"} While both safes you provided return "implementation":{
"value":"0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552",
"name":"Gnosis Safe: Singleton 1.3.0",
"logoUri":"https://safe-transaction-assets.gnosis-safe.io/contracts/logos/0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552.png"} These are the safe-deployments for L2 and version 1.3.0: https://github.com/safe-global/safe-deployments/blob/main/src/assets/v1.3.0/gnosis_safe_l2.json This makes me wonder if we miss a way of creating invalid safes if you used the UI for creating them or if I misunderstand how to get the expected version to compare it with the safe info. |
expect(isValid).toBe(true) | ||
}) | ||
|
||
it('returns true for L1 mastercopy in L2 chain and version 1.0.0', async () => { |
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.
What about an L2 version on the L1 chain?
Also a more general note: if a specific master copy is supported depends on the service running it. E.g. mainnet and GC support all master copies while all other networks only support the 1.3.0+L2 version. Not sure what the expected behavior is for this PR, but if the goal is to show what version can be used with our services, we should probably rely on server side information.
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.
Is there an endpoint to get the server side information which versions are supported by our services for a chainID?
I agree that it would be the cleanest solution.
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 believe it's this one: https://safe-transaction.optimism.gnosis.io/api/v1/about/master-copies/, but it needs to be extended to flag non-indexed singletons
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.
There's a gateway endpoint too: /v1/chains/{chainId}/about/master-copies
. The SDK has master copy function. It too would also need to be extended.
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.
Hmm could we probably detect it when looking at the lastIndexedBlockNumber
?
For some L2 networks where the L1 master copy won't work like polygon it seems to stay the same as the deployedBlockNumber
: https://safe-transaction.polygon.gnosis.io/api/v1/about/master-copies/
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 thought about that too, but not sure how reliable it is. I'd ask the infra team
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.
Apparently the infra team was considering to remove all non-relevant / unsupported master copies and will do that soon.
So I will change the PR now to use this endpoint and simply check if the master copy version is included in the response.
in a matter of design:
|
The infra team will change the endpoint such that only valid master copies will be returned by the sdk.
This PR should work as soon as safe-global/safe-transaction-service#887 is live! |
I have times where a safe sometimes fails the initial load and then loads properly, something that is not rare in some networks. The thing is that when it fails to load it shows the warning message, and then when it loads properly the message still shows. If you refresh the page the message is gone. I'm not sure if the system can check if the safe just failed to load so it doesn't show the message until it verifies that is the MC is actually not compatible. |
Even with the comment I made before, the ticket looks fine and I'm ok with passing it to done I just checked that for all the safe with a proper MC version, (those who show the safe version in the settings) don't show the warning message and those safe with an incompatible MC version show the warning message. Is impossible to be sure that it works for every safe out there, but I've checked over 100 safes in different networks and I didn't had issues |
This ticket was put in QA, but I don't see anything new. |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
9578056
to
693f860
Compare
@@ -233,7 +236,6 @@ const SafeHeader = ({ | |||
</Container> | |||
) | |||
} | |||
const chainInfo = getChainInfo() |
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.
Please avoid making unnecessary changes like this.
src/components/AppLayout/index.tsx
Outdated
@@ -134,6 +136,7 @@ const Layout: React.FC<Props> = ({ | |||
}): React.ReactElement => { | |||
const [mobileNotSupportedClosed, setMobileNotSupportedClosed] = useState(false) | |||
const [expanded, setExpanded] = useState(false) | |||
const [showMasterCopyError, setShowMasterCopyError] = useState(true) |
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.
If you return null
from InvalidMasterCopyError
when it's valid then you no longer need this state.
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 think this state is for when the user closes the banner
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.
This is used to hide the error if the user closes the alert.
I moved this state into the InvalidMasterCopyError component as it is not needed outside of it.
Ok, I'm not getting the warning message if the safe fails to load. Looks good to me |
What it solves
Resolves #3873
How this PR fixes it
Displays a warning in the SafeHeader if the safe uses a invalid master copy contract.
How to test it
Open this safe which was deployed with an invalid master copy
matic:0x5B7e9a88237Ca67591e751186b10623Db5653045
Screenshots
Cases to check: