subsquid / squid-sdk

The main repo of the squid SDK
Apache License 2.0
1.23k stars 151 forks source link

`substrate-ingest` failed to process the block with `tip` as object type #108

Closed ken-futureverse closed 2 years ago

ken-futureverse commented 2 years ago

Describe the bug This line of code throws error "Do not know how to serialize a BigInt" which originate from pg package. Turns out because the tip value is an object type {tip: 0n, feeExchange: undefined} instead of 0n

TypeError: Do not know how to serialize a BigInt
    at JSON.stringify (<anonymous>)
    at prepareObject (/Users/ken/relayer-services/node_modules/pg/lib/utils.js:85:19)
    at prepareValue (/Users/ken/relayer-services/node_modules/pg/lib/utils.js:66:12)
    at arrayString (/Users/ken/relayer-services/node_modules/pg/lib/utils.js:29:31)
    at prepareValue (/Users/ken/relayer-services/node_modules/pg/lib/utils.js:63:12)
    at prepareValueWrapper (/Users/ken/relayer-services/node_modules/pg/lib/utils.js:193:12)
    at writeValues (/Users/ken/relayer-services/node_modules/pg-protocol/dist/serializer.js:67:41)
    at Object.bind (/Users/ken/relayer-services/node_modules/pg-protocol/dist/serializer.js:98:5)
    at Connection.bind (/Users/ken/relayer-services/node_modules/pg/lib/connection.js:160:26)
    at Query.prepare (/Users/ken/relayer-services/node_modules/pg/lib/query.js:211:18

To Reproduce Steps to reproduce the behavior:

  1. Run substrate-ingest against our testnet
    yarn squid-substrate-ingest -e wss://nikau.centrality.me/public/ws --start-block 5001560 --out postgres://postgres:postgres@localhost:5432/nikau-archive --write-batch-size 1
  2. The process will hang, to get the actual error, wrap this block inside a try...catch

Expected behavior

Environment (please complete the following information):

Applicable to decoding issues:

belopash commented 2 years ago

Are you going to fix it by yourself?

ken-futureverse commented 2 years ago

@belopash yip, submitted a PR, please review when you can :)

eldargab commented 2 years ago

Closed by https://github.com/subsquid/squid/commit/f24f8ed01d806dc9cb0adaee595acd13299d5381