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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(rpc-call): Never return <wasm:stripped> from rpc calls #3655

Merged
merged 4 commits into from
Jan 12, 2024

Conversation

breathx
Copy link
Member

@breathx breathx commented Jan 12, 2024

These changes formalise error output of calculate gas calls:

  • Internal errors (that are supposed to be unreachable) if occur will be thrown as "Internal error: entered unreachable code '{ERROR EXPLANATION}'"
  • 馃コ Rpc calls no longer return <wasm:stripped>, that happened to be in case of underlying extrinsic failure. Instead, it returns name of the error occurred.
  • In case of non pallet-gear error returned it will contain pallet/module index within the runtime of the chain to resolve name collision.

Before

curl http://testnet.vara.network:9944 -H "Content-Type:application/json;charset=utf-8" -d "{
    \"jsonrpc\":\"2.0\",
    \"id\":1,
    \"method\":\"gear_calculateInitCreateGas\",
    \"params\": [
        \"0x0000000000000000000000000000000000000000000000000000000000000000\",
        \"0x0000000000000000000000000000000000000000000000000000000000000000\",
        \"\",
        0,
        true
    ]
}"
{"jsonrpc":"2.0","error":{"code":8000,"message":"Runtime error","data":"\"Internal error: create_program failed with '<wasm:stripped>'\""},"id":1}%   

Now

curl http://localhost:9944 -H "Content-Type:application/json;charset=utf-8" -d "{
    \"jsonrpc\":\"2.0\",
    \"id\":1,
    \"method\":\"gear_calculateInitCreateGas\",
    \"params\": [
        \"0x0000000000000000000000000000000000000000000000000000000000000000\",
        \"0x0000000000000000000000000000000000000000000000000000000000000000\",
        \"\",
        0,
        true
    ]
}"
{"jsonrpc":"2.0","error":{"code":8000,"message":"Runtime error","data":"Extrinsic `gear.create_program` failed: 'CodeDoesntExist'"},"id":1}

@breathx breathx added A0-pleasereview PR is ready to be reviewed by the team D2-node Gear Node C0-bug Something isn't working labels Jan 12, 2024
gsdk/tests/rpc.rs Show resolved Hide resolved
@breathx breathx merged commit 1f1f4ef into master Jan 12, 2024
11 checks passed
@breathx breathx deleted the dn-avoid-wasm-stripped-for-rpc-call branch January 12, 2024 10:11
@shamilsan shamilsan added the B1-releasenotes The feature deserves to be added to the Release Notes label Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A0-pleasereview PR is ready to be reviewed by the team B1-releasenotes The feature deserves to be added to the Release Notes C0-bug Something isn't working D2-node Gear Node
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants