-
Notifications
You must be signed in to change notification settings - Fork 102
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
in-memory child address tracking #1092
Conversation
* extract realtime data concurrently * cleanup * nits * more accurate matched filters * cleanup
* remove extra config * ready * sqlite database * postgres database * fix test type errors * fix tests * remove stale tests * cleanup db * schema => table_names * start docs * some docs * cleanup * database migration * remove maxHealthcheckDuration docs * create schema if not exists * drop finalized rows from reorg tables * fix docs link * nits * merge * use json operators
* remove maxBlockRange * cleanup * add isSuggested property to getLogsRetryRanges return * merge * dynamically increaing log ranges * remove maxBlockRange docs * fix test * nits * cleanup * nits * more cleanup * chore: changeset * chore: changeset
* build log events in memory * order events by checkpoint * . * realtime indexing cache * wip multichain * more work * start multichain tests * merge async generators * lol * typesafe * omnichain * prune rpc request by block * start * fix tests * cleanup * ponder_realtime_is_connected metric * status * fix accuracy of historical to realtime handoff * better generator * nits * skip refetching finalized blocks for completed networks * revert * ignore
* add debug log to sync * new sync duration metric + update tui * sum all sync metrics per network * protects against extraneous logs being thrown * chain specific metrics * cleanup * deprecate old sync metrics * fix historical metrics and tui * fix test * last refactor ever * changeset --------- Co-authored-by: typedarray <[email protected]>
@@ -624,7 +628,7 @@ export const createRealtimeSync = ( | |||
|
|||
// New block is exactly one block ahead of the local chain. | |||
// Attempt to ingest it. | |||
await handleBlock({ block, ...rest }); | |||
handleBlock({ block, ...rest }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy path worker for the realtime queue (bottleneck for handling a new block) is now synchronous
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Business logic looks good to me!
"address" in filter && | ||
isAddressFactory(filter.address) | ||
) { | ||
const addresses = await args.syncStore.getChildAddresses({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to use Promise.all
here?
: factory.childAddressLocation === "topic2" | ||
? 2 | ||
: 3; | ||
log.topics; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo?
Looks good to me, but while we're here I think it's worthwhile to add a couple unit tests for this, e.g. around casing
? finalizedChildAddresses.get(filter.address)!.has(log.address) || | ||
unfinalizedChildAddresses.get(filter.address)!.has(log.address) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we certain that the casing is consistent when doing these comparisons?
localChain = localChain.filter( | ||
(lb) => | ||
hexToNumber(lb.number) > hexToNumber(pendingFinalizedBlock.number), | ||
); | ||
|
||
// add child address from newly finalized blocks to `finalizedChildAddresses` | ||
for (const filter of factories) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, but I'd find this more readable if the factories
loop came after the if (factoryLogs !== undefined)
check
|
||
for (const filter of factories) { | ||
unfinalizedChildAddresses.set(filter, new Set()); | ||
for (const { hash } of localChain) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should rename localChain
to unfinalizedBlocks
// delete reorged blocks from `factoryLogsPerBlock` | ||
for (const { hash } of reorgedBlocks) { | ||
factoryLogsPerBlock.delete(hash); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this happen before we recompute unfinalizedChildAddresses
? It shouldn't matter, just double checking.
Closes #1091
getChildAddress
Realtime child address reorg handling strategy:
unfinalizedChildAddresses
andfinalizedChildAddresses
factoryLogsPerBlock
, so thatunfinalizedChildAddresses
can always be recomputedfactoryLogsPerBlock
and recomputeunfinalizedChildAddresses
finalizedChildAddresses
, evict finalized blocks fromfactoryLogsPerBlock
and recomputeunfinalizedChildAddresses