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

Concurrent indexing fails when indexing both factory and instance events #682

Closed
Destiner opened this issue Mar 1, 2024 · 2 comments
Closed

Comments

@Destiner
Copy link
Contributor

Destiner commented Mar 1, 2024

In some case, it might be useful.

For example, Biconomy Factory initializes new instances with the initial module value. Over time, an instance will emit EnableModule and DisableModule events, changing the module list. In that scenario, it is crucial to get the factory event first and then the instance events.

When trying to setup the indexing logic like that in Ponder, we eventually run into a race condition.

To reproduce, run the indexing for the following Ponder graph: https://github.com/Destiner/ponder-biconomy (might require a few retries).

Eventually, you will run into a race condition:

10:27:29 PM INFO  indexing   Indexed 10 BiconomyAccountFactory 2:AccountCreation events (chainId=80001 block=41619833 logIndex=5)
10:27:30 PM INFO  historical Sync is 89.4% complete with ~48s remaining (contract=BiconomyAccount2)
10:27:30 PM INFO  historical Sync is 89.4% complete with ~48s remaining (contract=BiconomyAccountFactory 2)
10:27:31 PM INFO  indexing   Indexed 1 BiconomyAccountFactory 2:AccountCreation event (chainId=80001 block=41620003 logIndex=1)
10:27:31 PM INFO  indexing   Indexed 13 BiconomyAccountFactory 2:AccountCreation events (chainId=80001 block=41622528 logIndex=12)
10:27:32 PM INFO  indexing   Indexed 15 BiconomyAccountFactory 2:AccountCreation events (chainId=80001 block=41628643 logIndex=11)
Account not found
10:27:32 PM WARN  indexing   Indexing function failed, retrying... (event=BiconomyAccount2:EnabledModule, block=41628643, error=TypeError: Cannot read properties of null (reading 'modules'))

Here's how the issue looks when you run into it locally:

22:35:33 INFO  indexing   Indexed 10 BiconomyAccountFactory 2:AccountCreation events (chainId=80001 block=40457685 logIndex=96)
Account not found
22:35:33 WARN  indexing   Indexing function failed, retrying... (event=BiconomyAccount2:EnabledModule, block=40452969, error=TypeError: Cannot read properties of null (reading 'modules'))
Account not found
22:35:33 WARN  indexing   Indexing function failed, retrying... (event=BiconomyAccount2:EnabledModule, block=40452969, error=TypeError: Cannot read properties of null (reading 'modules'))
Account not found
22:35:33 WARN  indexing   Indexing function failed, retrying... (event=BiconomyAccount2:EnabledModule, block=40452969, error=TypeError: Cannot read properties of null (reading 'modules'))
Account not found
22:35:33 ERROR indexing   Error while processing "BiconomyAccount2:EnabledModule" event at block 40452969:
TypeError: Cannot read properties of null (reading 'modules')
    at /Users/destiner/code/scope/ponder-biconomy/src/biconomyAccount2.ts:16:11
  14 |   await context.db.Account.update({
  15 |     id: getId(event.log.address, context.network.chainId),
> 16 |     data: {
     |           ^
  17 |       modules: [...account!.modules, module],
  18 |     },
  19 |   });
Event args:
  module:  0x000002FbFfedd9B33F4E7156F2DE8D48945E7489
22:35:42 INFO  historical Sync is 88.3% complete with ~46s remaining (contract=BiconomyAccount2)
@0xOlias
Copy link
Collaborator

0xOlias commented Mar 1, 2024

Hi, thanks for opening. I was able to reproduce this on 0.2.10, but it looks like we fixed the bug that caused this in 0.2.11 yesterday. Not able to reproduce the error on 0.2.13 just now after many attempts.

Let me know if you are still seeing the issue on 0.2.13.

@Destiner
Copy link
Contributor Author

Destiner commented Mar 2, 2024

Tested on 0.2.14 and couldn't reproduce as well.

@Destiner Destiner closed this as completed Mar 2, 2024
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

2 participants