ETHEREUM: A SECURE DECENTRALISED GENERALISED TRANSACTION LEDGER BYZANTIUM VERSION 7e819ec - 2019-10-20 7
more time to develop proof-of-stake and preventing the
network from “freezing” up.
The canonical gas limit
H
l
of a block of header
H
must
fulfil the relation:
H
l
< P (H)
H
l
+
P (H)
H
l
1024
∧(47)
H
l
> P (H)
H
l
−
P (H)
H
l
1024
∧
H
l
> 5000
H
s
is the timestamp (in Unix’s time()) of block
H
and
must fulfil the relation:
(48) H
s
> P (H)
H
s
This mechanism enforces a homeostasis in terms of the
time between blocks; a smaller period between the last two
blocks results in an increase in the difficulty level and thus
additional computation required, lengthening the likely
next period. Conversely, if the period is too large, the
difficulty, and expected time to the next block, is reduced.
The nonce, H
n
, must satisfy the relations:
(49) n 6
2
256
H
d
∧ m = H
m
with (n, m) = PoW(H
n
, H
n
, d).
Where
H
n
is the new block’s header
H
, but without the
nonce and mix-hash components,
d
being the current DAG,
a large data set needed to compute the mix-hash, and
PoW
is the proof-of-work function (see section 11.5): this evalu-
ates to an array with the first item being the mix-hash, to
prove that a correct DAG has been used, and the second
item being a pseudo-random number cryptographically
dependent on H and d. Given an approximately uniform
distribution in the range [0
,
2
64
), the expected time to find
a solution is proportional to the difficulty, H
d
.
This is the foundation of the security of the blockchain
and is the fundamental reason why a malicious node can-
not propagate newly created blocks that would otherwise
overwrite (“rewrite”) history. Because the nonce must sat-
isfy this requirement, and because its satisfaction depends
on the contents of the block and in turn its composed
transactions, creating new, valid, blocks is difficult and,
over time, requires approximately the total compute power
of the trustworthy portion of the mining peers.
Thus we are able to define the block header validity
function V (H):
V (H) ≡ n 6
2
256
H
d
∧ m = H
m
∧(50)
H
d
= D(H) ∧
H
g
≤ H
l
∧
H
l
< P (H)
H
l
+
P (H)
H
l
1024
∧
H
l
> P (H)
H
l
−
P (H)
H
l
1024
∧
H
l
> 5000 ∧
H
s
> P (H)
H
s
∧
H
i
= P (H)
H
i
+ 1 ∧
kH
x
k ≤ 32
where (n, m) = PoW(H
n
, H
n
, d)
Noting additionally that
extraData
must be at most
32 bytes.
5. Gas and Payment
In order to avoid issues of network abuse and to sidestep
the inevitable questions stemming from Turing complete-
ness, all programmable computation in Ethereum is subject
to fees. The fee schedule is specified in units of gas (see Ap-
pendix G for the fees associated with various computation).
Thus any given fragment of programmable computation
(this includes creating contracts, making message calls,
utilising and accessing account storage and executing op-
erations on the virtual machine) has a universally agreed
cost in terms of gas.
Every transaction has a specific amount of gas associ-
ated with it:
gasLimit
. This is the amount of gas which
is implicitly purchased from the sender’s account balance.
The purchase happens at the according
gasPrice
, also
specified in the transaction. The transaction is consid-
ered invalid if the account balance cannot support such
a purchase. It is named
gasLimit
since any unused gas
at the end of the transaction is refunded (at the same
rate of purchase) to the sender’s account. Gas does not
exist outside of the execution of a transaction. Thus for
accounts with trusted code associated, a relatively high
gas limit may be set and left alone.
In general, Ether used to purchase gas that is not re-
funded is delivered to the beneficiary address, the address
of an account typically under the control of the miner.
Transactors are free to specify any
gasPrice
that they
wish, however miners are free to ignore transactions as
they choose. A higher gas price on a transaction will there-
fore cost the sender more in terms of Ether and deliver
a greater value to the miner and thus will more likely be
selected for inclusion by more miners. Miners, in general,
will choose to advertise the minimum gas price for which
they will execute transactions and transactors will be free
to canvas these prices in determining what gas price to
offer. Since there will be a (weighted) distribution of min-
imum acceptable gas prices, transactors will necessarily
have a trade-off to make between lowering the gas price
and maximising the chance that their transaction will be
mined in a timely manner.
6. Transaction Execution
The execution of a transaction is the most complex part
of the Ethereum protocol: it defines the state transition
function Υ. It is assumed that any transactions executed
first pass the initial tests of intrinsic validity. These include:
(1)
The transaction is well-formed RLP, with no addi-
tional trailing bytes;
(2) the transaction signature is valid;
(3)
the transaction nonce is valid (equivalent to the
sender account’s current nonce);
(4)
the gas limit is no smaller than the intrinsic gas,
g
0
, used by the transaction; and
(5)
the sender account balance contains at least the
cost, v
0
, required in up-front payment.
Formally, we consider the function Υ, with
T
being a
transaction and σ the state:
(51) σ
0
= Υ(σ, T )
Thus
σ
0
is the post-transactional state. We also define
Υ
g
to evaluate to the amount of gas used in the execution
of a transaction, Υ
l
to evaluate to the transaction’s accrued