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
245 stars 151 forks source link

v3.0.5 @polkadot package bug with older blocks #461

Closed TarikGul closed 3 years ago

TarikGul commented 3 years ago

Description

On a GCP instance on Debian/10 running Sidecar v.3.0.5 I am currently running into this error when querying some older blocks with specific extrinsics.

Example: /blocks/214576. => polkadot chain.

When testing my benchmark scripts earlier I was getting successful behavior because I was working on a local branch that hadn't re-yarn-installed for v3.0.5. I tested v3.0.4 and everything worked fine.

I made sure to go through deleting my yarn and reseting the caches etc. but still received the errors.

error: REGISTRY: Error: Call: failed decoding utility.batch:: Struct: failed on args: {"calls":"Vec<Call>"}:: Call: failed dec
oding proxy.proxy:: Struct: failed on args: {"real":"AccountId","force_proxy_type":"Option<ProxyType>","call":"Call"}:: Unable to create Enum via 
index 4, in Any, NonTransfer, Governance, Staking, IdentityJudgement, CancelProxy
    at new GenericCall (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/generic/Call.js:147:13)
    at new Type (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/registry.js:340:16)
    at initType (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/createType.js:49:19)
    at createTypeUnsafe (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/createType.js:69:12)
    at createType (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/createType.js:84:10)
    at TypeRegistry.createType (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/registry.js:297:39)
    at Function.decodeExtrinsic (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/extrinsic/v4/Extrinsic.js:47:31)
    at new GenericExtrinsicV4 (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/extrinsic/v4/Extrinsic.js:30:27)
    at new Type (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/registry.js:340:16)
    at initType (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/createType.js:49:19)
2021-03-07 23:38:00 error: REGISTRY: Error: createType(Call):: Call: failed decoding utility.batch:: Struct: failed on args: {"calls":"Vec<Call>"}
:: Call: failed decoding proxy.proxy:: Struct: failed on args: {"real":"AccountId","force_proxy_type":"Option<ProxyType>","call":"Call"}:: Unable 
to create Enum via index 4, in Any, NonTransfer, Governance, Staking, IdentityJudgement, CancelProxy
    at createTypeUnsafe (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/createType.js:72:11)
    at createType (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/createType.js:84:10)
    at TypeRegistry.createType (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/registry.js:297:39)
    at Function.decodeExtrinsic (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/extrinsic/v4/Extrinsic.js:47:31)
    at new GenericExtrinsicV4 (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/extrinsic/v4/Extrinsic.js:30:27)
    at new Type (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/registry.js:340:16)
    at initType (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/createType.js:49:19)
    at createTypeUnsafe (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/createType.js:69:12)
    at createType (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/createType.js:84:10)
    at TypeRegistry.createType (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/registry.js:297:39)
2021-03-07 23:38:00 error: VEC: Unable to decode on index 3 createType(ExtrinsicV4):: createType(Call):: Call: failed decoding utility.batch:: Str
uct: failed on args: {"calls":"Vec<Call>"}:: Call: failed decoding proxy.proxy:: Struct: failed on args: {"real":"AccountId","force_proxy_type":"O
ption<ProxyType>","call":"Call"}:: Unable to create Enum via index 4, in Any, NonTransfer, Governance, Staking, IdentityJudgement, CancelProxy
2021-03-07 23:38:00 error: REGISTRY: Error: Struct: failed on block: {"header":"Header","extrinsics":"Vec<Extrinsic>"}:: Struct: failed on extrins
ics: Vec<Extrinsic>:: createType(ExtrinsicV4):: createType(Call):: Call: failed decoding utility.batch:: Struct: failed on args: {"calls":"Vec<Cal
l>"}:: Call: failed decoding proxy.proxy:: Struct: failed on args: {"real":"AccountId","force_proxy_type":"Option<ProxyType>","call":"Call"}:: Una
ble to create Enum via index 4, in Any, NonTransfer, Governance, Staking, IdentityJudgement, CancelProxy
    at /home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/codec/Struct.js:70:13
    at Array.reduce (<anonymous>)
    at decodeStructFromObject (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/codec/Struct.js:24:29)
    at decodeStruct (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/codec/Struct.js:111:10)
    at new Struct (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/codec/Struct.js:132:26)
    at new <anonymous> (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/codec/Struct.js:150:9)
    at new Type (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/registry.js:340:16)
    at initType (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/createType.js:49:19)
    at createTypeUnsafe (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/createType.js:69:12)
    at RpcCore._formatOutput (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/rpc-core/index.js:404:41)
2021-03-07 23:38:00 error: RPC-CORE: getBlock(hash?: BlockHash): SignedBlock:: createType(SignedBlock):: Struct: failed on block: {"header":"Heade
r","extrinsics":"Vec<Extrinsic>"}:: Struct: failed on extrinsics: Vec<Extrinsic>:: createType(ExtrinsicV4):: createType(Call):: Call: failed decod
ing utility.batch:: Struct: failed on args: {"calls":"Vec<Call>"}:: Call: failed decoding proxy.proxy:: Struct: failed on args: {"real":"AccountId
","force_proxy_type":"Option<ProxyType>","call":"Call"}:: Unable to create Enum via index 4, in Any, NonTransfer, Governance, Staking, IdentityJud
gement, CancelProxy
2021-03-07 23:38:00 error: createType(SignedBlock):: Struct: failed on block: {"header":"Header","extrinsics":"Vec<Extrinsic>"}:: Struct: failed o
n extrinsics: Vec<Extrinsic>:: createType(ExtrinsicV4):: createType(Call):: Call: failed decoding utility.batch:: Struct: failed on args: {"calls"
:"Vec<Call>"}:: Call: failed decoding proxy.proxy:: Struct: failed on args: {"real":"AccountId","force_proxy_type":"Option<ProxyType>","call":"Cal
l"}:: Unable to create Enum via index 4, in Any, NonTransfer, Governance, Staking, IdentityJudgement, CancelProxy 
 Error: createType(SignedBlock):: Struct: failed on block: {"header":"Header","extrinsics":"Vec<Extrinsic>"}:: Struct: failed on extrinsics: Vec<E
xtrinsic>:: createType(ExtrinsicV4):: createType(Call):: Call: failed decoding utility.batch:: Struct: failed on args: {"calls":"Vec<Call>"}:: Cal
l: failed decoding proxy.proxy:: Struct: failed on args: {"real":"AccountId","force_proxy_type":"Option<ProxyType>","call":"Call"}:: Unable to cre
ate Enum via index 4, in Any, NonTransfer, Governance, Staking, IdentityJudgement, CancelProxy
    at createTypeUnsafe (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/types/create/createType.js:72:11)
    at RpcCore._formatOutput (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/rpc-core/index.js:404:41)
    at callWithRegistry (/home/tariksnow37/substrate-api-sidecar/node_modules/@polkadot/rpc-core/index.js:272:42)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
2021-03-07 23:38:00 error: GET /blocks/214576 500 4630ms

Steps to Reproduce

The way I was able to reproduce was very simple via a GCP(Debian) instance as well as my local Macbook(OSX) pro.

// Git clone master, or download the global package
// Make sure its running on v3.0.5

1a. For local repo

yarn

yarn dev
or
yarn build
yarn start

1b. For global repo

substrate-api-sidecar
  1. Query the link
    http://127.0.0.1:8080/blocks/214576

I tested against polkadot chains, 2 archive nodes: one local, and the other on a GCP instance. As well as the public polkadot RPC node ie: wss://rpc.polkadot.io.

Will work on a investigating the bug, and getting a fix tomorrow.

TarikGul commented 3 years ago

The issue seems to be revolved around version >= @polkadot/api@3.11.1. Everything using v3.10.2 and lower works.

emostov commented 3 years ago

Fixed by #467