A rollup that tracks the gas consumption of every smart contract in another rollup by re-deriving it from L1 with a custom execution engine
A rollup's defining feature is that its entire state can be derived solely from L1 data. This project leverages this to create a rollup that exactly mirrors another rollup, except for some additional rules in its execution engine. These rules record the gas used by each smart contract and save that data onchain. Like a typical OP Stack rollup, this special blockchain can be fault-proven* in another chain, enabling trustless access to gas consumption data. Imagine a rollup operator like Optimism or Base that wanted to reward builders on its network by sharing a portion of collected rollup fees based on their onchain impact. For trustless distribution, data about a builder's impact—such as usage of their contracts, generated fees, and processed ETH—would have to be available on the chain where funds were to be distributed. While the generic execution engine of OP Stack rollups doesn't index this information, this project's approach can be used to make the required data accessible in them without needing to modify their source code.
*Optimism's Fault Proof System is still in development
First, I forked the OP Stack's rollup node. I added a few lines of golang code to op-geth to make it track the gas usage of smart contracts and store that data in a mapping in the storage trie of a hard-coded account. Then I slightly modified op-node (also golang) to support re-deriving another L2 with a modded execution engine.
Second, I extended the Optimism monorepo's local devnet setup code to optionally include an indexer rollup node. I used make, python, docker, and docker-compose.
Finally, I built a demo where users can prove the gas consumption of a smart contract in the original L2 through a web client. I used solidity and foundry for the contract that validates proofs and vanilla HTML, JS with ethers.js and chart.js, and CSS with Tailwind for the client.