Lazy Contracts: Alleviating High Gas Costs by Secure and Trustless Off-chain Execution of Smart Contracts

The Hong Kong University of Science and Technology
Department of Computer Science and Engineering


MPhil Thesis Defence


Title: "Lazy Contracts: Alleviating High Gas Costs by Secure and
Trustless Off-chain Execution of Smart Contracts"

By

Mr. Soroush FAROKHNIA


Abstract:

Smart contracts are programs that are executed on the blockchain and can hold,
manage and transfer assets in the form of cryptocurrencies. Any party can
interact with a smart contract by creating blockchain transactions that call
the desired functions of the contract. The contract's execution is then
performed on-chain and is subject to consensus, i.e. every node on the
blockchain network has to run the function calls and keep track of their
sideeffects, including updates to the variables in the contract's storage, as
well as transfers of cryptocurrency in and out of the contract. In most
programmable blockchains, such as Ethereum, the notion of gas is introduced to
prevent DoS attacks by malicious parties who might try to slow down the network
by performing time-consuming and resource-heavy computations. A fixed gas cost
is assigned to every atomic operation and the originator of a function call has
to pay the total gas cost of all its operations as a transaction fee. While the
gas model has largely succeeded in its goal of avoiding DoS attacks, the
resulting fees are extremely high. For example, in 2022, on Ethereum alone,
there has been a total gas usage of 1.77 Million ETH ≈ 4.3 Billion USD.

This thesis proposes "lazy contracts" as a solution to alleviate these costs.
Our solution moves most of the computation off-chain, ensuring that each
function call incurs only a tiny amount of gas usage, while preserving enough
data on-chain to guarantee an implicit consensus about the state of the
contract variables and ownership of funds. A complete on-chain execution of the
functions will only be triggered in case two parties to the contract are in
disagreement about the current state, which in turn can only happen if at least
one party is dishonest. In such cases, our protocol can identify the dishonest
party and penalize them by having them pay for the entire gas usage. In short,
using our protocol, no rational party has an incentive to act dishonestly and
only dishonest parties have to pay the full gas cost of the contract. If all
parties are rational and therefore honest, the total gas usage of the contract
shrinks dramatically.

Additionally, we provide an implementation of our protocol as a wrapper that
can be applied to any smart contract before its deployment on the blockchain.
Although we focus on Ethereum contracts written in Solidity, the same technique
can is also applicable to any other programmable blockchain. Finally, we
perform extensive experiments over 160,735 real-world Solidity contracts that
were involved in 9,055,492 transactions in January 2022 — January 2023 on
Ethereum and show that our approach reduces the overall gas usage by 55.4%,
which amounts to an astounding saving of 109.9 Million USD in gas fees.


Date:                   Wednesday, 26 July 2023

Time:                   2:00pm - 4:00pm

Venue:                  Room 3494
                        lifts 25/26

Committee Members:      Dr. Amir Goharshady (Supervisor)
                        Prof. Cunsheng Ding (Chairperson)
                        Dr. Jiasi Shen


**** ALL are Welcome ****