Issue with @polkadot/api access to older block

Hi

I am working with Node.js and @polkadot/api to extract transaction information for a set of accounts. This works well with blocks down to 908029. However, trying to access blocks below that point leads to an error. Are there some adjustments that are needed for @polkadot/api when accessing older blocks? There appears to be some chain migrations happening at around block 908029.

For example, trying to run the following code:

var blk = await api.rpc.chain.getBlock();
blk = parseInt(blk.block.header.number);
while( true ) {
var hsh = await api.rpc.chain.getBlockHash(blk);
blk = await api.rpc.chain.getBlock(hsh);
blk = parseInt(blk.block.header.number);
console.log( blk, “-”, hsh.toString() );

blk -= 1;
}

Results in

…
908031 - 0x78436015664f0666d31e17aa28052c47cd1f4a9c4b2584b53af920dcc3fb2a22
908030 - 0x8d816e4a46dbf9aa255f5e75708f0e8aa3fca3a5afcfd9a725fcd2f8b715181a
908029 - 0x5249033a0ae65bb7141624fe35c07f6090560f99a030ba155786b90e9d2c1d54

2022-010. -12 12:09:53 REGISTRY: Unknown signed extensions CheckMqSequence found, treating them as no-effect
2022-01-12 12:09:53 REGISTRY: Unable to resolve type SignedMessage, it will fail on construction
2022-01-12 12:09:53 VEC: Unable to decode on index 2 createType(ExtrinsicV4):: createType(Call):: Call: failed decoding phalaMq.syncOffchainMessage:: Struct: failed on args: :: decodeU8a: failed at 0x05505e7068616c612f6d696e696e672f… on signed_message:: DoNotConstruct: Cannot construct unknown type SignedMessage
2022-01-12 12:09:53 RPC-CORE: getBlock(hash?: BlockHash): SignedBlock:: createType(SignedBlock):: Struct: failed on block: {“header”:“Header”,“extrinsics”:“Vec”}:: Struct: failed on extrinsics: Vec:: createType(ExtrinsicV4):: createType(Call):: Call: failed decoding phalaMq.syncOffchainMessage:: Struct: failed on args: :: decodeU8a: failed at 0x05505e7068616c612f6d696e696e672f… on signed_message:: DoNotConstruct: Cannot construct unknown type SignedMessage
Error: createType(SignedBlock):: Struct: failed on block: {“header”:“Header”,“extrinsics”:“Vec”}:: Struct: failed on extrinsics: Vec:: createType(ExtrinsicV4):: createType(Call):: Call: failed decoding phalaMq.syncOffchainMessage:: Struct: failed on args: :: decodeU8a: failed at 0x05505e7068616c612f6d696e696e672f… on signed_message:: DoNotConstruct: Cannot construct unknown type SignedMessage

I get the same results both using local node or ‘wss://khala.api.onfinality.io/public-ws’ as the WSProvider endpoint. Also, trying to start at even older blocks results in the same issue. On the other hand, using Developer/Javascript Console in polkadot.js app works fine with Khala network.

On public nodes you will probably not get more than 250 block of history.
You need to specify parachain types - check how it is done in phala app