Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

[pallet-contracts] the design of instantiate_with_code, maybe we need to recover put_code #8671

@atenjin

Description

@atenjin

Hi @athei
Now, you guys remove put_code and design instantiate_with_code for implementation the rent of code. But just provide instantiate_with_code is very unfriendly for developer to deploy multi-contract.

Just the example for delegator in ink! example, the root contract need to init 3 contract in its constructor function, then pass 3 contract hash when init delegator root contract.

However developer need to put/deploy the 3 contract code before, otherwise the blockchain does not have those wasm codes. Then, if the developer only need to deploy those 3 contract code in the constructor or message function in root contract, he have to deploy the 3 contract before and init them. However in must case, it's useless to init instances for the 3 contract code, init them just for blockchain to store the wasm code in chain.

If you try to deploy the delegator contracts by yourself, no matter through apps or using Redspot to edit a script to deploy the contracts, you would understand what I mean.

Thus I think maybe we need to recover the method put_code for developers, providing them a way to just put the wasm code before initing the root contract, rather than require them must to init/deploy a contract before.

Considering the rent code feature, I think we should re-design the logic of rent code, for example we could design:

  1. The first one do a put_code, create a mock contract instance for rent requirement(the mock contract is not a real contract, just hold the ref of code), then the first real contract instance replace the reference of the first code ref, then delete the mock contract.
  2. when someone call put_code, he need to pay more fee for this operation, lock this fee, when the code has a reference, he could use another method to unlock the locked fee to get back the fee, or when the code has a reference, and then the contract instance is killed and the contract code reference become zero, the locked fee auto return to the put_code operator account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A5-stalePull request did not receive any updates in a long time. No review needed at this stage. Close it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions