Professional Documents
Culture Documents
Performance Benchmarking For Ethereum Opcodes: October 2018
Performance Benchmarking For Ethereum Opcodes: October 2018
net/publication/330474687
CITATIONS READS
12 861
3 authors:
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
Ethereum Gas costs and performance mesurment and benchmarking View project
All content following this page was uploaded by Amjad Aldweesh on 07 June 2019.
Abstract—Ethereum is a public (permissionless) blockchain in Ethereum every node also stores the most recent state of
with a Turing complete execution machine for smart contracts. smart contracts. The native currency of Ethereum is Ether. In
Miners that execute a smart contract receive a fee determined addition to transactions transferring Ether, Ethereum has two
by the gas associated with the operation codes (opcodes) in the
smart contract. It is important that the gas award is proportional more transactions to support smart contracts: contract-creation
to the computation resources required, to assure that incentives and contract-invoking.
are aligned and denial of service attacks are avoided. Currently, Ethereum has two types of accounts externally owned
the amount of gas awarded is set statically for each opcode, but accounts(e.g., users) and contract accounts. The former is
it is unknown if these values are correct for various computer controlled by private keys to create and sign transactions,
architectures. Therefore, we propose in this paper a benchmark
approach to assess the computational resources required per whereas the latter is controlled by their associated smart
opcode. We apply the benchmark approach to PC and MAC contract code. The associated code for the contract accounts
as a first illustration of the approach. is stored in the blockchain in a bytecode form and interpreted
Index Terms—Blockchain, Ethereum, Smart Contract, Bench- by the EVM. In the Ethereum blockchain, miners have a
marking. pool to maintain pending transactions(transactions that have
not been executed yet). Each time a miner wants to create
I. I NTRODUCTION and append a new block to the blockchain, they select a
Bitcoin and its underlying technology blockchain have number of transactions from their pool to be executed. If
gained huge interest from industry and academia. Ethereum is the transaction invokes an existing contract, miners execute
a permissionless crypto-currency blockchain that distinguishes the code associated with that contract using their local EVM.
itself by a Turing-complete execution machine, the Ethereum Upon successful execution, the state of the smart contact
Virtual Machine (EVM) [1], which executes distributed ap- variables, storage and balance will be adjusted accordingly.
plications through smart contracts. Miners that execute smart Gas is an abstraction that has been introduced in the
contracts charge a fee to the submitter, as compensation for Ethereum network to reward miners for their computation
them contributing their computing resources. Gas costs are set efforts invested to execute transactions. The submitter of a
per operational code (opcode) by the Ethereum foundation, transaction pays miners a fee according to the amount of
accounting for computation overheads, storage, and network Gas used by the miner, which depends on the complexity
costs [2]. of the transaction. In particular, each operation code in the
Inappropriate gas costs for opcodes might enable DoS transaction has associated a pre-defined amount of gas. Gas
attacks, if the cost is low but computational effort is high. introduces a manner to mitigate DoS attacks, since attackers
The Ethereum foundation has had to adjust the cost for would have to pay the fee associated with a transaction that
certain operational codes in response to DoS attacks, see, takes a long time (or run forever) to be executed. More
e.g., [3]. In addition, if the gas cost is not proportional to in general, the correct operation of Ethereum relies on the
the computational effort, miners are not awarded fairly, thus fact that miners are awarded proportional to their investment
potentially disincentivising miners to operate the blockchain of computational resources. It is therefore essential to have
in the best manner [4]. ways to assess and ensure that the gas cost associated with
As mentioned, gas cost per opcode is currently set statically a transaction is proportional to the cost of executing that
in [2], and it would therefore be useful to assess whether transaction [4]. For a complete solution, one wants to consider
the set values are correct for different hardware architectures. the actual cost of executing a smart contract to a miner, is
Therefore, we propose a benchmark approach to investigate dominated by energy usage. In this paper, we focus on CPU
whether the gas costs of EVM opcodes are set properly or usage, as a first approximation to miner costs.
not. We run the benchmark for PC and MAC, and show that
gas costs are not always proportional to computational effort. III. O PCODE B ENCHMARK D ESIGN
EVM is a stack-based virtual machine where each op-
II. BACKGROUND eration code is pushed onto the stack and executed. The
Ethereum blockchain is similar to Bitcoin’s, in that it oper- Ethereum foundation [2] has proposed a gas cost for each
ates as a distributed ledger, in which all transactions history is EVM opcode (e.g., opcode for additiona costs 3 units of gas)
recorded and stored in every node in the network. Additionally, depending on the computation overhead, storage and network
costs required by the opcode.The storage and network costs 1.50
CO M P UTAT IO N A L E FFO R T
PC
LT
Mac
NOT OR SGT SL T X OR
2.60 2.59
2.10
2.27
2.46
2.15
2.53
2.06
2017, pp. 164–186.
1.60 1.57 1.61
1.50 [4] M. Alharby and A. van Moorsel, “The impact of profit uncertainty on
1.10
0.60
0.48
0.68
0.41 0.38 0.38 0.44 0.48
0.71 0.72
0.48
miner decisions in blockchain systems,” Electronic Notes in Theoretical
0.35
0.10
AND BYTE EQ GT ISZERO LT NOT OR SGT SLT XOR Computer Science, vol. 340, pp. 151–167, 2018.
Mean PC Mean MAC
[5] A. Aldweesh, M. Alharby, E. Solaiman, and A. van Moorsel, “Perfor-
mance benchmarking of smart contracts to assess miner incentives in
Fig. 1. CPU Usage MAC vs PC ethereum,” in Dependable Computing Conference (EDCC), 2018 14th
European. IEEE, 2018.
Figure 1 presents a comparison of CPU usage for each [6] E. Foundation. (2014) Pyeth client. [Online]. Available:
https://bit.ly/2siwj2g
opcode between the MAC and the PC. The x-axis gives the