Decentralized gas-free Safe transaction with AA refunds on L2 with Transaction Inclusion Proofs
This project is a proof of concept for a novel implementation of gas-free Safe transactions with account abstraction refunds on L2.
Users of Safe do not need to execute their own transactions, rather using transaction inclusion proofs, anyone can execute a Safe transaction and receive a refund for the cost on L2.
This concept is an improvement on existing relayer models:
The vision is that using this design we can build permissionless account abstraction systems for Multisig Safe transactions that works out of the box in a multichain environment. There is a single L2 contract that can service any number of different blockchains without any additional code on those chains.
I think it is worthwhile exploring this system in greater depth as a possiblity for significantly increasing Safe ecosystem decentralization. While this demo focuses specifically on the implementation with Safe,
How does it work?
TL:DR Transaction Inclusion Proofs (TIPs) are a kind of primitive for building Intents where anyone can put a user's Intent onchain.
Transaction Inclusion Proofs are a novel kind of proof that proves only a transaction was successfully included in a block. Nothing more, nothing less. This is different than most proof systems which simultaneously prove something and the state of that something. TIPs only prove transaction inclusion, assuming that the authorization of action is protected by the smart contracts included in the transaction. This means we can assume if a transaction is successfully included in a block, the originating user intended the outcome transaction to happen, regardless of who puts the transaction onchain.
In this demo, we are awarding whoever puts a multisig transaction with Safe onchain with some "ETHParis Tokens" on L2 as a payment.
System Architecture
L1: A multisig contract that is used in the demo to create transactions using SafeKit API but not publish them onchain, but rather publish the Safe transaction to the Safe Transaction service.
L2: A smart contract Trusted Oracle tracks L1 Blocknumbers and L1 BlockHashes. A TransactionInclusionProver smart contract reads from the Trusted Oracle and takes a proof generated offchain, and calculates if the proof is valid.
Offchain: A SDK that is responsible for building the transaction proof to be submitted to the onchain L2 smart contracts.
DEMO:
A script using SafeCore is used to create, deploy and fund a new Safe to Ethereum Goerli.
Using the standard Safe UI or using the 'proposeTransaction' script with SafeKit API, a transaction is created on a Goerli Safe. This tx it is not executed, but the transaction is only signed.
A relayed running in the background uses the SafeKit API to poll for new queued transactions.
(Note: in the future this process would also be decentralized, see scripts/ExecuteTransactionDecentralized.ts for some initial explorations)
The relay is responsibile for:
Technologies used:
Safe{Core} Protocol, Safe{Core} APIKIT, Limechain TIP SDK, nodejs, Celo, Ethereum Goerli, Solidity
Celo was used as an L2 for its cheap transactions, future alignment with Ethereum, and its ideal placement for a shelling point for transaction refunding to power the future of Defi. Unfortunately, there was no L1->Celo arbitrary message bridge available, but in the end, we put the message layer to be out of scope.
Safe{Core} Protocol Kit was used to deploy Safes and the Safe{Core} API Kit was used to create Txs and fetch queued transactions.
This project was built with the assistance of AI technologies for code generation, formatting, error checking, and troubleshooting.
The AI technologies used were ChatGPT and Github CoPilot.
This project uses the smart contracts developed by the LimeChain team here as the prooving system. The idea of a transaction inclusion proof system was devised by Dennison Bertram prior to the hackathon. The first functional implementation of the concept was created by the team at LimeChain (https://limechain.tech/) prior to the hackathon.
Smart contracts: https://github.com/LimeChain/tx-inclusion-contracts/ Proving POC: https://github.com/LimeChain/tx-inclusion-poc-script/ SDK: https://github.com/LimeChain/tx-inclusion-sdk
A modified version of the LimeChain prover and Oracle smart contract was deployed for this project. The modifications were minimal convenience features and do not have a material impact on the project.
Modified contracts: https://github.com/crazyrabbitLTC/limechain-transaction-inclusion-proofs-demo-ethparis
The project references the LimeChain POC and utilizes the SDK. While Dennison Bertram has discssed in public the applications of Transaction Inclusion Proofs, the code in this project is original and was created in person during ETHParis 2023.
Out of Scope:
Creating a trustless blocknumber and blockhash oracle from L1 to L2 was out of scope for this project. I did however build a trustless relayer that could implement trustless updates to the Oracle. It was not used in the final project. See: scripts/blockRelayer.ts
Notes:
I needed to build several versions of the scripts as I worked through the project design in real time. The earlier version of the scripts can be found in the scripts directory. The final demo code used is script/execTxPushProof.js