Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Upgrade to py-evm v0.2.0 alpha 43 #637

Merged
merged 5 commits into from May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions .circleci/config.yml
Expand Up @@ -195,12 +195,12 @@ jobs:
environment:
TOXENV: py36-rpc-blockchain

py36-core:
py36-eth1-core:
<<: *common
docker:
- image: circleci/python:3.6
environment:
TOXENV: py36-core
TOXENV: py36-eth1-core
py36-integration:
<<: *common
docker:
Expand Down Expand Up @@ -282,12 +282,12 @@ jobs:
environment:
TOXENV: py37-rpc-state-zero_knowledge

py37-core:
py37-eth1-core:
<<: *common
docker:
- image: circleci/python:3.7
environment:
TOXENV: py37-core
TOXENV: py37-eth1-core
py37-integration:
<<: *common
docker:
Expand Down Expand Up @@ -350,7 +350,7 @@ workflows:
jobs:
- py36-docs

- py37-core
- py37-eth1-core
- py37-wheel-cli
- py37-p2p
- py37-eth2-core
Expand All @@ -372,7 +372,7 @@ workflows:
- py36-rpc-state-tangerine_whistle
- py36-rpc-blockchain

- py36-core
- py36-eth1-core
- py36-wheel-cli
- py36-p2p
- py36-eth2-core
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Expand Up @@ -3,6 +3,8 @@
import os
from setuptools import setup, find_packages

PYEVM_DEPENDENCY = "py-evm==0.2.0a43"


deps = {
'p2p': [
Expand All @@ -25,7 +27,7 @@
"eth-utils>=1.5.1,<2",
"ipython>=6.2.1,<7.0.0",
"plyvel==1.0.5",
"py-evm==0.2.0a42",
PYEVM_DEPENDENCY,
"web3==4.4.1",
"lahja==0.12.0",
"termcolor>=1.1.0,<2.0.0",
Expand Down Expand Up @@ -88,7 +90,7 @@
"lru-dict>=1.1.6",
"py-ecc>=1.6.0,<2.0.0",
"rlp>=1.1.0,<2.0.0",
"py-evm==0.2.0a42",
PYEVM_DEPENDENCY,
"ssz==0.1.0a8",
],
'libp2p': [
Expand Down
14 changes: 7 additions & 7 deletions tests/core/p2p-proto/test_state_sync.py
Expand Up @@ -14,14 +14,14 @@

from trie import HexaryTrie

from eth.db.backends.memory import MemoryDB
from eth.db.atomic import AtomicDB
from eth.db.account import AccountDB
from eth.tools.logging import ExtendedDebugLogger

from trinity.sync.full.hexary_trie import HexaryTrieSync
from trinity.sync.full.state import StateSync, TrieNodeRequestTracker

from tests.core.integration_test_helpers import FakeAsyncMemoryDB
from tests.core.integration_test_helpers import FakeAsyncAtomicDB


# produces a branch node with an extention node who's encoding is less than 32
Expand Down Expand Up @@ -59,8 +59,8 @@ def test_trie_sync(random, event_loop):
# like this for now. https://github.com/HypothesisWorks/hypothesis/pull/1343
async def _test_trie_sync():
src_trie, contents = make_random_trie(random)
dest_db = FakeAsyncMemoryDB()
nodes_cache = MemoryDB()
dest_db = FakeAsyncAtomicDB()
nodes_cache = AtomicDB()
scheduler = HexaryTrieSync(src_trie.root_hash, dest_db, nodes_cache,
ExtendedDebugLogger("test"))
requests = scheduler.next_batch()
Expand All @@ -78,7 +78,7 @@ async def _test_trie_sync():


def make_random_state(n):
raw_db = MemoryDB()
raw_db = AtomicDB()
account_db = AccountDB(raw_db)
contents = {}
for _ in range(n):
Expand All @@ -100,8 +100,8 @@ def make_random_state(n):
@pytest.mark.asyncio
async def test_state_sync():
raw_db, state_root, contents = make_random_state(1000)
dest_db = FakeAsyncMemoryDB()
nodes_cache = MemoryDB()
dest_db = FakeAsyncAtomicDB()
nodes_cache = AtomicDB()
scheduler = StateSync(state_root, dest_db, nodes_cache, ExtendedDebugLogger('test'))
requests = scheduler.next_batch(10)
while requests:
Expand Down
1 change: 0 additions & 1 deletion tests/json-fixtures-over-rpc/test_rpc_fixtures.py
Expand Up @@ -124,7 +124,6 @@
# not much research went into why, yet.
('GeneralStateTests/stSStoreTest/InitCollision_d0g0v0.json', 'InitCollision_d0g0v0_Constantinople'), # noqa: E501
('GeneralStateTests/stSStoreTest/InitCollision_d1g0v0.json', 'InitCollision_d1g0v0_Constantinople'), # noqa: E501
('GeneralStateTests/stSStoreTest/InitCollision_d2g0v0.json', 'InitCollision_d2g0v0_Constantinople'), # noqa: E501
('GeneralStateTests/stSStoreTest/InitCollision_d3g0v0.json', 'InitCollision_d3g0v0_Constantinople'), # noqa: E501
('GeneralStateTests/stSStoreTest/InitCollision_d0g0v0.json', 'InitCollision_d0g0v0_ConstantinopleFix'), # noqa: E501
('GeneralStateTests/stSStoreTest/InitCollision_d1g0v0.json', 'InitCollision_d1g0v0_ConstantinopleFix'), # noqa: E501
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
@@ -1,6 +1,6 @@
[tox]
envlist=
py{36,37}-{core,p2p,integration,lightchain_integration,eth2-core,eth2-fixtures,eth2-integration,plugins}
py{36,37}-{eth1-core,p2p,integration,lightchain_integration,eth2-core,eth2-fixtures,eth2-integration,plugins}
py36-long_run_integration
py36-rpc-blockchain
py36-rpc-state-{frontier,homestead,tangerine_whistle,spurious_dragon,byzantium,constantinople,petersburg}
Expand All @@ -20,7 +20,7 @@ usedevelop=True
passenv =
TRAVIS_EVENT_TYPE
commands=
core: pytest -n 4 {posargs:tests/core/}
eth1-core: pytest -n 4 {posargs:tests/core/}
eth2-core: pytest -n 4 {posargs:tests/eth2/core/}
eth2-fixtures: pytest -n 4 {posargs:tests/eth2/fixtures-tests/}
eth2-integration: pytest -n 4 {posargs:tests/eth2/integration/}
Expand Down
27 changes: 14 additions & 13 deletions trinity/rpc/modules/eth.py
Expand Up @@ -87,12 +87,13 @@ async def get_header(chain: BaseAsyncChain, at_block: Union[str, int]) -> BlockH
return at_header


async def account_db_at_block(chain: BaseAsyncChain,
at_block: Union[str, int],
read_only: bool=True) ->BaseAccountDB:
async def state_at_block(
chain: BaseAsyncChain,
at_block: Union[str, int],
read_only: bool=True) ->BaseAccountDB:
at_header = await get_header(chain, at_block)
vm = chain.get_vm(at_header)
return vm.state.account_db
return vm.state


async def get_block_at_number(chain: BaseAsyncChain, at_block: Union[str, int]) -> BaseBlock:
Expand Down Expand Up @@ -120,7 +121,7 @@ def dict_to_spoof_transaction(
nonce = txn_dict['nonce']
else:
vm = chain.get_vm(header)
nonce = vm.state.account_db.get_nonce(sender)
nonce = vm.state.get_nonce(sender)

gas_price = txn_dict.get('gasPrice', 0)
gas = txn_dict.get('gas', header.gas_limit)
Expand Down Expand Up @@ -177,8 +178,8 @@ async def gasPrice(self) -> str:

@format_params(decode_hex, to_int_if_hex)
async def getBalance(self, address: Address, at_block: Union[str, int]) -> str:
account_db = await account_db_at_block(self.chain, at_block)
balance = account_db.get_balance(address)
state = await state_at_block(self.chain, at_block)
balance = state.get_balance(address)

return hex(balance)

Expand Down Expand Up @@ -208,17 +209,17 @@ async def getBlockTransactionCountByNumber(self, at_block: Union[str, int]) -> s

@format_params(decode_hex, to_int_if_hex)
async def getCode(self, address: Address, at_block: Union[str, int]) -> str:
account_db = await account_db_at_block(self.chain, at_block)
code = account_db.get_code(address)
state = await state_at_block(self.chain, at_block)
code = state.get_code(address)
return encode_hex(code)

@format_params(decode_hex, to_int_if_hex, to_int_if_hex)
async def getStorageAt(self, address: Address, position: int, at_block: Union[str, int]) -> str:
if not is_integer(position) or position < 0:
raise TypeError("Position of storage must be a whole number, but was: %r" % position)

account_db = await account_db_at_block(self.chain, at_block)
stored_val = account_db.get_storage(address, position)
state = await state_at_block(self.chain, at_block)
stored_val = state.get_storage(address, position)
return encode_hex(int_to_big_endian(stored_val))

@format_params(decode_hex, to_int_if_hex)
Expand All @@ -239,8 +240,8 @@ async def getTransactionByBlockNumberAndIndex(self,

@format_params(decode_hex, to_int_if_hex)
async def getTransactionCount(self, address: Address, at_block: Union[str, int]) -> str:
account_db = await account_db_at_block(self.chain, at_block)
nonce = account_db.get_nonce(address)
state = await state_at_block(self.chain, at_block)
nonce = state.get_nonce(address)
return hex(nonce)

@format_params(decode_hex)
Expand Down