Skip to content

Commit

Permalink
Merge pull request #166 from carver/upgrade-pyevm
Browse files Browse the repository at this point in the history
Upgrade py-evm
  • Loading branch information
carver authored Sep 30, 2019
2 parents c1a2aee + 3d57437 commit 3ffa12b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Unreleased
----------

- Misc

- Upgrade to py-evm v0.3.0-b7
https://github.com/ethereum/eth-tester/pull/166

v0.2.0-beta.2
------------

Expand Down
11 changes: 7 additions & 4 deletions eth_tester/backends/pyevm/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
from .utils import is_pyevm_available

if is_pyevm_available():
from eth.constants import (
GENESIS_PARENT_HASH,
)
from eth.exceptions import (
HeaderNotFound as EVMHeaderNotFound,
InvalidInstruction as EVMInvalidInstruction,
Expand All @@ -59,6 +62,7 @@
EVMHeaderNotFound = None
EVMInvalidInstruction = None
EVMRevert = None
GENESIS_PARENT_HASH = None


ZERO_ADDRESS = 20 * b'\x00'
Expand All @@ -72,7 +76,6 @@
GENESIS_BLOCK_NUMBER = 0
GENESIS_DIFFICULTY = 131072
GENESIS_GAS_LIMIT = 3141592
GENESIS_PARENT_HASH = ZERO_HASH32
GENESIS_COINBASE = ZERO_ADDRESS
GENESIS_NONCE = b'\x00\x00\x00\x00\x00\x00\x00*' # 42 encoded as big-endian-integer
GENESIS_MIX_HASH = ZERO_HASH32
Expand Down Expand Up @@ -233,7 +236,7 @@ def _execute_and_revert_transaction(chain, transaction, block_number="latest"):

state = vm.state
snapshot = state.snapshot()
computation = state.execute_transaction(transaction)
computation = state.apply_transaction(transaction)
state.revert(snapshot)
return computation

Expand Down Expand Up @@ -300,11 +303,11 @@ def take_snapshot(self):
def revert_to_snapshot(self, snapshot):
block = self.chain.get_block_by_hash(snapshot)
chaindb = self.chain.chaindb

chaindb._set_as_canonical_chain_head(chaindb.db, block.header.hash, GENESIS_PARENT_HASH)
if block.number > 0:
chaindb._set_as_canonical_chain_head(chaindb.db, block.header.hash)
self.chain.import_block(block)
else:
chaindb._set_as_canonical_chain_head(chaindb.db, block.header.hash)
self.chain = self.chain.from_genesis_header(chaindb.db, block.header)

#
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
'py-evm': [
# Pin py-evm to exact version, until it leaves alpha.
# EVM is very high velocity and might change API at each alpha.
"py-evm==0.3.0a1",
"py-evm==0.3.0a7",
"eth-hash[pysha3]>=0.1.4,<1.0.0;implementation_name=='cpython'",
"eth-hash[pycryptodome]>=0.1.4,<1.0.0;implementation_name=='pypy'",
],
Expand Down

0 comments on commit 3ffa12b

Please sign in to comment.