-
Notifications
You must be signed in to change notification settings - Fork 428
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
Immutable contracts allowed to change state via env
#1969
Comments
Not a bug but a feature XD |
As discussed elsewhere. I disagree. Because it is hard to impossible to know inside our macros whether any state mutating API is called downstream. We should not pretend that we actually know this. And talk about it in the docs, and even include a
We simply shouldn't sell guarantees we can't fulfill, especially if they can have security implications. What do we gain from having this in the metadata when it is in fact completely meaningless? In the current state, the only thing "immutable message" means is that the storage can't be written directly (but via a plethora of other ways, some of them intended). Which is very missleading. However, while currently not implemented, we could enforce this in the runtime. Akin to a |
As discussed before, I think we should restrict the direct usage of |
This doesn't solve the issue fully, but would be helpful in a lint. Bottom line is we rely on the clients to do this correctly. The contracts-ui already honors it and fixed it in cargo contract. Additionally I am going to implement a static call flag in the contracts pallet so that contract to contract calls can have this guarantee. |
As per our docs:
However this isn't enforced: Via the
Environment
, supposedly immutable contracts can change the state in many ways. Things that are currently possible in immutable contracts that should fail to compile:call_runtime
Minimal reproducer
While direct storage writes are enforced by the
&self
receiver, this can easily be circumvented.The text was updated successfully, but these errors were encountered: