<!-- XE-13351 · Report bug · testnet -->
*Markdown view of <https://bounty.xe.network/XE-13351>. The page is the record; this is the same page for reading.*

XE-13351 · Bounty

# Report bug

Closed · duplicate
—
[xe#496](https://github.com/xeprotocol/xe/issues/496)
filed 2026-11-12 03:39 UTC
by Gib230223

Verdict
:   Duplicate

Tier
:   —

Claimed
:   —

Area
:   Node / API

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-20 00:38 UTC

Told
:   2026-11-20 00:34 UTC

### Patches

- [xe#523](https://github.com/xeprotocol/xe/pull/523) open by arturbarszcz78
  fix(node): do not report failure when gossip publish fails after block commit (#496)

### History

- [554018](https://bounty.xe.network/log/554018) 2026-11-20 00:34 UTC reply.mirrored
- [553991](https://bounty.xe.network/log/553991) 2026-11-20 00:34 UTC github.state\_pushed
- [553989](https://bounty.xe.network/log/553989) 2026-11-20 00:34 UTC github.labels
- [552468](https://bounty.xe.network/log/552468) 2026-11-20 00:33 UTC proposal.adopted
- [552467](https://bounty.xe.network/log/552467) 2026-11-20 00:33 UTC reply.sent
- [552466](https://bounty.xe.network/log/552466) 2026-11-20 00:33 UTC ticket.status new → closed
- [551856](https://bounty.xe.network/log/551856) 2026-11-20 00:33 UTC proposal.adopted
- [551855](https://bounty.xe.network/log/551855) 2026-11-20 00:33 UTC ticket.facts area
- [551854](https://bounty.xe.network/log/551854) 2026-11-20 00:33 UTC proposal.adopted
- [551853](https://bounty.xe.network/log/551853) 2026-11-20 00:33 UTC ticket.facts
- [551852](https://bounty.xe.network/log/551852) 2026-11-20 00:33 UTC proposal.adopted
- [551851](https://bounty.xe.network/log/551851) 2026-11-20 00:33 UTC ticket.facts

[Full history](https://bounty.xe.network/log?ref=XE-13351) · [JSON](https://bounty.xe.network/v1/tickets/XE-13351) · [markdown](https://bounty.xe.network/XE-13351.md)

### 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

**Joseph Denne**team2026-11-20 00:34 UTCgithub

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.
