Clarify Execution call stack #2051
adrien-zinger
started this conversation in
Smart contract engine
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Introduction to the interface
When executing a byte code with the runtime, the massa-execution module keep a trace of a kind of call stack in his context. With this discussion, I want to prepare a specification of how the node work with the call stack.
First, here is a presentation of the current interface with the runtime:
We bound these 6 functions with the runtime module, and the function's names are currently explicit enough to understand when it's called. Now, we all know the current status of the interface implementation and I can make a supposition of how the context would work. Before the implementation, it would be nice for all the team to be aware of that.
The call stack 👜
Call and pop the call stack
The call stack has a new entry for each call of
call
abi and is pop after the execution.Read and write accesses
The get and the set
A user has access through an ABI to the ledger and can get a module. On calling
set_data
andget_data
the massa-execution module should know where it has to look and never fail to look. For example, imagine a smart contract who grant the access to his own data. It can be an open source Pokédex where all user can add and update an entry:The getter and setter function represented and implemented in the interface in massa-execution module should always look at the last address in the call stack. The smart contract developer will define itself if the data is public or not with his own development.
In the current smart contract, the call of
get
andset
can have access to the smart contract database. Developing a smart contract, you may be careful because you can give access to the users to write on your own private data.The get_for and set_for behavior
The getter with a given address
get_data_for
can see everywhere. The nature of the publicity in the blockchain allow everyone to look at the data at a given address in the ledger. But when we executeset_data_for
we need to understand in the context of execution if the sender is currently an owner of the address.The sender is by definition the owner of his own address. For example, you can define a smart contract that feed with information to a private database.
Calling this smart contract will cause changes on your own database. If you call this smart contract, the context understand that you're the sender and the owner of your own database. Then,
whats_my_address
function will return the sender address. Finally, theset_for
will attempt to write on the current sender address database. This last operation will successfully write because the context understand that you have the access to the DB as owner.The other way to be the owner of an address is to create a smart contract. During the execution, the context will keep the new addresses created in a set.
The
set_data_for
function of the interface should look first if this list contains the target address before writing, or return an access error. You'll be able to set up your smart contract, like in this example:Call a module with a context
I would like to make a proposal, as well as a smart contract can be added and modified, the execution should be able to call a module with a given context. We can define these:
And give this ABI to the user:
Beta Was this translation helpful? Give feedback.
All reactions