Report
XE Bounty — Laporan siap file (temuan pass 4 #1)
File issue baru di: https://github.com/xeprotocol/xe/issues/new Paste judul + isi di bawah. Akun GitHub: Gib230223.
Judul
[Medium-Low] Node reports failure AFTER committing a money-moving block, so a retry double-charges (CreateLeaseBlock / RenewLease / Send)
Isi
Summary
Three 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.
The 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.
Evidence
// node/node.go:2116-2124 CreateLeaseBlock — AddBlock then bare Publish return:
if err := n.Ledger.AddBlock(b); err != nil { return err }
return n.Gossip.Publish(n.ctx, b) // :2124 — error AFTER commit
// node/lease_renew.go:76-82 RenewLease — same shape:
if err := n.Ledger.AddBlock(b); err != nil {
return nil, fmt.Errorf("add lease_renew: %w", err)
}
if n.Gossip != nil {
if err := n.Gossip.Publish(n.ctx, b); err != nil {
return nil, fmt.Errorf("gossip lease_renew: %w", err) // :80-81
}
}
// node/node.go:786-789 Send — same shape (AddBlock :786, then):
return n.Gossip.Publish(n.ctx, b) // :789
Callers 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.
The correct pattern already exists in the same file (node/node.go:1282-1291 SubmitBlock):
if err := n.Ledger.AddBlock(b); err != nil { return err }
n.syncTracker.MarkDirty()
if err := n.Gossip.Publish(n.ctx, b); err != nil {
log.Printf("block %s committed locally but gossip publish failed (sync will propagate): %v", b.Hash, err)
}
return nil
autoAcceptLease (node/node.go:1625) likewise only logs a publish failure after its accept block commits.
Impact (Medium-Low, money consequence)
A 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.
Reproduction (PoC)
MemStore ledger, CreateLeaseBlock with the pubsub service context cancelled (publish fails deterministically once the 32-slot sendMsg buffer is filled):
lease cost for 1vCPU/1024MB/10GB/3600s = 40000 uXUSD
attempt 1 (publish fails): err=context canceled
after failed attempt 1: chain len=2 (want 2: receive+lease), XUSD balance=999960000 (want 999960000)
BUG: attempt 1 returned an error, but the lease block IS committed and 40000 uXUSD IS escrowed
attempt 2 (retry, live gossip): err=<nil>
after retry: chain len=3 (want 3: receive+2 leases), XUSD balance=999920000 (want 999920000)
BUG REPRODUCED: one intended lease cost 40000 uXUSD twice (80000 total); two live lease blocks escrowed
Suggested fix
In 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.
Novelty note
No 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.
Repo: github.com/xeprotocol/xe, HEAD 89a542e, testnet-0005.
Thread
Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-13351 and says what differs; it is read like any other.