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

Factory trace filters #882

Merged
merged 20 commits into from
May 15, 2024
Merged

Factory trace filters #882

merged 20 commits into from
May 15, 2024

Conversation

kyscott18
Copy link
Collaborator

No description provided.

@kyscott18 kyscott18 marked this pull request as ready for review May 14, 2024 21:43
@@ -710,7 +716,74 @@ const getMatchedLogs = async (
logs,
logFilters: [
...service.logFilterSources.map((l) => l.criteria),
...factoryLogFilters,
...factoryLogFilters.filter((f) => f.address.length !== 0),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I actually caught a subtle bug in the getMatchedLogs function here that would cause us to match on every "address" in the case when there were no child addresses in the database.

@kyscott18 kyscott18 requested a review from 0xOlias May 15, 2024 14:17
block: RpcBlock;
transactions: RpcTransaction[];
transactionReceipts: RpcTransactionReceipt[];
traces: SyncCallTrace[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this isn't called RpcCallTrace?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Rpc prefixed types are all from viem

packages/core/src/sync-store/sqlite/store.ts Outdated Show resolved Hide resolved
Comment on lines +1668 to +1674
const logSources = sources.filter(
(s): s is LogSource | FactoryLogSource =>
sourceIsLog(s) || sourceIsFactoryLog(s),
);
const callTraceSources = sources.filter(
(s): s is CallTraceSource | FactoryCallTraceSource =>
sourceIsCallTrace(s) || sourceIsFactoryCallTrace(s),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this makes a lot of sense now

logOrFactorySources.some(
(source) => source.criteria.includeTransactionReceipts,
) ||
logSources.some((source) => source.criteria.includeTransactionReceipts) ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldJoinReceipts will always be true if there is a call trace source, right? Because callTraceSource.includeTransactionReceipts is hard-coded to true?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the includeTransactionReceipts config is still used to skip joins when possible if the user doesn't want the receipt in their indexing function. includeTransactionReceipt is not used when deciding whether or not to fetch transaction receipts in the sync services, because we know that we will always need them and because we always fetch them, we always cache them.

Comment on lines 344 to 345
(service.logFilterSources.length > 0 ||
service.factoryLogSources.length > 0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I'm wrong but I think this is redundant, and we can simply rename positiveBloomFilter to shouldRequestLogs?

@@ -108,9 +110,10 @@ export const create = ({
onFatalError: (error: Error) => void;
}): Service => {
const logFilterSources = sources.filter(sourceIsLog);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be renamed to logSources for consistency?

@kyscott18 kyscott18 merged commit 9b7fa83 into kjs/fn-call May 15, 2024
6 of 8 checks passed
@kyscott18 kyscott18 deleted the kjs/factory-tf branch May 15, 2024 16:47
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

Successfully merging this pull request may close these issues.

None yet

2 participants