polkadot-fellows / runtimes

The various runtimes which make up the core subsystems of networks for which the Fellowship is represented.
GNU General Public License v3.0
143 stars 97 forks source link

Add more integrations tests to People chains #499

Open rockbmb opened 3 weeks ago

rockbmb commented 3 weeks ago

https://github.com/open-web3-stack/polkadot-ecosystem-tests relies on chopsticks to create E2E tests using periodically (roughly daily) obtained runtimes from production relay chains/system parachains.

In particular, https://github.com/open-web3-stack/polkadot-ecosystem-tests/pull/63 does this for the People chains. In writing those tests, I was unable to use XCM to test pallet_identity::{kill_identity/add_username_authority/remove_username_authority}. I wrote this PR to replicate those tests at this layer, whose passing status falsify the hypothesis that there may have been an issue with the runtimes, and confirm that it was a problem with the way I wrote those tests.

rockbmb commented 2 weeks ago

@acatangiu certainly.

Thanks for the review!

bkchr commented 2 weeks ago

In writing those tests, I was unable to use XCM to test pallet_identity::{kill_identity/add_username_authority/remove_username_authority}.

Why?

github-actions[bot] commented 2 weeks ago

Review required! Latest push from author must always be reviewed

github-actions[bot] commented 2 weeks ago

Review required! Latest push from author must always be reviewed

rockbmb commented 2 weeks ago

In writing those tests, I was unable to use XCM to test pallet_identity::{kill_identity/add_username_authority/remove_username_authority}.

Why?

To test the following example, you'll need to:

  1. have https://github.com/AcalaNetwork/chopsticks available locally
  2. create a local network with a relay chain and people parachain:
    cd chopsticks
    npx @acala-network/chopsticks@latest xcm -r configs/polkadot.yml -p configs/polkadot-people.yml
  3. Open each of them in PJS

Consider the following encoded call: 0x630004000100b10f040406020700aea68f0282841e008c320a0078a302c5370300ab2bd8a65469a5061220cd07b3b3a17e5e3233d283e2ad46f0.

  1. Decoding it from the relay chain, you'll see it consists of a V4 XCM with a Transact instruction, to be sent to the people chain with a SuperUser origin, containing the encoded call: 0x320a0078a302c5370300ab2bd8a65469a5061220cd07b3b3a17e5e3233d283e2ad46f0.
  2. If you were to subsequently decode this in the people chain's tab, you would see a pallet_identity::kill_identity call on 13jBAtYJar4xujPaEx41FxjSt9PqU7LqJRbySJiVdMtuWN42, which is my DOT address. There should be an associated identity.

Now either

  1. sign and send it using the Alice development account, or
  2. Paste and run this in the relay chain's JavaScript tab:
const call = '0x630004000100b10f040406020700aea68f0282841e008c320a0078a302c5370300ab2bd8a65469a5061220cd07b3b3a17e5e3233d283e2ad46f0'

const number = (await api.rpc.chain.getHeader()).number.toNumber()

await api.rpc('dev_setStorage', {
  scheduler: {
    agenda: [
      [
        [number + 1], [
          {
            call: {
              Inline: call
            },
            origin: {
              system: 'Root'
            }
          }
        ]
      ]
    ]
  }
})
// Make a block to include the extrinsic
await api.rpc('dev_newBlock', { count: 1 })

In either instance, you will find, in the people chain's "recent events" list, messageQueue.ProcessingFailed.

@bkchr in conclusion, and to answer your question: I don't know why this happens, but I suspect it shouldn't. The above process is exactly how I tested add_registrar in https://github.com/open-web3-stack/polkadot-ecosystem-tests/pull/63, and it worked then.

I've been working to understand why, and this PR, as well as https://github.com/paritytech/polkadot-sdk/pull/6377#issuecomment-2469394201 are how.

rockbmb commented 2 weeks ago

@seadanda also, apologies for the delay: the above comment contains the snippet I mentioned in DMs.

My identity should exist when you fork the chain.