Bounty
XE-0127 · Bounty

Volume test pre-notice: bounded GET /frontiers cost measurement on testnet-0005

Closed · answered — xe#214 filed 2026-10-30 05:59 UTC by targammm

Report

Volume test pre-notice: bounded GET /frontiers cost measurement on testnet-0005

Pre-notification of a bounded, single-source, read-only measurement against the public testnet nodes, per the Rules on /bounty:

Volume testing against the public testnet nodes is authorized; open an issue before a sustained campaign so we can watch it and attribute the results to you.

This is a campaign notice, not a bug report and not a claim of a vulnerability.

What will be measured

GET /frontiers applies pagination after materialising every frontier in the lattice, and per account it reads a block body and deserialises the whole account chain (api/handler.go:688 → node/node.go:968 GetFrontiersDetailed). The handler has no result cache. The question is whether a single client can turn that into a measurable slowdown for other clients, and whether it reaches the node's own health sampler.

Already known — not claimed here

#70 reports the same defect class on GET /accounts and measures the health-sampler effect. This notice covers /frontiers only.

Measurements already taken (read-only, single source IP, no writes)

Lattice: 16,517 accounts / 123,227 blocks, node xe/4f19518.

Page size does not change cost:

GET /frontiers              -> 200, 4.06s,  22711 bytes
GET /frontiers?limit=1      -> 200, 3.81s,    230 bytes
GET /frontiers?limit=10     -> 200, 4.15s,   2270 bytes
GET /frontiers?limit=10000  -> 200, 5.00s, 226904 bytes

Reproduced on all three bootstrap nodes at limit=1: ldn 3.99 s, ffm 3.80 s, nyc 5.47 s. No cache: six back-to-back requests each cost the full ~3.8 s.

Paired arm, concurrency 12, 30 s, same client and pacing:

  • control GET /supply (O(1)): 632 requests, p50 0.5 s, 0 health 503
  • under test GET /frontiers?limit=1: 24 requests, p50 15.71 s, 0 health 503

At concurrency 24, 90 s: 72 requests, p50 33.49 s, max 37.31 s.

What the sustained campaign will add

  1. Sustained /frontiers?limit=1 — concurrency 12 and 24, up to 5 minutes per arm, on ldn and ffm, sampling /health every 2 s, to determine whether the sampler is driven toward its 45 s budget.
  2. Cross-endpoint interaction — whether /frontiers load raises latency for a separate client session on /accounts/{address}/balance.
  3. Recovery time — how long /health stays elevated after traffic stops.

Bounds

  • ≤ 24 concurrent connections, ≤ 5 minutes per arm, ≤ 3 arms per node.
  • Read-only GET only. No POST, no writes, no malformed input.
  • No traffic to the hosting layer (nginx / DNS / website / faucet) — out of scope per the bounty page.
  • Well under the documented read budget (200 rps / 1000 burst per IP).

Attribution

Wallet 6591eab453dbd93b27e2cd674712f94b42d9e7e4d52980b966fa6da4ccd832dc (testnet-0005, self-funded from faucet.test.network). GitHub: targammm. Disclosure credit handle: "Waguri".

Results will be posted as a comment on this issue whether or not anything is found, including the raw measurements and the measurement script, so the team can reproduce them.

Thread

targammm2026-10-30 06:16 UTCgithub

api: GET /frontiers does full-lattice N+1 work regardless of ?limit=, and has no result cache

Severity (suggested): Medium — "measurable slowdown under volume" / "degradation one client can cause". Read-only, unauthenticated, no malformed input, no writes, well under the documented read budget. Area: The HTTP API, its rate limits and the test.network proxy (Track 2 — volume & resilience) Node: testnet-0005, node xe/4f19518, reproduced on ldn.core.test.network and ffm.core.test.network Source: master @ 9787859 Campaign notice: #214 XE payout address: 6591eab453dbd93b27e2cd674712f94b42d9e7e4d52980b966fa6da4ccd832dc


Summary

GET /frontiers has the same defect class as #70, on a different handler, and it is more expensive per byte. The handler materialises every frontier in the lattice — and for each one reads a block body and deserialises the whole account chain — before paginateSlice is applied. The page size does not change the work, and unlike /blocks/recent this handler has no result cache, so every request pays the full cost.

#70 names /frontiers only in its suggested fix ("Frontiers() already returns the account→frontier map cheaply"). It is not reported as an affected endpoint, and the N+1-per-account shape in GetFrontiersDetailed is not covered anywhere.

Affected code

// api/handler.go:688
func (h *Handler) handleGetFrontiers(w http.ResponseWriter, r *http.Request) {
    offset, limit := parsePagination(r)
    frontiers := h.node.GetFrontiersDetailed()          // full lattice, BEFORE pagination
    sort.Slice(frontiers, func(i, j int) bool { return frontiers[i].Account < frontiers[j].Account })
    writeJSON(w, http.StatusOK, paginateSlice(frontiers, offset, limit))
}
// node/node.go:968
func (n *Node) GetFrontiersDetailed() []FrontierInfo {
    frontiers := n.Ledger.Frontiers()
    out := make([]FrontierInfo, 0, len(frontiers))
    for account, hash := range frontiers {
        info := FrontierInfo{Account: account, Frontier: hash}
        if b := n.Ledger.GetBlock(hash); b != nil {      // one block read per account
            info.BlockType = string(b.Type)
            info.Timestamp = b.Timestamp
            info.Representative = b.Representative
        }
        info.BlockCount = len(n.Ledger.GetChain(account)) // full chain deserialisation per account
        out = append(out, info)
    }
    return out
}

Per account this is GetBlock(hash) plus GetChain(account). Ledger.GetChain (core/ledger.go:2374) allocates a fresh []*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. So the handler does N block reads + N full-chain deserialisations, then discards all but limit entries.

For comparison, #70's /accounts does one GetChain per account (node/node.go:997). /frontiers adds the per-account GetBlock on top.

/blocks/recent has a 1 s result cache (api/handler.go:652-663). /frontiers has none, so back-to-back requests each pay full cost.

Measurements

Lattice at measurement time: 16,517 accounts / 123,227 blocks.

1. Cost is independent of ?limit=

GET /frontiers              -> 200, 4.06s,  22711 bytes
GET /frontiers?limit=1      -> 200, 3.81s,    230 bytes
GET /frontiers?limit=10     -> 200, 4.15s,   2270 bytes
GET /frontiers?limit=10000  -> 200, 5.00s, 226904 bytes

limit=1 returns 99× less data than the default page and costs the same or more.

2. Per-byte cost vs the endpoint #70 already reports as High

Five samples each, ldn, idle:

/supply                    median 0.53s   bytes 805   us/byte    654
/accounts?limit=1          median 3.66s   bytes 276   us/byte  13247   (#70, already reported)
/frontiers?limit=1         median 3.93s   bytes 230   us/byte  17083   <- this report

/frontiers?limit=1 is ~26× the per-byte cost of /supply and ~1.3× that of /accounts?limit=1.

3. No cache

Six back-to-back /frontiers?limit=1 requests each cost the full ~3.8 s:

/frontiers?limit=1 x6:   3.94  3.80  3.82  3.73  3.79  3.88
/blocks/recent?limit=1 x6: 3.52  0.50  3.50  0.48  0.49  3.52   <- 1s cache, alternates

4. Reproduced on two bootstrap nodes

node /frontiers?limit=1 (idle)
ldn 3.99 s
ffm 3.80 s
nyc 5.47 s

5. Paired-arm campaign (per #214)

Two arms, same script, same concurrency, same interval, same source IP.

Arm A — control, GET /supply (O(1) handler), concurrency 24, 60 s, ldn:

RESULT arm=supply requests=2700 p50=0.5s max=0.92s bytes=2173500 codes={200: 2700}
health samples=25 503s=0

Arm B — under test, GET /frontiers?limit=1, concurrency 24, 300 s, ldn:

RESULT arm=frontiers requests=257 p50=27.46s max=41.64s bytes=59110 codes={200: 257}
health samples=121 503s=0

Arm B on ffm, concurrency 24, 180 s:

RESULT arm=frontiers requests=192 p50=24.33s max=27.55s bytes=44160 codes={200: 192}
health samples=73 503s=0

At the same concurrency the control completed 2,700 requests in 60 s while /frontiers completed ~50 in the same window — a ~54× throughput reduction. The control returned 37× more bytes. The only material difference is which handler ran.

Latency scaling with concurrency on /frontiers?limit=1:

concurrency window requests p50 max
1 (sequential) — 6 3.8 s 4.06 s
12 30 s 24 15.71 s 17.03 s
24 90 s 72 33.49 s 37.31 s
24 300 s 257 27.46 s 41.64 s
24 (ffm) 180 s 192 24.33 s 27.55 s

6. Effect on the node's own health sampler

/health reports sampler_alive with a 45 s budget (node/observability.go, 3 * SampleInterval). Baseline is sample 4s old. During the 300 s arm at concurrency 24 it rose to 17–23 s and stayed there for the duration:

health 200 sample 23s old
health 200 sample 14s old
health 200 sample 20s old
health 200 sample 11s old
health 200 sample 17s old
health 200 sample 18s old
health 200 sample 18s old
health 200 sample 19s old
health 200 sample 19s old

It did not reach 503 at concurrency 24. #70 reached 503 with /accounts at the same concurrency, so /frontiers is the more expensive per byte endpoint but the sampler pressure from one endpoint at this concurrency is not sufficient to wedge it. Stating that plainly: this is a measurable slowdown, not a health-signal denial, and the suggested tier is Medium accordingly.

A separate client session on /accounts/{address}/balance was unaffected throughout (0.48–0.53 s, unchanged from idle), so the pressure is confined to the handler's own CPU share rather than blocking unrelated reads.

Impact

  1. Amplification. 230 bytes in, ~3.9 s of ledger work out — ~17,000 µs of handler time per response byte at limit=1, against ~654 µs/byte for the O(1) /supply control.
  2. Throughput collapse under modest concurrency. 12 concurrent clients reduce per-request latency from 3.8 s to 15.7 s; 24 concurrent clients to ~27–33 s. That is past the point where any upstream proxy or client timeout fires, while the requests keep consuming CPU.
  3. No cache to absorb repeat traffic. Unlike /blocks/recent, every request pays full cost, so honest explorer/wallet polling is as expensive as an attack.
  4. Memory churn. Every request allocates a fresh []FrontierInfo for all 16,517 accounts plus a fresh []*Block copy per account via GetChain — the same shape #59 measured at 1.86 GB RSS.

Reproduction

Read-only, no writes, no malformed input, single source IP, /health sampled every 2 s. Script attached (t2_frontiers_amp.py), run as:

python3 t2_frontiers_amp.py https://ldn.core.test.network --arm frontiers --concurrency 24 --seconds 300
python3 t2_frontiers_amp.py https://ldn.core.test.network --arm supply    --concurrency 24 --seconds 60

Suggested fix

Page before materialising, exactly as #70 suggests for /accounts:

func (h *Handler) handleGetFrontiers(w http.ResponseWriter, r *http.Request) {
    offset, limit := parsePagination(r)
    front := h.node.Ledger.Frontiers()          // cheap: frontier only, no block bodies
    addrs := make([]string, 0, len(front))
    for a := range front { addrs = append(addrs, a) }
    sort.Strings(addrs)
    page := paginateSlice(addrs, offset, limit)
    writeJSON(w, http.StatusOK, h.node.FrontierInfos(page))   // per-account work only for the page
}

Two follow-ups worth doing at the same time:

  1. Do not read block bodies for the page. FrontierInfo.BlockType/Timestamp/Representative come from the frontier block only, so one store.Block(frontierHash) per paged account is enough; the GetChain call is only needed for BlockCount, which the sampler already computes every 15 s (node/observability.go:195).
  2. Give the handler a cache or a concurrency cap. /blocks/recent uses a 1 s TTL (handler.go:652); /frontiers should reuse the sampler's snapshot or at minimum cap concurrent handler executions so the read path cannot outrun the sampler.

Notes on scope

  • Read-only GET only. No POST, no writes, no malformed blocks, no writes to other users' accounts.
  • No traffic to the hosting layer (nginx / DNS / website / faucet) — out of scope per the bounty page.
  • Peak client-side rate was well under the documented read budget (200 rps / 1000 burst per IP); the point is that the budget is the wrong shape for this handler, not that it was exceeded.
  • Campaign ran under the pre-notice in #214, within the announced bounds (≤ 24 concurrent, ≤ 5 minutes per arm, read-only).
  • Prior-art check. Searched all issues for frontiers, /frontiers, GetFrontiersDetailed. GetFrontiersDetailed returns zero matches. /frontiers appears in #70, #78, #59, #19, #185 — in #70 only inside the suggested fix text, and in the others incidentally. No issue reports the pagination cost, the per-account GetBlock+GetChain pair, or the missing cache on this handler. This is orthogonal to #70: same defect class, different handler, higher per-byte cost.
XE deskteam2026-11-14 22:49 UTCgithub

Thanks for the report. We have read it and answered what it raises.

This report is closed as answered. If there is more to it, file a new report that links https://bounty.xe.network/XE-0127; it is read like any other.