{"id":"XE-0260","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"243","source_url":"https://github.com/xeprotocol/xe/issues/243","reporter_id":39,"title":"statechain sync: zero-progress round reports success and gap-resync stops at the first non-erroring peer","area":"p2p-sync","claimed_tier":null,"assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":null,"status":"triaging","closed_reason":null,"github_state":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-02T21:17:59.223415+00:00","updated_at":"2026-11-08T20:17:41.885067+00:00","source_created_at":"2026-11-02T21:17:47+00:00","told_at":"2026-11-08T20:18:39.311972+00:00","status_changed_at":"2026-11-08T20:17:48.793137+00:00","url":"https://bounty.xe.network/XE-0260","body":"## Ringkas\n\n`requestSync` mengembalikan `nil` ketika tidak ada satu blok pun yang bisa diambil, sehingga pemanggil tidak bisa membedakan \"sudah sinkron\" dari \"peer kosong / tertinggal\". `ResyncOnGap` lalu berhenti pada peer pertama yang errornya nihil, menganggap perbaikan selesai padahal nol blok masuk, dan cooldown 30 detik sudah terbakar.\n\n## Akar\n\n`statechain/sync.go:185-196`:\n\n```go\nif !resp.HasMore {\n    break\n}\n...\nif added > 0 {\n    logging.Debugf(\"statechain sync: synced %d block(s) from %s\", added, pid.ShortString())\n}\nreturn nil\n```\n\nTidak ada jalur yang membedakan `added == 0`. Peer yang tertinggal menjawab `{blocks:[], has_more:false}` (`sync.go:102-115`) — sah, tapi tanpa progres.\n\n`statechain/sync.go:216-225`:\n\n```go\nfor i, pid := range h.Network().Peers() {\n    if i >= 3 { return }\n    if err := requestSync(h, pid, chain); err != nil {\n        logging.Warnf(\"statechain gap-resync with %s failed: %v\", pid.ShortString(), err)\n        continue\n    }\n    logging.Debugf(\"statechain gap-resync: tip now %d\", chain.Tip().Index)\n    return                      // berhenti di peer pertama yang tidak error\n}\n```\n\nKarena `requestSync` selalu `nil` untuk peer kosong, `return` terjadi walau `tip` tidak bergerak. `lastGapSync` juga sudah disetel, jadi percobaan berikutnya menunggu `gapSyncBackoff = 30s`.\n\n## Reproduksi\n\n```\ngo test ./statechain/ -run 'TestAuditRequestSyncNilOnZeroProgress' -v\n```\n\nPada `9787859` gagal (`expected error for zero progress, got nil`); 12/12 ronde dengan peer kosong berakhir tanpa blok dan cooldown terbakar 12/12.\n\n## Dampak\n\nJalur ini dipakai node yang ketinggalan karena gap blok gossip (`node/node.go:2239-2243`). Kalau peer pertama pada `Peers()` kebetulan tertinggal atau liar, resync berakhir tanpa satu blok pun, dicatat `tip now N` seolah sukses, dan node nyangkut di tinggi lama tanpa alarm — sementara peer sehat ada di mesh. Efeknya node diam-diam tertinggal, bukan error yang terlihat.\n\n## Saran perbaikan\n\nKembalikan error (atau `added, error`) saat `added == 0`, dan di `ResyncOnGap` lanjutkan ke peer berikutnya bila tidak ada progres — bukan berhenti pada `nil` saja.\n","patch_refs":[],"thread":[{"id":113,"source":"github","source_ref":"6588999181","author":"hayokakoweda75","team":false,"body":"Tracked privately on the bounty desk as **XE-0264** — same defect, verified with the same PoC. Filing here too so the evidence stays public.","created_at":"2026-11-02T21:33:20+00:00"},{"id":1592,"source":"desk","source_ref":"reply:493","author":"Joseph Denne","team":true,"body":"Thanks for the report. We have confirmed the behaviour you describe in statechain gap repair and it is being handled; we will update https://bounty.xe.network/XE-0260 when there is a fix to point at.","created_at":"2026-11-08T20:17:41.885067+00:00"}]}