A lock-and-mint bridge has one job: never mint on chain B what nobody locked on chain A. When that check fails, the first bad mint is rarely the expensive one. The expensive part is everyone else noticing and replaying it, block after block, until a human wakes up. The Nomad bridge lost about $190M that way over roughly two and a half hours.
The awkward part is where a guard would have to sit. A contract on Base sees Locked but never Minted. A contract on Unichain sees Minted but never Locked. Neither side can tell that a mint has no lock behind it, because each one is holding half of the ledger.
I built Ledgerlock for the Reactive Omni Buildathon to see how fast one contract that can read both halves shuts the bridge. All of it runs on testnets, and every measured number below can be regenerated from rows committed in the repo.
- Live page (no wallet needed): https://ledgerlock.edycu.dev/
- Judge path, six explorer links: https://ledgerlock.edycu.dev/judge
- Code + evidence: https://github.com/edycutjong/ledgerlock
The headline numbers
Over 100 attack runs on our own fixture bridge (Base Sepolia → Unichain Sepolia, guarded from Reactive Lasna):
| What | Result |
|---|---|
Both gates shut, block timestamps (mint block → the later gate's Paused block) |
p50 2 s · p95 3 s · max 3 s |
| Base gate alone, block timestamps | p50 1 s · p95 2 s |
| Unichain gate alone, same chain | p50 2 s · p95 3 s |
| Pauses on in-order legitimate transfers (lock before mint) | 0 of 80 |
Polling observer through public RPCs (an upper bound): mint → Lasna react() seen |
p50 3.873 s · p95 4.391 s |
| Polling observer: both gates seen shut | p50 5.92 s · p95 8.245 s · max 10.97 s |
| Burst runs | 20 of 20 stopped at the first reverted copycat; at most 1 copycat landed |
The claim is deliberately narrow: loss ≤ the mints that land inside the measured pause window. Ledgerlock does not stop the first unbacked mint. It stops the replay.
Inverting the ledger so the normal case is free
The obvious design is "every mint asks whether its lock exists." That puts a callback, and a cross-chain round trip, on every legitimate transfer. I flipped it. The reactive contract subscribes to Locked on Base and Minted on Unichain, and keeps one slot per bridge nonce. A mint whose lock is already recorded just marks the slot consumed. No callback goes out.
Only a mint with no matching lock does anything expensive, and it does it inside the same react() call. Here is the destination-side handler, lightly trimmed (from src/LedgerlockReactive.sol):
function _onDst(uint256 r, Side side, uint256 key, address to, uint256 amt, bytes32 originTx) internal {
uint8 dir = side == Side.MINT ? FWD : REV;
State storage st = states[r];
Slot storage s = slots[r][dir][key];
if (s.srcSeen && !s.consumed && s.srcAmt == amt && s.srcTo == to && s.pendSince == 0) {
s.consumed = true;
return;
}
uint256 hs = highestSrc[r][dir];
bool implausible = (key > hs && key - hs > routes[r].keySlack) || s.consumed || s.pendSince != 0 || s.srcSeen;
if (_addUnbacked(r, dir, to, amt)) implausible = true; // an amount that does not fit latches
_pauseBoth(r, originTx, key); // two callbacks in THIS react() (no-op if already paused)
emit Mismatch(r, side, key, amt, to, originTx, st.epoch);
if (implausible) _latch(r, Cause.REPEAT);
// … queue the mint as pending so its lock can still clear it
}
_pauseBoth sends one callback to a small gate contract on each chain. Each gate flips the bridge's own pause switch (comments trimmed):
function _pauseBoth(uint256 r, bytes32 originTx, uint256 key) internal {
State storage st = states[r];
if (st.paused && !_exhausted(r)) return; // copycats never re-bill a pause that is confirmed or still in flight
st.paused = true;
uint64 e = ++st.epoch;
emit PauseRequested(r, e, originTx, key);
_request(r, 0, Kind.PAUSE, e, originTx, key); // mint side first: it stops further issuance
_request(r, 1, Kind.PAUSE, e, originTx, key); // release side: freezes collateral exits
}
The mint-side gate stops further issuance. The release-side gate freezes collateral, so the attacker can't carry the forged balance home.
Because transfers can arrive out of order, a mint that might be legitimate is queued, not condemned. If its lock lands within the window W (60 s on our routes), both gates reopen on their own. I tested that path on purpose. In run lf-104 the lock was sent 8 seconds after its mint, the gates paused, and they reopened by themselves. In that run the longest a gate stayed shut was 5.1 s (observer clock). How long a false pause lasts depends on how late the lock is: across the 19 timed forced runs, where the lock arrives 2–20 s after the mint by design, a pause lasted p50 15.2 s and p95 23.1 s. A forger who guesses an implausible nonce, or reuses one, latches the route shut until the owner resolves it. That fail-closed choice has a cost of its own, covered in the limits below.
One attack, end to end
Run bu-021 is a forged 500 tUSD mint on Unichain Sepolia with nothing locked on Base. Every step is a transaction you can open:
- Forged mint mined on Unichain:
0x4bfe94f2…a84e, block 67743041 - One Lasna
react()with twoCallbackRequestlogs:0xbacbf5a0…9068 - Gate B
Pausedon Base:0x5eacdc82…4303. Gate UPausedon Unichain:0x60f4bcba…f3c4, block 67743043 - The next copycat reverts with
GatePaused, block 67743044. The forged release on Base reverts too.
Exposure for that run was 1,000 tUSD: the forged mint plus one copycat that landed before the pause. The judge page links each hash to its explorer.
For contrast, I ran a paired control: 5 runs per arm, same forged 500 tUSD mint. The unguarded copy of the bridge let 6 copycats land, issued 3,500 tUSD and released 500 tUSD of collateral. The guarded arm let 1 copycat land, issued 1,000 tUSD, and the release reverted. The two arms fire copycats on different schedules, so read this as an illustration of the effect, not a like-for-like rate.
The wall: my stopwatch said the effect came before the cause
This is the part I didn't expect. Latency is measured by an off-chain observer that polls public RPCs every 400 ms and stamps when it first sees each transaction. In 66 of 100 runs it saw the Base gate's Paused before the Lasna react() that caused it. In bu-021 above, the gate showed up at 2.184 s and the react() at 3.175 s.
A callback can't land before the transaction that requested it. So either the guard had a bug, or the clock did.
The block timestamps settle it. They never invert: 0 of 100. In bu-021 the mint is at block time 1794595469, gate B at 1794595470 and gate U at 1794595471. Lasna's react() is polled through a different RPC than the gates, and its first-seen time trails reality. We attribute this to Lasna RPC visibility lag. We didn't measure that lag separately, so I'm not putting a number on it.
What changed in the write-up because of it:
- Observer seconds are labelled "first seen through public RPCs", not on-chain times. Polling plus RPC delay means they are upper bounds.
- The headline is now the on-chain one: whole-second block timestamps, both gates p50 2 s / p95 3 s after the mint. The Base and Unichain sequencers are separate clocks, so allow about a second either way, and Lasna stamps its blocks up to a second before the origin block, so I publish no mint →
react()block delta at all. - In the demo video's live run, the observer's 7.986 s for gate U is called out as an upper bound. Its receipt is 2 blocks after the mint.
If you benchmark cross-chain automation from a laptop, check your ordering against block timestamps before you trust it.
How the evidence is kept honest
- Every pause is stored as a triple: origin tx → Lasna
react()→ gate callback.evidence/frozen3-triples.csvhas 846 rows. 500 of 500 callback legs are joined to theirreact(), with 0CallbackFailure. -
pnpm bench:summaryregenerates the latency table fromevidence/frozen3-bench-runs.csv. CI fails if the output isn't byte-for-byte identical to the committed summary. -
pnpm burst:verifyre-reads the 25 burst rows (20 headline + 5 paired control) from the chains with public RPC reads and no keys. - 113 contract tests and 29 reactive-kit Solidity tests run on the Reactive Test Lib, with 100% line, statement, branch and function coverage on
src/. One property test walks 262,144 random queue steps.
Honest limits
- The first unbacked mint is lost. So is anything else that lands before the pause.
-
Both routes are mine. Route A is my own fixture bridge with a reproduced Nomad-class bug. Route B is my own Hyperlane warp route, delivered by my own
Mailbox.process, because the public relayer didn't deliver within 6 minutes. - If Lasna stops, the guard is blind, and nothing pages the operator. A latched route stays shut until someone looks.
- A forger who picks a plausible nonce can hold the route shut until the owner resolves it. Legitimate mints wait.
- Reorg handling is simulation only, in the Test Lib, and labelled as such.
- Testnet only. No mainnet deployment and no outside users yet. Every bench transaction was sent by my own scripts.
- One measurement was dropped. Two Lasna self-callback requests were never delivered, so there are no hop-sensitivity rows.
Try it
You can check all of it without a wallet. The live status page reads both gates' state from public testnet RPCs: https://ledgerlock.edycu.dev/status/. The judge path is https://ledgerlock.edycu.dev/judge. To re-run the attack bench on your own deployment, DEMO.md has the steps (about 25 lREACT on Lasna).
Repo: https://github.com/edycutjong/ledgerlock. If you run a bridge or a warp route, I'd like to know what pause length you could live with.