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

FET-1573 pagination issue #193

Merged
merged 37 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b8a3946
FET-1573 fix pagination
SagiSan Aug 13, 2024
583d437
fix lint
SagiSan Aug 13, 2024
317451a
add nvmrc
SagiSan Aug 19, 2024
d84ee2c
FET-1573 fix desc query
SagiSan Sep 3, 2024
fe8e49c
first commit
storywithoutend Aug 19, 2024
9f03f25
fix bugs with concurrent registration
storywithoutend Sep 11, 2024
e848364
FET-1573 tests
SagiSan Sep 19, 2024
2a84283
add sample and tests for concurrent name generation
storywithoutend Sep 19, 2024
5d73c07
FET-1573 expiry subname not working
SagiSan Sep 23, 2024
c587ad9
pushed example with same expiry dates
storywithoutend Sep 23, 2024
8321b4f
FET-1573 inconsistent results
SagiSan Sep 25, 2024
553a940
fix filters for expiryDate and createdAt for getNamesForAddress and g…
storywithoutend Oct 11, 2024
e66d8d8
log out an error in ci
storywithoutend Oct 11, 2024
17783fb
Merge branch 'main' into FET-1573_pagination_issue
storywithoutend Oct 14, 2024
974bd00
fix unit test snapshots
storywithoutend Oct 14, 2024
f63e4a4
add dependencies to delete names deploy script
storywithoutend Oct 14, 2024
12e2714
clean up sonar cloud issues
storywithoutend Oct 14, 2024
857c47f
add extra logging to debug ci
storywithoutend Oct 14, 2024
2c4f4ee
remove verbosity from test script
storywithoutend Oct 14, 2024
650c3ba
increase timeout in ens-test-env for running subgraph
storywithoutend Oct 14, 2024
cde53af
increase timeout before graph loads
storywithoutend Oct 14, 2024
83e27c8
increase even more
storywithoutend Oct 14, 2024
13179f2
add timeout after deploy script finishes
storywithoutend Oct 15, 2024
f401985
ens-test-env stops when error is thrown in script
storywithoutend Oct 15, 2024
764501a
testing delayed deploy
storywithoutend Oct 15, 2024
b85c4cb
fetch latest block number from rpc
storywithoutend Oct 16, 2024
9446cbe
refactor timing of docker container launches and subgraph sync
storywithoutend Oct 16, 2024
5604d70
add log of latest block number
storywithoutend Oct 16, 2024
87d560c
more cleanup
storywithoutend Oct 16, 2024
a101c97
add release.yml
storywithoutend Nov 4, 2024
f51d235
Update release.yml
storywithoutend Nov 4, 2024
b3d0520
v4.0.2-alpha.4
github-actions[bot] Nov 4, 2024
854aebb
Update release.yml
storywithoutend Nov 4, 2024
0c95002
v4.0.2-alpha.5
github-actions[bot] Nov 4, 2024
cf54da1
update sepolia and holesky eth controller, public resolver and revers…
storywithoutend Nov 10, 2024
3b7d947
revert version number
storywithoutend Nov 10, 2024
f8c39e9
Merge branch 'main' into FET-1573_pagination_issue
storywithoutend Nov 10, 2024
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
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.18.2
97 changes: 57 additions & 40 deletions packages/ens-test-env/src/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ const awaitCommand = async (name, command) => {
deploy.stdout.pipe(outPrepender).pipe(process.stdout)
}
deploy.stderr.pipe(errPrepender).pipe(process.stderr)
deploy.stderr.on('data', cleanup.bind(null, { exit: true }))
return new Promise((resolve) => deploy.on('exit', () => resolve()))
}

Expand Down Expand Up @@ -188,6 +189,7 @@ export const main = async (_config, _options, justKill) => {
const compose = await getCompose()

try {
console.log('Starting anvil...')
await compose.upOne('anvil', opts)
} catch (e) {
console.error('e: ', e)
Expand Down Expand Up @@ -279,11 +281,62 @@ export const main = async (_config, _options, justKill) => {

if (options.graph) {
try {
console.log('Starting graph-node...')
await compose.upOne('graph-node', opts)

await waitOn({ resources: ['http://localhost:8040'] })

const latestBlock = await rpcFetch('eth_getBlockByNumber', ['latest', false])
const latestBlockNumber = parseInt(latestBlock.result.number, 16)
if (Number.isNaN(latestBlockNumber)) {
console.error('Failed to fetch latest block number')
return cleanup(undefined, 0)
}
console.log('latest block number:', latestBlockNumber)

let indexArray = []
const getCurrentIndex = async () =>
fetch('http://localhost:8000/subgraphs/name/graphprotocol/ens', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: `
{
_meta {
block {
number
}
}
}
`,
variables: {},
}),
})
.then((res) => res.json())
.then((res) => {
if (res.errors) return 0
return res.data._meta.block.number
})
.catch(() => 0)
do {
const index = await getCurrentIndex()
console.log('subgraph index:', index)
indexArray.push(await getCurrentIndex())
if (indexArray.length > 10) indexArray.shift()
await new Promise((resolve) => setTimeout(resolve, 1000))
if (indexArray.every((i) => i === indexArray[0]) && indexArray.length === 10) {
console.error('Subgraph failed to launch properly')
return cleanup(undefined, 0)
}
} while (
indexArray[indexArray.length - 1] < latestBlockNumber
)
console.log('Starting remaining docker containers...')
await compose.upAll(opts)
} catch {}

await waitOn({ resources: ['http://localhost:8040'] })

if (options.save) {
const internalHashes = [
{
Expand Down Expand Up @@ -336,48 +389,12 @@ export const main = async (_config, _options, justKill) => {
'http-get://localhost:8000/subgraphs/name/graphprotocol/ens',
],
})
await new Promise((resolve) => setTimeout(resolve, 100))
}
}

await new Promise((resolve) => setTimeout(resolve, 100))

if (!options.save && cmdsToRun.length > 0 && options.scripts) {
if (options.graph) {
let indexArray = []
const getCurrentIndex = async () =>
fetch('http://localhost:8000/subgraphs/name/graphprotocol/ens', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: `
{
_meta {
block {
number
}
}
}
`,
variables: {},
}),
})
.then((res) => res.json())
.then((res) => {
if (res.errors) return 0
return res.data._meta.block.number
})
.catch(() => 0)
do {
indexArray.push(await getCurrentIndex())
if (indexArray.length > 10) indexArray.shift()
await new Promise((resolve) => setTimeout(resolve, 100))
} while (
!indexArray.every((i) => i === indexArray[0]) ||
indexArray.length < 2 ||
indexArray[0] === 0
)
}
/**
* @type {import('concurrently').ConcurrentlyResult['result']}
**/
Expand Down
221 changes: 221 additions & 0 deletions packages/ensjs/deploy/00_register_concurrently.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable no-await-in-loop */
// eslint-disable-next-line @typescript-eslint/naming-convention
const { BigNumber } = require('ethers')
const { ethers } = require('hardhat')
const {
makeNameGenerator: makeWrappedNameGenerator,
} = require('../utils/wrappedNameGenerator.cjs')
const {
makeNameGenerator: makeLegacyNameGenerator,
} = require('../utils/legacyNameGenerator.cjs')
const { makeNonceManager } = require('../utils/nonceManager.cjs')
const { encodeFuses } = require('../dist/cjs/utils/fuses')
const { MAX_DATE_INT } = require('../dist/cjs/utils/consts')

const DURATION = 31556000

/**
* @type {{
* label: string
* namedOwner: string
* namedAddr?: string
* type: 'wrapped' | 'legacy'
* data?: any[]
* reverseRecord?: boolean
* fuses?: number
* subnames?: {
* label: string
* namedOwner: string
* fuses?: number
* expiry?: number
* }[]
* duration?: number | BigNumber
* }[]}
*/

const names = [
...Array.from({ length: 2 }, (_, index) => ({
label: `concurrent-legacy-name-${index}`,
type: 'legacy',
namedOwner: 'owner4',
reverseRecord: true,
duration: DURATION,
})),
...Array.from({ length: 2 }, (_, index) => ({
label: `concurrent-wrapped-name-${index}`,
type: 'wrapped',
namedOwner: 'owner4',
fuses: encodeFuses({
input: {
child: {
named: ['CANNOT_UNWRAP'],
},
},
}),
duration: DURATION,
subnames: [
{
label: `xyz`,
namedOwner: 'owner4',
type: 'wrapped',
expiry: MAX_DATE_INT,
fuses: encodeFuses({
input: {
parent: {
named: ['PARENT_CANNOT_CONTROL'],
},
child: {
named: ['CANNOT_UNWRAP'],
},
},
}),
},
],
})),
]

/**
* @type {import('hardhat-deploy/types').DeployFunction}
*/
const func = async function (hre) {
const { network } = hre

const nonceManager = await makeNonceManager(hre)
const wrappedNameGenerator = await makeWrappedNameGenerator(hre, nonceManager)
const legacyNameGenerator = await makeLegacyNameGenerator(hre, nonceManager)

await network.provider.send('evm_setAutomine', [false])

// Commit
const commitTxs = await Promise.all(
names.map(
({
label,
type,
namedOwner,
namedAddr = namedOwner,
data = [],
reverseRecord = false,
fuses = 0,
duration = 31536000,
}) => {
console.log(`Committing commitment for ${label}.eth...`)
if (type === 'legacy')
return legacyNameGenerator.commit({
label,
namedOwner,
namedAddr,
})
return wrappedNameGenerator.commit({
label,
namedOwner,
data,
reverseRecord,
fuses,
duration,
})
},
),
)

network.provider.send('evm_mine')
await Promise.all(
commitTxs.map(async (tx) => {
return tx.wait()
}),
)

const oldTimestamp = (await ethers.provider.getBlock('latest')).timestamp
await network.provider.send('evm_setNextBlockTimestamp', [oldTimestamp + 60])
await network.provider.send('evm_increaseTime', [300])
await network.provider.send('evm_mine')

// Register
const registerTxs = await Promise.all(
names.map(
({
label,
type,
namedOwner,
namedAddr = namedOwner,
data = [],
reverseRecord = false,
fuses = 0,
duration = 31536000,
}) => {
if (type === 'legacy')
return legacyNameGenerator.register({
label,
namedOwner,
namedAddr,
duration,
})
return wrappedNameGenerator.register({
label,
namedOwner,
data,
reverseRecord,
fuses,
duration,
})
},
),
)

await network.provider.send('evm_mine')
await Promise.all(
registerTxs.map(async (tx) => {
return tx.wait()
}),
)

await network.provider.send('evm_setAutomine', [true])

// Create subnames
for (const {
label,
namedOwner,
type,
subnames,
} of names) {
if (!subnames) continue
console.log(`Setting subnames for ${label}.eth...`)
for (const {
label: subnameLabel,
namedOwner: namedSubnameOwner,
fuses: subnameFuses = 0,
expiry: subnameExpiry = BigNumber.from(2).pow(64).sub(1),
} of subnames) {
let setSubnameTx
if (type === 'legacy')
setSubnameTx = await legacyNameGenerator.subname({
label,
namedOwner,
subnameLabel,
namedSubnameOwner,
})
else
setSubnameTx = await wrappedNameGenerator.subname({
label,
namedOwner,
subnameLabel,
namedSubnameOwner,
subnameFuses,
subnameExpiry,
})
console.log(` - ${subnameLabel} (tx: ${setSubnameTx.hash})...`)
await setSubnameTx.wait()
}
}

await network.provider.send('evm_mine')
return true
}

func.id = 'register-concurrent-names'
func.tags = ['register-concurrent-names']
func.dependencies = ['ETHRegistrarController', 'register-wrapped-names']
func.runAtTheEnd = true

module.exports = func
Loading