Skip to content

Commit cb6f44c

Browse files
authored
Merge pull request #2021 from carver/london-tests
Run London fork tests
2 parents 421ebbc + 92095eb commit cb6f44c

File tree

15 files changed

+118
-42
lines changed

15 files changed

+118
-42
lines changed

.circleci/config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ jobs:
8282
- image: circleci/python:3.6
8383
environment:
8484
TOXENV: py36-native-blockchain-istanbul
85+
py36-native-blockchain-london:
86+
<<: *common
87+
docker:
88+
- image: circleci/python:3.6
89+
environment:
90+
TOXENV: py36-native-blockchain-london
8591
py36-native-blockchain-petersburg:
8692
<<: *common
8793
docker:
@@ -247,6 +253,7 @@ workflows:
247253
- py36-native-blockchain-frontier
248254
- py36-native-blockchain-homestead
249255
- py36-native-blockchain-istanbul
256+
- py36-native-blockchain-london
250257
- py36-native-blockchain-petersburg
251258
- py36-native-blockchain-tangerine_whistle
252259
- py36-native-blockchain-spurious_dragon

docs/guides/quickstart.rst

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ This guide teaches how to use Py-EVM as a library. For contributors, please chec
88
:doc:`Contributing Guide </contributing>` which explains how to set everything up for development.
99

1010

11-
Installing on Ubuntu
12-
--------------------
11+
Installing Python on Ubuntu
12+
---------------------------
1313

1414
Py-EVM requires Python 3.6 as well as some tools to compile its dependencies. On Ubuntu, the
1515
``python3.6-dev`` package contains everything we need. Run the following command to install it.
@@ -25,30 +25,19 @@ we need to install the ``python3-pip`` package through the following command.
2525
2626
apt-get install python3-pip
2727
28-
.. note::
29-
.. include:: /fragments/virtualenv_explainer.rst
30-
31-
Then, we need make to sure you have the latest version of ``pip`` so that all dependencies can be installed correctly:
32-
33-
.. code:: sh
34-
35-
pip3 install -U pip
3628
37-
Finally, we can install the ``py-evm`` package via pip.
38-
39-
.. code:: sh
40-
41-
pip3 install -U py-evm
42-
43-
Installing on macOS
44-
-------------------
29+
Installing Python on macOS
30+
--------------------------
4531

4632
First, install Python 3 with brew:
4733

4834
.. code:: sh
4935
5036
brew install python3
5137
38+
Installing py-evm
39+
-----------------
40+
5241
.. note::
5342
.. include:: /fragments/virtualenv_explainer.rst
5443

docs/guides/understanding_the_mining_process.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,4 +380,4 @@ zero value transfer transaction.
380380
... )
381381

382382
>>> chain.mine_block(mix_hash=mix_hash, nonce=nonce)
383-
<ByzantiumBlock(#Block #1-0x41f6..2913)>
383+
<ByzantiumBlock(#Block #1-0xe372..385c)>

eth/_utils/headers.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,12 @@ def compute_gas_limit_bounds(previous_limit: int) -> Tuple[int, int]:
105105
Compute the boundaries for the block gas limit based on the parent block.
106106
"""
107107
boundary_range = previous_limit // GAS_LIMIT_ADJUSTMENT_FACTOR
108-
upper_bound = min(GAS_LIMIT_MAXIMUM, previous_limit + boundary_range)
109-
lower_bound = max(GAS_LIMIT_MINIMUM, previous_limit - boundary_range)
110-
return lower_bound, upper_bound
108+
109+
# the boundary range is the exclusive limit, therefore the inclusive bounds are
110+
# (boundary_range - 1) and (boundary_range + 1) for upper and lower bounds, respectively
111+
upper_bound_inclusive = min(GAS_LIMIT_MAXIMUM, previous_limit + boundary_range - 1)
112+
lower_bound_inclusive = max(GAS_LIMIT_MINIMUM, previous_limit - boundary_range + 1)
113+
return lower_bound_inclusive, upper_bound_inclusive
111114

112115

113116
def compute_gas_limit(parent_header: BlockHeaderAPI, genesis_gas_limit: int) -> int:
@@ -152,12 +155,14 @@ def compute_gas_limit(parent_header: BlockHeaderAPI, genesis_gas_limit: int) ->
152155

153156
gas_limit = max(
154157
GAS_LIMIT_MINIMUM,
155-
parent_header.gas_limit - decay + usage_increase
158+
# + 1 because the decay is an exclusive limit we have to remain inside of
159+
(parent_header.gas_limit - decay + 1) + usage_increase
156160
)
157161

158162
if gas_limit < GAS_LIMIT_MINIMUM:
159163
return GAS_LIMIT_MINIMUM
160164
elif gas_limit < genesis_gas_limit:
161-
return parent_header.gas_limit + decay
165+
# - 1 because the decay is an exclusive limit we have to remain inside of
166+
return parent_header.gas_limit + decay - 1
162167
else:
163168
return gas_limit

eth/_utils/rlp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,6 @@ def validate_rlp_equal(obj_a: BaseBlock,
106106

107107

108108
validate_imported_block_unchanged = validate_rlp_equal(
109-
obj_a_name="block",
110-
obj_b_name="imported block",
109+
obj_a_name="locally executed block",
110+
obj_b_name="proposed block",
111111
)

eth/tools/_utils/normalization.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,8 @@ def normalize_block(block: Dict[str, Any]) -> Dict[str, Any]:
567567
for transaction
568568
in block['transactions']
569569
]
570+
if 'expectException' in block:
571+
normalized_block['expectException'] = block['expectException']
570572
return normalized_block
571573

572574

eth/vm/base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,13 @@ def validate_uncle(cls,
669669
f"the limit ({uncle.gas_limit})"
670670
)
671671

672+
uncle_parent_gas_limit = uncle_parent.gas_limit
673+
if not hasattr(uncle_parent, 'base_fee_per_gas') and hasattr(uncle, 'base_fee_per_gas'):
674+
# if Berlin -> London transition, double the parent limit for validation
675+
uncle_parent_gas_limit *= 2
676+
677+
validate_gas_limit(uncle.gas_limit, uncle_parent_gas_limit)
678+
672679
#
673680
# State
674681
#

eth/vm/logic/system.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,15 @@ def __call__(self, computation: ComputationAPI) -> None:
163163
computation.stack_push_int(0)
164164
computation.return_data = b''
165165
if insufficient_funds:
166-
err_msg = f"Insufficient Funds: {storage_address_balance} < {stack_data.endowment}"
166+
self.logger.debug2(
167+
"%s failure: %s",
168+
self.mnemonic,
169+
f"Insufficient Funds: {storage_address_balance} < {stack_data.endowment}"
170+
)
167171
elif stack_too_deep:
168-
err_msg = "Stack limit reached"
169-
self.logger.debug2("%s failure: %s", self.mnemonic, err_msg,)
172+
self.logger.debug2("%s failure: %s", self.mnemonic, "Stack limit reached")
173+
else:
174+
raise RuntimeError("Invariant: error must be insufficient funds or stack too deep")
170175
return
171176

172177
call_data = computation.memory_read_bytes(
@@ -183,11 +188,12 @@ def __call__(self, computation: ComputationAPI) -> None:
183188
is_collision = computation.state.has_code_or_nonce(contract_address)
184189

185190
if is_collision:
191+
computation.stack_push_int(0)
192+
computation.return_data = b''
186193
self.logger.debug2(
187194
"Address collision while creating contract: %s",
188195
encode_hex(contract_address),
189196
)
190-
computation.stack_push_int(0)
191197
return
192198

193199
child_msg = computation.prepare_child_message(

newsfragments/2017.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Pass all London tests from the ethereum/tests repo

newsfragments/2021.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Make header gas limit more restrictive. Was too permissive by one gas. Tightened the bounds.
2+
- Validate uncle gas limits are within bounds. This was previously not validated at all.

0 commit comments

Comments
 (0)