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

Request support on contract usage #1026

Closed
Keith-CY opened this issue Mar 21, 2023 · 7 comments
Closed

Request support on contract usage #1026

Keith-CY opened this issue Mar 21, 2023 · 7 comments
Assignees
Labels
help wanted Extra attention is needed P-Medium

Comments

@Keith-CY
Copy link
Contributor

Hi team, we(gwscan team) are going to verify the feature of showing data of the target contract on the proxy contract page.

We've deployed a pair of proxy contract and implementation contract but failed to invoke them. An error message

Returned error: {"jsonrpc":"2.0","error":"Internal JSON-RPC error.","id":2866772054041844}

was returned

The source code of contracts have been uploaded at https://gist.github.com/FrederLu/7978291563509a94020afb31cca2f01a

We have checked it but haven't located the error since we're unfamiliar with the proxy contract.

Could you team do us a favor to have a look at the code? Thanks in advance

@Flouse Flouse added the help wanted Extra attention is needed label Mar 21, 2023
@magicalne
Copy link
Contributor

@Keith-CY Hi, I would like to take a look the failed tx. But I can't find it. Could you please provide a link to to the failed tx?

@FrederLu
Copy link

FrederLu commented Mar 21, 2023

@magicalne
Hello, when I execute curl following the steps on https://docs.godwoken.io/debug-replay-rpc, no data is found.
Please take a look, the tx is 0x183466fab616eeca6cc4aa605a101b288e6b8743b811fc2d432718148218815e.

curl --location --request POST https://v1.testnet.godwoken.io/rpc/ --header 'Content-Type: application/json' --data-raw '{"id": 2866772054050555, "jsonrpc": "2.0", "method": "gw_debug_replay_transaction", "params": ["0xacf47527fe55114fadc3fc319ecbddb5f9d7203b97b9e39f91237ac787016a02"]}'

{"jsonrpc":"2.0","id":2866772054050555,"result":null}

@magicalne
Copy link
Contributor

That's where you need poly_getGwTxHashByEthTxHash.
Before replaying the failed tx, you need to get the godwoken tx hash by eth tx hash:

curl --location --request POST 'https://v1.testnet.godwoken.io/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "poly_getGwTxHashByEthTxHash",
    "params": [
        "0x183466fab616eeca6cc4aa605a101b288e6b8743b811fc2d432718148218815e"
    ],
    "id": 74
}'

Then you can debug the failed tx by sending debug replay rpc with the godwoken tx hash.

@magicalne
Copy link
Contributor

I just check the contract log. I cannot tell what's wrong with the contract code.

      "[execute_in_evmone] code size => 1666",
      "[execute_in_evmone] input_size => 164",
      "[handle_message] used_memory(Bytes) => 800",
      "[handle_message] gas left => 2768012",
      "[handle_message] status_code => 2",

status_code = 2, it means evm returned a revert error. That could be anything...
I can see the error happened in the first call of the delegation call. I hope this is helpful.

@FrederLu
Copy link

After adjusting as you said, the RPC is called to get the data, please take a look.
curl --location --request POST https://v1.testnet.godwoken.io/rpc/ --header 'Content-Type: application/json' --data-raw '{"id": 2866772054050555, "jsonrpc": "2.0", "method": "gw_debug_replay_transaction", "params": ["0x7e75ee5be3170f55f838876c60c86fd5efcbb49e3ef16ef601299cc46700d0a6"]}'

{"jsonrpc":"2.0","id":2866772054050555,"result":{"cycles":{"execution":"0x2b60c1","total":"0x2b60c1","virtual":"0x0"},"debug_log":["","v1.5.3","BEGIN parse_message()","args_len => 2424","[call_kind] => 0","[gas_limit] => 458595","[gas_price] => 100000000000","[input_size] => 2372","END parse_message()","load_account_script, account_id: => 21280","load_account_script, account_id: => 4","chain_id => 71401","creator_account_id => 4","g_rollup_script_hash 0x702359ea7f073558921eb50d8c1c77e92f760c8f8656bde4995f26b8963e2dd8","g_sudt_id => 1","[run_polyjuice] initial gas limit => 458595","[run_polyjuice] take a snapshot id => 1","load_account_script, account_id: => 21280","[load_account_code] account_id => 21280","[load_account_code] code_size before loading => 24576","[load_account_code] code_size after loading => 5532","[handle_transfer] sender 0x7c3321c073b071f8eedf4e121f6693eee48a9a67","[handle_transfer] destination 0xde2022a8ab68ae86b0cd3ba5efa10aab859d0293","[handle_transfer] msg->value 0x0000000000000000000000000000000000000000000000000000000000000000","[handle_message] msg.kind => 0","[execute_in_evmone] code size => 5532","[execute_in_evmone] input_size => 2372","BEGIN get_storage","END get_storage","BEGIN get_storage","END get_storage","BEGIN get_storage","END get_storage","BEGIN set_storage","END set_storage","BEGIN get_storage","END get_storage","BEGIN get_storage","END get_storage","BEGIN set_storage","END set_storage","BEGIN get_storage","END get_storage","BEGIN get_storage","END get_storage","BEGIN set_storage","END set_storage","BEGIN get_storage","END get_storage","BEGIN get_storage","END get_storage","BEGIN set_storage","END set_storage","BEGIN get_storage","END get_storage","BEGIN get_storage","END get_storage","BEGIN set_storage","END set_storage","BEGIN get_storage","END get_storage","BEGIN get_storage","END get_storage","BEGIN set_storage","END set_storage","BEGIN get_storage","END get_storage","BEGIN get_storage","END get_storage","BEGIN set_storage","END set_storage","BEGIN get_storage","END get_storage","BEGIN get_storage","END get_storage","BEGIN set_storage","END set_storage","BEGIN get_storage","END get_storage","BEGIN get_storage","END get_storage","BEGIN set_storage","END set_storage","BEGIN get_storage","END get_storage","BEGIN get_storage","END get_storage","BEGIN set_storage","END set_storage","BEGIN get_storage","END get_storage","BEGIN get_storage","END get_storage","BEGIN set_storage","END set_storage","BEGIN get_storage","END get_storage","BEGIN get_storage","END get_storage","BEGIN set_storage","END set_storage","BEGIN get_storage","END get_storage","BEGIN get_storage","END get_storage","BEGIN set_storage","END set_storage","BEGIN get_storage","END get_storage","BEGIN get_storage","END get_storage","BEGIN set_storage","END set_storage","BEGIN get_storage","END get_storage","BEGIN get_storage","END get_storage","BEGIN set_storage","END set_storage","BEGIN get_storage","END get_storage","BEGIN get_storage","END get_storage","BEGIN set_storage","END set_storage","BEGIN get_storage","END get_storage","BEGIN get_storage","END get_storage","BEGIN set_storage","END set_storage","[handle_message] used_memory(Bytes) => 1824","[handle_message] gas left => 30000","[handle_message] status_code => 0","[run_polyjuice] gas left => 30000","[run_polyjuice] gas_used => 428595","set return data size => 0","[run_polyjuice] finalize"],"execution_time_ms":9,"exit_code":0,"logs":[{"account_id":"0x5320","data":"0x338a060000000000338a060000000000000000000000000000000000000000000000000000000000","service_flag":"0x2"},{"account_id":"0x1","data":"0x02000000140000007c3321c073b071f8eedf4e121f6693eee48a9a670200000014000000715ab282b873b79a7be8b0e8c13c4e8966a520400038c0f87c449800000000000000000000000000000000000000000000000000","service_flag":"0x1"}],"read_data_hashes":["0xea1b45c30d644dee17d7f41425e89346af18a8da7231052786faf23cdc5f4b0d"],"return_data":"0x","write_data_hashes":[],"write_mem_smt_time_ms":2}}%

@magicalne
Copy link
Contributor

magicalne commented Mar 21, 2023

0x183466fab616eeca6cc4aa605a101b288e6b8743b811fc2d432718148218815e
Those are debug logs of a successfull tx.

Please take a look my last reply. And how about running this contract on hardhat? Does hardhat throw any error?

@FrederLu
Copy link

0x183466fab616eeca6cc4aa605a101b288e6b8743b811fc2d432718148218815e
Those are debug logs of a successfull tx.

Please take a look my last reply. And how about running this contract on hardhat? Does hardhat throw any error?

@magicalne Thanks for your answer.
Finally, it was found that it was caused by the problem of calling parameters of delegatecall triggered at the contract level.

@Flouse Flouse closed this as completed Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed P-Medium
Projects
None yet
Development

No branches or pull requests

4 participants