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

feat(cross-chain-indexing): enable multiple concurrent plugins #24

Merged
merged 42 commits into from
Jan 17, 2025

Conversation

tk-o
Copy link
Contributor

@tk-o tk-o commented Jan 13, 2025

For example. with this change, it's possible to get a list of all names a given address owns across multiple chains (i.e. base.eth subnames on Base, and linea.eth subnames on Linea.

Example query

query GetOwnedDomains($ownerAddreess: String!) {
  domains(
    where: {OR: [{ownerId: $ownerAddreess}, {wrappedOwnerId: $ownerAddreess}]}
  ) {
    items {
      labelName
      name
      ownerId
      wrappedOwnerId
      createdAt
      expiryDate
    }
  }
}

Preview

Domain names under eth, base.eth, and linea.eth:

untitled (1)


This PR overrides:

Copy link
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

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

@tk-o Super updates 👍 Reviewed and shared feedback 🙌

tk-o and others added 2 commits January 14, 2025 14:05
Apply PR suggestion regarding the in-code documentation

Co-authored-by: lightwalker.eth <[email protected]>
Create an idepotenet function that takes a domain token ID and makes sure there is a database entity created for it.
Copy link
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

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

@tk-o Thanks for updates 👍 Reviewed and shared a few more points of feedback.

tk-o added 6 commits January 14, 2025 15:56
… -m "Had to replace `.onConflictDoNothing()` with `.onConflictDoUpdate({})` as the former would not return a DB entity if there was a conflict. The later would apply the delta on conflict, but since delta is an empty object, there will be no update at all. And yet, the existing DB entity will be always returned."
Declare all plugins active with the default `ACTIVE_PLUGINS` env var.
@lightwalker-eth lightwalker-eth changed the title feat(cross-chain-indexing): enable multiple plugins in one go feat(cross-chain-indexing): enable multiple concurrent plugins Jan 17, 2025
Copy link
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

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

@tk-o Hey nice updates, thanks. Just very minor nitpicks 👍

Co-authored-by: lightwalker.eth <[email protected]>
Copy link
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

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

@tk-o Thanks for updates. I made one last end-to-end review of the PR (rather than just reviewing the incremental changes since a prior review).

Let's do a great job on all the details. Thanks!

export default function () {
// support NameRegisteredWithRecord for BaseRegistrar as it used by Base's RegistrarControllers
ponder.on(pluginNamespace("BaseRegistrar:NameRegisteredWithRecord"), async ({ context, event }) =>
handleNameRegistered({ context, event }),
);

ponder.on(pluginNamespace("BaseRegistrar:NameRegistered"), async ({ context, event }) => {
await upsertAccount(context, event.args.owner);
Copy link
Member

Choose a reason for hiding this comment

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

@tk-o Thanks for the background info.

I'm still not clear here however.

The reason why is because I see the call to handleNameRegistered at the end of this function. My understanding is that handleNameRegistered will perform this upsertAccount to match the subgraph equivalency you linked in your reply above.

So my question is still open: Why are we calling upsertAccount again here?

Copy link
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

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

@tk-o Very close. Getting there 😄 A few more feedbacks.

export default function () {
// support NameRegisteredWithRecord for BaseRegistrar as it used by Base's RegistrarControllers
ponder.on(pluginNamespace("BaseRegistrar:NameRegisteredWithRecord"), async ({ context, event }) =>
handleNameRegistered({ context, event }),
);

ponder.on(pluginNamespace("BaseRegistrar:NameRegistered"), async ({ context, event }) => {
await upsertAccount(context, event.args.owner);
Copy link
Member

Choose a reason for hiding this comment

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

@tk-o This is still an open question for me. Can you please clarify?

Copy link
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

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

@tk-o All now looks good to me 🚀 @shrugs we created a separate follow up question for you here that we can follow up on outside of this PR if you like: #34

@shrugs Please take the lead on reviewing this PR and merging it in when it looks good to you 👍

Copy link
Contributor

@shrugs shrugs left a comment

Choose a reason for hiding this comment

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

LGTM, merging

export default function () {
// support NameRegisteredWithRecord for BaseRegistrar as it used by Base's RegistrarControllers
ponder.on(pluginNamespace("BaseRegistrar:NameRegisteredWithRecord"), async ({ context, event }) =>
handleNameRegistered({ context, event }),
);

ponder.on(pluginNamespace("BaseRegistrar:NameRegistered"), async ({ context, event }) => {
await upsertAccount(context, event.args.owner);
Copy link
Contributor

Choose a reason for hiding this comment

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

correct.

side note: ponder doesn't enforce foreign key constraints in the postgres schema, so technically either order works but we should prefer the order you've suggested here, since domain records should depend on account record existing.

@shrugs shrugs merged commit a2f3ce2 into main Jan 17, 2025
1 of 2 checks passed
@shrugs shrugs deleted the feat/cross-chain-indexing branch January 17, 2025 21:43
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.

3 participants