Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not store self smart-contract code: use MYCODE asm instruction instead #1012

Open
imartemy1524 opened this issue Nov 1, 2024 · 1 comment
Assignees
Labels
gas Gas consumption and fee-related things scope: codegen Code generation, a.k.a. compiler backend
Milestone

Comments

@imartemy1524
Copy link

The problem

Lets take a look on a 2 simple smart-contracts:

contract Parent{
    id: Int = 0;
    init(){}
    receive("new"){
        self.id += 1;
        let data = initOf Child(self.id);
        self.forward(contractAddress(data), "init".asComment(), true, data);
    }
}

contract Child{
    id: Int;
    init(id: Int){
        self.id = id;
    }

    receive("init"){}

    receive("deploy_random"){
        let data = initOf Child(randomInt());
        self.forward(contractAddress(data), "init".asComment(), true, data);
    }
}

Under the hood, both Parent and Child contracts stores the code of Child smart contract in the system dictionary, because in both of them initOf Child() used.

But storing code of Child smart contract inside Child is useless because one can call MYCODE asm instruction to get it.

This approach would reduce not only storageFees, but also forwardFees when initializing new smart-contracts.

It is really useful feature for developing Jetton smart contracts (when one child deploys another child), which optimizes fees a lot.

Feel free to argue to my point.

@novusnota novusnota added the gas Gas consumption and fee-related things label Nov 1, 2024
@Gusarich
Copy link
Member

you're definitely right!

@Gusarich Gusarich self-assigned this Nov 18, 2024
@Gusarich Gusarich added this to the v1.6.0 milestone Nov 18, 2024
@anton-trunov anton-trunov changed the title [Feature request] Do not store self smart-contract code: use MYCODE asm instruction instead Do not store self smart-contract code: use MYCODE asm instruction instead Nov 18, 2024
@anton-trunov anton-trunov added the scope: codegen Code generation, a.k.a. compiler backend label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gas Gas consumption and fee-related things scope: codegen Code generation, a.k.a. compiler backend
Projects
None yet
Development

No branches or pull requests

4 participants