entropyxyz / entropy-core

Protocol and cryptography development.
https://docs.entropy.xyz/
GNU Affero General Public License v3.0
11 stars 2 forks source link

Connecting to a node with incompatible version #1145

Open mixmix opened 2 weeks ago

mixmix commented 2 weeks ago

The problem

I noticed a really unhelpful test when trialing the CLI. I told it to make a register an account and got this:

Attempting to register the address: 5CBCdVRZDw8zTvnVkcrwSriAuJKLTnajLpZkz2BU4aNWgGNs
file:///home/projects/ENTROPY/cli/node_modules/@polkadot/types/metadata/decorate/extrinsics/createUnchecked.js:11
            throw new Error(`Extrinsic ${section}.${funcName} expects ${expectedArgs.length} arguments, got ${args.length}.`);
                  ^

Error: Extrinsic registry.register expects 3 arguments, got 2.
    at extrinsicFn (file:///home/projects/ENTROPY/cli/node_modules/@polkadot/types/metadata/decorate/extrinsics/createUnchecked.js:11:19)
    at Object.decorated [as register] (file:///home/projects/ENTROPY/cli/node_modules/@polkadot/api/base/Decorate.js:539:50)
    at RegistrationManager.register (file:///home/projects/ENTROPY/cli/node_modules/@entropyxyz/sdk/dist/index.js:99:51)
    at Entropy.register (file:///home/projects/ENTROPY/cli/node_modules/@entropyxyz/sdk/dist/index.js:831:57)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Very unhelpful response as a CLI user.

The actual problem is that the default endpoint it was connecting to is on an old version of Entropy core compared to CLI.

Questions

I'm wondering

Obviously we would make less breaking changes, but as the CLI developer I'm wanting to make it clear/ safe for my users.

ameba23 commented 2 weeks ago

I think you can get the current version number of the runtime from a subxt client by doing api.runtime_version().spec_version. I imagine polkadot js has something similar. But i don't know whether this is telling you the runtime version the client is expecting (from the entropy-metadata.scale file) or the runtime version of the connected chain endpoint (by actually doing a query).

Ideally you want to know both and be able to compare them.

Usually though with subxt i get a pretty clear error MetadataError::IncompatibleCodegen which can be shown to the user as 'you need to update your client'.