Skip to content

Commit

Permalink
add an unchanging block frequency so that validations have a more sta…
Browse files Browse the repository at this point in the history
…ble environment
  • Loading branch information
apexearth committed Dec 19, 2024
1 parent ec191d2 commit 2a6b180
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 23,638 deletions.
13 changes: 5 additions & 8 deletions scripts/generate-validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const LIMIT = 1000
const gql = (query: string) => query

const executeQuery = async (query: string) => {
const response = await fetch('https://origin.squids.live/origin-squid/graphql', {
const response = await fetch('https://origin.squids.live/origin-squid@v65/api/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -27,12 +27,9 @@ const executeQuery = async (query: string) => {
throw err
}
}
const takeEvery = (arr: any[], takeEvery: number) => {
if (takeEvery <= 0) {
throw new Error('takeEvery must be greater than 0')
}

return arr.filter((_, index) => index % takeEvery === 0)
const takeValidationEntries = (arr: any[]) => {
return arr.filter((entry) => entry.blockNumber % 100000 === 0)
}

const oTokens = (prefix: string, address: string) => {
Expand Down Expand Up @@ -337,9 +334,9 @@ export const transactionDetails = (prefix: string, from: string) => {
txHash
from
to
gasCost
gasUsed
effectiveGasPrice
transactionFee
}
`)
}
Expand Down Expand Up @@ -414,7 +411,7 @@ const main = async () => {
throw new Error('Query failed')
}
for (const key of Object.keys(result.data)) {
entities[key] = takeEvery(result.data[key], 25)
entities[key] = takeValidationEntries(result.data[key])
}
}

Expand Down
1 change: 1 addition & 0 deletions src/utils/blockFrequencyUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const blockFrequencyTracker = (params: { from: number }) => {
(ctx._chain.client as any).url.includes('tenderly') ||
// Normal logic down below.
block.header.height % frequency === 0 ||
block.header.height % 100000 || // For validation generation we need something reliable and unchanging.
isAerodromeImportantBlock(ctx, block)
)
}
Expand Down
Loading

0 comments on commit 2a6b180

Please sign in to comment.