Bounty
XE-0995 · Bounty

verifyBlockCredential uses unfinalized frontier keyset instead of keyset at b.Previous, and addBlock conflict staging omits BlockLeaseSettle stake refund

Patched Medium web filed 2026-11-07 04:07 UTC by Ashev Ardiansyah

Report

Two validation defects in core/ledger.go cause valid sibling blocks in conflict forks to be rejected before conflict resolution can run:

1. verifyBlockCredential validates sibling conflicts against the unfinalized frontier keyset (core/ledger.go:1544-1567)

When a multisig account M has an unfinalized multisig_update block B1 at height h that rotates its keyset from K1 to K2, B1 immediately mutates l.keysets[M] = K2 on ingest (core/ledger.go:1428).

If a competing sibling block B2 at the same height h (sharing B2.Previous == B1.Previous) arrives signed by the prior quorum K1, addBlock calls l.verifyBlockCredential(B2) at core/ledger.go:804 before reaching the conflict fork detection at core/ledger.go:819:

func (l *Ledger) verifyBlockCredential(b *Block) error {
    ...
    ks := l.GetKeyset(b.Account)
    if ks != nil {
        if len(b.Signatures) == 0 {
            return fmt.Errorf("multisig account %s requires threshold signatures", b.Account[:12])
        }
        return verifyMultisig(ks, hashBytes, b.Signatures)
    }

Because l.GetKeyset(b.Account) returns the unfinalized frontier keyset K2 installed by B1 rather than the keyset active at b.Previous (K1), verifyBlockCredential(B2) fails with an unknown/insufficient signer error and drops B2 before registerConflict(B1, B2) is ever reached. Thus an unfinalized multisig_update cannot be contested at the same height by a sibling block signed under the keyset that was actually active at b.Previous.

2. addBlock conflict staging parentBalance inline loop omits BlockLeaseSettle +lease.Stake XUSD refund (core/ledger.go:838-869)

When a sibling conflict is detected at core/ledger.go:819 (headHash != "" && b.Previous != headHash), addBlock reconstructs parentBalance and parentAssetBalances at b.Previous using an inline loop over chain[:len(chain)-1] (core/ledger.go:838-869) instead of calling computeParentState (core/ledger.go:2408-2469).

While computeParentState handles BlockLeaseSettle (core/ledger.go:2447-2454) by crediting lease.Stake back to assets[AssetXUSD], the inline loop in addBlock (core/ledger.go:840-865) only handles BlockSend, BlockReceive, BlockMint, BlockBurn, BlockSwap, BlockSlashing, BlockEpochRewards, and BlockLeaseOpen, completely omitting BlockLeaseSettle, BlockLeaseAccept, BlockLeaseRenew, BlockLeaseCancel, and BlockLeaseForceSettle.

Consequently, if an account settles a lease (BlockLeaseSettle, receiving its +lease.Stake XUSD refund) and then has two conflicting blocks at the next height where the second block spends that refunded XUSD, validateBlockStaged checks parentAssetBalances[AssetXUSD] (0 instead of lease.Stake) and rejects the valid sibling block with insufficient XUSD balance: have 0, need ....

Remediation

  1. In addBlock, replace the duplicated inline parentBalance / parentAssetBalances reconstruction at core/ledger.go:838-869 with l.computeParentState(b.Account, chain) (and extend computeParentState to include BlockLeaseRenew, BlockLeaseCancel, and BlockLeaseForceSettle).
  2. When b.Previous != headHash on a multisig account, resolve the keyset effective at b.Previous rather than the unfinalized tip keyset.

Thread

Joseph Denneteam2026-11-08 20:39 UTCdesk

Thanks for the report. We have read both parts against the current tree. The first part is being handled alongside related work already in progress. The second part refers to functions that are not present in the ledger code at head, so we could not confirm it as described. We will update this ticket when there is more to say.

XE deskteam2026-11-17 16:39 UTCdesk

Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is updated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0995.