paritytech / substrate-api-sidecar

REST service that makes it easy to interact with blockchain nodes built using Substrate's FRAME framework.
https://paritytech.github.io/substrate-api-sidecar/dist/
GNU General Public License v3.0
247 stars 152 forks source link

`v19.3.0`: Missing field `senderAddress` on request body. #1530

Closed exp0nge closed 2 weeks ago

exp0nge commented 2 weeks ago

Description

[Please add a clear description of the bug you are encountering, such as any details about your machine, the file where you think this bug may be, error messages, screenshots, versions of software used, etc.]

When sending a simulate transaction request, we get the following error on 19.3.0:

Missing field `senderAddress` on request body.

Is this a new change?

Steps to Reproduce

[Provide detailed steps for someone else to reproduce your bug.]

Expected vs. Actual Behavior

[A clear description of what you expected to happen and what actually happened.]

Imod7 commented 2 weeks ago

Yes, the dry-run endpoint was recently updated (with this PR) to work with the new runtime call. So, now you need to provide also the senderAddress along with the tx in the request body. Please refer to the docs for more details. While you can optionally include the block hash, it is not necessary. I acknowledge that this could have been stated more clearly in the release notes and version. My apologies for any inconvenience this caused.

exp0nge commented 2 weeks ago

Yes, the dry-run endpoint was recently updated (with this PR) to work with the new runtime call. So, now you need to provide also the senderAddress along with the tx in the request body. Please refer to the docs for more details. While you can optionally include the block hash, it is not necessary. I acknowledge that this could have been stated more clearly in the release notes and version. My apologies for any inconvenience this caused.

Thanks for the links. Once senderAddress is also included (using the from address of the tx), I get a different error:

sender: 5DCTmm7rZMB1JSEsMM2E8isDb5TQx1UcNk3Ssf2f4sQkVFUR tx

590284003226c89e9b9823c20703944fb3865dc37fc2915b7bc7c80f0f21d7218947dfc7004c2e5ab3a46eb958061a0c573f33f7a727411193499c2755cac6f40c333fe768a12366566a341a553f5039d71f44f0525adafbad485349e346caf4de9f17bf073300000700e40b5402000400005413cfabc8305ec7519adf8336729bf1bcf957eafab9691ae0c0072827c7c39d0700ac23fc06

error:

{"code":400,"error":"Unable to dry-run transaction","transaction":"0x590284003226c89e9b9823c20703944fb3865dc37fc2915b7bc7c80f0f21d7218947dfc7004c2e5ab3a46eb958061a0c573f33f7a727411193499c2755cac6f40c333fe768a12366566a341a553f5039d71f44f0525adafbad485349e346caf4de9f17bf073300000700e40b5402000400005413cfabc8305ec7519adf8336729bf1bcf957eafab9691ae0c0072827c7c39d0700ac23fc06","cause":"createType(RococoRuntimeRuntimeCall):: findMetaCall: Unable to find Call with index [89, 2]/[89,2]","stack":"Error: createType(RococoRuntimeRuntimeCall):: findMetaCall: Unable to find Call with index [89, 2]/[89,2]\n    at createTypeUnsafe (/usr/local/share/.config/yarn/global/node_modules/@polkadot/types-create/cjs/create/type.js:54:22)\n    at TypeRegistry.createTypeUnsafe (/usr/local/share/.config/yarn/global/node_modules/@polkadot/types/cjs/create/registry.js:230:52)\n    at /usr/local/share/.config/yarn/global/node_modules/@polkadot/api/cjs/base/Decorate.js:492:110\n    at Array.map (<anonymous>)\n    at /usr/local/share/.config/yarn/global/node_modules/@polkadot/api/cjs/base/Decorate.js:492:87\n    at /usr/local/share/.config/yarn/global/node_modules/@polkadot/api/cjs/promise/decorateMethod.js:43:30\n    at new Promise (<anonymous>)\n    at decorateCall (/usr/local/share/.config/yarn/global/node_modules/@polkadot/api/cjs/promise/decorateMethod.js:39:12)\n    at Object.dryRunCall (/usr/local/share/.config/yarn/global/node_modules/@polkadot/api/cjs/promise/decorateMethod.js:73:15)\n    at TransactionDryRunService.dryRuntExtrinsic (/usr/local/share/.config/yarn/global/node_modules/@substrate/api-sidecar/build/src/services/transaction/TransactionDryRunService.js:32:36)","at":{}}

I did not supply at, is there additional pre-condition that is expected? In my call, sender address is funded with 20 DOT on Rococo prior to the RPC call. If this is unrelated to this issue, let me know.

Imod7 commented 2 weeks ago

Rococo was deprecated (related forum post) and shut down two weeks ago. So, make sure that the sender address has sufficient funds in one of the alternative testnets, such as Westend or Paseo, and try to dry run connected to one of those.

While connected to Westend, the correct input to use is the following :

where tx is the encoded call data.

You can double check that in pjs apps (Developer > Runtime Calls > dryRunApi - dryRunCall > system - Signed) :

Input Account : sender mentioned previously Call : tx mentioned previously

and the Output is the following :

1: dryRunApi.dryRunCall: Result<XcmRuntimeApisDryRunCallDryRunEffects, XcmRuntimeApisDryRunError>

{
  Ok: {
    executionResult: {
      Err: {
        postInfo: {
          actualWeight: null
          paysFee: Yes
        }
        error: {
          Token: FundsUnavailable
        }
      }
    }
    emittedEvents: []
    localXcm: null
    forwardedXcms: []
  }
}

which returns the FundsUnavailable error message.

In Sidecar the corresponding request should be the following :

curl -X 'POST' \
  'http://127.0.0.1:8080/transaction/dry-run' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "senderAddress": "5DCTmm7rZMB1JSEsMM2E8isDb5TQx1UcNk3Ssf2f4sQkVFUR",
  "tx": "0x0400005413cfabc8305ec7519adf8336729bf1bcf957eafab9691ae0c0072827c7c39d0700ac23fc06"
  }'

but there is an issue with the types so that is why you see the Unable to dry-run transaction message. I will fix this asap.

exp0nge commented 2 weeks ago

Sorry, to be precise, we're use a private net Rococo version (--dev).

The test does pass on the previous version of sidecar.

Imod7 commented 2 weeks ago

I understand but the endpoint changed. Can you try to submit with the tx input that I shared and see if it works ? It is the corresponding unsigned call.

exp0nge commented 2 weeks ago

I understand but the endpoint changed. Can you try to submit with the tx input that I shared and see if it works ? It is the corresponding unsigned call.

Ah, missed that part. Now I get the new response:

{"at":{"hash":"","height":"0"},"result":{"resultType":"DispatchOutcome","result":{"actualWeight":null,"paysFee":"Yes"}}}

Thanks!

Imod7 commented 2 weeks ago

@exp0nge Closing this issue as resolved. Just a heads up that I will also add a fix on the dry-run endpoint (related issue https://github.com/paritytech/substrate-api-sidecar/issues/1532) which is a bug that I found while testing your case. So if you are not getting the expected error msg from the dry-run endpoint, this will be fixed asap.