Building a sort of optimistic rollup protocol which stores the resulting data either on mainnet of polygon, depending on the gas price
During the hackathon, we had been working on an optimistic rollup protocol. We were curious about how it works and what has to be done. Additionally, we wanted also to think if there is a possibility to optimize the protocol even more. We were able to build a simple optimistic rollup protocol, which consists of an Orderer, Executor, Publisher, and Smart Contract. The Orderer accepts transactions from Polygon, Ethereum, or directly from users and orderers those according to your protocol rules. Those transactions are then forwarded to the Executor, who executes the transactions locally. Once the execution step has been done, the resulting storage root + transaction is transferred to the Publisher. The Publisher takes the information from the Executor and sends those to our Smart Contract residing on Polygon and Ethereum. But it won't send it to both Smart Contracts, but rather choose the chain to send to based on the current gas price. In case Ethereum's gas price is very high, we are sending to information to Polygon. In case the gas price in Polygon is very high, we send the information to Ethereum.
Additionaly, we are compressing the transactions send to the Smart Contract, by removing the Nonce, Gas Price, and Gas Limit from every transaction. By compressing we are able to store more transactions in a transaction send to the Smart Contract.
The Orderer, Executor, and Publisher have been written in JavaScript and use Ethers.js for all Ethereum / Polygon-related functions. All services have been dockerized and are executed with docker-compose.
The local off-chain execution environment for the transactions is Ganache, running in it's own Docker Container along with the Executor :)
The Smart Contract has been written in Solidity using Hardhat and deployed on Ropsten and Polygon Mumbai.