-
Notifications
You must be signed in to change notification settings - Fork 113
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
Add readOnly to NEP-3 #104
Conversation
Camelcase for json property names
Co-Authored-By: Erik Zhang <erik@neo.org>
Can we discuss it again, why do we need |
Is for ensure that is not possible to execute a write operation in these methods, in order to prevent the write access |
Why to prevent the write access? |
As @igormcoelho said:
Before this change, the developer promise to not modify the state if the method is Also, the Abi will be compleated by the compiler acording to the Attributes, and developers doesn't need to create/modify the Abi. |
Can we remove |
But then, how the wallet know when they need to execute the context as readOnly? |
Why a wallet need to execute the context as readOnly? |
Imagine that you want to create a website like etherscan.io, and allow to execute readOnly methods (without relay), you need to know what methods are https://etherscan.io/address/0x01eacc3ae59ee7fbbc191d63e8e1ccfdac11628c#readContract |
I think readOnly and relay are irrelevant. |
How do you do this website without know which methods are readOnly and which methods not? |
I don't know. Why people need to know it? If I make this website, I will provide a uniform list of methods without distinguishing between read-only or not. |
🤔 🤔 🤔 Maybe we need a "no storage" flag instead of a readOnly. A method that has no access to the storage (stateless) can be used in optimizations since these are certain to be "thread safe". |
This is precisely for this, allow to create methods that ensure that no changes will be made on the blockchain, has the same behavior of |
@shargon but read-only still depends on the state, even if it is read-only, we can have different results if the content of the storage is changed. This is not true for real stateless methods |
maybe we need three states instead of two
But is very important this information in the abi. |
Why do we need the readonly? I think we only need stateful and stateless methods. And I believe all methods should be either of them, always. If nothing is said, it is stateful. What do you think @shargon ? I can't see the gains of only having "read only". Can you point it to me? |
I think even the same method can have different state dependencies on each execution. if (needToWrite)
{
//Write something to storage
}
else
{
//return constant
} So we should specify an option each time we call a method, which can include an agreement on whether the called method has permission to access the state. |
For me is the same case as https://solidity.readthedocs.io/en/latest/contracts.html#view-functions "This means library view functions do not have run-time checks that prevent state modifications" |
Any news? this should be closed or updated? |
Another reason that makes this interesting is that it allows libraries that interact with the blockchain, such as neon-js, to detect which calls require actual transactions and which can be done using a simple RPC call to any node, while providing a unified API. Example:
|
The This proposal is to move it from manifest to abi. It is a different thing. |
I see, you are right in that my comment is invalid then. |
I vote to move this to the ABI, we can use an attribute at smart contract level. As @corollari mentioned, this is helpful to know when we can use RPC directly and it may also be useful for optimizations. Also, the ABI is an adequate place for it because it is where we store information about the methods in our contract. |
Camelcase for json property names