everx-labs / TVM-Solidity-Compiler

Solidity compiler for TVM
GNU General Public License v3.0
125 stars 72 forks source link

Unable to deploy contract if contract has a lot of string variables. #35

Closed Pafaul closed 3 years ago

Pafaul commented 3 years ago

Encountered another problem: if there are a lot of string type variables in Solidity contract than it's impossible to deploy contract. Example of contract:

pragma solidity >= 0.6.0;

pragma AbiHeader pubkey;
pragma AbiHeader expire;
pragma AbiHeader time;

contract Test {
    uint static _randomNonce;

    string a = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string a1 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string a2 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string a3 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string a4 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string a5 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string a6 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string a7 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string a8 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string a9 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string a1o = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string a11 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";

    constructor () public {
        tvm.accept();
    }
}

Strings are just random symbols, content doesn't matter.

It compiles correctly, but when you try to deploy it following error occures:

{
  code: 414,
  message: "Contract execution was terminated with error: compute phase isn't succeeded, exit code: -14 (out of gas). Check account balance. For more information about exit code check the contract source code or ask the contract developer",
  data: {
    core_version: '1.9.0',
    phase: 'computeVm',
    exit_code: -14,
    exit_arg: 10260,
    account_address: '0:bec974fd38ad880a45de4e3c6b60be6d81bc1c94a2422f616c788c48a8e25196',
    gas_used: 0,
    description: 'out of gas',
    transaction_id: '2955686a15c1c2230db770b45fd78de5e3ece16ee3d723134692777833f6f53b',
    config_servers: [ 'http://localhost:3333' ],
    query_url: 'http://localhost:3333/graphql'
  }
}

It can be fixed by adding constant modificator to variables. Maybe there is a problem with Solidity compiler and strings. So, valid contract looks like this:

pragma solidity >= 0.6.0;

pragma AbiHeader pubkey;
pragma AbiHeader expire;
pragma AbiHeader time;

contract Test {
    uint static _randomNonce;

    string constant a = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string constant a1 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string constant a2 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string constant a3 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string constant a4 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string constant a5 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string constant a6 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string constant a7 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string constant a8 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string constant a9 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string constant a1o = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";
    string constant a11 = "asdfasfasjofuahwpiufhawklfhaiwhefiauwhefiwhef;oe;eofhawoefhawe";

    constructor () public {
        tvm.accept();
    }
}
IgorKoval commented 3 years ago

Thank you, it has been fixed in version 0.40.