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(ponder-ens): introduce plugin architecture #3

Merged
merged 31 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
dcc37b3
feat(ponder-ens): introduce plugin architecture
tk-o Dec 31, 2024
a5bfb00
feat(ponder-ens-plugin): update abis and contract configs
tk-o Jan 3, 2025
2578b0f
fix(ens-base-plugin): enalbe domain insert setup event
tk-o Jan 3, 2025
fae9508
feat(ponder-ens-plugin): include early adopter registrar contract
tk-o Jan 3, 2025
e1dad39
feat(ponder-ens-plugin): focus plugins around domain names
tk-o Jan 3, 2025
1931ec7
checkpoint: pull shared logic for registry and resolvers into shared …
shrugs Jan 3, 2025
3d181f9
feat: refactor plugin logic, DRY handler code
shrugs Jan 3, 2025
2d079a7
chore: inline some addreses
shrugs Jan 3, 2025
32912d5
refactor: DRY up registrar code
shrugs Jan 3, 2025
7f84cff
Merge pull request #4 from namehash/refactor/plugin-logic
shrugs Jan 3, 2025
a88933e
feat(ponder-ens-plugin): use domain name path as a namespace
tk-o Jan 3, 2025
7e5af0e
chore(ponder-ens-plugin): use biomejs formatter
tk-o Jan 3, 2025
cd152a6
fix: tidy registrar handlers
shrugs Jan 3, 2025
dc0bfdd
fix: handle preminted domain in base node
shrugs Jan 4, 2025
77c1ec2
fix(base.eth): handle `NameRegisteredWithRecord` event
tk-o Jan 4, 2025
ff0b2af
fix(deps): update ponder version
tk-o Jan 5, 2025
b3c17e5
fix: use selected root domain name
tk-o Jan 5, 2025
0e35dd8
refactor: rename consts to apply feedback
tk-o Jan 6, 2025
e5d7541
docs(base.eth): update readme
tk-o Jan 6, 2025
067f570
refactor(ponder-plugins): simplify architecture
tk-o Jan 7, 2025
e3b62c0
refactor(ponder-plugins): use `managed subname` term
tk-o Jan 7, 2025
aad651c
refactor(ponder-plugins): make generic handlers to use ponder types
tk-o Jan 7, 2025
00c9935
chore(code-style): apply `biome format --fix`
tk-o Jan 8, 2025
a39200f
fix(ci): run static analysis
tk-o Jan 8, 2025
9eb9eef
refactor(plugins): rename plugins directory
tk-o Jan 8, 2025
728ec62
refactor(plugins): rename plugin helpers
tk-o Jan 8, 2025
7c4bc1e
refactor(plugins): rename plugin helpers file
tk-o Jan 8, 2025
9891ed0
refactor(plugins): rename ponder plugins to just plugins
tk-o Jan 8, 2025
7b81161
refactor(plugins): drop the ACTIVE_PLUGIN env var parser
tk-o Jan 8, 2025
1dbe2a9
refactor(plugins): use `ownedSubname` name
tk-o Jan 8, 2025
cc6f2c3
refactor(plugins): rename `ownedSubname` to `ownedName`
tk-o Jan 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# RPC urls, follow the format RPC_URL_{chainId}={rpcUrl}

PONDER_RPC_URL_1=https://ethereum-rpc.publicnode.com
PONDER_RPC_URL_8453=https://base-rpc.publicnode.com
PONDER_RPC_URL_59144=https://linea-rpc.publicnode.com

# ponder indexer ens deployment configuration
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# ponder indexer ens deployment configuration
# Identify which ENS indexer plugin to activate.

Can we please add more docs here? For example? Does this value always need to be a single value, or can it be multiple values? If it can be multiple values, how to format it? It can also be nice to document which values are supported here or perhaps in the overall README.md.

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 feedback


INDEX_SUBNAME=base.eth

# ponder indexer database configuration

## one schema name per chain ID, i.e. ponder_ens_${INDEX_SUBNAME}
DATABASE_SCHEMA=ponder_ens_base.eth
Copy link
Member

Choose a reason for hiding this comment

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

Can you please document more details about how this DATABASE_SCHEMA should be set? Please also explain how this value might relate to the INDEX_SUBNAMES environment variable.

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 remains an open feedback item.

I'm also concerned to read "chain id" here. I'm very worried we're getting key ideas confused. In my understanding, "chain id" should not be THE key consideration in our configurations. The INDEX_SUBNAME should be THE number 1 consideration, and then everything else should flow downstream from that.

For example, the chain to index is determined by the subnames to be indexed. Not the other way around.

DATABASE_URL=postgresql://dbuser:abcd1234@localhost:5432/my_database
31 changes: 31 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Static Analysis
Copy link
Member

Choose a reason for hiding this comment

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

Great to see this!


on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
biome-ci:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install pnpm
run: npm install -g pnpm

- name: Install dependencies
run: pnpm install

- name: Run Biome CI
run: pnpm biome ci
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ various resources use both null and zeroAddress to indicate emptiness, this is h

### ens indexing plugin

l2 ens deployments are very similar — write plugin to make configuring source addresses easy and pass node that domains in these handlers are implicitly parented to (assuming that l2 deployments make nodes against the NAMEHASH_ZERO i.e. every name is basically a 2LD)
l2 ens deployments are very similar — write plugin to make configuring source addresses easy and pass node that domains in these handlers are implicitly parented to (assuming that l2 deployments make nodes against the ROOT_NODE i.e. every name is basically a 2LD)

### registry

Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"files": {
"ignoreUnknown": false,
"ignore": []
"ignore": [".ponder", "generated"]
},
"formatter": {
"enabled": true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"dependencies": {
"hono": "^4.6.14",
"ponder": "^0.8.8",
"ponder": "^0.8.17",
"viem": "^2.21.57"
},
"devDependencies": {
Expand Down
30 changes: 15 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

123 changes: 27 additions & 96 deletions ponder.config.ts
Original file line number Diff line number Diff line change
@@ -1,98 +1,29 @@
import { createConfig, factory, mergeAbis } from "ponder";
import { http, getAbiItem } from "viem";
import { INDEXED_SUBNAME } from "./src/lib/ens-helpers";
import {
activate as activateEthBase,
config as ethBaseConfig,
managedSubname as ethBaseManagedSubname,
} from "./src/ponder-ens-plugins/eth.base/ponder.config";
import {
activate as activateEth,
config as ethConfig,
managedSubname as ethManagedSubname,
} from "./src/ponder-ens-plugins/eth/ponder.config";

import { BaseRegistrar } from "./abis/BaseRegistrar";
import { EthRegistrarController } from "./abis/EthRegistrarController";
import { EthRegistrarControllerOld } from "./abis/EthRegistrarControllerOld";
import { LegacyPublicResolver } from "./abis/LegacyPublicResolver";
import { NameWrapper } from "./abis/NameWrapper";
import { Registry } from "./abis/Registry";
import { Resolver } from "./abis/Resolver";
type AllConfigs = typeof ethConfig & typeof ethBaseConfig;

// just for testing...
const END_BLOCK = 12_000_000;

const RESOLVER_ABI = mergeAbis([LegacyPublicResolver, Resolver]);

const REGISTRY_OLD_ADDRESS = "0x314159265dd8dbb310642f98f50c066173c1259b";
const REGISTRY_ADDRESS = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";

const BASE_REGISTRAR_ADDRESS = "0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85";
const ETH_REGISTRAR_CONTROLLER_OLD_ADDRESS = "0x283Af0B28c62C092C9727F1Ee09c02CA627EB7F5";
const ETH_REGISTRAR_CONTROLLER_ADDRESS = "0x253553366Da8546fC250F225fe3d25d0C782303b";
const NAME_WRAPPER_ADDRESS = "0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401";

export default createConfig({
networks: {
mainnet: {
chainId: 1,
transport: http(process.env.PONDER_RPC_URL_1),
},
},
contracts: {
RegistryOld: {
network: "mainnet",
abi: Registry,
address: REGISTRY_OLD_ADDRESS,
startBlock: 3327417,
endBlock: END_BLOCK,
},
Registry: {
network: "mainnet",
abi: Registry,
address: REGISTRY_ADDRESS,
startBlock: 9380380,
endBlock: END_BLOCK,
},
OldRegistryResolvers: {
network: "mainnet",
abi: RESOLVER_ABI,
address: factory({
address: REGISTRY_OLD_ADDRESS,
event: getAbiItem({ abi: Registry, name: "NewResolver" }),
parameter: "resolver",
}),
startBlock: 9380380,
endBlock: END_BLOCK,
},
Resolver: {
network: "mainnet",
abi: RESOLVER_ABI,
address: factory({
address: REGISTRY_ADDRESS,
event: getAbiItem({ abi: Registry, name: "NewResolver" }),
parameter: "resolver",
}),
startBlock: 9380380,
endBlock: END_BLOCK,
},
BaseRegistrar: {
network: "mainnet",
abi: BaseRegistrar,
address: BASE_REGISTRAR_ADDRESS,
startBlock: 9380410,
endBlock: END_BLOCK,
},
EthRegistrarControllerOld: {
network: "mainnet",
abi: EthRegistrarControllerOld,
address: ETH_REGISTRAR_CONTROLLER_OLD_ADDRESS,
startBlock: 9380471,
endBlock: END_BLOCK,
},
EthRegistrarController: {
network: "mainnet",
abi: EthRegistrarController,
address: ETH_REGISTRAR_CONTROLLER_ADDRESS,
startBlock: Math.min(16925618, END_BLOCK),
endBlock: END_BLOCK,
},
NameWrapper: {
network: "mainnet",
abi: NameWrapper,
address: NAME_WRAPPER_ADDRESS,
startBlock: Math.min(16925608, END_BLOCK),
endBlock: END_BLOCK,
},
},
});
// here we export only a single 'plugin's config, by type it as every config
// this makes all of the mapping types happy at typecheck-time, but only the relevant
// config is run at runtime
export default ((): AllConfigs => {
switch (INDEXED_SUBNAME) {
case ethManagedSubname:
activateEth();
return ethConfig as AllConfigs;
case ethBaseManagedSubname:
activateEthBase();
return ethBaseConfig as AllConfigs;
default:
throw new Error(`Unsupported base name: ${INDEXED_SUBNAME}`);
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
throw new Error(`Unsupported base name: ${INDEXED_SUBNAME}`);
throw new Error(`Unsupported INDEXED_SUBNAME: ${INDEXED_SUBNAME}`);

})();
Loading
Loading