Smart contracts are programs that are executed on the blockchain and can hold, manage and transfer assets in the form of cryptocurrencies. 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 side-effects. 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 heavy computations. A fixed cost to each atomic operation, and the initiator of a function call pays the total gas cost as a transaction fee. This helps prevent DoS attacks, but 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. Hence, no rational party has an incentive to act dishonestly. 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.
翻译:智能合约是运行在区块链上的程序,能够以加密货币形式持有、管理和转移资产。合约的执行在链上进行并遵循共识机制,即区块链网络中的每个节点都必须执行函数调用并追踪其副作用。在以太坊等可编程区块链中,引入了Gas概念以防止恶意方通过执行大量计算来拖慢网络的拒绝服务攻击。每项原子操作均设定固定成本,函数调用发起者需支付总Gas成本作为交易费用。这有助于防止拒绝服务攻击,但导致费用极为高昂。例如,仅2022年以太坊上Gas总消耗量就达177万ETH(约43亿美元)。本论文提出“懒合约”作为缓解这些成本的解决方案。我们的方案将大部分计算移至链下,确保每次函数调用仅消耗极少量Gas,同时在链上保留足够数据以保证合约变量状态与资金所有权实现隐性共识。仅当合约双方对当前状态存在分歧时(这必然意味着至少一方存在不诚实行为),才会触发函数的完整链上执行。此时协议可识别不诚实方并通过让其承担全部Gas成本进行惩罚,因此理性方均无动机实施不诚实行为。最后,我们基于2022年1月至2023年1月以太坊上参与9,055,492笔交易的160,735个真实Solidity合约开展广泛实验,结果表明该方法能降低55.4%的总Gas消耗,相当于节省1.099亿美元的Gas费用。