Skip to content

Check tokens created within all tokens processing time window - #1637

Open
stefangutica wants to merge 4 commits into
developmentfrom
tokens-cache-warming-improvements
Open

Check tokens created within all tokens processing time window#1637
stefangutica wants to merge 4 commits into
developmentfrom
tokens-cache-warming-improvements

Conversation

@stefangutica

Copy link
Copy Markdown
Collaborator

Reasoning

  • getAllTokensRaw, run by the cache warmer every 2 minutes, takes tens of seconds: it fetches the token list once at the start and then processes every token. Any token created after that initial fetch is missing from the result until the next refresh.
  • This also races with the token creation handler in the transaction processor. If warming starts at t1, a token is created at t2 and appended to the cached list by the transaction processor, and warming finishes at t3 (t1 < t2 < t3), the warmer overwrites the cache with a list that does not contain the new token. The token appears and then disappears until the next refresh.

Proposed Changes

  • After the full processing pass, re-fetch the fungible token properties and MetaESDT collections, and process only the tokens that were not in the initial list. They are merged in before sorting.
  • This narrows the window for both issues from the whole processing time (tens of seconds) to the duration of the second, much smaller pass (a few seconds at most).
  • If the second fetch fails, the error is logged and the already processed list is still returned, so a failure there cannot discard the full refresh.
  • Extracted the list fetch into fetchAllTokensWithoutDetails so both passes share it.

How to test

  • Run npx jest src/test/unit/services/tokens.spec.ts. The new cases check that only tokens created in the meantime are processed in the second pass and that they are included in the result, and that a failing second fetch keeps the already processed tokens.
  • On devnet, issue a token or register a MetaESDT collection while the All Tokens invalidations cron is running. The token should still be in GET /tokens after the warmer finishes, and the logs should show Processing N tokens created while processing all tokens.
  • When no tokens are created during a refresh, GET /tokens returns the same count and order as before.

@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown

k6 load testing comparison.
Base Commit Hash: 4a67c69
Target Commit Hash: 27fbe52

Metric Base Target Diff
AvgMax9095AvgMax9095AvgMax9095
Nodes68.8915789.1252.2055.0563.3317112.4659.4062.59-8.06% ✅+8.38% 🔴+13.79% 🔴+13.69% 🔴
Blocks42.92837.0452.7056.9747.19708.7658.0961.97+9.96% 🔴-15.33% ✅+10.21% 🔴+8.78% 🔴
Transactions73.2414363.7853.4057.6667.7416092.6259.3461.96-7.52% ✅+12.04% 🔴+11.13% 🔴+7.46% 🔴
Mex32.47186.0242.5051.7738.90429.5554.7859.59+19.80% 🔴+130.91% 🔴+28.90% 🔴+15.12% 🔴
Tokens32.68582.9542.9751.8739.12512.3554.9259.68+19.70% 🔴-12.11% ✅+27.81% 🔴+15.07% 🔴
Accounts34.101523.1845.5353.0340.03578.8756.4460.55+17.37% 🔴-62.00% ✅+23.95% 🔴+14.20% 🔴
Pool32.68524.7842.9751.7739.13490.3454.8759.72+19.74% 🔴-6.56% ✅+27.71% 🔴+15.36% 🔴
Test Run Duration60002.7760002.66

Legend: Avg - Average Response Time, Max - Maximum Response Time, 90 - 90th Percentile, 95 - 95th Percentile
All times are in milliseconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant