ProvableHQ/sdk

[Bug] The fee of deploying the program looks incorrect and is too high

YaakovHuang opened this issue ยท 3 comments

๐Ÿ› Bug Report

I tried to deploy the token program by estimating the fee. The estimated fee was too high. aleo.tools also had the same problem.

The estimated cost is 100005.62599999999

Steps to Reproduce

const program = `program token.aleo;

    record token:
        owner as address.private;
        amount as u64.private;
    
    
    mapping account:
      key as address.public;
      value as u64.public;
    
    function mint_public:
        input r0 as address.public;
        input r1 as u64.public;
        async mint_public r0 r1 into r2;    output r2 as token.aleo/mint_public.future;
    
    finalize mint_public:
        input r0 as address.public;
        input r1 as u64.public;
        get.or_use account[r0] 0u64 into r2;
        add r2 r1 into r3;
        set r3 into account[r0];
    
    
    function mint_private:
        input r0 as address.private;
        input r1 as u64.private;
        cast r0 r1 into r2 as token.record;
        output r2 as token.record;
    
    
    function transfer_public:
        input r0 as address.public;
        input r1 as u64.public;
        async transfer_public self.caller r0 r1 into r2;    output r2 as token.aleo/transfer_public.future;
    
    finalize transfer_public:
        input r0 as address.public;
        input r1 as address.public;
        input r2 as u64.public;
        get.or_use account[r0] 0u64 into r3;
        sub r3 r2 into r4;
        set r4 into account[r0];
        get.or_use account[r1] 0u64 into r5;
        add r5 r2 into r6;
        set r6 into account[r1];
    
    
    function transfer_private:
        input r0 as token.record;
        input r1 as address.private;
        input r2 as u64.private;
        sub r0.amount r2 into r3;
        cast r0.owner r3 into r4 as token.record;
        cast r1 r2 into r5 as token.record;
        output r4 as token.record;
        output r5 as token.record;
    
    
    function transfer_private_to_public:
        input r0 as token.record;
        input r1 as address.public;
        input r2 as u64.public;
        sub r0.amount r2 into r3;
        cast r0.owner r3 into r4 as token.record;
        async transfer_private_to_public r1 r2 into r5;    output r4 as token.record;
        output r5 as token.aleo/transfer_private_to_public.future;
    
    finalize transfer_private_to_public:
        input r0 as address.public;
        input r1 as u64.public;
        get.or_use account[r0] 0u64 into r2;
        add r2 r1 into r3;
        set r3 into account[r0];
    
    
    function transfer_public_to_private:
        input r0 as address.public;
        input r1 as u64.public;
        cast r0 r1 into r2 as token.record;
        async transfer_public_to_private self.caller r1 into r3;    output r2 as token.record;
        output r3 as token.aleo/transfer_public_to_private.future;
    
    finalize transfer_public_to_private:
        input r0 as address.public;
        input r1 as u64.public;
        get.or_use account[r0] 0u64 into r2;
        sub r2 r1 into r3;
        set r3 into account[r0];`;

    const imports = await programManager.networkClient.getProgramImports(program);
    console.log("Estimating deployment fee..");
    const feeInt = await programManager.executionEngine.estimateDeploymentFee(program, imports);
    const fee = Number(feeInt) / 1000000 + 0.01;
    console.log("fee = " + fee);

Your Environment

sdk: 0.6.2

Hmm yeah confirmed on the latest aleo.tools as well will look into this...

Web worker: Deployment fee estimation completed in 51955.984999999404 ms
Deployment Fee Estimation: 100005616000 microcredits

Any idea @iamalwaysuncomfortable ?

Hmm yeah confirmed on the latest aleo.tools as well will look into this...

Web worker: Deployment fee estimation completed in 51955.984999999404 ms
Deployment Fee Estimation: 100005616000 microcredits

Any idea @iamalwaysuncomfortable ?

If the program's name is too short, you will need to pay extra. The minimum length that does not require extra fees here seems to be 10.

@YaakovHuang ah okay yeah this seems expected then. Perhaps we can add some messaging in the future to make this more clear.