Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polkadot/api fails to fetch very early blocks with the latest type definitions #32

Open
dzhelezov opened this issue Jul 6, 2021 · 6 comments

Comments

@dzhelezov
Copy link

I'm using the latest type definitions and polkadot/api v4.17.1 and edgeware type definitions from master.
When trying to fetch the blocks of height 1 and later, with API, I get

Failed to execute "get signed block by hash 0xb106f23a8e0900855ab2d6cad2bdfb12bdc19c0afc8d917d910287357bde86de" 
2021-07-06 16:26:48             VEC: Unable to decode on index 1 createType(ExtrinsicV4):: createType(Call):: Call: failed decoding imOnline.heartbeat:: Struct: failed on args: {"heartbeat":"Heartbeat","_signature":"Signature"}:: decodeU8a: failed at 0x42c59312af11636c… on _signature: H512:: Expected at least 64 bytes (512 bits), found 60 bytes
2021-07-06 16:26:48        RPC-CORE: getBlock(hash?: BlockHash): SignedBlock:: createType(SignedBlock):: Struct: failed on block: {"header":"Header","extrinsics":"Vec<Extrinsic>"}:: Struct: failed on extrinsics: Vec<Extrinsic>:: createType(ExtrinsicV4):: createType(Call):: Call: failed decoding imOnline.heartbeat:: Struct: failed on args: {"heartbeat":"Heartbeat","_signature":"Signature"}:: decodeU8a: failed at 0x42c59312af11636c… on _signature: H512:: Expected at least 64 bytes (512 bits), found 60 bytes

Fetching blocks with height > 1M seems to work fine

@wliyongfeng
Copy link

Hi, we have the same issue. My code:

const blockHash = await api.rpc.chain.getBlockHash(1);
const block = await api.rpc.chain.getBlock(blockHash);
const allEvents = await api.query.system.events.at(blockHash);

It produced following errors:

2021-11-14 20:36:16        REGISTRY: Unable to resolve type RewardDestinationTo257, it will fail on construction
2021-11-14 20:36:16        REGISTRY: Error: Call: failed decoding staking.bond:: Struct: failed on args: :: Cannot construct unknown type RewardDestinationTo257
    at new GenericCall (/Users/mac/work/os/play/edg/node_modules/@polkadot/types/generic/Call.cjs:147:13)
    at new Type (/Users/mac/work/os/play/edg/node_modules/@polkadot/types/create/registry.cjs:349:16)
    at initType (/Users/mac/work/os/play/edg/node_modules/@polkadot/types/create/createType.cjs:44:19)
    at createTypeUnsafe (/Users/mac/work/os/play/edg/node_modules/@polkadot/types/create/createType.cjs:63:12)
    at createType (/Users/mac/work/os/play/edg/node_modules/@polkadot/types/create/createType.cjs:78:10)
    at TypeRegistry.createType (/Users/mac/work/os/play/edg/node_modules/@polkadot/types/create/registry.cjs:306:39)
    at Function.decodeExtrinsic (/Users/mac/work/os/play/edg/node_modules/@polkadot/types/extrinsic/v4/Extrinsic.cjs:47:31)
    at new GenericExtrinsicV4 (/Users/mac/work/os/play/edg/node_modules/@polkadot/types/extrinsic/v4/Extrinsic.cjs:30:27)
    at new Type (/Users/mac/work/os/play/edg/node_modules/@polkadot/types/create/registry.cjs:349:16)
    at initType (/Users/mac/work/os/play/edg/node_modules/@polkadot/types/create/createType.cjs:44:19)

@wliyongfeng
Copy link

I tried @polkadot/api 3.4.1, and it works.

@Asmadek
Copy link

Asmadek commented Jan 28, 2022

Is there any solution to fix it in @polkadot/api ^6 version?

polkadot js has troubles with started blocks https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fmainnet.edgewa.re#/explorer/query/0xecfe590f070b93fef6bfc5620c3f9b925afd0b1c8ca3182e9af206110d3e7b31

But subscan show it correctly https://edgeware.subscan.io/block/0xecfe590f070b93fef6bfc5620c3f9b925afd0b1c8ca3182e9af206110d3e7b31?tab=log

@Asmadek
Copy link

Asmadek commented Feb 16, 2022

We made some research and find some bugs and solutions for edgeware types. But one of this bugs (number 3) we can't fix on our side.

  1. Unable to retrieve the specified block details. createType(SignedBlock):: Struct: failed on block: {"header":"Header","extrinsics":"Vec<Extrinsic>"}:: Struct: failed on extrinsics: Vec<Extrinsic>:: createType(ExtrinsicV4):: createType(Call):: Call: failed decoding staking.bond:: Struct: failed on args: :: decodeU8a: failed at 0x00… on payee:: DoNotConstruct: Cannot construct unknown type RewardDestinationTo257

Can be fixed by add custom type

types: {
    RewardDestinationTo257: {
        "_enum": ["Staked", "Stashed", "Controller"]
    }
}
  1. ERROR failed to fetch block Error: createType(SignedBlock):: Struct: failed on block: {"header":"Header","extrinsics":"Vec<Extrinsic>"}:: Struct: failed on extrinsics: Vec<Extrinsic>:: createType(ExtrinsicV4):: createType(Call):: Call: failed decoding imOnline.heartbeat:: Struct: failed on args: {"heartbeat":"Heartbeat","_signature":"Signature"}:: decodeU8a: failed at 0x42c59312af11636cb36475277cfeb800… on _signature: H512:: Expected at least 64 bytes (512 bits), found 60 bytes

Can be fixed by add custom type

types: {
    Signature: '[u8; 60]'
}
  1. ERROR failed to fetch block Error: createType(SignedBlock):: Struct: failed on block: {"header":"Header","extrinsics":"Vec<Extrinsic>"}:: Struct: failed on extrinsics: Vec<Extrinsic>:: createType(ExtrinsicV4):: createType(Call):: Call: failed decoding utility.batch:: Struct: failed on args: {"calls":"Vec<Call>"}:: decodeU8a: failed at 0x100600ff32d7e231759c2a47d0fbce0e… on calls: Vec<Call>:: decodeU8a: failed at 0x08ff6ea12c8193339b2a058cbe43dc12…: Call:: findMetaCall: Unable to find Call with index [8, 255]/[8,255]

Repeates on different blocks (e.g. 1632627, 4310374). Problem meets in batch transactions with set_controller function. This is specific for the spec version under 45.

UPD: Issue number 3 can be fixed with custom type

types: {
    ValidatorPrefs: {
      commission: "Compact<Perbill>",
    },
}

@flipchan
Copy link

@Asmadek seems to be an on-chain migration issue, here, keep in mind that this repo is about to be decomissioned very soon:
The official edgeware repo's you can always find here:
https://github.com/edgeware-network

@flipchan
Copy link

This looks like a storage migration issue, I will look deeper into this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants