AcalaNetwork / chopsticks

Create parallel reality of your Substrate network.
Apache License 2.0
126 stars 74 forks source link

How to fix "Error: Cannot find pallet"? #745

Closed spazcoin closed 3 months ago

spazcoin commented 3 months ago

I'm trying to test XCM calls between chains by running Chopsticks locally.

1) If I invoke Chopsticks including Phala:

npx @acala-network/chopsticks@latest xcm -r polkadot -p phala

then I see error at launch:

XCM setup with relaychain and parachains

Options:
  -v, --version     Show version number                                [boolean]
  -h, --help        Show help                                          [boolean]
  -c, --config      Path to config file with default options
  -r, --relaychain  Relaychain config file path                         [string]
  -p, --parachain   Parachain config file path                [array] [required]

Error: Cannot find pallet Sudo
    at objectToStorageItems (/home/spaz/.npm/_npx/81ad9c881cb83600/node_modules/@acala-network/chopsticks-core/dist/cjs/utils/set-storage.js:20:28)
    at setStorage (/home/spaz/.npm/_npx/81ad9c881cb83600/node_modules/@acala-network/chopsticks-core/dist/cjs/utils/set-storage.js:82:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async overrideStorage (/home/spaz/.npm/_npx/81ad9c881cb83600/node_modules/@acala-network/chopsticks/dist/cjs/utils/override.js:39:23)
    at async setupContext (/home/spaz/.npm/_npx/81ad9c881cb83600/node_modules/@acala-network/chopsticks/dist/cjs/context.js:143:5)
    at async setupWithServer (/home/spaz/.npm/_npx/81ad9c881cb83600/node_modules/@acala-network/chopsticks/dist/cjs/setup-with-server.js:16:21)
    at async Object.handler (/home/spaz/.npm/_npx/81ad9c881cb83600/node_modules/@acala-network/chopsticks/dist/cjs/cli.js:43:27)

2) If I invoke Chopsticks including Astar:

npx @acala-network/chopsticks@latest xcm -r polkadot -p hydradx -p astar

then it launches correctly. Then using Polkadot.js connected to the Astar instance, in JS console I run:

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

However, I receive:

i: 1: Error: Cannot find pallet scheduler
    at s (https://polkadot.js.org/apps/modu.ea1d2d064aa90f2e.js:1:7899)
    at x.decodeResponse (https://polkadot.js.org/apps/modu.ea1d2d064aa90f2e.js:1:8474)
    at m.internalonSocketMessageResult (https://polkadot.js.org/apps/modu.ea1d2d064aa90f2e.js:1:29572)
    at WebSocket.internalonSocketMessage (https://polkadot.js.org/apps/modu.ea1d2d064aa90f2e.js:1:29334)

I don't think Astar has scheduler pallet, nor does Phala have sudo pallet. And I don't see anything about pallets in the per-chain config files. I turned on LOG_LEVEL=debug but didn't see any additional useful info.

qiweiii commented 3 months ago
  1. xcm -r polkadot -p phala is using default configs in this repo, seems they are outdated, you could raise a pr to update it (remove the sudo section) or create a local config like phala.yml and run it with xcm -r polkadot -p ./phala.yml

  2. as you mentioned I don't think Astar has scheduler pallet, nor does Phala have sudo pallet,and in your dev_setStorage, it's setting storage for scheduler, so it gives the error

spazcoin commented 3 months ago

@qiweiii Thank you, I see both of the issues now. I'll submit a PR to remove sudo from config/phala.yml.

May I also ask - in the config.interlay.yml file, the tokens: already listed I think are registered in the tokens pallet. However, tokens from other chains are added to the assetRegistry pallet (such as HDX, BNC). Lending tokens (on Interlay, q tokens) are registered in the loans pallet (such as qDOT, qUSDT). What is the correct syntax to add tokens from the assetRegistry and loans pallets to the list of existing account balances? In the Hydra config I see - 12 to use the assetRegistry index, whereas in the Mangata config I see - token: 12.

qiweiii commented 3 months ago

Yea this also troubles me sometimes, I think it depends on the chain's data structure, one way to check it is to use pjs app:

for acala:

image
- 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
- token: AUSD

for astar

image
# DOT
- '340282366920938463463374607431768211455'
- 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY

please correct me if I'm wrong @xlc

xlc commented 3 months ago

Yeah the value in config file is just a JSON and we then encode it to whatever type the chain defines. So you need to inspect each chain for the right data format.

spazcoin commented 3 months ago

Thanks for the help and guidance. Closing this issue and opened https://github.com/AcalaNetwork/chopsticks/pull/746 to contribute changes.