Skip to content

Pool count from gateway - #1647

Open
stefangutica wants to merge 20 commits into
developmentfrom
pool-count-from-gateway
Open

stefangutica wants to merge 20 commits into
developmentfrom
pool-count-from-gateway

Conversation

@stefangutica

@stefangutica stefangutica commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Reasoning

  • /pool/count downloaded the whole pool from the gateway and returned its length, so it failed whenever the pool response exceeded the 2MB limit the API sets for it.
  • In that case /pool returned a generic error, so the FE could not tell it apart from any other failure, and the pool was downloaded again, up to the limit, on every request.

Proposed Changes

  • Gateway:
    • getTransactionPool returns null when the response exceeds the size limit. Any other error still throws.
    • New getTransactionPoolCount sums the per-shard counts from transaction/pool/count.
  • Pool cache: a pool that is too large is cached as null under txpool (explicit cacheNullable: true), so it is not downloaded again until the value expires.
  • Count: /pool/count still counts the pool, so it matches what /pool lists. Whenever the pool cannot be read, too large or for any other reason, it returns the total from the gateway, cached under txpool:count for 1s, whatever the filters.
  • REST: /pool and /pool/:txhash have two kinds of errors:
    • 503 with { "statusCode": 503, "code": "transaction_pool_too_large", "message": "The transaction pool is too large to be displayed" } when the pool is too large, documented in Swagger;
    • 500 for any other failure, as before.
  • Websocket: every poolUpdate now carries a status: success, tooLarge or internalServerError.
    • pool is null unless the status is success.
    • poolCount is the total from the gateway when the pool cannot be read, or null when the count fails as well.
  • Cache warmer: when the pool is too large, it caches it as null and also refreshes the total count from the gateway, with transactionPoolWarmer.ttlInSeconds, as before.
  • Price per unit: unchanged. The pool it reads fails when the pool is too large, so this case is handled like any other failure of the pool.

How to test

  • Unit tests:
    • pool.spec.ts: counts, null cache, gateway fallback for too large and for other failures, pool with filters failing when too large;
    • pool.too.large.spec.ts: 503/500 responses, websocket statuses, price per unit;
    • cache.warmer.pool.spec.ts: warming;
    • gateway.pool.count.spec.ts: size limit, other errors, count sum.
  • Checked against the real ApiService: a 1MB pool is returned, a 3MB pool is detected as too large, and an unreachable gateway still throws.
  • Checked over HTTP: with the pool too large, /pool and /pool/:txhash answer 503 and /pool/count answers 200 with the gateway total. With any other failure, /pool and /pool/:txhash answer 500.
  • Note: the gateway count covers only regular transactions, not smart contract results or rewards, updates once per block, and takes no filters. transaction/pool/count exists from mx-chain-proxy-go#520 on; mainnet and testnet gateways don't have it yet at the time of writing.

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

k6 load testing comparison.
Base Commit Hash: c533f21
Target Commit Hash: f4332d3

Metric Base Target Diff
AvgMax9095AvgMax9095AvgMax9095
Mex41.08878.6754.1559.6942.50937.7457.2361.28+3.46% 🔴+6.72% 🔴+5.69% 🔴+2.66% 🔴
Pool40.90612.4054.1159.6642.32484.8357.1961.28+3.47% 🔴-20.83% ✅+5.69% 🔴+2.72% 🔴
Transactions73.9016484.9361.0467.4571.3412563.7864.6776.02-3.45% ✅-23.79% ✅+5.94% 🔴+12.70% 🔴
Blocks50.47890.6358.4062.6154.931021.7161.4866.50+8.85% 🔴+14.72% 🔴+5.28% 🔴+6.21% 🔴
Tokens41.03722.4054.2759.7942.34573.7657.1961.28+3.20% 🔴-20.58% ✅+5.38% 🔴+2.49% 🔴
Accounts47.621239.0658.7264.5246.53948.9261.1867.12-2.30% ✅-23.42% ✅+4.19% 🔴+4.02% 🔴
Nodes74.8117399.2479.2890.3568.2416778.6761.1466.61-8.77% ✅-3.57% ✅-22.88% ✅-26.28% ✅
Test Run Duration60002.3260005.83

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

@stefangutica
stefangutica marked this pull request as draft September 29, 2026 12:01
@stefangutica
stefangutica marked this pull request as ready for review September 30, 2026 09:33
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.

2 participants