-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Upgradable contracts using set_code
function
#10567
Comments
CC @athei |
This should already be possible with a |
@shawntabrizi, please take a look at this wip pr to see what is used to make it work. |
The idea of |
You mean the How could I ever trust a contract which uses |
@athei, let me bring up some background for this:
The upgrade flow looks like this:
We have to trust that new lib contract is compatible with state of ContractA With
We achieve the same functionality with lower costs for user (no cross contract call) and easier upgrade flow for developer. Feels like there is the same amount of trust as with a |
@athei if the argument is around "trust" or worrying that a contract can change itself, there can simply be a flag which enables or disables a contract from using this feature. Once it is disabled, it cannot be enabled again without ROOT. |
I agree. Having some storage field that can be changed to call an arbitrary code in the storage context of the current contract has the same consequences. This is merely moving this popular pattern to pallet-contracts in order to optimize it. I think this makes sense.
I don't think this changes anything. Contracts which don't make use of this are already identifiable by not importing the |
Anyone want to tackle this: @yarikbratashchuk @xgreenx ? |
Yea, we already implemented it. Now it is on review in our company repo, after passing it, we will create a PR=) |
Together with a team at Supercolony we want to propose and discuss possible first class approach for upgradability in substrate smart contracts. This is up for discussion and comments/suggestions are very welcome.
The approach:
set_code
function in contracts exposed api. The signature could look like this:This function will update
code_hash
for existing contract. This way we can keep the same contract and its storage, but upgrade the executable code. it is a contract owner responsibility to make sure that new code is compatible with existing storage and that it remains upgradable (by having a method for usingset_code
).Proxy
pattern for upgradable contracts anymore and so the execution cost is reduced as there is no call to proxy contract.The upgrade flow:
set_code
with a new deployed contract'scode_hash
as a parameter.Status of Ethereum like !ink based upgradable contracts can be tracked here - #7
The text was updated successfully, but these errors were encountered: