Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests v7 beta1 and updates Istanbul numbers #1871

Merged
merged 19 commits into from
Nov 5, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ jobs:
- image: circleci/python:3.6
environment:
TOXENV: py36-native-blockchain-homestead
py36-native-blockchain-istanbul:
<<: *common
docker:
- image: circleci/python:3.6
environment:
TOXENV: py36-native-blockchain-istanbul
py36-native-blockchain-petersburg:
<<: *common
docker:
Expand Down Expand Up @@ -171,6 +177,7 @@ workflows:
- py36-native-blockchain-constantinople
- py36-native-blockchain-frontier
- py36-native-blockchain-homestead
- py36-native-blockchain-istanbul
- py36-native-blockchain-petersburg
- py36-native-blockchain-tangerine_whistle
- py36-native-blockchain-spurious_dragon
Expand Down
5 changes: 5 additions & 0 deletions eth/chains/goerli/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@
# Petersburg
#
PETERSBURG_GOERLI_BLOCK = BlockNumber(0)

#
# Istanbul
#
ISTANBUL_GOERLI_BLOCK = BlockNumber(1561651)
4 changes: 4 additions & 0 deletions eth/chains/mainnet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
MAINNET_CHAIN_ID,
BYZANTIUM_MAINNET_BLOCK,
PETERSBURG_MAINNET_BLOCK,
ISTANBUL_MAINNET_BLOCK,
TANGERINE_WHISTLE_MAINNET_BLOCK,
HOMESTEAD_MAINNET_BLOCK,
SPURIOUS_DRAGON_MAINNET_BLOCK,
Expand All @@ -34,6 +35,7 @@
ByzantiumVM,
FrontierVM,
HomesteadVM,
IstanbulVM,
PetersburgVM,
SpuriousDragonVM,
TangerineWhistleVM,
Expand Down Expand Up @@ -80,6 +82,7 @@ class MainnetHomesteadVM(MainnetDAOValidatorVM):
SPURIOUS_DRAGON_MAINNET_BLOCK,
BYZANTIUM_MAINNET_BLOCK,
PETERSBURG_MAINNET_BLOCK,
ISTANBUL_MAINNET_BLOCK,
)
MAINNET_VMS = (
FrontierVM,
Expand All @@ -88,6 +91,7 @@ class MainnetHomesteadVM(MainnetDAOValidatorVM):
SpuriousDragonVM,
ByzantiumVM,
PetersburgVM,
IstanbulVM,
)

MAINNET_VM_CONFIGURATION = tuple(zip(MAINNET_FORK_BLOCKS, MAINNET_VMS))
Expand Down
5 changes: 5 additions & 0 deletions eth/chains/mainnet/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@
# Petersburg Block
#
PETERSBURG_MAINNET_BLOCK = BlockNumber(7280000)

#
# Istanbul Block
#
ISTANBUL_MAINNET_BLOCK = BlockNumber(9069000)
15 changes: 12 additions & 3 deletions eth/tools/_utils/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,17 @@ def normalize_account_state(account_state: FixtureAccountState) -> AccountState:
}


def normalize_post_state(postate: FixtureAccountState) -> AccountState:
# poststate might not be present in some fixtures
# https://github.com/ethereum/tests/issues/637#issuecomment-534072897
if postate is None:
return {}
else:
return normalize_account_state(postate)


@to_dict
def normalize_post_state(post_state: Dict[str, Any]) -> Iterable[Tuple[str, bytes]]:
def normalize_post_state_hash(post_state: Dict[str, Any]) -> Iterable[Tuple[str, bytes]]:
yield 'hash', decode_hex(post_state['hash'])
if 'logs' in post_state:
yield 'logs', decode_hex(post_state['logs'])
Expand All @@ -391,7 +400,7 @@ def normalize_statetest_fixture(fixture: Dict[str, Any],
normalized_fixture = {
'env': normalize_environment(fixture['env']),
'pre': normalize_account_state(fixture['pre']),
'post': normalize_post_state(post_state),
'post': normalize_post_state_hash(post_state),
'transaction': normalize_unsigned_transaction(
fixture['transaction'],
post_state['indexes'],
Expand Down Expand Up @@ -538,7 +547,7 @@ def normalize_blockchain_fixtures(fixture: Dict[str, Any]) -> Dict[str, Any]:
'genesisBlockHeader': normalize_block_header(fixture['genesisBlockHeader']),
'lastblockhash': decode_hex(fixture['lastblockhash']),
'pre': normalize_account_state(fixture['pre']),
'postState': normalize_account_state(fixture['postState']),
'postState': normalize_post_state(fixture.get('postState')),
'network': fixture['network'],
}

Expand Down
9 changes: 7 additions & 2 deletions eth/tools/fixtures/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
FrontierVM,
HomesteadVM as BaseHomesteadVM,
SpuriousDragonVM,
IstanbulVM,
)


Expand Down Expand Up @@ -121,6 +122,10 @@ def chain_vm_configuration(fixture: Dict[str, Any]) -> Iterable[Tuple[int, Type[
return (
(0, PetersburgVM),
)
elif network == 'Istanbul':
return (
(0, IstanbulVM),
)
elif network == 'FrontierToHomesteadAt5':
HomesteadVM = BaseHomesteadVM.configure(support_dao_fork=False)
return (
Expand All @@ -146,10 +151,10 @@ def chain_vm_configuration(fixture: Dict[str, Any]) -> Iterable[Tuple[int, Type[
(0, SpuriousDragonVM),
(5, ByzantiumVM),
)
elif network == 'ByzantiumToConstantinopleAt5':
elif network == 'ByzantiumToConstantinopleFixAt5':
return (
(0, ByzantiumVM),
(5, ConstantinopleVM),
(5, PetersburgVM),
)
else:
raise ValueError(f"Network {network} does not match any known VM rules")
Expand Down
21 changes: 12 additions & 9 deletions eth/vm/forks/spurious_dragon/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@


@to_set
def collect_touched_accounts(computation: BaseComputation) -> Iterable[Address]:
def collect_touched_accounts(computation: BaseComputation,
ancestor_had_error: bool = False) -> Iterable[Address]:
"""
Collect all of the accounts that *may* need to be deleted based on
`EIP-161 <https://eips.ethereum.org/EIPS/eip-161>`_.
Expand All @@ -32,7 +33,7 @@ def collect_touched_accounts(computation: BaseComputation) -> Iterable[Address]:

# collect those explicitly marked for deletion ("beneficiary" is of SELFDESTRUCT)
for beneficiary in sorted(set(computation.accounts_to_delete.values())):
if computation.is_error and computation.is_origin_computation:
if computation.is_error or ancestor_had_error:
# Special case to account for geth+parity bug
# https://github.com/ethereum/EIPs/issues/716
if beneficiary == THREE:
Expand All @@ -43,15 +44,17 @@ def collect_touched_accounts(computation: BaseComputation) -> Iterable[Address]:

# collect account directly addressed
if computation.msg.to != constants.CREATE_CONTRACT_ADDRESS:
if computation.is_error and computation.is_origin_computation:
# Special case to account for geth+parity bug
# https://github.com/ethereum/EIPs/issues/716
if computation.is_error or ancestor_had_error:
# collect RIPEMD160 precompile even if ancestor computation had error;
# otherwise, skip collection from children of errored-out computations;
# if there were no special-casing for RIPEMD160, we'd simply `pass` here
if computation.msg.to == THREE:
yield computation.msg.to
else:
yield computation.msg.to

# recurse into nested computations if this one was successful
if not computation.is_error:
for child in computation.children:
yield from collect_touched_accounts(child)
# recurse into nested computations (even errored ones, since looking for RIPEMD160)
for child in computation.children:
yield from collect_touched_accounts(
child,
ancestor_had_error=(computation.is_error or ancestor_had_error))
2 changes: 1 addition & 1 deletion fixtures
2 changes: 2 additions & 0 deletions newsfragments/1858.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Set Istanbul block number for mainnet to 9069000, and for Görli to 1561651, as per
`EIP-1679 <https://eips.ethereum.org/EIPS/eip-1679#activation>`_.
3 changes: 3 additions & 0 deletions newsfragments/1858.internal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Update upstream test fixtures to `v7.0.0 beta.1 <https://github.com/ethereum/tests/releases/tag/v7.0.0-beta.1>`_
and address the two arising disagreements on what accounts should be collected for state trie clearing (as per
`EIP-161 <https://eips.ethereum.org/EIPS/eip-161>`_) if a nested call frame had an error.
1 change: 1 addition & 0 deletions newsfragments/validate_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'.performance.rst',
'.doc.rst',
'.removal.rst',
'.internal.rst',
'.misc.rst',
}

Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ directory = "removal"
name = "Deprecations and Removals"
showcontent = true

[[tool.towncrier.type]]
directory = "internal"
name = "Internal Changes - for Contributors"
showcontent = true

[[tool.towncrier.type]]
directory = "misc"
name = "Miscellaneous internal changes"
Expand Down
10 changes: 5 additions & 5 deletions scripts/benchmark/checks/deploy_dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
)

FIRST_TX_GAS_LIMIT = 367724
SECOND_TX_GAS_LIMIT = 62050
THIRD_TX_GAS_LIMIT = 104789
SECOND_TX_GAS_LIMIT = 63042
THIRD_TX_GAS_LIMIT = 105781
FORTH_TX_GAS_LIMIT = 21272
FIFTH_TX_GAS_LIMIT = 21272

Expand Down Expand Up @@ -153,7 +153,7 @@ def deploy_dos_contract(self, chain: MiningChain) -> None:
block, receipt, computation = chain.apply_transaction(tx)
self.deployed_contract_address = computation.msg.storage_address

assert computation.is_success
computation.raise_if_error()

# Interact with the deployed contract by calling the totalSupply() API ?????
self.dos_contract = self.w3.eth.contract(
Expand All @@ -176,7 +176,7 @@ def sstore_uint64(self, chain: MiningChain) -> None:

block, receipt, computation = chain.apply_transaction(tx2)

assert computation.is_success
computation.raise_if_error()

def create_empty_contract(self, chain: MiningChain) -> None:
w3_tx3 = self.dos_contract.functions.createEmptyContract().buildTransaction(W3_TX_DEFAULTS)
Expand All @@ -193,7 +193,7 @@ def create_empty_contract(self, chain: MiningChain) -> None:

block, receipt, computation = chain.apply_transaction(tx3)

assert computation.is_success
computation.raise_if_error()

def sstore_uint64_revert(self, chain: MiningChain) -> None:
w3_tx4 = self.dos_contract.functions.storageEntropyRevert().buildTransaction(W3_TX_DEFAULTS)
Expand Down
12 changes: 8 additions & 4 deletions scripts/benchmark/checks/erc20_interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ def _deploy_simple_token(self, chain: MiningChain) -> None:
# Keep track of deployed contract address
self.deployed_contract_address = computation.msg.storage_address

assert computation.is_success
computation.raise_if_error()

# Keep track of simple_token object
self.simple_token = self.w3.eth.contract(
address=Web3.toChecksumAddress(encode_hex(self.deployed_contract_address)),
Expand All @@ -174,7 +175,8 @@ def _erc_transfer(self, addr: str, chain: MiningChain) -> None:

block, receipt, computation = chain.apply_transaction(tx)

assert computation.is_success
computation.raise_if_error()

assert to_int(computation.output) == 1

def _erc_approve(self, addr2: str, chain: MiningChain) -> None:
Expand All @@ -195,7 +197,8 @@ def _erc_approve(self, addr2: str, chain: MiningChain) -> None:

block, receipt, computation = chain.apply_transaction(tx)

assert computation.is_success
computation.raise_if_error()

assert to_int(computation.output) == 1

def _erc_transfer_from(self, addr1: str, addr2: str, chain: MiningChain) -> None:
Expand All @@ -218,7 +221,8 @@ def _erc_transfer_from(self, addr1: str, addr2: str, chain: MiningChain) -> None

block, receipt, computation = chain.apply_transaction(tx)

assert computation.is_success
computation.raise_if_error()

assert to_int(computation.output) == 1


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"cached-property>=1.5.1,<2",
"eth-bloom>=1.0.3,<2.0.0",
"eth-keys>=0.2.1,<0.3.0",
"eth-typing>=2.0.0,<3.0.0",
"eth-typing>=2.2.0,<3.0.0",
"eth-utils>=1.7.0,<2.0.0",
"lru-dict>=1.1.6",
"mypy_extensions>=0.4.1,<1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import datetime
import logging
import os
from eth.tools.logging import DEBUG2_LEVEL_NUM
from eth_utils.logging import DEBUG2_LEVEL_NUM

@pytest.yield_fixture(autouse=True)
def _file_logging(request):
Expand Down
4 changes: 2 additions & 2 deletions tests/core/chain-object/test_build_block_incrementally.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_building_block_incrementally_with_single_transaction(
private_key=funded_address_private_key,
)
_, _, computation = chain.apply_transaction(tx)
assert computation.is_success
computation.raise_if_error()

# test that the *latest* block hasn't changed
assert chain.get_canonical_head().hash == head_hash
Expand All @@ -57,7 +57,7 @@ def test_building_block_incrementally_with_multiple_transactions(
)
txns.append(tx)
_, _, computation = chain.apply_transaction(tx)
assert computation.is_success
computation.raise_if_error()

# test that the pending block has the expected number of transactions
vm = chain.get_vm()
Expand Down
4 changes: 2 additions & 2 deletions tests/core/chain-object/test_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ def test_import_block(chain, tx):
if hasattr(chain, 'apply_transaction'):
# working on a Mining chain which can directly apply transactions
new_block, _, computation = chain.apply_transaction(tx)
assert computation.is_success
computation.raise_if_error()
else:
# working on a non-mining chain, so we have to build the block to apply manually
new_block, receipts, computations = chain.build_block_with_transactions([tx])
assert computations[0].is_success
computations[0].raise_if_error()

block, _, _ = chain.import_block(new_block)

Expand Down
11 changes: 11 additions & 0 deletions tests/core/chain-object/test_contract_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
ByzantiumVM,
ConstantinopleVM,
PetersburgVM,
IstanbulVM,
)


Expand Down Expand Up @@ -212,6 +213,16 @@ def test_get_transaction_result(
'useLotsOfGas()',
OutOfGas,
),
(
IstanbulVM,
'doRevert()',
Revert,
),
(
IstanbulVM,
'useLotsOfGas()',
OutOfGas,
),
),
)
def test_get_transaction_result_revert(
Expand Down
Loading