{"id":"XE-13351","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"496","source_url":"https://github.com/xeprotocol/xe/issues/496","reporter_id":1981,"title":"Report bug","area":"node-api","claimed_tier":null,"assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T20:42:10.354727+00:00","updated_at":"2026-11-20T00:38:15.935355+00:00","source_created_at":"2026-11-12T03:39:07+00:00","told_at":"2026-11-20T00:34:52+00:00","status_changed_at":"2026-11-20T00:33:18.865559+00:00","url":"https://bounty.xe.network/XE-13351","body":"# XE Bounty — Laporan siap file (temuan pass 4 #1)\n\nFile issue baru di: https://github.com/xeprotocol/xe/issues/new\nPaste judul + isi di bawah. Akun GitHub: Gib230223.\n\n---\n\n## Judul\n\n[Medium-Low] Node reports failure AFTER committing a money-moving block, so a retry double-charges (CreateLeaseBlock / RenewLease / Send)\n\n## Isi\n\n## Summary\n\nThree node-side constructors commit a block with `Ledger.AddBlock` and then return a gossip-`Publish` failure as if the whole operation failed — while the block is already committed and the funds already moved. A caller that treats the error as \"did not happen\" and retries builds a fresh block from the new frontier: a second lease (new escrow) or a second renewal (second segment charge). There is no idempotency key, no landed-check, and no \"committed but ungossiped\" outcome anywhere on these paths.\n\nThe codebase already knows the right shape: `SubmitBlock` logs a publish failure after commit and returns nil. Only `CreateLeaseBlock`, `RenewLease`, and `Send` return the post-commit publish error as a failure.\n\n## Evidence\n\n```go\n// node/node.go:2116-2124 CreateLeaseBlock — AddBlock then bare Publish return:\nif err := n.Ledger.AddBlock(b); err != nil { return err }\nreturn n.Gossip.Publish(n.ctx, b)              // :2124 — error AFTER commit\n\n// node/lease_renew.go:76-82 RenewLease — same shape:\nif err := n.Ledger.AddBlock(b); err != nil {\n    return nil, fmt.Errorf(\"add lease_renew: %w\", err)\n}\nif n.Gossip != nil {\n    if err := n.Gossip.Publish(n.ctx, b); err != nil {\n        return nil, fmt.Errorf(\"gossip lease_renew: %w\", err)   // :80-81\n    }\n}\n\n// node/node.go:786-789 Send — same shape (AddBlock :786, then):\nreturn n.Gossip.Publish(n.ctx, b)              // :789\n```\n\nCallers treat the error as \"did not happen\" and retry: `POST /lease/request` (`api/vm.go:141-147`, operator endpoint) returns 400 on the error; `POST /lease/{hash}/renew` (`api/vm.go:170-176`) returns 400; `xe lease renew` CLI (`cmd/xe/main.go:1126-1141`) prints `renew rejected` and exits non-zero.\n\nThe correct pattern already exists in the same file (`node/node.go:1282-1291` `SubmitBlock`):\n\n```go\nif err := n.Ledger.AddBlock(b); err != nil { return err }\nn.syncTracker.MarkDirty()\nif err := n.Gossip.Publish(n.ctx, b); err != nil {\n    log.Printf(\"block %s committed locally but gossip publish failed (sync will propagate): %v\", b.Hash, err)\n}\nreturn nil\n```\n\n`autoAcceptLease` (`node/node.go:1625`) likewise only logs a publish failure after its accept block commits.\n\n## Impact (Medium-Low, money consequence)\n\nA retry after a publish failure escrows a second lease/renewal charge for one intended operation. Trigger is narrow — `Gossip.Publish` effectively never fails in steady state (it ignores the call context and succeeds with zero peers); it fails when the pubsub service is shutting down / its context is done (node restart window), the topic is closed, or the block fails the node's own local gossip validator — but the consequence when it fires is a silent double-spend of the operator's own retry, and the fix is a two-line alignment with `SubmitBlock` (log + return the committed hash / nil). Severity is Medium-Low, not Medium: narrow trigger, real money consequence.\n\n## Reproduction (PoC)\n\nMemStore ledger, `CreateLeaseBlock` with the pubsub service context cancelled (publish fails deterministically once the 32-slot `sendMsg` buffer is filled):\n\n```\nlease cost for 1vCPU/1024MB/10GB/3600s = 40000 uXUSD\nattempt 1 (publish fails): err=context canceled\nafter failed attempt 1: chain len=2 (want 2: receive+lease), XUSD balance=999960000 (want 999960000)\nBUG: attempt 1 returned an error, but the lease block IS committed and 40000 uXUSD IS escrowed\nattempt 2 (retry, live gossip): err=<nil>\nafter retry: chain len=3 (want 3: receive+2 leases), XUSD balance=999920000 (want 999920000)\nBUG REPRODUCED: one intended lease cost 40000 uXUSD twice (80000 total); two live lease blocks escrowed\n```\n\n## Suggested fix\n\nIn `CreateLeaseBlock`, `RenewLease`, and `Send`, align with `SubmitBlock`: after `AddBlock` succeeds, log a gossip-`Publish` failure and return success (the committed block / nil) instead of returning the publish error, so callers never retry an already-committed money-moving block.\n\n## Novelty note\n\nNo ticket covers a node-side publish-after-commit error. Closest, all verified: XE-3091 (SDK-side `holdLease` re-signs a duplicate renewal after an ambiguous submit failure — TypeScript SDK client retry after a *lost response*, different repo/component/trigger/fix); XE-0608 / XE-0005 (gossip-ingestion panic, unrelated); XE-0661 / XE-7481 (overflow / rollback double-spend, unrelated mechanism). GitHub closest: #183 (concurrent lease mutations from different accounts — different), #381 (archiveExpiredLease race — different). Checked the live bounty board (High+Medium and Minor views) and the GitHub repo issues, 2026-11-12.\n\nRepo: github.com/xeprotocol/xe, HEAD 89a542e, testnet-0005.\n","patch_refs":[{"id":569,"repo":"xeprotocol/xe","kind":"pr","ref":"523","title":"fix(node): do not report failure when gossip publish fails after block commit (#496)","url":"https://github.com/xeprotocol/xe/pull/523","note":"","state":"open","author":"arturbarszcz78","added_by":"desk","created_at":"2026-11-14T20:42:20.223021+00:00"}],"thread":[{"id":13219,"source":"github","source_ref":"7026487642","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, 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-13351 and says what differs; it is read like any other.","created_at":"2026-11-20T00:34:52+00:00"}]}