Current Situation
On Tezos, we can’t “call” another Smart-Contract (SC). What I mean by that is that there is no operation to get some output from another SC. What has to be done is to convert the two contracts into Continuation Passing Style.
This was a conscious decision, made to avoid reentrancy attacks.
However, as it is, this decision has some drawbacks:
- Reading the state from another SC requires some cooperation from it
- Writing the code is a bother (which is being mitigated with higher-level languages, but can only be mitigated)
Proposed Improvement
Content
I suggest the addition of two Michelson instructions:
-
GET_STORAGE sc_type
, which gets the storage of some SC. (Important for adversarial reads.) -
VIEW view_name view_type
, which calls a view of some SC.
A view is a function from the view parameter and the storage of the SC to some output. Views don’t change the storage nor generate operations.
Advantages
- With
GET_STORAGE
, migrating to a new SC becomes much easier. - It is easier to define accessors in interfaces.
- It is easier to interact between contracts in general.
Technical Details
I’m not sure about a lot of implementation details, that I will consequently leave to others. What I am doing:
- Adding the instructions and their syntax
- Adding view entry-points
- Adding some tests
What needs to be done:
- Deciding what can be outputted by views (can they generate or return
big_map
s?) - Gas
- More tests and reviews
- Adding relevant error messages
- Listing contracts that will be read before applying
- Adding RPC clients
I’ll post a message once I will have pushed to a branch.