Closed timolegros closed 3 weeks ago
SubQuery is an indexing system built in Typescript that supports 208+ networks (any EVM chain, most Substrate chains, and most Cosmos chains). In SubQuery you create mapping functions at the block, transaction, or log level to populate a database with a fully customizable schema defined in GraphQL. SubQuery pairs a Postgres database with a PostGraphile server which enables running GraphQL queries over Postgres data. SubQuery supports real-time indexing via 'unfinalized blocks' and real-time client updates via GraphQL subscriptions.
Existing
/communities/:community_id
Communities.namespace
and Communities.namespace_address
respectively.Change
Communities.namespace_created_at
timestamp column and a Communities.namespace_finalized
boolean columnnamespace_finalized
is false and not null AND namespace_created_at
is less than X hours/days in the past when querying a community (or schedule a cron job to execute in X hours/minutes via graphile-worker on namespace creation), query SubQuery NamespaceDeployed events to find a finalized (X confirmations) transaction with a matching namespace.namespace_created_at
is older than X hours/days ago, clear Communities.namespace
, Communities.namespace_address
and Communities.namespace_finalized
.Existing
/communityStakes/:community_id/:stake_id
Communities.namespace_address
and stake_id
CommunityStakes
record in the databaseChange TBD
Existing
StakeTransactions
table via CE v2community.getStakeTransaction
(v1 tRPC API) to get transaction historyChange
StakeTransactions
table and community.getStakeTransaction
routeExisting
contest.createContestMetadata
ContestManagers
recordContestTopics
recordsChange
namespace
is a property in the new model.ContestManagers
tableContestTopics
then delete the ContestTopics
record since the contest no longer exists -> eventually consistent (this can also be done from the API - TBD)Existing
Contests
ContestActions
Change
Contests
projection with an equivalent model in SubQuery that is created from the ContestStarted
event
score
column is TBD. Could include a combination of other indexed data. Reference: updateScore
functionContestActions
projection with an equivalent model in SubQuery that is created from the ContestContentAdded
or ContestContentUpvoted
eventsExisting
Change
Bumping to reflect the amount of time this ticket really took. Creating the MVP took longer than anticipated since the MVP initially did not work due to caveats like:
While it may seem like a long time for a spike, using SubQuery would be a significant shift in how we interact with chain data so it warranted a deeper investigation to discover the caveats/underlying issues before diving into the deep end.
We will not use SubQuery or its managed service until https://github.com/subquery/subql/issues/2493 and a follow-up ticket for unfinalized blocks in multichain projects are complete since the list of chains we need to index is growing and costs (both in the managed service and development) for separate SubQuery projects would become unsustainable.
Thanks for the research, Tim! I'll close this ticket as completed. Let's follow up once the subquery updates land.
Description
Notes
Additional context