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

add invoked contract #657

Merged
merged 18 commits into from
Dec 15, 2021
Merged

Conversation

Ashuaidehao
Copy link
Contributor

@Ashuaidehao Ashuaidehao commented Oct 20, 2021

Relate #656.

@Ashuaidehao Ashuaidehao marked this pull request as ready for review November 11, 2021 07:34
@shargon
Copy link
Member

shargon commented Nov 11, 2021

@superboyiii tested?

@superboyiii
Copy link
Member

@superboyiii tested?

Give me more time.

@superboyiii
Copy link
Member

superboyiii commented Nov 15, 2021

@shargon
invoke result of Neoverse Mint, can see invokedcontracts contains completed invoked contract hash.

  1. invoked script hash(not contract), 2. GAS, 3. BlindBox, 4. StdLib, 5. LedgerContract, 6. ContractManagement
{
    "jsonrpc": "2.0",
    "id": 3,
    "result": {
        "script": "DANuZnQCAMqaOwwUQG9HkCtsPwiAbqyM+fMqDVxetrMMFMCY5KzwsgkN0W7LPVjeQmqHFYUbFMAfDAh0cmFuc2ZlcgwUz3bii9AGLEpHjuNVYQETGfPPpNJBYn1bUg==",
        "state": "HALT",
        "gasconsumed": "21513739",
        "exception": null,
        "invokedcontracts": [
            "0x7411589817d51cfb6ee7d322a1f2dee8c5613185",
            "0xd2a4cff31913016155e38e474a2c06d08be276cf",
            "0xb3b65e5c0d2af3f98cac6e80083f6c2b90476f40",
            "0xacce6fd80d44e1796aa0c2c625e9e4e0ce39efc0",
            "0xda65b600f7124ce6c79950c1772a36403104f2be",
            "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd"
        ],
        "stack": [
            {
                "type": "Boolean",
                "value": true
            }
        ],
        "tx": "ACaP5i4LRkgBAAAAAKDiAQAAAAAA4R8KAAHAmOSs8LIJDdFuyz1Y3kJqhxWFG4AAXgwDbmZ0AgDKmjsMFEBvR5ArbD8IgG6sjPnzKg1cXrazDBTAmOSs8LIJDdFuyz1Y3kJqhxWFGxTAHwwIdHJhbnNmZXIMFM924ovQBixKR47jVWEBExnzz6TSQWJ9W1IBQgxAiZrW3UeII/mf9oKMTWv3p+T4Q8bAJySMjNcRYHAMvMK2ZxkgVUMvYnLdd7uu7ncu23M0UAnme6It/9QYCMH4TSgMIQKNWcem5o/HrWiwhxgZW8nce5BzQ4To6abGD/mj+1t7PEFW57Mn"
    }
}

shargon
shargon previously approved these changes Nov 15, 2021
{
json["diagnostics"] = new JObject()
{
["invokedcontracts"] = engine.Diagnostic.InvocationTree.GetItems().Distinct().Select(v => (JString)v.ToString()).ToArray()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returns the InvocationTree?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also we can return the storage changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not a simple renaming, but also storing the tree structure into an array.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InvocationTree seems cannot traverse tree structure outside now. Need some more support.

JObject json = new();
json["script"] = Convert.ToBase64String(script);
json["state"] = engine.State;
json["gasconsumed"] = engine.GasConsumed.ToString();
json["exception"] = GetExceptionMessage(engine.FaultException);
if (useDiagnostic)
{
json["diagnostics"] = new JObject()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, do we need this wrapper structure?

Copy link
Member

@erikzhang erikzhang Nov 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we will add more data to it later.

@roman-khimov
Copy link
Contributor

Going back to the #656 (comment) list, can we also add notifications as something always returned for invoke* calls? The node has this data already, but we don't give it back to the user and it also might be important for the receiver to ensure that side-effects produced by transaction are the ones intended.

@shargon
Copy link
Member

shargon commented Dec 2, 2021

@Ashuaidehao NeoFS.API must be updated

shargon
shargon previously approved these changes Dec 3, 2021
shargon
shargon previously approved these changes Dec 10, 2021
@superboyiii
Copy link
Member

Test Failed:
Current ["storagechanges"] will overwrite ["invokedcontracts"] in json["diagnostics"]

@superboyiii
Copy link
Member

Test Pass
Now it works well.

{
    "jsonrpc": "2.0",
    "id": 3,
    "result": {
        "script": "DA9CbGluZCBCb3ggIzE3NTERwB8MCHVuQm94aW5nDBR/jtStf6tG7M4EV8/3LtzjPQni2UFifVtS",
        "state": "HALT",
        "gasconsumed": "7757705",
        "exception": null,
        "notifications": [
            {
                "eventname": "Transfer",
                "contract": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                "state": {
                    "type": "Array",
                    "value": [
                        {
                            "type": "ByteString",
                            "value": "wJjkrPCyCQ3Rbss9WN5CaocVhRs="
                        },
                        {
                            "type": "Any"
                        },
                        {
                            "type": "Integer",
                            "value": "1"
                        },
                        {
                            "type": "ByteString",
                            "value": "QmxpbmQgQm94ICMxNzUx"
                        }
                    ]
                }
            },
            {
                "eventname": "Transfer",
                "contract": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                "state": {
                    "type": "Array",
                    "value": [
                        {
                            "type": "Any"
                        },
                        {
                            "type": "ByteString",
                            "value": "wJjkrPCyCQ3Rbss9WN5CaocVhRs="
                        },
                        {
                            "type": "Integer",
                            "value": "1"
                        },
                        {
                            "type": "ByteString",
                            "value": "RnJhZ21lbnQgQSAjNDU2"
                        }
                    ]
                }
            }
        ],
        "diagnostics": {
            "invokedcontracts": {
                "hash": "0x18f4ea90a5612a7fdd6f7ef0928e6d3686d2d48a",
                "call": [
                    {
                        "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                        "call": [
                            {
                                "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f"
                            },
                            {
                                "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                                "call": [
                                    {
                                        "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                                        "call": [
                                            {
                                                "hash": "0xacce6fd80d44e1796aa0c2c625e9e4e0ce39efc0"
                                            }
                                        ]
                                    },
                                    {
                                        "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f"
                                    },
                                    {
                                        "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                                        "call": [
                                            {
                                                "hash": "0xacce6fd80d44e1796aa0c2c625e9e4e0ce39efc0"
                                            }
                                        ]
                                    },
                                    {
                                        "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                                        "call": [
                                            {
                                                "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                                                "call": [
                                                    {
                                                        "hash": "0xacce6fd80d44e1796aa0c2c625e9e4e0ce39efc0"
                                                    }
                                                ]
                                            },
                                            {
                                                "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f"
                                            },
                                            {
                                                "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f"
                                            },
                                            {
                                                "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f"
                                            },
                                            {
                                                "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f"
                                            },
                                            {
                                                "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                                                "call": [
                                                    {
                                                        "hash": "0xacce6fd80d44e1796aa0c2c625e9e4e0ce39efc0"
                                                    }
                                                ]
                                            },
                                            {
                                                "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                                                "call": [
                                                    {
                                                        "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                                                        "call": [
                                                            {
                                                                "hash": "0xacce6fd80d44e1796aa0c2c625e9e4e0ce39efc0"
                                                            }
                                                        ]
                                                    },
                                                    {
                                                        "hash": "0xacce6fd80d44e1796aa0c2c625e9e4e0ce39efc0"
                                                    }
                                                ]
                                            }
                                        ]
                                    },
                                    {
                                        "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                                        "call": [
                                            {
                                                "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                                                "call": [
                                                    {
                                                        "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f"
                                                    },
                                                    {
                                                        "hash": "0xacce6fd80d44e1796aa0c2c625e9e4e0ce39efc0"
                                                    }
                                                ]
                                            }
                                        ]
                                    },
                                    {
                                        "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                                        "call": [
                                            {
                                                "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f"
                                            }
                                        ]
                                    },
                                    {
                                        "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                                        "call": [
                                            {
                                                "hash": "0xacce6fd80d44e1796aa0c2c625e9e4e0ce39efc0"
                                            },
                                            {
                                                "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                                                "call": [
                                                    {
                                                        "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f"
                                                    }
                                                ]
                                            },
                                            {
                                                "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f"
                                            },
                                            {
                                                "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f"
                                            }
                                        ]
                                    },
                                    {
                                        "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                                        "call": [
                                            {
                                                "hash": "0xacce6fd80d44e1796aa0c2c625e9e4e0ce39efc0"
                                            },
                                            {
                                                "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                                                "call": [
                                                    {
                                                        "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f"
                                                    }
                                                ]
                                            },
                                            {
                                                "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f"
                                            },
                                            {
                                                "hash": "0xd9e2093de3dc2ef7cf5704ceec46ab7fadd48e7f",
                                                "call": [
                                                    {
                                                        "hash": "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd"
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                ]
            },
            "storagechanges": [
                {
                    "state": "Added",
                    "key": "aAAAABMAyAE=",
                    "value": "6Ao="
                },
                {
                    "state": "Changed",
                    "key": "aAAAABIw",
                    "value": "5wo="
                },
                {
                    "state": "Changed",
                    "key": "aAAAABFjb3VudGVy",
                    "value": "xQA="
                },
                {
                    "state": "Deleted",
                    "key": "aAAAAANCbGluZCBCb3ggIzE3NTE=",
                    "value": "QAcoFMCY5KzwsgkN0W7LPVjeQmqHFYUbKA9CbGluZCBCb3ggIzE3NTEhACEAIQLXBigcaHR0cHM6Ly9uZW8ub3JnL0JsaW5kQm94LnBuZygcaHR0cHM6Ly9uZW8ub3JnL0JsaW5kQm94Lm1wNA=="
                },
                {
                    "state": "Changed",
                    "key": "aAAAAAHAmOSs8LIJDdFuyz1Y3kJqhxWFGw==",
                    "value": "UAE="
                },
                {
                    "state": "Deleted",
                    "key": "aAAAAATAmOSs8LIJDdFuyz1Y3kJqhxWFG0JsaW5kIEJveCAjMTc1MQ==",
                    "value": ""
                },
                {
                    "state": "Changed",
                    "key": "aAAAAAA=",
                    "value": "4g0="
                },
                {
                    "state": "Added",
                    "key": "aAAAAANGcmFnbWVudCBBICM0NTY=",
                    "value": "QAcoFMCY5KzwsgkN0W7LPVjeQmqHFYUbKA9GcmFnbWVudCBBICM0NTYhAQEhACECyAEoHWh0dHBzOi8vbmVvLm9yZy9GcmFnbWVudEEucG5nKB1odHRwczovL25lby5vcmcvRnJhZ21lbnRBLm1wNA=="
                },
                {
                    "state": "Added",
                    "key": "aAAAAATAmOSs8LIJDdFuyz1Y3kJqhxWFG0ZyYWdtZW50IEEgIzQ1Ng==",
                    "value": ""
                }
            ]
        },
        "stack": [
            {
                "type": "Boolean",
                "value": true
            }
        ]
    }
}

shargon
shargon previously approved these changes Dec 13, 2021
@Ashuaidehao Ashuaidehao changed the base branch from master to develop December 14, 2021 07:02
@Ashuaidehao Ashuaidehao dismissed shargon’s stale review December 14, 2021 07:02

The base branch was changed.

@superboyiii superboyiii merged commit 08ef3b7 into neo-project:develop Dec 15, 2021
AnnaShaleva pushed a commit to nspcc-dev/neo-go that referenced this pull request Feb 17, 2022
erikzhang pushed a commit that referenced this pull request Apr 21, 2022
* add invoked contract (#657)

* add in file copyright (#679)

* witness rule support (#676)

* Prevent SSRF (#692)

* limit free gas (#697)

* add log when exception happens under debug mode (#690)

* dbft: tune MaxBlock* parameters (#688)

* Fix StateAPI.MakeFindStatesParams (#699)

* update Console to ConsoleHelper (#682)

* refac log (#700)

* Make RpcServer.ProcessAsync public to enable better neo express integration (#701)

* Limit result stack (#696)

* fix MaxBlockSystemFee (#703)

* code optimise (#704)

* Add oracle global timeout (#698)
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 this pull request may close these issues.

5 participants