neo3 ABI readonly methods

Created on 16 Jul 2019  路  21Comments  路  Source: neo-project/neo

Neo3 should provide readonly identifier on manifest. When these functions are demanded, two things happen: offchain services execute operations by themselves (unless forced to send to chain); and two, a readonly storage context is provided. This way, a readonly invoked method will.not be able to invoke a read write method.

blocked design feature ledger

Most helpful comment

Ok, it's approved on the vm side: https://github.com/neo-project/neo-vm/pull/191
We can advance on this one now, to validate those changes before merging.

All 21 comments

in order to implement it, could you especify what methods?

The simplest example I have in mind is: balanceOf.

Suppose you do the appcall contractX "balanceOf" myscripthash. Neo3 would look into contractXmanifest, and notice that balanceOf has readonly flag (similar to safe flag, or is it the same?). If it's readonly, the application engine is loaded in readonly mode, and syscall GetCurrentContext would fail, for example (it would require GetReadOnlyStorageContext).

On C# devpack, it could be an attribute:

[ReadOnlyMethod]
BigInteger balanceOf(byte[] me)

What happens, from wallet side, is that it process locally this invocation instead of issuing a transaction (unless you are forced to, via sendrawtransaction). To do that efficiently, we would need the state messages from blockchain or p2p, in order to properly calculate locally the whole state, with 100% confidence. Once in readonly application mode, you can never get out of it, even using dynamic/static invokes.

@erikzhang is it exactly the same concept as safe flag? if it's the same, I then propose to rename safe to readonly.

Same.

Maybe is better to call it readonly

Agree. And also we can move it to ABI.

@igormcoelho isn't this the same as #829 ? We can keep the discussion here if you guys prefer

No, we need to put this on NEP-3 Ammendment... another one.

@igormcoelho could you describe the difference between this one and #829? Maybe we need to rename one of them because they look equal to me 馃槀

Ok, perhaps this is why I didn't understand it at first :joy:

There are many situations where you could possibly "lock" state updates.

  • The proposal here is to lock it during invocation of a Neo Standard Method (these methods with strings and parameters), which is already what Erik had proposed months ago (but by the name of safe methods). This is a lock specially related to ABI invocation of methods, and indirectly connected to NEP-3

  • At #829 I saw a different perspective, for example, by locking methods when invoked from inside a smart contract. I mean, during a CALL, or an APPCALL (now System.Call). Or even during multiple transactions (I didn't get that part). That one is a very different perspective, because it affects how neovm-appengine would process everything after jumps (or calls), so I didn't understand how to do that.

In short, if both are the same, good for us: we just need to rename safe to readonly and close two issues ;)

No need to lock this feature to me. Focusing on other things first.

Sorry @igormcoelho . I assigned you because you said you would like to work on this task later. I suppose someone else can do this while you are working on other tasks?

@igormcoelho do you want to implement this? otherwise @lock9 you can assign it to me

In order to proceed with this change , we need to be able to store some information inside ExecutionContext because currently there are no way to store a flag in this class.

https://github.com/neo-project/neo/blob/cf768c63a3e2c07cda839495f8b836223832c634/neo/SmartContract/InteropService.cs#L554

I propose to modify neo-vm for be able to extend the ExecutionContext class, this could allow to add the script hash in the future in this class too

Proposed changes : https://github.com/neo-project/neo-vm/pull/191

@shargon, I'm not sure that extending ExecutionContext is a good path... but I understand why you need this.
Perhaps we just need a flag field on ExecutionContext, and reuse it, for many things.

Today is one flag, tomorrow two flags xD i don't like this model 馃槄

Ok, it's approved on the vm side: https://github.com/neo-project/neo-vm/pull/191
We can advance on this one now, to validate those changes before merging.

This will be do o should be closed?

This will be merged or should be closed? @neo-project/core

Hi @shargon, let's continue the discussion here: https://github.com/neo-project/proposals/pull/104
We need to update NEP-3 before continuing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

coranos picture coranos  路  85Comments

igormcoelho picture igormcoelho  路  34Comments

erikzhang picture erikzhang  路  43Comments

EdgeDLT picture EdgeDLT  路  59Comments

brianlenz picture brianlenz  路  37Comments