AcalaNetwork / chopsticks

Create parallel reality of your Substrate network.
Apache License 2.0
131 stars 78 forks source link

Dry-running extrinsic using Chopsticks on command line returns "length less than remainder, expected at least 133, found 91" #747

Closed spazcoin closed 4 months ago

spazcoin commented 4 months ago

I'm trying to test XCM governance proposals using Chopsticks but running into issues. I've cloned and compiled Chopsticks within GitBash on Windows. However, when I try to dry run it with an extrinsic I receive an Error message Extrinsic: length less than remainder, expected at least 133, found 91 that I don't know how to overcome.

> npx @acala-network/chopsticks@latest dry-run -c hydradx --extrinsic=0x0d020c4101090000000110270000102700000d0301017369626cd60700000000000000000000000000000000000000000000000000003b0209000000000000ffcf8529967e7704000000000041010900000001f401000010270000
@polkadot/types-create has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
        cjs 10.12.6     node_modules/@polkadot/types-create/cjs
        cjs 10.13.1     node_modules/@polkadot/types-known/node_modules/@polkadot/types-create/cjs
@polkadot/types-codec has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
        cjs 10.12.6     node_modules/@polkadot/types-codec/cjs
        cjs 10.13.1     node_modules/@polkadot/types-known/node_modules/@polkadot/types-codec/cjs
[04:40:11.391] INFO: Loading config file https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/hydradx.yml
    app: "chopsticks"
chopsticks dry-run

Dry run an extrinsic

Options:
<<< clipped help text printout for brevity >>>

Error: createType(GenericExtrinsic):: Extrinsic: length less than remainder, expected at least 133, found 91
    at createTypeUnsafe (/home/spaz/.npm/_npx/81ad9c881cb83600/node_modules/@polkadot/types-create/cjs/create/type.js:54:22)
    at TypeRegistry.createType (/home/spaz/.npm/_npx/81ad9c881cb83600/node_modules/@polkadot/types/cjs/create/registry.js:224:52)
    at dryRunExtrinsic (/home/spaz/.npm/_npx/81ad9c881cb83600/node_modules/@acala-network/chopsticks-core/dist/cjs/blockchain/block-builder.js:377:24)
    at async Blockchain.dryRunExtrinsic (/home/spaz/.npm/_npx/81ad9c881cb83600/node_modules/@acala-network/chopsticks-core/dist/cjs/blockchain/index.js:321:41)
    at async dryRunExtrinsic (/home/spaz/.npm/_npx/81ad9c881cb83600/node_modules/@acala-network/chopsticks/dist/cjs/plugins/dry-run/dry-run-extrinsic.js:26:38)
    at async Object.handler (/home/spaz/.npm/_npx/81ad9c881cb83600/node_modules/@acala-network/chopsticks/dist/cjs/plugins/dry-run/cli.js:45:13)

I posted this question on StackExchange a week ago as well: https://substrate.stackexchange.com/questions/11352/dry-running-extrinsic-using-chopsticks-on-command-line-length-less-than-remaind

another example call that returns a similar error: npx @acala-network/chopsticks@latest dry-run --config=configs/astar.yml --extrinsic=0x0b030a016d6f646c70792f747273727900000000000000000000000000000000000000003700000000000000000000000000000000000000d012d9cbb7ab7f7704000000000003010200c91f01007369626cd607000000000000000000000000000000000000000000000000000000

Trying to more closely follow your README.md examples, when I supply an address param then it will execute without that error. However, I'm trying to test governance extrinsics so I need to run them as root. In the Chopsticks UI, I see that you can dry-run an extrinsic using {"system":"Root"} but that doesn't work on the command line. What's the correct command line call to run an extrinsic as root?

Finally, for many chains I can run a local instance of Chopsticks, connect polkadot.js and then submit extrinsics in the Javascript console using the call below. However, it doesn't work for Astar because Astar doesn't have the scheduler pallet. Is there another syntax that can be used to submit extrinsics from Root on the Javascript console for chains that don't have scheduler available?

const number = (await api.rpc.chain.getHeader()).number.toNumber()
await api.rpc('dev_setStorage', {
 scheduler: {
   agenda: [
     [
       [number + 1], [
         {
           call: {
             Inline: '0x4d047369626cd6070000000000000000000000000000000000000000000000000000090000001f00001062fde3f00184770400'
           },
           origin: {
             system: 'Root'
           }
         }
       ]
     ]
   ]
 }
})
await api.rpc('dev_newBlock', { count: 1})
xlc commented 4 months ago

There is no universal way to run a call from root origin so there is no such command line can be implemented. Astar have sudo pallet so you can just modify the sudo key and use it

In this case, just launch a chopsticks chain with sudo key overriden, and use pjs apps to dispatch the call and see if it works.