Open dzhelezov opened 3 years ago
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)
I tried @polkadot/api 3.4.1, and it works.
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
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.
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"]
}
}
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]'
}
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>",
},
}
@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
This looks like a storage migration issue, I will look deeper into this
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
Fetching blocks with height > 1M seems to work fine