Concurrent indexing fails when indexing both factory and instance events
Destiner opened this issue · comments
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)
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
.
Tested on 0.2.14
and couldn't reproduce as well.