-
Notifications
You must be signed in to change notification settings - Fork 8
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
Query Wildcard events concurrently with static events #409
base: main
Are you sure you want to change the base?
Conversation
…istering wildcard event
| Normal({ | ||
contractAddressMapping: ContractAddressingMap.mapping, | ||
//Used to prune dynamic contract registrations in the event | ||
//of a rollback. | ||
dynamicContracts: array<TablesStatic.DynamicContractRegistry.t>, | ||
}) |
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.
In the future, to support topic filtering for rpc, we'll need to have a partition per event.
switch (p, target) { | ||
| ({kind: Wildcard}, _) | ||
| (_, {kind: Wildcard}) => (p, Some(target)) | ||
| ( | ||
{ | ||
kind: Normal({ | ||
contractAddressMapping: mergingContractAddressMapping, | ||
dynamicContracts: mergingDynamicContracts, | ||
}), | ||
}, | ||
{ | ||
kind: Normal({ | ||
contractAddressMapping: targetContractAddressMapping, | ||
dynamicContracts: targetDynamicContracts, | ||
}), | ||
}, | ||
) => { |
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.
The code is the same as before, it only skips merging for Wildcard partitions
type queryTarget = | ||
| Head | ||
| EndBlock({toBlock: int}) | ||
| Merge({ | ||
// The partition we are going to merge into | ||
// It shouldn't be fetching during the query | ||
intoPartitionId: string, | ||
toBlock: int, | ||
}) | ||
|
||
// Strip internal fields from partition kind like dynamicContracts | ||
type querySelection = | ||
| Wildcard | ||
| Normal({contractAddressMapping: ContractAddressingMap.mapping}) | ||
|
||
type mergeQuery = { | ||
// The catching up partition | ||
type query = { | ||
partitionId: string, | ||
// The partition we are going to merge into | ||
// It shouldn't be fetching during the query | ||
intoPartitionId: string, | ||
fromBlock: int, | ||
toBlock: int, | ||
contractAddressMapping: ContractAddressingMap.mapping, | ||
} | ||
|
||
type query = | ||
| PartitionQuery(partitionQuery) | ||
| MergeQuery(mergeQuery) | ||
|
||
let queryFromBlock = query => { | ||
switch query { | ||
| PartitionQuery({fromBlock}) => fromBlock | ||
| MergeQuery({fromBlock}) => fromBlock | ||
} | ||
} | ||
|
||
let queryPartitionId = query => { | ||
switch query { | ||
| PartitionQuery({partitionId}) => partitionId | ||
| MergeQuery({partitionId}) => partitionId | ||
} | ||
selection: querySelection, | ||
target: queryTarget, |
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.
Change to make it easier to work according to the suggestion #405 (comment)
Even though the change looks scary, these are mostly test updates. What's going on:
Besides the partitions refactoring done in the previous release, the mane challenge of the PR is to make sure, that we always create partitions with the correct initial addresses (you can see it in the ChainFetcher logic). Now, a normal partition without addresses shouldn't be possible, so we throw an error on FetchState creation.