Skip to main content
Orange isometric cube with a white U-shaped cutout
Language

Automatic translations of public app and website text. Your proof, messages, wallet addresses, and transaction amounts stay unchanged.

Back to blog
engineering

Five bugs that only a real chain finds

September 2, 2026 8 min read

We moved the daily check-in of a habit app onto Solana: stakes held in an escrow program, the once-a-day attestation running inside a MagicBlock Ephemeral Rollup, settlement paying finishers out of what the quitters forfeited. This is about the five things that broke, because all five compiled cleanly and passed a full hermetic test suite first.

1. The macros do not use your account order

The ephemeral-rollups SDK gives you two attribute macros. #[delegate] hands an account to a rollup; #[commit] brings it home. Both rewrite the account list, and neither does it in the order your Rust struct reads.

#[delegate] inserts a buffer, a delegation record and a metadata account before the field being delegated, then appends the owner program, the delegation program and the system program. #[commit] appends the magic program and then the magic context, in that order and not the other one.

Build the instruction the way the struct looks and you get ConstraintSeeds, which reads like a PDA derivation problem and is not one. The fix is trivial once you know. Knowing took a while.

2. The rollup charges more rent than the base layer

This one is a good trap because the failure lands nowhere near the cause.

Anchor's init funds a new account to exactly rent-exempt on the base layer. Delegate that account and everything succeeds. Then the first check-in inside the rollup fails with InsufficientFundsForRent, naming an address that does not appear anywhere in your instruction.

The rollup's rent floor is higher than L1's. An account that is exactly at the line on one chain is below it on the other. We now top the account up during delegation, before it leaves; the surplus comes back with it.

3. The router accepted transactions and threw them away

This is the one that had actually shipped, and the one worth the most to anyone building on the same stack.

The Magic Router is documented to inspect a transaction's writable accounts and forward it to whichever chain currently holds them. We built on that sentence. It is not true in the direction that matters.

Measured on devnet against a real, active, undelegated enrollment: the router accepts the send, returns a signature, and the transaction never confirms. The base layer has never heard of that signature. The account is unchanged. No error is raised at any point. The identical instruction sent straight to L1 lands immediately.

The router carries transactions only for accounts a rollup is already holding. For anything else it takes them and drops them, which is the worst failure shape available: the caller gets a signature and no error.

What made this expensive is that delegation is a separate, deliberate call. An account that has never been delegated is the default state. So routing everything through the router meant the ordinary case was the broken one, and it reported success while doing it.

We now read the account's owner and decide from that. One extra getAccountInfo buys a transaction that actually lands.

4. A confirmation is not a success

Found immediately after, while fixing the first one.

confirmTransaction resolves as soon as a transaction is included in a block. Whether it executed or reverted is in the result, not in whether the promise rejects. And with skipPreflight turned on, which the router requires because it does not implement simulateTransaction, nothing throws on the way either.

Our catch-up sweeper sent seven attestations, counted seven signatures, and reported seven days recorded against a chain whose day count had not moved at all. Every one had been refused.

Two changes. Read conf.value.err on every send. And count effects from chain state rather than from transactions sent: the sweeper now reports days recorded as the difference the chain actually moved.

5. The last day is a different instruction

This is the one that would have taken money from people who did everything right.

The program has two ways to record a day. attest_day counts one. submit_proof counts the final one and returns the stake with interest and registers the player as a finisher. Both refuse once proven days equals the challenge length.

Our check-in path called attest_day on every accepted proof, including the last. So on day fourteen of fourteen: the counter reaches the total, submit_proof is refused forever after with ChallengeAlreadyComplete, the stake is never returned, and the player is never counted as a finisher. Then the cohort window closes, and an enrollment sitting at full days with an active status satisfies the condition for being lapsed.

Somebody who checked in every single morning for two weeks would have had their entire stake slashed into the pool that pays everybody else.

It is guarded in three places now, because one guard for that is not enough: the check-in switches instruction on the last day, the catch-up sweeper stops one day short, and the lapse path refuses outright when proven days has reached the total, whatever the schedule arithmetic says.

What we changed about how we work

Every one of these was invisible to a compiler and to a test suite that did not touch a chain. Three of them returned success while doing nothing.

So the scripts that verify this stack do not mock. They create a real cohort, enrol a real wallet with real staked tokens, delegate, prove a day inside the rollup, commit it home, and read the balances back before and after. They refuse to run anywhere but devnet, checked by genesis hash before anything is minted. When we say the settlement path works, that sentence means twenty-four assertions ran against token accounts that moved.

The other habit worth keeping: after fixing something, break it again on purpose and check the test fails. Two of our assertions passed against deliberately broken code, which meant they were testing nothing. One of them was the test for the router bug.

Where this is

Devnet, unaudited, not holding real money. The write-up with the reasoning behind each decision is in ARCHITECTURE.md in the repository, and the commands that check every claim are listed on our engineering page.

One small step, today

Make room for a little progress.

Choose a manageable commitment and try the daily routine with a free challenge.