-
Notifications
You must be signed in to change notification settings - Fork 3
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
System.checkAuthority using getContractMetadata #74
Conversation
updates from the official repository
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.
With the implicit calls to getArguments
and getCaller
in function signatures, do we want to add some internal caching so when those calls are made multiple times, we can short circuit and return the cached object?
I have also requested @sgerbino's review on this PR to ensure correctness and usability before we release it to contract devs. |
Good suggestion. I just added a cache value for these 2 functions. |
Sorry for the delay in review. LGTM, I want @sgerbino to look at it as well before we merge. |
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.
Looking at this again, there are no tests for this new behavior. We probably need to add contract metadata to MockVM so we can be sure this authority check works in the scenario it is intended to address.
I've been very busy in other topics. I'd appreciate if someone can work in the unit tests. |
Brief description
This PR takes advantage of the new system contract called "get_contract_metadata", which is used to determine if an account has a contract or not. This is useful to improve the security of the assets (see references).
Changes:
System.getContractMetadata
System.checkAuthority
has been renamed toSystem.checkAuthorityLegacy
System.checkAuthority
which calls getContractMetadata internally.System.checkCallContractAuthority
which calls the checkAuthority and fill the arguments.System.requireAuthority
updated.References
Checklist
Demonstration
I deployed 3 contracts in mainnet: smart wallet, assets contract, and third party contract. These contracts interact between them to demonstrate the advantages of the new system call. They are working as expected.
You can follow the tests described in this post but using these addresses for mainnet: