entrypoints without stateful
annotation affecting state changes
#343
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Created by: marc0olo
in the discussions today we got aware of the fact that currently entrypoints without the
stateful
annotation can still be used to:stateful
entrypoints of remote contractsthis is documented accordingly here:
IMO we should definitely address this issue and do not allow the actions mentioned above in entrypoints without the
stateful
annotationCreated by: marc0olo
according to @hanssv this issue is better placed in the main aeternity repo. maybe somebody can move the issue there so that we don't need to close and re-open it.
Created by: UlfNorell
Depends on what guarantees you are after. The compiler could certainly disallow calling stateful entrypoints from non-stateful code, but since there are no statefulness checks in the VM, it would just be checking that you didn't call an endpoint that you claim is stateful.
Created by: radrow
This looks like a result of misunderstanding what "stateful" means. When an entrypoint is not stateful, it is guaranteed not to change the state of this particular contract. It doesn't apply to general stuff on the blockchain, including other contracts.
Since a remote contract can be arbitrary and statefulness is not a thing in the VM, putting these checks in the compiler would leave a hole that could be shamelessly exploited.
There are solutions to that:
If needed,
pure
keyword could be added that would be stricter than non-stateful
by additionally forbidding state reads, chain queries and remote calls. But I see it an overkill.Also, what's wrong with events?
Created by: marc0olo
I think the docs reflect it correctly. nothing to fix here. it seems like this wasn't discussed deep enough in the past and here we are now discussing it :-)
=> expectation (or assumption) of many devs is (or was) that non-stateful entrypoints cannot perform state changes (neither local, nor remote)
maybe we should first have a look again how the EVM and Solidity deal with that topic right now. according to @nikita-fuchs this isn't possible there.
not sure about that here. there was just a general assumption that it's not possible to emit events or perform any state change if an entrypoint isn't declared
stateful
I think we should start collecting a list of important consensus-breaking changes. because we already have a bunch of them discussed during the last few weeks.
at the moment I am not even sure if we already have an issue for the assembly operations we would like to have (cc @hanssv @bogdan-manole). this is probably sth. very important for us.
Created by: hanssv
@marc0olo Yes, #337 cover the bitwise VM-operations we've discussed.
Created by: radrow
I guess this is to be closed?
Created by: marc0olo
if we aim to address this somewhere else I would prefer moving the issue to the respective repository over closing this. we shouldn't ignore/forget that topic :D
Created by: nikita-fuchs
Yep, please let's not lose track of this.
Marco Walz @.***> schrieb am Fr., 24. Sept. 2021, 08:54:
Created by: radrow
Closing this as I don't see any reason to keep it. You have no control over remote contracts' statefulness (if ACI says it, it does not have to be true) and events do not change contract's state. If you would like to have an option to protect yourself from sending events, I would rather introduce a
pure
keyword and expand the restrictions to allow only stateless and pure operations.Created by: marc0olo
to me it is still nonsense that it is allowed to execute stateful entrypoints from remote contracts in non-stateful entrypoints of the main contract.
doesn't sound like a Sophia topic as discussed above. but IMO it should be prevented somehow. I wouldn't expect any non-stateful entrypoint being able to change any state, also not on remote contracts.
Created by: nikita-fuchs
I'm absolutely with @marc0olo on this one !
Created by: hanssv
I had forgotten about this one...
First observation, if you are worried that a non-stateful entrypoint may possibly have side effects - then don't run it on-chain!
Then yes, depending on the mental picture of
state
, it could be a surprise that you are allowed to emit events and call stateful remote functions in a non-stateful context - but the documentation is clear on it so no urgency.Options moving forward (in order of complexity/work):
Created by: marc0olo
I think it isn't an urgent topic and not worth the effort at this point of time. I am totally fine with "doing nothing" for now 👍