{"id":"XE-0130","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"219","source_url":"https://github.com/xeprotocol/xe/issues/219","reporter_id":40,"title":"net/sync: 10,000-block cap produces a terminal response despite unsent blocks; no explicit continuation signal","area":null,"claimed_tier":"minor","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":null,"status":"triaging","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-30T13:16:01.428020+00:00","updated_at":"2026-11-05T04:17:58.961230+00:00","source_created_at":"2026-10-30T13:13:59+00:00","told_at":null,"status_changed_at":"2026-11-05T04:17:38.935863+00:00","url":"https://bounty.xe.network/XE-0130","body":"**Suggested severity:** Minor, potentially Medium if the readiness implication is confirmed end-to-end (team to assess).\n**Area:** P2P frontier synchronization / node observability.\n**Tested version:** `xeprotocol/xe` commit `978785929bc17a2f4ab30c383e5fc9cf4d634512` (Go 1.25.0), network `testnet-0005`.\n\n## Summary\nWhen a peer is missing more than 10,000 blocks, `findMissingBlocksPaginated` stops at `maxServerBlocks = 10000` and can emit its final response with `has_more:false` even though the source chain still has unsent blocks. `capHit` is tracked locally but discarded. `SyncResponse` includes a cursor, but `SyncRequest` has no cursor/continuation field. The receiving peer can eventually retrieve the remainder **if** its frontier advances and it makes another request; without frontier progress, it receives the same first 10,000 blocks on each request.\n\nThis is a **confirmed completion/continuation ambiguity**, not a claim of permanent synchronization failure. Whether `has_more` is intentionally scoped only to pages within one request needs clarification. A related readiness risk is that a nil return from `requestSync` is marked a successful sync round; `/ready` checks the timestamp of that success, not independently established full convergence. This potential false-green readiness outcome follows the code path but has **not** been reproduced end-to-end.\n\n## Affected code\n- `net/sync.go:20-40`: `maxServerBlocks` and `maxTotalBlocks` each 10,000.\n- `net/sync.go:651-751`: `findMissingBlocksPaginated` stops on cap, sends `HasMore:false` at lines 743-748, discards `capHit` at line 750.\n- `net/messages.go:16-26`: `SyncRequest` only contains `Frontiers` and `PageSize`; `SyncResponse` includes `Cursor`.\n- `net/sync.go:529-648` and `326-337, 366-377`: `requestSync` can return nil after processing a capped stream; callers record `RecordSyncRound(true)` on nil.\n- `metrics/metrics.go:228-245` and `node/observability.go:554-567`: successful-round timestamp is used for the `synced` readiness check.\n\n## Reproduction (offline, in-memory; no public-node load)\nFrom repository checkout at the commit above, save the following as `net/xe_sync_replay_repro_test.go` and run `go test -p 2 -count=1 -run '^TestXECapReplayAndResume$' -v ./net`:\n\n```go\npackage net\n\nimport (\n    \"fmt\"\n    \"testing\"\n    \"github.com/xeprotocol/xe/core\"\n    \"github.com/xeprotocol/xe/store\"\n)\n\nfunc TestXECapReplayAndResume(t *testing.T) {\n    s := store.NewMemStore()\n    l := core.NewLedger(s, core.LedgerConfig{})\n    const account = \"synthetic-offline\"\n    blocks := make([]*core.Block, 10001)\n    for i := range blocks {\n        blocks[i] = &core.Block{Account: account, Hash: fmt.Sprintf(\"%064x\", i+1)}\n    }\n    if err := s.PutAccountChain(account, &core.AccountChain{Blocks: blocks}); err != nil { t.Fatal(err) }\n    if err := s.PutFrontier(account, blocks[10000].Hash); err != nil { t.Fatal(err) }\n\n    request := l.Frontiers()\n    delete(request, account) // genesis already known; synthetic account unknown\n    collect := func() (count int, last string, terminal bool) {\n        for resp := range findMissingBlocksPaginated(request, l, 64) {\n            count += len(resp.Blocks)\n            if len(resp.Blocks) > 0 { last = resp.Blocks[len(resp.Blocks)-1].Hash }\n            if !resp.HasMore { terminal = true }\n        }\n        return\n    }\n    n1, h1, end1 := collect()\n    n2, h2, end2 := collect()\n    t.Logf(\"NO_CLIENT_PROGRESS round1=%d round2=%d same_last=%t server_terminal=%t source_chain=10001\", n1, n2, h1 == h2, end1 && end2)\n    if n1 != 10000 || n2 != 10000 || h1 != h2 || !end1 || !end2 { t.Fatal(\"unexpected capped replay\") }\n\n    request[account] = h1 // control: receiver persists the 10,000-block prefix\n    n3, h3, end3 := collect()\n    t.Logf(\"AFTER_ADVANCING_FRONTIER remaining=%d final_hash_is_tail=%t terminal=%t\", n3, h3 == blocks[10000].Hash, end3)\n    if n3 != 1 || h3 != blocks[10000].Hash || !end3 { t.Fatal(\"resume differs from expected\") }\n}\n```\n\n**Observed, 2026-10-30:**\n```text\n=== RUN   TestXECapReplayAndResume\nNO_CLIENT_PROGRESS round1=10000 round2=10000 same_last=true server_terminal=true source_chain=10001\nAFTER_ADVANCING_FRONTIER remaining=1 final_hash_is_tail=true terminal=true\n--- PASS: TestXECapReplayAndResume (0.14s)\nPASS\nok  github.com/xeprotocol/xe/net 0.246s\n```\n\nThis validates both the repeated capped prefix when the receiver has not advanced and the negative control: after advancing its frontier, the last block is supplied successfully.\n\n## Supplementary observation (not a separate bounty claim)\nA short testnet-0005 run of a fresh node on a 4-vCPU VPS connected to 7 peers. It processed 463 blocks while an official bootstrap node had about 135,623 at that time. Its XE journal contained 131 occurrences of `sync: hit maxTotalBlocks cap (10000), stopping`. `/health` returned HTTP 200; `/ready` returned HTTP 503 with `synced=false` (so **no false-positive ready was observed**). Memory increased to ~2.3 GiB before the XE node was stopped. Memory growth and slow shutdown are already separately reported and are not claimed here.\n\n## Why this matters / suggested clarification\nThe protocol offers no explicit signal distinguishing “this sync request has ended because the 10,000-block server cap was hit” from “there is no more remote state to send.” A client or operational readiness monitor may treat a successful capped request as evidence of completion. Possible fixes: a `truncated` / `more_after_cap` indicator, documented frontier-based continuation, or request-cursor support; additionally, do not equate merely successful request completion with proven convergence in the readiness signal.\n\n## Existing reports and scope limits\nRelated accepted reports: #59 (overlapping sync goroutines and resource exhaustion), #60 (shutdown waits on in-flight sync), #57 (lease-family blocks not syncing). This report **does not re-claim** their resource, SIGTERM, or lease-dependency findings. There is no demonstrated permanent stall, fund loss, or exploitable security impact here; maintainers may regard stream-scoped `has_more` as intended semantics.\n\n**Testing ethics:** Reproduction is local and synthetic. No keys, wallets, other users’ workloads, or public sustained load were used. Only an ordinary short first-boot test was performed on public testnet.\n\n**XE payout address (testnet wallet; confirm mainnet compatibility at launch):** `6cae644263a88b2fc1167c7b3680ec182e81035777b682827c02ccf1be027a39`.","patch_refs":[{"id":229,"repo":"xeprotocol/xe","kind":"pr","ref":"223","title":"fix(net): signal sync truncation on server block cap and prevent false convergence (fixes #219)","url":"https://github.com/xeprotocol/xe/pull/223","note":"","state":"open","author":"arturbarszcz78","added_by":"desk","created_at":"2026-10-30T14:53:08.777867+00:00"}],"thread":[{"id":75,"source":"github","source_ref":"6525365624","author":"freestriker00","team":false,"body":"### Additional bounded local P2P evidence (2026-10-30)\n\nFollowing the earlier code-path hypothesis, I ran a second reproduction through **real in-process libp2p hosts on `127.0.0.1`**, with no public-network traffic. The controlled peer responds to `/xe/sync/1.0.0` with a syntactically valid, empty terminal `SyncResponse{Blocks:nil, HasMore:false}`. The unmodified `SetupSync` client records `metrics.LastSuccessfulSync()` as nonzero. Using that **actual** sync-success timestamp, `NewFixedObserver` then returns `ready=true` with a **synthetic snapshot** containing just one local genesis block and otherwise passing readiness conditions.\n\nThis is stronger evidence that `synced` is a **recent successful stream/round** check rather than a proof of convergence. It does **not** demonstrate a public-node HTTP `/ready` false positive, because the observer's other inputs were supplied by a test fixture. It also does **not** prove a permanent stall or security-critical outcome. A fully validating, multi-peer end-to-end test would still be needed to establish the live operational impact.\n\n```text\n=== RUN   TestXELocalEmptySyncMarksPeerReady\nACTUAL_LOCAL_P2P_EMPTY_TERMINAL: local_blocks=1 peer_count=1 sync_success_nonzero=true ready=true status=ready\n--- PASS: TestXELocalEmptySyncMarksPeerReady (0.07s)\nPASS\nok github.com/xeprotocol/xe/net 0.101s\n```\n\nTo reproduce on pinned commit `978785929bc17a2f4ab30c383e5fc9cf4d634512`, save the test below as `net/xe_p2p_readiness_local_test.go`:\n\n```go\npackage net_test\n\nimport (\n \"context\"\n \"encoding/json\"\n \"testing\"\n \"time\"\n \"github.com/libp2p/go-libp2p\"\n libnetwork \"github.com/libp2p/go-libp2p/core/network\"\n \"github.com/libp2p/go-libp2p/core/peer\"\n \"github.com/xeprotocol/xe/core\"\n \"github.com/xeprotocol/xe/store\"\n xenet \"github.com/xeprotocol/xe/net\"\n \"github.com/xeprotocol/xe/metrics\"\n \"github.com/xeprotocol/xe/node\"\n)\n\nfunc TestXELocalEmptySyncMarksPeerReady(t *testing.T) {\n metrics.ResetSyncProgress()\n defer metrics.ResetSyncProgress()\n server,err:=libp2p.New(libp2p.ListenAddrStrings(\"/ip4/127.0.0.1/tcp/0\"))\n if err!=nil {t.Fatal(err)}\n defer server.Close()\n client,err:=libp2p.New(libp2p.ListenAddrStrings(\"/ip4/127.0.0.1/tcp/0\"))\n if err!=nil {t.Fatal(err)}\n ctx,cancel:=context.WithCancel(context.Background())\n defer cancel()\n defer client.Close()\n server.SetStreamHandler(\"/xe/sync/1.0.0\",func(s libnetwork.Stream){\n  defer s.Close()\n  var req xenet.SyncRequest\n  if err:=json.NewDecoder(s).Decode(&req);err!=nil{return}\n  _=json.NewEncoder(s).Encode(&xenet.SyncResponse{Blocks:nil,HasMore:false})\n })\n ledger:=core.NewLedger(store.NewMemStore(),core.LedgerConfig{})\n _,wait:=xenet.SetupSync(ctx,client,ledger)\n defer func(){cancel();_ = client.Close();wait()}()\n if err:=client.Connect(ctx,peer.AddrInfo{ID:server.ID(),Addrs:server.Addrs()});err!=nil {t.Fatal(err)}\n deadline:=time.Now().Add(5*time.Second)\n for metrics.LastSuccessfulSync().IsZero() && time.Now().Before(deadline) {\n  time.Sleep(20*time.Millisecond)\n }\n last:=metrics.LastSuccessfulSync()\n if last.IsZero(){t.Fatal(\"No sync success from empty terminal response\")}\n snap:=&node.Snapshot{At:time.Now(),Blocks:1,Accounts:1,\n  DelegatedWeight:42,Representatives:1,ActiveRepresentatives:1,\n  QuorumMargin:0.33,UnfinalizedPositions:0}\n obs:=node.NewFixedObserver(node.ObsConfig{MinPeers:1},snap,1,last)\n ready:=obs.Ready()\n t.Logf(\"ACTUAL_LOCAL_P2P_EMPTY_TERMINAL: local_blocks=%d peer_count=1 sync_success_nonzero=%t ready=%t status=%s\",\n  snap.Blocks,!last.IsZero(),ready.Ready,ready.Status)\n if !ready.Ready {t.Fatalf(\"Unexpected checks: %+v\",ready.Checks)}\n}\n```\n\nThen run: `go test -p 2 -count=1 -run '^TestXELocalEmptySyncMarksPeerReady$' -v ./net`.\n\nOnly loopback P2P and in-memory storage were used. I am keeping this as supporting evidence for #219, not a separate resource-exhaustion claim or a request to raise severity.","created_at":"2026-10-30T14:36:22+00:00"},{"id":80,"source":"github","source_ref":"6525692636","author":"arturbarszcz78","team":false,"body":"[comment from a blocked account removed]","created_at":"2026-10-30T14:51:42+00:00"},{"id":81,"source":"github","source_ref":"6526464199","author":"freestriker00","team":false,"body":"Thank you, @arturbarszcz78, for preparing PR #223 and implementing a proposed fix for the synchronization issue reported here.\n\nI appreciate your work on the fix and the additional regression tests.\n\nFor clarity regarding Bug Bounty attribution, I would like to emphasize that **the original issue was identified, reproduced, documented, and reported by me under #219 (@freestriker00), before PR #223 was submitted.**\n\nThe original report included a reproducible 10,001-block test case, analysis of the truncation and convergence behavior, and additional local P2P evidence concerning the readiness mechanism.\n\nI fully recognize and appreciate @arturbarszcz78's contribution as the author of the proposed fix. However, **credit for discovering and reporting the issue should be distinguished from credit for implementing its solution.**\n\nSince PR #223 includes separate reward addresses, I would kindly ask the XE maintainers to clarify how Bug Bounty attribution and any potential rewards will be handled.\n\nMy original XE payout address remains the one provided in issue #219.\n\nI am also happy to help validate PR #223 against the original reproduction cases.\n\nThank you for your consideration and for improving the XE protocol.","created_at":"2026-10-30T15:26:15+00:00"},{"id":83,"source":"github","source_ref":"6528792278","author":"freestriker00","team":false,"body":"### Additional public-testnet observation: `/ready` can be green during incomplete historical sync (2026-10-30)\n\nI performed a **bounded ordinary cold-start** of one real XE node on public `testnet-0005` as part of the announced, protocol-only research campaign #224.\n\nAt **2026-10-30 17:11:37 UTC**, the fresh node returned:\n\n```text\nGET /node     200  network_id=testnet-0005, block_count=32\nGET /health   200  ok=true\nGET /ready    200  ready=true, checks.synced=true, peer_count=6\n```\n\nShortly before this run, `GET https://ldn.core.test.network/node` reported `network_id=testnet-0005` and `block_count=144688`. The fresh node was therefore visibly nowhere near the official bootstrap ledger's block count while claiming to be synced/ready. The local journal recorded **25** `sync: hit maxTotalBlocks cap (10000), stopping` warnings.\n\nThis supplements the earlier offline tests with an **actual public-node readiness mismatch**, but **does not isolate the 10,000-block cap as the unique cause**, establish permanent stalling, or claim a new severity. The node had only one configured bootstrap but six observed connected peers; the reported mismatch is a single sampled snapshot, not a time-series study.\n\nThe run was stopped under resource controls, with no transaction writes or request flood. Full operational caveats, including the apparent-vs-allocated disk monitoring error, are documented in campaign #224, comment https://github.com/xeprotocol/xe/issues/224#issuecomment-6528787448. I am keeping this as **further evidence for the original report #219**, not an additional bounty claim.","created_at":"2026-10-30T17:14:17+00:00"},{"id":86,"source":"github","source_ref":"6528992697","author":"freestriker00","team":false,"body":"### Time-series follow-up to #219: premature `/ready` during ordinary public-testnet sync\n\nA **second, separately started research node** on public `testnet-0005` reproduced the `ready=true` / `synced=true` mismatch during incomplete historical synchronization. Unlike the previous single-snapshot observation, this run recorded **18 samples at five-second intervals**.\n\n- At **t=15s**, the pinned research-client binary (`xe/dev`, source commit `978785929bc17a2f4ab30c383e5fc9cf4d634512`) had **16 blocks**, but `GET /ready` returned **HTTP 200, ready=true, checks.synced=true**.\n- `ready` remained true through **t=85s**, when the local ledger held only **288 blocks**.\n- The official London bootstrap node (`xe/4f19518`, same `network_id=testnet-0005` but **different software build**) reported **145,130 blocks before** and **145,190 afterward**.\n- The local journal logged **47** `sync: hit maxTotalBlocks cap (10000), stopping` events. These logs do **not** establish the cap as the unique root cause of this readiness mismatch.\n- Memory rose to **848.1 MB**, below the safety cap; actual allocated data was ~5.6 MB at the final sample; the run had five to six connected peers. No transaction writes or load were generated, and the node is stopped.\n\nFull second-run methodology, 18 data points, explicit limitations and termination details are in the pre-notified campaign report **[#224, follow-up comment](https://github.com/xeprotocol/xe/issues/224#issuecomment-6528987743)**.\n\nThis is **supporting operational evidence** for the existing issue #219, not a new bug report, an additional reward claim, proof of permanent sync stall, or proof that the latest public build behaves identically.","created_at":"2026-10-30T17:24:19+00:00"}]}