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

Bug: last_indexed_block reset to Zero after reaching the seed blocks #300

Open
shardAstronaut opened this issue Jun 25, 2024 · 6 comments
Open

Comments

@shardAstronaut
Copy link
Contributor

Description

I'm indexing ETH contract on Starknet, the indexer index all the blocks but just after reaching last seed block the last_indexed_block is set to ZERO and the data is deleted.

"@snapshot-labs/checkpoint": "^0.1.0-beta.31",

issue

@bonustrack
Copy link
Contributor

@shardAstronaut This is weird, it might have been fixed already. Can you try using a more recent version of Checkpoint? 0.1.0-beta.35 or 0.1.0-beta.36 (this latest version support only Postgres and Checkpoint ORM).

@shardAstronaut
Copy link
Contributor Author

@bonustrack I upgraded the package to beta.36 and I still have the same issue. On the logs I get this error {"error":"RangeError: Maximum call stack size exceeded"}
I'll indexing without seed blocks and see.

@bonustrack
Copy link
Contributor

@shardAstronaut Is your code available on GitHub to check?

shardAstronaut added a commit to 0xSpaceShard/checkpoint that referenced this issue Jun 26, 2024
…xed_block reset to Zero after reaching the seed blocks checkpoint-labs#300)

When indexing contracts with a big number of events the array.push method will throw an error.

When you use spread operator all items of the source array are stored in the stack as arguments list, so having a large number of items (~ > 100K) will cause the this stack size exceed.

The most simple work-around is to manually push all items one by one.
@shardAstronaut
Copy link
Contributor Author

@bonustrack
I pushed the code to this repo https://github.com/shardAstronaut/checkpoint-template
When running the indexer you will get this log error just after the indexer reach the seed blocks.

[1719415002170] DEBUG: handling transaction done
    component: "checkpoint"
    txIndex: 141
[1719415002170] DEBUG: handling transaction
    component: "checkpoint"
    txIndex: 142
[1719415002170] INFO: found contract event
    component: "checkpoint"
    contract: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"
    event: "Transfer"
    handlerFn: "liquity_eth_Transfer"
[1719415002171] DEBUG: handling transaction done
    component: "checkpoint"
    txIndex: 142
[1719415002171] DEBUG: handling transaction
    component: "checkpoint"
    txIndex: 143
[1719415002171] INFO: found contract event
    component: "checkpoint"
    contract: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"
    event: "Transfer"
    handlerFn: "liquity_eth_Transfer"
[1719415002171] INFO: found contract event
    component: "checkpoint"
    contract: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"
    event: "Transfer"
    handlerFn: "liquity_eth_Transfer"
[1719415002173] DEBUG: handling transaction done
    component: "checkpoint"
    txIndex: 143
[1719415002173] DEBUG: handling block done
    component: "checkpoint"
    blockNumber: 250990
[1719415002176] DEBUG: next checkpoint blocks
    component: "checkpoints_store"
    result: []
    block: 250991
    contracts: [
      "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"
    ]
toBlock 251991
toBlock 251991
events 0
addressEvents 336273
----------------Before-------------------
/home/astro/Desktop/checkpoint-template/node_modules/@snapshot-labs/checkpoint/dist/src/providers/starknet/provider.js:257
            events.push(...addressEvents);
                   ^
RangeError: Maximum call stack size exceeded
    at StarknetProvider.getCheckpointsRange (/home/astro/Desktop/checkpoint-template/node_modules/@snapshot-labs/checkpoint/dist/src/providers/starknet/provider.js:257:20)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Checkpoint.preload (/home/astro/Desktop/checkpoint-template/node_modules/@snapshot-labs/checkpoint/dist/src/checkpoint.js:274:33)
    at async Checkpoint.next (/home/astro/Desktop/checkpoint-template/node_modules/@snapshot-labs/checkpoint/dist/src/checkpoint.js:295:40)
    at async Checkpoint.start (/home/astro/Desktop/checkpoint-template/node_modules/@snapshot-labs/checkpoint/dist/src/checkpoint.js:160:16)
    at async run (/home/astro/Desktop/checkpoint-template/src/index.ts:26:3)

The issue is with the array.push method that stores the data in stack which throws Maximum call stack size exceeded
I opened a PR here with a fix #302

shardAstronaut added a commit to 0xSpaceShard/checkpoint that referenced this issue Jun 27, 2024
…xed_block reset to Zero after reaching the seed blocks checkpoint-labs#300)

When indexing contracts with a big number of events the array.push method will throw an error. When you use spread operator all items of the source array are stored in the stack as arguments list, so having a large number of items (~ > 100K) will cause the this stack size exceed. The most simple work-around is to manually push all items one by one.
@Sekhmet
Copy link
Contributor

Sekhmet commented Jun 27, 2024

@shardAstronaut just to confirm, this issue (last_indexed_block is 0) is still there even on latest version with your bug fix applied?

@Sekhmet
Copy link
Contributor

Sekhmet commented Jun 27, 2024

I couldn't reproduce this issue on master with your demo repo:
image

It will pause for a bit as it scans 1000 blocks at the time initially and then jumps to process all those blocks it found related events at (and for high-traffic token like ETH it's pretty much every block).

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

3 participants