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

Error on invokescript with a contract deployment script #458

Closed
csmuller opened this issue Jan 12, 2021 · 6 comments · Fixed by #463
Closed

Error on invokescript with a contract deployment script #458

csmuller opened this issue Jan 12, 2021 · 6 comments · Fixed by #463

Comments

@csmuller
Copy link

Describe the bug
When calling invokescript with a script that deploys a new contract, I get the error Exception has been thrown by the target of an invocation.. When sending the script via sendrawtransaction, the deployment is successful.
This issue only arises when i use a _deploy method in the contract.

To Reproduce

  1. Compile a dummy contract with a _deploy() method. E.g.:
using Neo.SmartContract.Framework;

public class Contract : SmartContract
{

    public static void _deploy(bool update)
    {
    }
}
  1. Build the deployment script. (Or deploy it with neo-cli and get the deployment script with getrawtransaction.)

  2. Call invokescript with the deployment script as an argument (and a signer).

Expected behavior
Success response with the correct GAS amount consumed by the deployment.

Platform:

  • OS: MacOS BigSur
  • Neo Version: neo3-preview4
@vncoelho
Copy link
Member

The same here,@csmuller. It is good that you reported.
I have been discussing with @superboyiii.

Let's keep this in mind because this is important for us to test the current master.

@bettybao1209
Copy link
Contributor

Hi, I reproduced your case, but I can get the expected result. Here is my use case:

{
  "jsonrpc": "2.0",
  "method": "invokescript",
  "params": ["DQgBeyJuYW1lIjoiIiwiZ3JvdXBzIjpbXSwic3VwcG9ydGVkc3RhbmRhcmRzIjpbXSwiYWJpIjp7Im1ldGhvZHMiOlt7Im5hbWUiOiJfZGVwbG95IiwicGFyYW1ldGVycyI6W3sibmFtZSI6InVwZGF0ZSIsInR5cGUiOiJCb29sZWFuIn1dLCJvZmZzZXQiOjAsInJldHVybnR5cGUiOiJWb2lkIiwic2FmZSI6ZmFsc2V9XSwiZXZlbnRzIjpbXX0sInBlcm1pc3Npb25zIjpbeyJjb250cmFjdCI6IioiLCJtZXRob2RzIjoiKiJ9XSwidHJ1c3RzIjpbXSwiZXh0cmEiOm51bGx9DFJORUYzbmVvbgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAzLjAuMC4wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFcAAUBQhEnJEsAfDAZkZXBsb3kMFEUOzD/1NEmzTBDSZRJ5Prv9IeS+QWJ9W1I=",
  [
         {
          "account": "NaqFR6Qv3VM3XWLLqbuK6PwRi9uYGGDk1e",
          "scopes": "CalledByEntry",
          "allowedcontracts":[],
          "allowedgroups":[]
        }
    ]],
  "id": 1
}

Also, I think we'd better show the message of base exception for better understanding, like #463

@csmuller
Copy link
Author

csmuller commented Jan 13, 2021

I get another deployment script from neo-cli. My invokescript call JSON is below. I assume you used the dummy contract from above.

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "invokescript",
  "params": [ "DQgBeyJuYW1lIjoiIiwiZ3JvdXBzIjpbXSwic3VwcG9ydGVkc3RhbmRhcmRzIjpbXSwiYWJpIjp7Im1ldGhvZHMiOlt7Im5hbWUiOiJfZGVwbG95IiwicGFyYW1ldGVycyI6W3sibmFtZSI6InVwZGF0ZSIsInR5cGUiOiJCb29sZWFuIn1dLCJvZmZzZXQiOjAsInJldHVybnR5cGUiOiJWb2lkIiwic2FmZSI6ZmFsc2V9XSwiZXZlbnRzIjpbXX0sInBlcm1pc3Npb25zIjpbeyJjb250cmFjdCI6IioiLCJtZXRob2RzIjoiKiJ9XSwidHJ1c3RzIjpbXSwiZXh0cmEiOm51bGx9DE1ORUYzbmVvbgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAzLjAuMC4wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARXAAFAn7e0hxLADAZkZXBsb3kMFKvW6K2fQQlBN2WRzd+a1oINt5fNQWJ9W1I=",
    [
      {
       "account": "NZNos2WqTbu5oCgyfss9kUJgBXJqhuYAaj",
       "scopes": "CalledByEntry",
       "allowedcontracts":[],
       "allowedgroups":[]
      }
    ]
  ]
}

When i do the call with your JSON I get the exception:
"exception": "Object of type 'Neo.VM.Types.Integer' cannot be converted to type 'Neo.VM.Types.Array'.",

Also, I think we'd better show the message of base exception for better understanding, like #463

Yes, definitely 👍

@chenzhitong
Copy link
Member

chenzhitong commented Jan 14, 2021

Works fine in mine.

  1. Compile contract

    public class Contract1 : SmartContract
    {
        //TODO: Replace it with your own address.
        static readonly UInt160 Owner = "NiNmXL8FjEUEs1nfX9uHFBNaenxDHJtmuB".ToScriptHash();
    
        private static bool IsOwner() => Runtime.CheckWitness(Owner);
    
        public static bool Verify() => IsOwner();
    
        public static void _deploy(bool update)
        {
            if (update) return;
    
            // It will be executed during deploy
            Storage.Put(Storage.CurrentContext,"Hello", "World");
        }
    }    
  2. Deploy contract

    image

  3. GetRawTransaction
    request:

    {
        "jsonrpc": "2.0",
        "id": 1,
        "method": "getrawtransaction",
        "params": ["0xdbeec16cab25402c7cba5c3db2a15ee53254fd0f4793a160bbbe61ac847bc4df", 1]
    }

    response:

    {
        "jsonrpc": "2.0",
        "id": 1,
        "result": {
            "hash": "0xdbeec16cab25402c7cba5c3db2a15ee53254fd0f4793a160bbbe61ac847bc4df",
            "size": 960,
            "version": 0,
            "nonce": 1445711785,
            "sender": "NgaiKFjurmNmiRzDRQGs44yzByXuSkdGPF",
            "sysfee": "10.0201856",
            "netfee": "0.0194361",
            "validuntilblock": 5760,
            "signers": [
                {
                    "account": "0x86df72a6b4ab5335d506294f9ce993722253b6e2",
                    "scopes": "None"
                }
            ],
            "attributes": [],
            "script":     "DUUCeyJuYW1lIjoiIiwiZ3JvdXBzIjpbXSwic3VwcG9ydGVkc3RhbmRhcmRzIjpbXSwiYWJpIjp7Im1ldGhvZHMiOlt7Im5hbWUiOiJfZGVwbG95IiwicGFyYW1ldGVycyI6W3sibmFtZSI6InVwZGF0ZSIsInR5cGUiOiJCb29sZWFuIn1dLC  Jv    ZmZzZXQiOjAsInJldHVybnR5cGUiOiJWb2lkIiwic2FmZSI6ZmFsc2V9LHsibmFtZSI6Il9pbml0aWFsaXplIiwicGFyYW1ldGVycyI6W10sIm9mZnNldCI6MzcsInJldHVybnR5cGUiOiJWb2lkIiwic2FmZSI6ZmFsc2V9LHsibmFtZSI6ImE  iL    CJwYXJhbWV0ZXJzIjpbXSwib2Zmc2V0Ijo2MywicmV0dXJudHlwZSI6IlZvaWQiLCJzYWZlIjpmYWxzZX0seyJuYW1lIjoidmVyaWZ5IiwicGFyYW1ldGVycyI6W10sIm9mZnNldCI6OTIsInJldHVybnR5cGUiOiJCb29sZWFuIiwic2FmZSI6  Zm    Fsc2V9XSwiZXZlbnRzIjpbXX0sInBlcm1pc3Npb25zIjpbeyJjb250cmFjdCI6IioiLCJtZXRob2RzIjoiKiJ9XSwidHJ1c3RzIjpbXSwiZXh0cmEiOnsiQXV0aG9yIjoiTmVvIiwiRW1haWwiOiJkZXZAbmVvLm9yZyIsIkRlc2NyaXB0aW9uI  jo  iVGhpcyBpcyBhIGNvbnRyYWN0IGV4YW1wbGUifX0MrU5FRjNuZW9uAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADMuMC4wLjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABfVwEBeHBoJgQiHCFBm/    ZnzgwFSGVsbG8MBVdvcmxkU0HmPxiEQFYBDBT2ZENJjTh40yuZTk4Sg8aTRCHa/mBAQAwU9mRDSY04eNMrmU5OEoPGk0Qh2v5B+CfsjEA05EAsKIotEsAfDAZkZXBsb3kMFEUOzD/1NEmzTBDSZRJ5Prv9IeS+QWJ9W1I=",
            "witnesses": [
                {
                    "invocation": "DEDANtRu0WcEHleHwZUwKdRP/JR23X0IP1WQ4rIu+xqpJYOss76eZwdytgeDxyiJuDoYNL5wZthTC85bWD9yjNs8",
                    "verification": "EQwhAs7UMjl93ETtugMcC8O5M/KP3ZZ3eS17IObANt2qrPHiEQtBE43vrw=="
                }
            ]
        }
    }
  4. InvodeScript
    request:

    {
        "jsonrpc": "2.0",
        "method": "invokescript",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SZRJ5Prv9IeS+QWJ9W1I=",
            [
                {
                    "account": "NgaiKFjurmNmiRzDRQGs44yzByXuSkdGPF",
                    "scopes": "CalledByEntry",
                    "allowedcontracts": [],
                    "allowedgroups": []
                }
            ]
        ],
        "id": 1
    }

    response:

    {
        "jsonrpc": "2.0",
        "id": 1,
        "result": {
            "script":     "DUUCeyJuYW1lIjoiIiwiZ3JvdXBzIjpbXSwic3VwcG9ydGVkc3RhbmRhcmRzIjpbXSwiYWJpIjp7Im1ldGhvZHMiOlt7Im5hbWUiOiJfZGVwbG95IiwicGFyYW1ldGVycyI6W3sibmFtZSI6InVwZGF0ZSIsInR5cGUiOiJCb29sZWFuIn1dLC  Jv    ZmZzZXQiOjAsInJldHVybnR5cGUiOiJWb2lkIiwic2FmZSI6ZmFsc2V9LHsibmFtZSI6Il9pbml0aWFsaXplIiwicGFyYW1ldGVycyI6W10sIm9mZnNldCI6MzcsInJldHVybnR5cGUiOiJWb2lkIiwic2FmZSI6ZmFsc2V9LHsibmFtZSI6ImE  iL    CJwYXJhbWV0ZXJzIjpbXSwib2Zmc2V0Ijo2MywicmV0dXJudHlwZSI6IlZvaWQiLCJzYWZlIjpmYWxzZX0seyJuYW1lIjoidmVyaWZ5IiwicGFyYW1ldGVycyI6W10sIm9mZnNldCI6OTIsInJldHVybnR5cGUiOiJCb29sZWFuIiwic2FmZSI6  Zm    Fsc2V9XSwiZXZlbnRzIjpbXX0sInBlcm1pc3Npb25zIjpbeyJjb250cmFjdCI6IioiLCJtZXRob2RzIjoiKiJ9XSwidHJ1c3RzIjpbXSwiZXh0cmEiOnsiQXV0aG9yIjoiTmVvIiwiRW1haWwiOiJkZXZAbmVvLm9yZyIsIkRlc2NyaXB0aW9uI  jo  iVGhpcyBpcyBhIGNvbnRyYWN0IGV4YW1wbGUifX0MrU5FRjNuZW9uAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADMuMC4wLjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABfVwEBeHBoJgQiHCFBm/    ZnzgwFSGVsbG8MBVdvcmxkU0HmPxiEQFYBDBT2ZENJjTh40yuZTk4Sg8aTRCHa/mBAQAwU9mRDSY04eNMrmU5OEoPGk0Qh2v5B+CfsjEA05EAsKIotEsAfDAZkZXBsb3kMFEUOzD/1NEmzTBDSZRJ5Prv9IeS+QWJ9W1I=",
            "state": "HALT",
            "gasconsumed": "10.0201856",
            "exception": null,
            "stack": [
                {
                    "type": "Array",
                    "value": [
                        {
                            "type": "Integer",
                            "value": "1"
                        },
                        {
                            "type": "Integer",
                            "value": "0"
                        },
                        {
                            "type": "ByteString",
                            "value": "OULDM51NSO0nTW/sQpOMzdGf3Oc="
                        },
                        {
                            "type": "ByteString",
                            "value": "TkVGM25lb24AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMy4wLjAuMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF9XAQF4cGgmBCIcIUGb9mfODAVIZWxsbwwFV29ybGRTQeY/    GIRAVgEMFPZkQ0mNOHjTK5lOThKDxpNEIdr+YEBADBT2ZENJjTh40yuZTk4Sg8aTRCHa/kH4J+yMQDTkQCwoii0="
                        },
                        {
                            "type": "ByteString",
                            "value":     "eyJuYW1lIjoiIiwiZ3JvdXBzIjpbXSwic3VwcG9ydGVkc3RhbmRhcmRzIjpbXSwiYWJpIjp7Im1ldGhvZHMiOlt7Im5hbWUiOiJfZGVwbG95IiwicGFyYW1ldGVycyI6W3sibmFtZSI6InVwZGF0ZSIsInR5cGUiOiJCb2  9s    ZWFuIn1dLCJvZmZzZXQiOjAsInJldHVybnR5cGUiOiJWb2lkIiwic2FmZSI6ZmFsc2V9LHsibmFtZSI6Il9pbml0aWFsaXplIiwicGFyYW1ldGVycyI6W10sIm9mZnNldCI6MzcsInJldHVybnR5cGUiOiJWb2lkIiwic2F  mZ    SI6ZmFsc2V9LHsibmFtZSI6ImEiLCJwYXJhbWV0ZXJzIjpbXSwib2Zmc2V0Ijo2MywicmV0dXJudHlwZSI6IlZvaWQiLCJzYWZlIjpmYWxzZX0seyJuYW1lIjoidmVyaWZ5IiwicGFyYW1ldGVycyI6W10sIm9mZnNldCI6  OT    IsInJldHVybnR5cGUiOiJCb29sZWFuIiwic2FmZSI6ZmFsc2V9XSwiZXZlbnRzIjpbXX0sInBlcm1pc3Npb25zIjpbeyJjb250cmFjdCI6IioiLCJtZXRob2RzIjoiKiJ9XSwidHJ1c3RzIjpbXSwiZXh0cmEiOnsiQXV0a  G9  yIjoiTmVvIiwiRW1haWwiOiJkZXZAbmVvLm9yZyIsIkRlc2NyaXB0aW9uIjoiVGhpcyBpcyBhIGNvbnRyYWN0IGV4YW1wbGUifX0="
                        }
                    ]
                }
            ]
        }
    }

State: HALT
I used neo-cli, RpcServer and neo-devpack-dotnet on the latest master branch.

@superboyiii
Copy link
Member

superboyiii commented Jan 14, 2021

When i do the call with your JSON I get the exception:
"exception": "Object of type 'Neo.VM.Types.Integer' cannot be converted to type 'Neo.VM.Types.Array'.",

I think it could be related to RetrunValue in EmitDynamicCall, we've fixed it before. It works well now on mine.

@csmuller
Copy link
Author

Ok, then i'll assume that it is fixed on master and will work with the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants