Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c4d7e7a
fix: timeout prisma
chedieck Sep 30, 2025
5e348b1
feat: rework priceService
chedieck Oct 9, 2025
d2f879c
feat: reworkTransactionService
chedieck Oct 9, 2025
59e15e7
feat: update constants
chedieck Oct 9, 2025
cb2cb09
refactor:
chedieck Oct 10, 2025
004ab84
fix: race condition
chedieck Oct 10, 2025
13aa9e1
fix: error throwing
chedieck Oct 10, 2025
5981431
feat: add log info
chedieck Oct 10, 2025
570e549
fix: comment
chedieck Oct 11, 2025
cfd81d6
fix: chronik processing txs blocked
chedieck Oct 22, 2025
0354b72
Merge branch 'fix/chronik-tx-processing-freezing' into fix/timeout-pr…
chedieck Oct 22, 2025
daa9b1f
chore: update prices
chedieck Oct 22, 2025
7b33a1c
fix: sync job teardown on failure
chedieck Oct 22, 2025
b1ba146
feat: better logging
chedieck Oct 22, 2025
b63b7c3
chore: commit productiontxs
chedieck Oct 22, 2025
d9f8608
feat: force restart of jobs
chedieck Oct 22, 2025
4957a55
refac: remove unecessary changes
chedieck Oct 22, 2025
b17fb30
fix: typing
chedieck Oct 22, 2025
7918341
test: add chronik tests
chedieck Oct 22, 2025
af60833
test: fix tx tets
chedieck Oct 22, 2025
5394bf9
fix: overriding bug
chedieck Oct 24, 2025
e81f825
refac: improve variable name
chedieck Oct 28, 2025
a8cb702
feat: add log to 404 retry
chedieck Oct 28, 2025
79feee5
fix: call without retrying on 404
chedieck Oct 28, 2025
f476d3f
chore: update jest types
chedieck Oct 28, 2025
576b2ea
fix: Buffer type errors
chedieck Oct 28, 2025
c2b0ccc
test: add chronik tests
chedieck Oct 28, 2025
92f403c
fix: await finish syncing on jobs
chedieck Oct 28, 2025
e0f33ae
feat: wrap TX_CONFIRMED in try block
chedieck Oct 28, 2025
b9225a0
test: removed accidental .only
chedieck Oct 28, 2025
3637b2f
fix: unit
chedieck Oct 28, 2025
7704f33
test: fix module resetting
chedieck Oct 28, 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
8 changes: 4 additions & 4 deletions constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export const HUMAN_READABLE_DATE_FORMAT = 'YYYY-MM-DD'

export const PRICE_API_DATE_FORMAT = 'YYYY-MM-DD'
export const PRICE_API_TIMEOUT = 40 * 1000 // 40 seconds
export const PRICE_API_MAX_RETRIES = 3
export const PRICE_API_MAX_RETRIES = 1

export const SYNC_TXS_JOBS_MAX_RETRIES = 3
export const SYNC_TXS_JOBS_RETRY_DELAY = 2000
Expand Down Expand Up @@ -279,9 +279,9 @@ export const MEMPOOL_PROCESS_DELAY = 100
// On chronik, the max allowed is 200
export const CHRONIK_FETCH_N_TXS_PER_PAGE = 200

export const INITIAL_ADDRESS_SYNC_FETCH_CONCURRENTLY = 512
export const TX_EMIT_BATCH_SIZE = 10_000 // for our generator, not chronik
export const DB_COMMIT_BATCH_SIZE = 10_000 // tamanho dos lotes para commit no DB
export const INITIAL_ADDRESS_SYNC_FETCH_CONCURRENTLY = 128
export const TX_EMIT_BATCH_SIZE = 2_000 // for our generator, not chronik
export const DB_COMMIT_BATCH_SIZE = 2_000 // tamanho dos lotes para commit no DB

export const TRIGGER_POST_CONCURRENCY = 100
export const TRIGGER_EMAIL_CONCURRENCY = 100
Expand Down
23 changes: 18 additions & 5 deletions jobs/initJobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ import { syncCurrentPricesWorker, syncBlockchainAndPricesWorker, cleanupClientPa
EventEmitter.defaultMaxListeners = 20

const main = async (): Promise<void> => {
// --- force fresh start ---
const pricesQueue = new Queue('pricesSync', { connection: redisBullMQ })
const blockchainQueue = new Queue('blockchainSync', { connection: redisBullMQ })
const cleanupQueue = new Queue('clientPaymentCleanup', { connection: redisBullMQ })

await pricesQueue.obliterate({ force: true })
await blockchainQueue.obliterate({ force: true })
await cleanupQueue.obliterate({ force: true })

await pricesQueue.add('syncCurrentPrices',
{},
{
Expand All @@ -21,18 +29,23 @@ const main = async (): Promise<void> => {

await syncCurrentPricesWorker(pricesQueue.name)

const blockchainQueue = new Queue('blockchainSync', { connection: redisBullMQ })
await blockchainQueue.add('syncBlockchainAndPrices', {}, { jobId: 'syncBlockchainAndPrices' })
await blockchainQueue.add('syncBlockchainAndPrices',
{},
{
jobId: 'syncBlockchainAndPrices',
removeOnComplete: true,
removeOnFail: true
}
)
await syncBlockchainAndPricesWorker(blockchainQueue.name)

const cleanupQueue = new Queue('clientPaymentCleanup', { connection: redisBullMQ })

await cleanupQueue.add(
'cleanupClientPayments',
{},
{
jobId: 'cleanupClientPayments',
removeOnFail: false,
removeOnComplete: true,
removeOnFail: true,
repeat: {
every: CLIENT_PAYMENT_EXPIRATION_TIME
}
Expand Down
9 changes: 6 additions & 3 deletions jobs/workers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ export const syncBlockchainAndPricesWorker = async (queueName: string): Promise<
})

worker.on('failed', (job, err) => {
if (job != null) {
console.error(`job ${job.id as string}: FAILED — ${err.message}`)
}
void (async () => {
if (job != null) {
console.error(`job ${job.id as string}: FAILED — ${err.message}`)
}
await multiBlockchainClient.destroy()
})()
})
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"xecaddrjs": "^0.0.1"
},
"devDependencies": {
"@types/jest": "^27.5.1",
"@types/jest": "^30.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Align Jest types with Jest/ts-jest versions.

@types/jest is ^30 while jest is ^29.7 and ts-jest is ^29.2.5. This can cause TS inference/compile breakage.

Two safe paths:

  • Keep Jest 29: downgrade types.
-    "@types/jest": "^30.0.0",
+    "@types/jest": "^29.5.12",
  • Or upgrade the stack together (only if you intend to move): bump jest and ts-jest to matching 30.x.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"@types/jest": "^30.0.0",
"@types/jest": "^29.5.12",
🤖 Prompt for AI Agents
In package.json around line 75, @types/jest is ^30 while jest is ^29.7 and
ts-jest is ^29.2.5 causing type/compile mismatch; fix by either downgrading
@types/jest to a 29.x version that aligns with jest (e.g., ^29.0.0) or by
upgrading both jest and ts-jest to matching 30.x versions (bump jest and ts-jest
to 30.x, update any config if required), then run install and the test/type
checks to verify no remaining type errors.

"@types/node": "^12.0.12",
"@types/nodemailer": "^6.4.16",
"@types/react": "^16.9.44",
Expand Down
482 changes: 480 additions & 2 deletions prisma-local/seeds/prices.csv

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion prisma-local/seeds/prices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function createPricesFile (): Promise<void> {
const prices: PriceFileData[] = []

await Promise.all(Object.values(NETWORK_TICKERS).map(async (networkTicker) => {
const pricesByNetworkTicker = await getAllPricesByNetworkTicker(networkTicker)
const pricesByNetworkTicker = await getAllPricesByNetworkTicker(networkTicker, true)

pricesByNetworkTicker?.forEach(price => {
if (isEmpty(price.Price_in_CAD) || isEmpty(price.Price_in_USD)) { throw new Error(`Price came back with at least one quote empty from API: ${JSON.stringify(price)}`) }
Expand Down
6 changes: 5 additions & 1 deletion prisma-local/seeds/productionTxs.csv
Original file line number Diff line number Diff line change
Expand Up @@ -131466,4 +131466,8 @@ fe95acd641f4ced15eb81dbfeb508124c322f8ca6cbb8e1868ea6024fcba3574,1000119.19,1754
baba23425aa5e5bb5c3b2b1b3e9a7f30dd4fe333f58be276700be85ff2cf49f0,1000023.22,1754861586,d1266537-9c17-4ec5-b09f-b05a81811c60,true
39c84db94eb3c7d9e9b9307060a840ba36dbefeb4add2713f81f911d7bcc3a3f,1000152.16,1754861467,d1266537-9c17-4ec5-b09f-b05a81811c60,truefb2dce1149b2a9a1722954c931964a061704a06910682e6ddd6f676e1c01e0af,1000043.31,1754947609,d1266537-9c17-4ec5-b09f-b05a81811c60,true
2db424bd1ae48962d0a2eea6bdf6d21fa02af129e7d54d8ecda02511d7d3760a,1000131.92,1754946651,d1266537-9c17-4ec5-b09f-b05a81811c60,true
eedd73ccf42e75872329a68f2cc0a98513bf58ad0fe8c2314c5a7ea5bb3430a3,1000035.45,1754946080,d1266537-9c17-4ec5-b09f-b05a81811c60,true
eedd73ccf42e75872329a68f2cc0a98513bf58ad0fe8c2314c5a7ea5bb3430a3,1000035.45,1754946080,d1266537-9c17-4ec5-b09f-b05a81811c60,true924125cf4bb5cbe292d7a1f9a78ea2b03daeac23af8d5b51e8f122ca6dc21ebb,1000030.75,1761165795,d1266537-9c17-4ec5-b09f-b05a81811c60,true
298aa89e9d0e352492386d4e35f1f53135e6e79d6abdd2043cfcb73ef4e73fec,1000000,1761165132,d1266537-9c17-4ec5-b09f-b05a81811c60,true
746ad0dde27297c0c29f0e844b488fd06abdc5091e678a2a0e1b0b5c1d5efbd1,1000036.53,1761165079,d1266537-9c17-4ec5-b09f-b05a81811c60,true
d0180fa8ffb28760f64bdadb2fd7289196f003cd27a2adcee6e6419e848c1597,1000000,1761164173,d1266537-9c17-4ec5-b09f-b05a81811c60,true
f9f64587e7f7b11f771e130455b59fd84e5a3422215ac1f08505418fd395dc07,1000068.28,1761164139,d1266537-9c17-4ec5-b09f-b05a81811c60,true7e6312169483006fec8d6d1d9d4311c82f3334be4c58fe4a188cbc9e088de75c,1000716.35,1761169691,d1266537-9c17-4ec5-b09f-b05a81811c60,true
3 changes: 2 additions & 1 deletion scripts/updateAllPriceConnections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ async function fixMisconnectedTxs (): Promise<void> {
select: {
price: {
select: {
timestamp: true
timestamp: true,
networkId: true
}
}
}
Expand Down
Loading