Font Size: a A A

Symbolic Execution Based Optimization Of Ethereum Smart Contracts' Bytecode

Posted on:2022-08-11Degree:MasterType:Thesis
Country:ChinaCandidate:S Y ShenFull Text:PDF
GTID:2518306725981339Subject:Computer technology
Abstract/Summary:PDF Full Text Request
Blockchain is a new distributed computing paradigm that has attracted wide attention with the development of cryptocurrencies such as Bitcoin.Smart contracts are computer programs that run on a blockchain platform to help users manage digital assets.As one of the most popular blockchain platforms,Ethereum has built in a programming language called Solidity for ordinary users to write smart contracts,and provides a compilation suite that can convert the source code of a contract into bytecode that can be interpreted and executed.Unlike ordinary program execution,the execution of a contracts' bytecode consumes gas,which can be converted into real currency.The excessive gas cost of contract execution will bring extremely high transaction costs to users.Therefore,it is of great significance to reduce the gas cost of the bytecode execution.To reduce the gas cost,currently relevant scholars have conducted preliminary studies by identifying optimizable code patterns in bytecode.However,previous researches only focus on predefined code patterns,and have a very limited range of application.Also there is no deployment of optimized contracts in real scenarios for experimental evaluation.To address the limitations of the above researches,we find two global optimizable code patterns by investigating a large number of contracts' bytecodes,and propose two bytecode optimization methods based on symbolic execution.Our main contribution is as follows:1.Bytecode optimization method for redundant assertion.Since there may be a large number of security vulnerabilities in the contract,users and the Solidity compiler have inserted many assertions for security check,but many of them are redundant,which brings additional overhead.In order to optimize redundant assertions,we first use symbolic execution to determine instructions'jump relationship within the bytecode to construct a control flow graph;then conduct the reachability analysis of assertion-related nodes based on the control flow graph;finally use symbolic execution to identify bytecode sequences related to redundant assertions,and then remove the bytecode sequences to reduce the gas cost.2.Bytecode optimization method for repeated reads of storage.Because the bytecode's execution environment does not have registers to store temporary variables,the Solidity compiler often causes repeated reads of the same storage space when generating instructions for reading storage,and the gas cost is very high.In order to reduce the number of storage's reads and reduce instructions' execution overhead,we use symbolic execution to identify repeated reads of storage through the control flow graph,and calculate the semantically equivalent bytecode sequence with lower gas overhead,and then replace the bytecode sequence to reduce the gas cost.3.Tool implementation and experimental evaluation.Based on the above work,we implement the prototype tool evmOp to analyze and optimize redundant assertion and storage's repeated reads,and conduct experimental evaluation.We use 1147 real-world contracts to build an Ethereum private chain and use the real transaction data corresponding to the contract to conduct experiments.Then we compare the deployment cost and transaction cost of the contract before and after optimization.The experimental data shows that for the above two types of optimizable code patterns,evmOp can reduce gas overhead by up to 7%and 42%.This shows that the optimization methods we propose can efficiently optimize the contract's bytecode and significantly reduce the user's transaction overhead.
Keywords/Search Tags:blockchain, smart contract, Ethereum, gas optimization, bytecode optimization
PDF Full Text Request
Related items