ponder-sh / ponder

A backend framework for crypto apps
https://ponder.sh
MIT License
592 stars 86 forks source link

[Bug] Inconsistent missing events near tip of chain #974

Closed spennyp closed 1 week ago

spennyp commented 2 months ago

My ponder app seems to be missing events within ~1 week from the tip of the chain. It's inconsistent, sometime it will work, and after some debugging I am able to make it work consistently with a few weird tweaks (changing start block, or commenting out other handlers).

Here is a minimal reproducible example:

// ponder.config.ts

export default createConfig({
  networks: {
    mainnet: { chainId: 1, transport: http(process.env.MAINNET_RPC_URL) },
    base: {
      chainId: base.id,
      transport: 
        rateLimit(http(process.env.BASE_RPC_URL), {
          requestsPerSecond: 12,
        }),
    },
  },
  contracts: {
    NounsToken: {
      abi: NounsTokenAbi,
      address: "0x9c8ff314c9bc7f6e59a9d9225fb22946427edc03",
      network: "mainnet",
      startBlock: 12985438, // REF_A
    },
    NounsErc20Base: {
      abi: erc20Abi,
      address: "0x0a93a7BE7e7e426fC046e204C44d6b03A302b631",
      network: "base",
      startBlock: 17125047,
    },
  },
});
// ./src/handler.ts

ponder.on("NounsToken:Transfer", async ({ event, context }) => {
  console.log("DEBUG", event.args.tokenId);
});

// REF_B
ponder.on("NounsErc20Base:Transfer", async ({ event, context }) => {
  console.log("BASE TRANSFER");
});

With this configuration as is, the NounsToken:Transfer handler misses events from the past ~1 week.

But, I am able to make it pickup these events by making ANY of these changes:

Really strange behavior

mchmatt commented 1 month ago

Had the same happen to me this week, unfortunately I can't reproduce it after redeploying (created new DB and indexer instance, live swapped the old one) I might be able to provide a DB dump (the one where the issue happened), if that's helpful let me know and I'll ask around

mchmatt commented 1 month ago

Are you able to reproduce this w/ 0.5.3? You might have been affected by https://github.com/ponder-sh/ponder/issues/999 like I did; 0.5.3 fixes that

spennyp commented 1 week ago

Sorry for the delay, yes this seems to have solved! Thanks