25 min

Bridges: the first fix and its scars

Lock-and-mint bridges copy an asset instead of settling it, which creates a custodian worth robbing; the sums lost taught the field to swap or settle rather than copy.

Where you are. Lesson 1 put two ledgers on the bench and showed that no transaction spans them. Ten lessons of markets later, the gap is still there. This lesson covers the first thing the field tried, and why it is a cautionary tale rather than an answer.

The idea is disarmingly simple. Take the asset on ledger A and lock it in a vault. Mint a copy on ledger B representing a claim on that vault. Now the asset trades on B, and anybody wanting the original burns the copy and unlocks the vault.

It works. It is used constantly. And it has been the single most expensive design decision in this field.

The idea in one paragraph

A lock-and-mint bridge does not settle an asset across ledgers; it immobilises the original and issues a claim somewhere else, which means the vault holding the originals accumulates everything anybody has ever bridged. That vault is a single address holding the entire backing of every wrapped token in circulation, and it is protected by whatever its own code and key management happen to be rather than by the security of either ledger. The wrapped tokens are only ever as good as that vault, and when it is emptied, both ledgers continue to balance perfectly while every wrapped token quietly becomes a claim on nothing.

ledger A ledger B the bridge vault the real bond, locked, all of it here wrapped copies a claim on that vault mint whoever takes the vault takes it from every holder here at once, and ledger B never finds out
A lock-and-mint bridge: the vault holds the whole backing on one ledger while copies circulate on another

Wider than the screen; scroll it sideways.

Draining it

The exercise builds the bridge and takes nine tenths of the vault.

Afterwards, ledger A balances: the vault fell and the liability written against it fell with it, so its books are internally consistent. Ledger B balances too, and has no idea anything happened; every wrapped token is still there, still transferable, still trading. The backing ratio has gone from one to one tenth and nothing anywhere raised an error.

vaultwrapped in circulationbacking per token
before1,0001,0001.00
after1001,0000.10

n = 1 trial · nine tenths of the vault taken

What the field learned

The expensive lesson was a design principle rather than a security practice, and it is worth stating plainly: do not copy an asset across a boundary; either swap it or settle it.

A swap means two parties exchange assets they already hold on their respective ledgers, so nothing is created and no vault exists. A settlement means the asset genuinely moves, with the record on one side reduced as the other rises. Both avoid the pooled honeypot entirely, because in neither case does anybody hold the backing for everybody.

The next lesson builds the swap version, and it is the answer this module has been walking towards since lesson 1.

Check yourself

1. What does a lock-and-mint bridge actually do to the asset?

It immobilises the original in a vault on one ledger and issues a claim on that vault somewhere else. The asset does not move; it is copied, and the copy’s value depends entirely on the vault continuing to hold the original.

2. After the drain, both ledgers balance. Why is that not reassuring?

Because each ledger checks only its own internal consistency, and both remain consistent. The property that mattered, that the wrapped tokens are backed by what is in the vault, spans both ledgers and neither one checks it. There is no error anywhere.

3. Why is the concentration the problem rather than the possibility of a hack?

Because a vault holds the backing for every holder at once, so one compromise reaches all of them simultaneously, and it is guarded by its own code rather than by either ledger’s security. A design that never pools the backing limits any single failure to one trade.

4. What principle did the field take from this?

Do not copy an asset across a boundary: swap it or settle it. A swap exchanges assets the two parties already hold, and a settlement genuinely moves one. Neither creates a vault holding everybody’s backing, which is the structure that produced the losses.

Do this

Build the bridge and empty it.

python3 code/bridge.py

The starter builds both ledgers and the backing ratio, and leaves you drain: take the amount out of the vault and write down the matching liability so ledger A still balances afterwards. The assertions check that the backing ratio falls to a tenth, that not one wrapped token was destroyed, and that both ledgers pass their own checks throughout.

The completed version is in solutions/bridge.py.

What you can now do. You can build a lock-and-mint bridge, drain it, and explain why both ledgers balance while every wrapped token has become a claim on nothing. The next lesson settles the same trade without copying anything at all.

What you can now do

You can drain a bridge vault and show every wrapped token is now an unbacked claim while both ledgers still balance.