-
Notifications
You must be signed in to change notification settings - Fork 2.7k
seal: Storage rent for code #6596
Comments
Naming proposal:
|
At some point in the future, it would be great to have libraries stored on chain. For example, a wasm dynamic linked library could be available as code. Maybe we |
Those would get an additional set of interface functions anyways. Alone for the reason that we can't change the semantics of existing interface functions once deployed. In order to make sure that someone pays for the code of the shared lib we would add a function that supplies two code blobs: The code of the lib and the code of a contract that is its first user. The latter code would be automatically instantiated and that is the contract that pays rent for both the lib and its own code. Adding more users of that lib though |
This rename would change the semantic of an existing name. I don't want to cause confusing and code churn by doing so. Keeping I would just replace the
|
How about |
I did not consider that because it is misleading: It is not guaranteed that the instantiated code is new. If you upload a code and the code hash already exists this existing code will be used. |
Currently, no rent is collected for code that is stored on-chain. Only the state of the individual contracts is subject to rent payments. This is because code is deployed independently of a contract and can then be used by any contract without further costs. There is also no way (apart from governance) to remove code stored on the chain.
This opens up the chain to DoS because anyone can clutter the storage with code with only a one time cost that covers the computation costs of uploading the code.
For that reason, we propose that contracts should pay for the code they use. To incentives code sharing the costs are also shared between all users of a code blob. We change the rent formula that is calculated on contract access or
claim_surcharge
to:The costs for code storage converge against zero with more users using it. Due to integer arithmetic is reaches zero once
num_code_users > code_size
.One issue is that the rent is not collected every block but only when the contract is accessed or
claim_surcharge
is called. Thenum_code_users
can change in between blocks making the calculation inaccurate. However, we argue despite the inaccuracy we cannot come up with an attack that turns this into a DoS vector.Steps that are necessary for implementation:
set_code
dispatchable is replaced withinstantiate_with_code
because every code_hash needs at least one user. Theseal_instantiate
contract callable function stays untouched. Contracts cannot deploy code.The text was updated successfully, but these errors were encountered: