<!-- XE-10255 · Consensus State Inconsistency: confirmConflict demotes mainBlock to staged store before swapBlockLocked succeeds creating duplicate phantom staged blocks · testnet -->
*Markdown view of <https://bounty.xe.network/XE-10255>. The page is the record; this is the same page for reading.*

XE-10255 · Bounty

# Consensus State Inconsistency: confirmConflict demotes mainBlock to staged store before swapBlockLocked succeeds creating duplicate phantom staged blocks

Closed · invalid
—
web
filed 2026-11-12 11:16 UTC
by xe:e4cd6974

Verdict
:   Invalid

Tier
:   —

Claimed
:   —

Area
:   Consensus

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-20 00:48 UTC

Told
:   2026-11-20 00:48 UTC

### Patches

None linked.

### History

- [557045](https://bounty.xe.network/log/557045) 2026-11-20 00:48 UTC reply.sent
- [553318](https://bounty.xe.network/log/553318) 2026-11-20 00:33 UTC proposal.adopted
- [553092](https://bounty.xe.network/log/553092) 2026-11-20 00:33 UTC proposal.adopted
- [553091](https://bounty.xe.network/log/553091) 2026-11-20 00:33 UTC ticket.status new → closed
- [552420](https://bounty.xe.network/log/552420) 2026-11-20 00:33 UTC proposal.adopted
- [552419](https://bounty.xe.network/log/552419) 2026-11-20 00:33 UTC ticket.facts area
- [552415](https://bounty.xe.network/log/552415) 2026-11-20 00:33 UTC proposal.adopted
- [552414](https://bounty.xe.network/log/552414) 2026-11-20 00:33 UTC ticket.facts
- [551370](https://bounty.xe.network/log/551370) 2026-11-20 00:32 UTC note.added
- [551368](https://bounty.xe.network/log/551368) 2026-11-20 00:32 UTC proposal.created
- [551367](https://bounty.xe.network/log/551367) 2026-11-20 00:32 UTC proposal.created
- [551366](https://bounty.xe.network/log/551366) 2026-11-20 00:32 UTC proposal.created

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

### Report

## Vulnerability Summary

In `core/quorum.go:320-340`, `confirmConflict` promotes a BFT quorum winner block by swapping out the demoted block (`mainBlock`):

```
			for _, loserHash := range result.LoserHashes {
				if _, lerr := qm.ledger.GetBlockHeight(result.ConflictAccount, loserHash); lerr != nil {
					continue
				}
				mainBlock := qm.ledger.GetBlock(loserHash)
				if mainBlock != nil {
					// Persist demoted block into staged store before swapping
					if err := qm.conflictMgr.SaveStagedBlock(mainBlock); err != nil {
						return fmt.Errorf("confirmConflict: SaveStagedBlock (demoted): %w", err)
					}
					if err := qm.ledger.swapBlockLocked(result.ConflictAccount, loserHash, result.WinnerHash, winnerBlock); err != nil {
						if errors.Is(err, ErrWinnerFullValidation) && !IsRetryableError(err) {
							qm.failedPromotions[failedPromotionKey(result.ConflictAccount, result.ConflictPrev, result.WinnerHash)] = Now()
...
						}
						return fmt.Errorf("confirmConflict: SwapBlock: %w", err)
					}
					swapped = true
					break
				}
			}
```

Critical ordering flaw:

1. Non-Atomic Staging: `qm.conflictMgr.SaveStagedBlock(mainBlock)` writes `mainBlock` directly to the persistent staged store (`prefixStaged` in BadgerDB) *before* `swapBlockLocked` executes.
2. Failure Mid-Operation: If `swapBlockLocked` fails (e.g. due to downstream validation errors, transient storage errors, or deterministic `ErrWinnerFullValidation`), the function aborts and returns an error.
3. Invariant Breach: `mainBlock` was NOT removed from the active account chain in `ledger`, yet it now simultaneously exists in the staged block store.
4. Duplicate Entity Corruption: If the node subsequently runs `GetBlockOrStaged(loserHash)`, or if subsequent conflict evaluation routines query the staged store, `mainBlock` appears in both committed and uncommitted states, corrupting conflict history and preventing clean re-arbitration.

## Proposed Remediation

Perform the staged demotion atomically within `swapBlockLocked` or revert the staged save on swap failure:

```
					if err := qm.ledger.swapBlockLocked(result.ConflictAccount, loserHash, result.WinnerHash, winnerBlock); err != nil {
						// Ensure mainBlock is not left orphaned in staged store
						_ = qm.conflictMgr.DeleteStagedBlock(loserHash)
						return fmt.Errorf("confirmConflict: SwapBlock: %w", err)
					}
					if err := qm.conflictMgr.SaveStagedBlock(mainBlock); err != nil {
						return fmt.Errorf("confirmConflict: SaveStagedBlock: %w", err)
					}
```

### Thread

**XE desk**team2026-11-20 00:48 UTCdesk

Thanks for the report. We read it against the code and could not confirm a bug in what it describes.

This report is closed as invalid. If we have missed something, file a new report that links
https://bounty.xe.network/XE-10255 and says what; it is read like any other.
