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

Lower metadata seed interval #335

Merged
merged 1 commit into from
Jan 28, 2025
Merged
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
26 changes: 26 additions & 0 deletions packages/seeder/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import { monitorOperatorApy } from './monitors/operatorApy'
import { seedLogStrategyWhitelist } from './events/seedLogStrategyWhitelist'
import { seedLogsDistributionRootSubmitted } from './events/seedLogsDistributionRootSubmitted'
import { seedMetricsStakerRewards } from './metrics/seedMetricsStakerRewards'
import { monitorAvsMetadata } from './monitors/avsMetadata'
import { monitorOperatorMetadata } from './monitors/operatorMetadata'

console.log('Initializing Seeder ...')

Expand Down Expand Up @@ -211,6 +213,27 @@ async function seedApyData(retryCount = 0) {
}
}

/**
* Seed metadata
*
* @returns
*/
async function seedMetadata() {
try {
console.log('\nSeeding AVS metadata ...')
await monitorAvsMetadata()
} catch (error) {
console.error('Failed to seed AVS metadata', error)
}

try {
console.log('\nSeeding Operator metadata ...')
await monitorOperatorMetadata()
} catch (error) {
console.error('Failed to seed Operator metadata', error)
}
}

// Start seeding data instantly
seedEigenData()

Expand All @@ -219,3 +242,6 @@ cron.schedule('5 0 * * *', () => seedEigenDailyData())

// Schedule seedApyData to run at 5 minutes past 2am every day
cron.schedule('5 2 * * *', () => seedApyData())

// Schedule seedMetadata to run every 30 minutes
cron.schedule('*/30 * * * *', () => seedMetadata())
5 changes: 5 additions & 0 deletions packages/seeder/src/monitors/avsMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export async function monitorAvsMetadata() {

const avsEntries = await prismaClient.avs.findMany({
where: {
metadataUrl: {
not: ''
},
isMetadataSynced: false
},
take: take,
Expand All @@ -23,6 +26,8 @@ export async function monitorAvsMetadata() {
}
})

console.log('[Monitor] Updating AVS metadatas: ', avsEntries.length)

if (avsEntries.length === 0) {
break
}
Expand Down
5 changes: 5 additions & 0 deletions packages/seeder/src/monitors/operatorMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export async function monitorOperatorMetadata() {

const operatorEntries = await prismaClient.operator.findMany({
where: {
metadataUrl: {
not: ''
},
isMetadataSynced: false
},
take: take,
Expand All @@ -23,6 +26,8 @@ export async function monitorOperatorMetadata() {
}
})

console.log('[Monitor] Updating Operator metadatas: ', operatorEntries.length)

if (operatorEntries.length === 0) {
break
}
Expand Down
2 changes: 1 addition & 1 deletion packages/seeder/src/utils/seeder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export async function getBlockDataFromDb(fromBlock: bigint, toBlock: bigint) {
return new Map(blockData.map((block) => [block.number, block.timestamp]))
}

export async function fetchWithTimeout(url: string, timeout = 5000): Promise<Response> {
export async function fetchWithTimeout(url: string, timeout = 2500): Promise<Response> {
const controller = new AbortController()
const timeoutId = setTimeout(() => controller.abort(), timeout)

Expand Down
Loading