So the whole idea behind optimistic rollups is that the L1 network “optimistically” accepts the results of a smart contract as calculated by a group that runs the same contract’s code independently outside the network (L2).
This is great because it means you’re not spending expensive network computation time handling the internal smart contract logic, you only pay to set the final outcome’s values on the network.
The issue then becomes, what if that group cheats and changes the outcome? That’s where the real genius of the solution comes in. Since the smart contract logic is still deployed, but not running, on L1, anyone can independently verify that the results are correct by running the inputs through the smart contract themselves on their own system, and checking that they get the same output as the outside group did.
In the event that they have a different outcome, they can pay a fee to have the L1 network actually rerun the logic, but this time using the smart contract that’s normally unused on L1. If the L1 network finds a different result, then all results that were produced from that point forward by the outside group are undone, and never actually finalized on the L1 network.
The downside of this is that there has to be a delay between when the optimistic rollup runs the contract, and when the result is finalized to L1, to give people time to potentially invalidate the result.
However, if you keep your money in the optimistic rollup, you can continue to use that money for additional transactions in the same rollup, even though it hasn’t been finalized on L1 yet.
It’s an absolutely genius way of optimizing things, because you take advantage of basic game theory to allow the network to offload most computation off network, while still maintaining a trustless system.
I’m continually amazed by the genius applications of game theory to smart contracts, I never fully appreciated them until the past year or so.
I highly recommend this post by Vitalik if you are interested in a more technical explanation: