Account implementation late binding #28
Replies: 2 comments 3 replies
-
In the description above, the Accoun's linking table, and the the way the registry is used to link a symbol to an implementation would be part of the protocol. However the way the symbol is defined would be by convention, e.g. the user could add a symbol The above would also lack any type of validation if the table is not public. For that reason I would add one escape hatch, with would be the |
Beta Was this translation helpful? Give feedback.
-
Achieving goal 1 (decoupling interface from implementation) would be difficult for technical reasons (because of how MAST works) - but I would also argue that it is undesirable, especially if we allow code upgradeability. The reason for this is that when I create a note which calls some methods on an account I want to bind this note to the exact implementation of what is going to be executed. Otherwise, the recipient could update the code of the account and executing the note would result in something that I didn't intend. A simple example of this would be an atomic swap described in #22. If the implementation of There are other benefits to binding interfaces to implementations - so, I'd say this is "a feature, not a bug". Regarding goal 2 (interface discoverability) - this really depends on whether account data is stored on chain or off chain. For off chain accounts, there is no interface to discover - so, the owner would need to reveal the part of the interface which is relevant for a given transaction. For accounts which are stored on-chain, the plan is to store serialized AST for each interface method - so, it would be fairly easy to figure out which methods are available. There could be other ways as well (i.e., a list of MAST roots which the ASTs compile into). Regarding goal 3 (code evolution): as mentioned above, I don't think it is a good idea to allow changing implementation of a given method as it could lead to all kinds of security issues. We can always allow users to add or remove methods to an account. This does affect code root for the account - but that shouldn't be a problem. Regarding goal 4: it is a bit more tricky. A note could have conditional statements which allow it to be executed against different accounts. So, just by looking through |
Beta Was this translation helpful? Give feedback.
-
Goals:
receive_asset
without having to know the implementation)Constraints
Design space
Goals.1
andGoals.2
required a way to determine an external symbolhash("receive_asset(asset)")
. This is the approach taken by Solidity. The advantages here is that one can control the size of the symbol very easily (better than name mangling). If we use a word we can also prevent collisionsGoals.2
require a form of registry with the account itself (a linking table of sorts, mapping symbols to implementations).Goals.3
could be as simple as updating the aforementioned Merkle rootGoals.4
could be done by parsing the Note's code prior to execution, and checking all thecall
instructions.Note: I often call this dynamic binding too, but that can be confusing with runtime dynamic binding. So instead I'm going try to stick to late binding to make it a bit clearer that this does not happen program execution
Beta Was this translation helpful? Give feedback.
All reactions