Loading the ledger engine (Go → WebAssembly)…

Daftar دفتر

A double-entry payments ledger that proves itself: exactly-once requests, holds and captures, refunds, payouts, tamper-evident history and mada settlement reconciliation. This page runs the same Go engine as the server, compiled to WebAssembly.

1,000/1,000chaos seeds pass: crashes, lost, duplicated and reordered messages
4,246/spayments on PostgreSQL (MacBook, 16 clients), p99 23 ms
398 → 0DB connections killed mid-transaction → inconsistencies
6/6planted bugs caught by the checkers, each on the first seed

Send a request


Network chaos

Lose the response30%
Deliver twice20%
Crash mid-transaction20%

Whatever goes wrong, the client retries with the same idempotency key, and the ledger applies the request exactly once.

What happened on the wire

  • Send a request to see every attempt, crash, retry and replay.

Balance sheet (SAR)

Payments

Journal: every transfer, every leg

Recompute everything from history

The auditor ignores cached balances and rebuilds the ledger line by line from its append-only history. In PostgreSQL a trigger also refuses any UPDATE or DELETE on history.

    Play the attacker

    Rewrite one line of history directly in storage, bypassing the engine, then run the audit.

    Account

    Each line's hash covers the previous line's hash, so changing any line breaks the chain from that point on, even if the attacker rehashes it.

    Hash chain

    Account

    Each block is one line: a balance change on this account. Arrows are hash links, and they turn red where the chain no longer verifies.

    Receive a mada settlement file

    The simulated card scheme settles every unsettled card payment and refund, then injects the faults below. Daftar matches each line to the ledger, posts what matches, and sends every discrepancy to a suspense account with a reason.

    Missing (late) lines10%
    Duplicated lines10%
    Wrong amounts10%
    Unknown payments10%

    Reconciliation result

    View the settlement file (CSV)

    Run the chaos campaign

    Each seed is a complete, deterministic simulation: 6 clients running payment flows through a network that drops, duplicates and reorders messages, a server that crashes mid-transaction, hold expiry, and a card scheme sending faulty settlement files. After each run, five independent checks must pass.

    Seeds
    Ops per seed

    The full campaign (1,000 seeds × 400 ops) runs natively in 5.8 s. In your browser, 100 seeds take a few seconds.

    Test the tests

    A checker that never fails proves nothing. Each mutant plants one real bug in the engine; the campaign must catch every one.

    Campaign totals

    The five checks, after every seed

    1. Audit. Hash chains verify, cached balances equal their history, every transfer balances, no account breaches its limit, and debits equal credits.
    2. Exactly-once. Every answer a client ever received for a key equals the one committed for that key.
    3. Reference model. Every committed request is replayed through an independent, naive implementation. It must agree on each verdict and on the final balances.
    4. Reconciliation. The reconciler reports exactly the faults the scheme injected: none missed, no false alarms.
    5. Liveness. Every call resolves, and no hold stays open past its deadline.

    How it works

    Engine

    Stateless Go. Each request locks its idempotency key, then its transfers, then its accounts, always in sorted order. It checks every rule on locked copies, then writes everything in one transaction, or nothing.

    Storage

    PostgreSQL in production (row locks under READ COMMITTED, CHECK constraints on balances, an append-only trigger on history). In memory for the simulator and this page. Both implement one interface.

    Proof

    A deterministic simulator with a reference model, Go fuzzing (364k runs), mutation testing, and a PostgreSQL load test that kills connections, sends duplicate requests at once, and then audits the result.

    Measured on PostgreSQL 17 (MacBook, 8 cores, fsync on every commit)

    RunPayments/sp50p99Result
    16 clients, hot platform accounts not sharded2,4621.8 ms32 msaudit clean
    16 clients, fee and receivable accounts sharded ×84,2462.5 ms23 msaudit clean
    Every payment to one merchant (a single hot row)1,6829.3 ms34 msaudit clean
    Chaos: a connection killed every 20 ms, 20% of requests sent twice at once3,3973.2 ms26 ms0 inconsistencies