{"id":"XE-16985","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"696","source_url":"https://github.com/xeprotocol/xe/issues/696","reporter_id":2920,"title":"[Low] Statechain sync 10MB TOTAL client cap vs server serving up to 10,000 blocks","area":"p2p-sync","claimed_tier":null,"assessed_tier":null,"verdict":"duplicate","duplicate_of":"XE-0120","tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-17T08:13:52.071171+00:00","updated_at":"2026-11-22T23:26:15.560741+00:00","source_created_at":"2026-11-17T08:12:13+00:00","told_at":"2026-11-22T23:26:15.592225+00:00","status_changed_at":"2026-11-22T23:26:15.574849+00:00","url":"https://bounty.xe.network/XE-16985","body":"## Summary\n\nStatechain sync has a 10 MB **total** client cap against a server that serves up to 10,000 blocks per round with no byte cap. The client decodes the entire stream through ONE `io.LimitReader` — not per-page (contrast ledger sync's per-page 10 MB + 32 MB session cap) — so a full 10k-block sync breaks whenever the average block JSON exceeds ~1,048 bytes. The client applies blocks inline as decoded, so a capped round makes partial progress and resumes on the next trigger — noisy multi-round sync, not a hard stall.\n\n## Root Cause\n\n- **Server side:** statechain sync serves pages of 64 blocks, total cap 10,000 blocks, no byte cap (`statechain/sync.go:23-28`: `syncPageSize = 64`, `syncMaxBlocks = 10000`). Per-block max MaxBlockSize=256KB (`statechain/types.go:102`); per-op value cap MaxValueSize=65536 (`:101`).\n- **Client side:** decodes the ENTIRE stream through one `io.LimitReader(s, syncMaxResponseSize=10MB)` (`statechain/sync.go:215`, `syncMaxResponseSize = 10 << 20` at `:28`).\n\n## Verification\n\nExecuted PoC (in-package `net` test, block-size quantification):\n\n```\nminimal DAO block JSON: 693 bytes -> 10MB cap fits 15130 blocks\nepoch-like block JSON: 1391 bytes -> 10MB cap fits 7538 blocks\nserver serves up to 10000 blocks/round; break-even avg block size: 1048 bytes\nfull 10k-block sync at minimal size: 6930000 bytes (cap 10485760) — fits\nfull 10k-block sync at epoch-like size: 13910000 bytes (cap 10485760) — FAILS\n```\n\n## Note on related reports\n\nSearched \"statechain sync 10MB total cap\", \"statechain sync response size cap\", \"statechain sync 10000 blocks\" — only #284 (read-path lock), #244 (ledger-sync frontiers 1 MiB, different protocol), #58 (timestamps), #245 (apply loop) — none cover this mechanism.\n\n## Suggested fix\n\nApply the response cap per page (like ledger sync) instead of per round, or bound the total blocks served per round by bytes.\n","patch_refs":[],"thread":[{"id":18855,"source":"desk","source_ref":"reply:16532","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as https://bounty.xe.network/XE-0120, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-16985 and says what differs; it is read like any other.","created_at":"2026-11-22T23:26:15.560741+00:00"}]}