Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ export const buildOptions = {
'process.env.NODE_ENV': `"${process.env.NODE_ENV ?? 'production'}"`,
'process.env.APP_NAME': `'${pkg.name}'`,
'process.env.APP_VERSION': `'${pkg.version}'`,
'process.env.GIT_REVISION': `'${rev}'`
'process.env.GIT_REVISION': `'${rev}'`,
'process.env.DEBUG': 'undefined'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Workaround while waiting for this to be released ethereumjs/ethereumjs-monorepo#4265

},
entryPoints: [
'src/index.tsx',
Expand Down
39 changes: 39 additions & 0 deletions debug-ens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* eslint-disable no-console */
import { resolveEthDnsLink } from './src/sw/lib/ens-resolver.ts'

async function main (): Promise<void> {
const name = process.argv[2] ?? 'vitalik.eth'

const startedAt = Date.now()

console.log(`[debug:ens] resolving ${name}`)

try {
const result = await resolveEthDnsLink(name)
const elapsedMs = Date.now() - startedAt

console.log('[debug:ens] success')
console.log(`[debug:ens] dnsLinkPath=${result.dnsLinkPath}`)
console.log(`[debug:ens] blockNumber=${result.blockNumber}`)
console.log(`[debug:ens] blockHash=${result.blockHash}`)
console.log(`[debug:ens] elapsedMs=${elapsedMs}`)
} catch (err) {
const elapsedMs = Date.now() - startedAt
console.error('[debug:ens] failure')
console.error(`[debug:ens] elapsedMs=${elapsedMs}`)

if (err instanceof Error) {
console.error(`[debug:ens] name=${err.name}`)
console.error(`[debug:ens] message=${err.message}`)
if (err.stack != null) {
console.error(err.stack)
}
} else {
console.error(String(err))
}

process.exitCode = 1
}
}

await main()
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"build": "node --experimental-strip-types build.js && go build -o service-worker-gateway main.go",
"build:test": "cross-env NODE_ENV=test npm run build",
"start": "cross-env NODE_ENV=development node --experimental-strip-types ./serve.ts --load-fixtures --watch",
"debug:ens": "cross-env NODE_ENV=development node --experimental-strip-types ./debug-ens.ts",
"test": "cross-env NODE_ENV=test aegir test -- --experimental-strip-types",
"test:chrome": "npm run build:test && playwright test -c playwright.config.js --project chromium",
"test:firefox": "npm run build:test && playwright test -c playwright.config.js --project firefox no-service-worker",
Expand Down Expand Up @@ -41,11 +42,13 @@
"@chainsafe/is-ip": "^2.1.0",
"@chainsafe/libp2p-noise": "^17.0.0",
"@chainsafe/libp2p-yamux": "^8.0.1",
"@ensdomains/ensjs": "^4.2.2",
"@helia/block-brokers": "^5.2.1",
"@helia/delegated-routing-v1-http-api-client": "^6.0.1",
"@helia/routers": "^5.1.0",
"@helia/utils": "^2.5.0",
"@helia/verified-fetch": "^7.2.11",
"@ipshipyard/verified-eth-provider": "github:ipshipyard/verified-eth-provider#f12ce4f877467df59bb3348d27e5c14b07c7f7c9",
"@ipld/dag-cbor": "^9.2.5",
"@ipld/dag-json": "^10.2.5",
"@ipld/dag-pb": "^4.1.5",
Expand Down Expand Up @@ -76,6 +79,7 @@
"react-router-dom": "^7.9.5",
"tachyons": "^4.12.0",
"uint8arrays": "^5.1.0",
"viem": "^2.48.4",
"weald": "^1.1.1"
},
"devDependencies": {
Expand Down
10 changes: 9 additions & 1 deletion src/config/index-development.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,13 @@ export const config: Config = {
},
fetchTimeout: 30_000,
serviceWorkerTTL: 86_400_000,
debug: '*,*:trace'
debug: '*,*:trace',
ens: {
primaryRpc: 'https://ethereum.publicnode.com',
witnessRpcs: [
'https://eth-mainnet.public.blastapi.io',
'https://mainnet.gateway.tenderly.co'
],
maxSafeBlockAgeMs: 20 * 60 * 1_000
}
}
11 changes: 10 additions & 1 deletion src/config/index-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,14 @@ export const config: Config = {
},
fetchTimeout: 1_000,
serviceWorkerTTL: 86_400_000,
debug: '*,*:trace'
debug: '*,*:trace',
ens: {
// Pointed at the local test fixture server
primaryRpc: 'http://127.0.0.1:3336',
witnessRpcs: [
'http://127.0.0.1:3337',
'http://127.0.0.1:3338'
],
maxSafeBlockAgeMs: 60 * 60 * 24 * 365 * 1_000 // never stale in tests
}
}
32 changes: 31 additions & 1 deletion src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
export interface EnsConfig {
/**
* Primary Ethereum RPC endpoint. Must support eth_getProof and
* eth_getBlockByNumber.
*/
primaryRpc: string
/**
* Two witness Ethereum RPC endpoints used to independently verify the safe
* block returned by the primary. Only eth_getBlockByNumber is required.
*/
witnessRpcs: [string, string]
/**
* Maximum age in milliseconds for the safe block timestamp before we
* consider it stale and reject the lookup.
*/
maxSafeBlockAgeMs: number
}

export interface Config {
gateways: string[]
routers: string[]
dnsResolvers: Record<string, string | string[]>
fetchTimeout: number
serviceWorkerTTL: number
debug: string
ens: EnsConfig
}

/**
Expand All @@ -22,5 +41,16 @@ export const config: Config = {
},
fetchTimeout: 30_000,
serviceWorkerTTL: 86_400_000,
debug: globalThis?.location?.hostname?.search(/localhost|inbrowser\.dev|127\.0\.0\.1/) === -1 ? '' : '*,*:trace'
debug: globalThis?.location?.hostname?.search(/localhost|inbrowser\.dev|127\.0\.0\.1/) === -1 ? '' : '*,*:trace',
ens: {
// Primary endpoint for safe block and proof-backed ENS reads
primaryRpc: 'https://ethereum.publicnode.com',
// Two independent witness providers for block-hash verification
witnessRpcs: [
'https://eth-mainnet.public.blastapi.io',
'https://mainnet.gateway.tenderly.co'
],
// Reject safe-head older than 5 minutes
maxSafeBlockAgeMs: 20 * 60 * 1_000
}
}
Loading
Loading