Deploy contract successed but "Address not contract address"


#1

Here is my contract: https://pastebin.com/Kb5VarMV

The deploy result:

{"id":1,"jsonrpc":"2.0","result":{"ID":"05e0b99c9274427ec47400a35c4dc93c0bdf2b90d8638462c95f2a1b230f8ba8","amount":"0","gasLimit":"80000","gasPrice":"1000000000","nonce":"52","receipt":{"cumulative_gas":"21474","epoch_num":"210702","success":true},"senderPubKey":"0x0205273E54F262F8717A687250591DCFB5755B8CE4E3BD340C7ABEFD0DE1276574","signature":"0xE8DA566850B4A7FD01251A6280D0502AC61F08BD63B88F6FF1BD7AEBD6D87630856660F573A2BFA5C0DF0D0DE55EC45259C224985438B407A234D724F33A29C4","toAddr":"0000000000000000000000000000000000000000","version":"21823489"}}

{"error":{"code":-5,"data":null,"message":"Address not contract address"},"id":1,"jsonrpc":"2.0"}

But when remove the last transition it still worked. I didn’t image how could this happen. Please help!!!

transition setHolderStatus(holder: ByStr20, b: Bool)
    isAuthorized = checkContractOwner owner _sender;
    match isAuthorized with
    | True =>
        contractHolderMap[holder] := b;
        (* Emit success event *)
        e = {_eventname: "setHolderStatus successful"; by: _this_address; recipient: _sender; approved: b};
        event e
    | False =>
        (* Unauthorized transaction - sender is not the contract owner*)
        e = let raisedAt = "setHolderStatus" in makeErrorEvent raisedAt code_not_authorized;
        event e
    end
end

I checked again. If I keep above transition but remove other, it worked too.
And some relative with cumulative_gas.

ok
"cumulative_gas":"19744",
"cumulative_gas":"21001"
"cumulative_gas":"20884"
"cumulative_gas":"20927"

nok
"cumulative_gas":"21619"
"cumulative_gas":"21717"
"cumulative_gas":"22294"
"cumulative_gas":"21121"
"cumulative_gas":"21495"
"cumulative_gas":"21474"

It like the limit gas usage is 21001 ?!?


#2

I checked zilliqa code and see
<MAX_CODE_SIZE_IN_BYTES>20480</MAX_CODE_SIZE_IN_BYTES>

    if (tx.GetCode().size() > MAX_CODE_SIZE_IN_BYTES) {
      throw JsonRpcException(RPC_VERIFY_REJECTED, "Code size is too large");
    }

It mean maximum code length is 20kb
That’s reason.
I must to say it too small for a complex contract


#3

I found a workaround is to strip the deployed contract’s code of comments. However, it is not ideal for people reading the contract from GetSmartContractCode api.

We are thinking of ways to solve this, while ensuring that packet size will not be too huge that it will hinder the consensus process. (as pBFT is extremely time-sensitive)