· ~1 min

Recovering lost rewards by replaying the chain

At bemo we inherited a legacy reward-accrual path that had been quietly undercounting some users’ rewards. By the time it surfaced, the wrong numbers had been compounding for a while: stored balances disagreed with what users had actually earned, and nobody could say by how much without doing the math properly.

The tempting fix is a forward patch: correct the accrual formula, maybe add a one-off compensation, move on. We didn’t do that, because a forward patch preserves every historical error forever — you keep paying interest on a number you know is wrong.

Instead we treated the blockchain as the source of truth it is and recomputed everything from scratch:

The replay engine was plain Python. The interesting work was in the guarantees around it:

Users got their missing rewards, and the incident left behind something more useful than an apology: a replayable pipeline. The next time anyone doubts a balance, the answer is one replay away, not one spreadsheet-archaeology session away.

← back to ~/ruslan-korneev