diff --git a/.circleci/config.yml b/.circleci/config.yml index 82338dd7b1..3d818a85da 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -82,6 +82,12 @@ jobs: - image: circleci/python:3.6 environment: TOXENV: py36-native-blockchain-istanbul + py36-native-blockchain-london: + <<: *common + docker: + - image: circleci/python:3.6 + environment: + TOXENV: py36-native-blockchain-london py36-native-blockchain-petersburg: <<: *common docker: @@ -247,6 +253,7 @@ workflows: - py36-native-blockchain-frontier - py36-native-blockchain-homestead - py36-native-blockchain-istanbul + - py36-native-blockchain-london - py36-native-blockchain-petersburg - py36-native-blockchain-tangerine_whistle - py36-native-blockchain-spurious_dragon diff --git a/docs/guides/quickstart.rst b/docs/guides/quickstart.rst index 1fb4c444e8..0e15e2f3e8 100644 --- a/docs/guides/quickstart.rst +++ b/docs/guides/quickstart.rst @@ -8,8 +8,8 @@ This guide teaches how to use Py-EVM as a library. For contributors, please chec :doc:`Contributing Guide ` which explains how to set everything up for development. -Installing on Ubuntu --------------------- +Installing Python on Ubuntu +--------------------------- Py-EVM requires Python 3.6 as well as some tools to compile its dependencies. On Ubuntu, the ``python3.6-dev`` package contains everything we need. Run the following command to install it. @@ -25,23 +25,9 @@ we need to install the ``python3-pip`` package through the following command. apt-get install python3-pip -.. note:: - .. include:: /fragments/virtualenv_explainer.rst - -Then, we need make to sure you have the latest version of ``pip`` so that all dependencies can be installed correctly: - -.. code:: sh - - pip3 install -U pip -Finally, we can install the ``py-evm`` package via pip. - -.. code:: sh - - pip3 install -U py-evm - -Installing on macOS -------------------- +Installing Python on macOS +-------------------------- First, install Python 3 with brew: @@ -49,6 +35,9 @@ First, install Python 3 with brew: brew install python3 +Installing py-evm +----------------- + .. note:: .. include:: /fragments/virtualenv_explainer.rst diff --git a/docs/guides/understanding_the_mining_process.rst b/docs/guides/understanding_the_mining_process.rst index 5e8f7b884a..c206a3cf0d 100644 --- a/docs/guides/understanding_the_mining_process.rst +++ b/docs/guides/understanding_the_mining_process.rst @@ -380,4 +380,4 @@ zero value transfer transaction. ... ) >>> chain.mine_block(mix_hash=mix_hash, nonce=nonce) - + diff --git a/eth/_utils/headers.py b/eth/_utils/headers.py index 90712d232b..98b8cb94bb 100644 --- a/eth/_utils/headers.py +++ b/eth/_utils/headers.py @@ -105,9 +105,12 @@ def compute_gas_limit_bounds(previous_limit: int) -> Tuple[int, int]: Compute the boundaries for the block gas limit based on the parent block. """ boundary_range = previous_limit // GAS_LIMIT_ADJUSTMENT_FACTOR - upper_bound = min(GAS_LIMIT_MAXIMUM, previous_limit + boundary_range) - lower_bound = max(GAS_LIMIT_MINIMUM, previous_limit - boundary_range) - return lower_bound, upper_bound + + # the boundary range is the exclusive limit, therefore the inclusive bounds are + # (boundary_range - 1) and (boundary_range + 1) for upper and lower bounds, respectively + upper_bound_inclusive = min(GAS_LIMIT_MAXIMUM, previous_limit + boundary_range - 1) + lower_bound_inclusive = max(GAS_LIMIT_MINIMUM, previous_limit - boundary_range + 1) + return lower_bound_inclusive, upper_bound_inclusive 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) -> gas_limit = max( GAS_LIMIT_MINIMUM, - parent_header.gas_limit - decay + usage_increase + # + 1 because the decay is an exclusive limit we have to remain inside of + (parent_header.gas_limit - decay + 1) + usage_increase ) if gas_limit < GAS_LIMIT_MINIMUM: return GAS_LIMIT_MINIMUM elif gas_limit < genesis_gas_limit: - return parent_header.gas_limit + decay + # - 1 because the decay is an exclusive limit we have to remain inside of + return parent_header.gas_limit + decay - 1 else: return gas_limit diff --git a/eth/_utils/rlp.py b/eth/_utils/rlp.py index 862ef1b7d1..f737dd83b9 100644 --- a/eth/_utils/rlp.py +++ b/eth/_utils/rlp.py @@ -106,6 +106,6 @@ def validate_rlp_equal(obj_a: BaseBlock, validate_imported_block_unchanged = validate_rlp_equal( - obj_a_name="block", - obj_b_name="imported block", + obj_a_name="locally executed block", + obj_b_name="proposed block", ) diff --git a/eth/tools/_utils/normalization.py b/eth/tools/_utils/normalization.py index d70f5eedb8..34b678e278 100644 --- a/eth/tools/_utils/normalization.py +++ b/eth/tools/_utils/normalization.py @@ -567,6 +567,8 @@ def normalize_block(block: Dict[str, Any]) -> Dict[str, Any]: for transaction in block['transactions'] ] + if 'expectException' in block: + normalized_block['expectException'] = block['expectException'] return normalized_block diff --git a/eth/vm/base.py b/eth/vm/base.py index a80f5c9f9e..826131367a 100644 --- a/eth/vm/base.py +++ b/eth/vm/base.py @@ -669,6 +669,13 @@ def validate_uncle(cls, f"the limit ({uncle.gas_limit})" ) + uncle_parent_gas_limit = uncle_parent.gas_limit + if not hasattr(uncle_parent, 'base_fee_per_gas') and hasattr(uncle, 'base_fee_per_gas'): + # if Berlin -> London transition, double the parent limit for validation + uncle_parent_gas_limit *= 2 + + validate_gas_limit(uncle.gas_limit, uncle_parent_gas_limit) + # # State # diff --git a/eth/vm/logic/system.py b/eth/vm/logic/system.py index d0b8c5b58b..214346f49b 100644 --- a/eth/vm/logic/system.py +++ b/eth/vm/logic/system.py @@ -163,10 +163,15 @@ def __call__(self, computation: ComputationAPI) -> None: computation.stack_push_int(0) computation.return_data = b'' if insufficient_funds: - err_msg = f"Insufficient Funds: {storage_address_balance} < {stack_data.endowment}" + self.logger.debug2( + "%s failure: %s", + self.mnemonic, + f"Insufficient Funds: {storage_address_balance} < {stack_data.endowment}" + ) elif stack_too_deep: - err_msg = "Stack limit reached" - self.logger.debug2("%s failure: %s", self.mnemonic, err_msg,) + self.logger.debug2("%s failure: %s", self.mnemonic, "Stack limit reached") + else: + raise RuntimeError("Invariant: error must be insufficient funds or stack too deep") return call_data = computation.memory_read_bytes( @@ -183,11 +188,12 @@ def __call__(self, computation: ComputationAPI) -> None: is_collision = computation.state.has_code_or_nonce(contract_address) if is_collision: + computation.stack_push_int(0) + computation.return_data = b'' self.logger.debug2( "Address collision while creating contract: %s", encode_hex(contract_address), ) - computation.stack_push_int(0) return child_msg = computation.prepare_child_message( diff --git a/newsfragments/2017.feature.rst b/newsfragments/2017.feature.rst new file mode 100644 index 0000000000..00797779d9 --- /dev/null +++ b/newsfragments/2017.feature.rst @@ -0,0 +1 @@ +Pass all London tests from the ethereum/tests repo diff --git a/newsfragments/2021.bugfix.rst b/newsfragments/2021.bugfix.rst new file mode 100644 index 0000000000..46bbe04183 --- /dev/null +++ b/newsfragments/2021.bugfix.rst @@ -0,0 +1,2 @@ +- Make header gas limit more restrictive. Was too permissive by one gas. Tightened the bounds. +- Validate uncle gas limits are within bounds. This was previously not validated at all. diff --git a/newsfragments/2021.doc.rst b/newsfragments/2021.doc.rst new file mode 100644 index 0000000000..ed1775857f --- /dev/null +++ b/newsfragments/2021.doc.rst @@ -0,0 +1 @@ +Squash sphinx warnings with a small documentation reorg. diff --git a/tests/core/vm/test_london.py b/tests/core/vm/test_london.py index 1ab1dfdb69..af7387173f 100644 --- a/tests/core/vm/test_london.py +++ b/tests/core/vm/test_london.py @@ -222,7 +222,7 @@ def test_state_revert_on_reserved_0xEF_byte_for_create_transaction_post_london( block_import, _, computations = chain.mine_all( [create_successful_contract_transaction], - gas_limit=84082, + gas_limit=84081, ) successful_create_computation = computations[0] successful_create_computation_state = successful_create_computation.state @@ -336,7 +336,7 @@ def test_state_does_not_revert_on_reserved_0xEF_byte_for_create_transaction_pre_ block_import, _, computations = chain.mine_all( [create_contract_txn_0xef_byte], - gas_limit=99903 + gas_limit=99904 ) computation = computations[0] diff --git a/tests/core/vm/test_vm.py b/tests/core/vm/test_vm.py index 8be14c4f9e..74610f6bcd 100644 --- a/tests/core/vm/test_vm.py +++ b/tests/core/vm/test_vm.py @@ -133,7 +133,7 @@ def test_validate_gas_limit_almost_too_low(noproof_consensus_chain): block1 = noproof_consensus_chain.mine_block() block2 = noproof_consensus_chain.mine_block() - max_reduction = block1.header.gas_limit // constants.GAS_LIMIT_ADJUSTMENT_FACTOR + max_reduction = block1.header.gas_limit // constants.GAS_LIMIT_ADJUSTMENT_FACTOR - 1 barely_valid_low_gas_limit = block1.header.gas_limit - max_reduction barely_valid_header = block2.header.copy(gas_limit=barely_valid_low_gas_limit) @@ -146,8 +146,8 @@ def test_validate_gas_limit_too_low(noproof_consensus_chain): block1 = noproof_consensus_chain.mine_block() block2 = noproof_consensus_chain.mine_block() - max_reduction = block1.header.gas_limit // constants.GAS_LIMIT_ADJUSTMENT_FACTOR - invalid_low_gas_limit = block1.header.gas_limit - max_reduction - 1 + exclusive_decrease_limit = block1.header.gas_limit // constants.GAS_LIMIT_ADJUSTMENT_FACTOR + invalid_low_gas_limit = block1.header.gas_limit - exclusive_decrease_limit invalid_header = block2.header.copy(gas_limit=invalid_low_gas_limit) vm = noproof_consensus_chain.get_vm(block2.header) @@ -160,7 +160,7 @@ def test_validate_gas_limit_almost_too_high(noproof_consensus_chain): block1 = noproof_consensus_chain.mine_block() block2 = noproof_consensus_chain.mine_block() - max_increase = block1.header.gas_limit // constants.GAS_LIMIT_ADJUSTMENT_FACTOR + max_increase = block1.header.gas_limit // constants.GAS_LIMIT_ADJUSTMENT_FACTOR - 1 barely_valid_high_gas_limit = block1.header.gas_limit + max_increase barely_valid_header = block2.header.copy(gas_limit=barely_valid_high_gas_limit) @@ -173,8 +173,8 @@ def test_validate_gas_limit_too_high(noproof_consensus_chain): block1 = noproof_consensus_chain.mine_block() block2 = noproof_consensus_chain.mine_block() - max_increase = block1.header.gas_limit // constants.GAS_LIMIT_ADJUSTMENT_FACTOR - invalid_high_gas_limit = block1.header.gas_limit + max_increase + 1 + exclusive_increase_limit = block1.header.gas_limit // constants.GAS_LIMIT_ADJUSTMENT_FACTOR + invalid_high_gas_limit = block1.header.gas_limit + exclusive_increase_limit invalid_header = block2.header.copy(gas_limit=invalid_high_gas_limit) vm = noproof_consensus_chain.get_vm(block2.header) diff --git a/tests/json-fixtures/blockchain/test_blockchain.py b/tests/json-fixtures/blockchain/test_blockchain.py index 0162611ffc..44b0e75cc1 100644 --- a/tests/json-fixtures/blockchain/test_blockchain.py +++ b/tests/json-fixtures/blockchain/test_blockchain.py @@ -41,9 +41,12 @@ SLOWEST_TESTS = { ('GeneralStateTests/stAttackTest/ContractCreationSpam.json', 'ContractCreationSpam_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stAttackTest/ContractCreationSpam.json', 'ContractCreationSpam_d0g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stAttackTest/ContractCreationSpam.json', 'ContractCreationSpam_d0g0v0_London'), # noqa: E501 ('GeneralStateTests/stCallCreateCallCodeTest/Call1024BalanceTooLow.json', 'Call1024BalanceTooLow_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stCallCreateCallCodeTest/Call1024PreCalls.json', 'Call1024PreCalls_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stCallCreateCallCodeTest/Call1024PreCalls.json', 'Call1024PreCalls_d0g1v0_Istanbul'), # noqa: E501 + ('GeneralStateTests/stCallCreateCallCodeTest/Call1024PreCalls.json', 'Call1024PreCalls_d0g0v0_London'), # noqa: E501 + ('GeneralStateTests/stCallCreateCallCodeTest/Call1024PreCalls.json', 'Call1024PreCalls_d0g1v0_London'), # noqa: E501 ('GeneralStateTests/stCallCreateCallCodeTest/CallRecursiveBombPreCall.json', 'CallRecursiveBombPreCall_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stCallCreateCallCodeTest/Callcode1024BalanceTooLow.json', 'Callcode1024BalanceTooLow_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stChangedEIP150/Call1024BalanceTooLow.json', 'Call1024BalanceTooLow_d0g0v0_Istanbul'), # noqa: E501 @@ -53,8 +56,10 @@ ('GeneralStateTests/stCreate2/Create2OnDepth1024.json', 'Create2OnDepth1024_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stCreate2/Create2Recursive.json', 'Create2Recursive_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stCreate2/Create2Recursive.json', 'Create2Recursive_d0g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stCreate2/Create2Recursive.json', 'Create2Recursive_d0g0v0_London'), # noqa: E501 ('GeneralStateTests/stCreate2/Create2Recursive.json', 'Create2Recursive_d0g1v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stCreate2/Create2Recursive.json', 'Create2Recursive_d0g1v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stCreate2/Create2Recursive.json', 'Create2Recursive_d0g1v0_London'), # noqa: E501 ('GeneralStateTests/stDelegatecallTestHomestead/Call1024BalanceTooLow.json', 'Call1024BalanceTooLow_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stDelegatecallTestHomestead/Call1024PreCalls.json', 'Call1024PreCalls_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stDelegatecallTestHomestead/Call1024PreCalls.json', 'Call1024PreCalls_d0g1v0_Istanbul'), # noqa: E501 @@ -69,8 +74,10 @@ ('GeneralStateTests/stRevertTest/LoopCallsDepthThenRevert3.json', 'LoopCallsDepthThenRevert3_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stRevertTest/LoopCallsThenRevert.json', 'LoopCallsThenRevert_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stRevertTest/LoopCallsThenRevert.json', 'LoopCallsThenRevert_d0g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stRevertTest/LoopCallsThenRevert.json', 'LoopCallsThenRevert_d0g0v0_London'), # noqa: E501 ('GeneralStateTests/stRevertTest/LoopCallsThenRevert.json', 'LoopCallsThenRevert_d0g1v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stRevertTest/LoopCallsThenRevert.json', 'LoopCallsThenRevert_d0g1v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stRevertTest/LoopCallsThenRevert.json', 'LoopCallsThenRevert_d0g1v0_London'), # noqa: E501 ('GeneralStateTests/stShift/shiftCombinations.json', 'shiftCombinations_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call1024BalanceTooLow.json', 'static_Call1024BalanceTooLow_d1g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call1024BalanceTooLow2.json', 'static_Call1024BalanceTooLow2_d1g0v0_Istanbul'), # noqa: E501 @@ -79,26 +86,38 @@ ('GeneralStateTests/stStaticCall/static_Call1024PreCalls2.json', 'static_Call1024PreCalls2_d1g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call1024PreCalls3.json', 'static_Call1024PreCalls3_d1g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call1MB1024Calldepth.json', 'static_Call1MB1024Calldepth_d1g0v0_Istanbul'), # noqa: E501 + ('GeneralStateTests/stStaticCall/static_Call1MB1024Calldepth.json', 'static_Call1MB1024Calldepth_d1g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stStaticCall/static_Call1MB1024Calldepth.json', 'static_Call1MB1024Calldepth_d1g0v0_London'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000.json', 'static_Call50000_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000.json', 'static_Call50000_d0g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stStaticCall/static_Call50000.json', 'static_Call50000_d0g0v0_London'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000.json', 'static_Call50000_d1g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000.json', 'static_Call50000_d1g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stStaticCall/static_Call50000.json', 'static_Call50000_d1g0v0_London'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000_ecrec.json', 'static_Call50000_ecrec_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000_ecrec.json', 'static_Call50000_ecrec_d0g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stStaticCall/static_Call50000_ecrec.json', 'static_Call50000_ecrec_d0g0v0_London'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000_ecrec.json', 'static_Call50000_ecrec_d1g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000_ecrec.json', 'static_Call50000_ecrec_d1g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stStaticCall/static_Call50000_ecrec.json', 'static_Call50000_ecrec_d1g0v0_London'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000_identity.json', 'static_Call50000_identity_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000_identity.json', 'static_Call50000_identity_d0g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stStaticCall/static_Call50000_identity.json', 'static_Call50000_identity_d0g0v0_London'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000_identity.json', 'static_Call50000_identity_d1g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000_identity.json', 'static_Call50000_identity_d1g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stStaticCall/static_Call50000_identity.json', 'static_Call50000_identity_d1g0v0_London'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000_identity2.json', 'static_Call50000_identity2_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000_identity2.json', 'static_Call50000_identity2_d0g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stStaticCall/static_Call50000_identity2.json', 'static_Call50000_identity2_d0g0v0_London'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000_identity2.json', 'static_Call50000_identity2_d1g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000_identity2.json', 'static_Call50000_identity2_d1g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stStaticCall/static_Call50000_identity2.json', 'static_Call50000_identity2_d1g0v0_London'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000_rip160.json', 'static_Call50000_rip160_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000_rip160.json', 'static_Call50000_rip160_d0g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stStaticCall/static_Call50000_rip160.json', 'static_Call50000_rip160_d0g0v0_London'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000_rip160.json', 'static_Call50000_rip160_d1g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000_rip160.json', 'static_Call50000_rip160_d1g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stStaticCall/static_Call50000_rip160.json', 'static_Call50000_rip160_d1g0v0_London'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000bytesContract50_1.json', 'static_Call50000bytesContract50_1_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000bytesContract50_1.json', 'static_Call50000bytesContract50_1_d1g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Call50000bytesContract50_2.json', 'static_Call50000bytesContract50_2_d0g0v0_Istanbul'), # noqa: E501 @@ -107,17 +126,23 @@ ('GeneralStateTests/stStaticCall/static_LoopCallsDepthThenRevert3.json', 'static_LoopCallsDepthThenRevert3_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_LoopCallsThenRevert.json', 'static_LoopCallsThenRevert_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_LoopCallsThenRevert.json', 'static_LoopCallsThenRevert_d0g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stStaticCall/static_LoopCallsThenRevert.json', 'static_LoopCallsThenRevert_d0g0v0_London'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_LoopCallsThenRevert.json', 'static_LoopCallsThenRevert_d0g1v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_LoopCallsThenRevert.json', 'static_LoopCallsThenRevert_d0g1v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stStaticCall/static_LoopCallsThenRevert.json', 'static_LoopCallsThenRevert_d0g1v0_London'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Return50000_2.json', 'static_Return50000_2_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stStaticCall/static_Return50000_2.json', 'static_Return50000_2_d0g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stStaticCall/static_Return50000_2.json', 'static_Return50000_2_d0g0v0_London'), # noqa: E501 ('GeneralStateTests/stSystemOperationsTest/CallRecursiveBomb0_OOG_atMaxCallDepth.json', 'CallRecursiveBomb0_OOG_atMaxCallDepth_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stTimeConsuming/CALLBlake2f_MaxRounds.json', 'CALLBlake2f_MaxRounds_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stTimeConsuming/CALLBlake2f_MaxRounds.json', 'CALLBlake2f_MaxRounds_d0g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stTimeConsuming/CALLBlake2f_MaxRounds.json', 'CALLBlake2f_MaxRounds_d0g0v0_London'), # noqa: E501 ('GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json', 'static_Call50000_sha256_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json', 'static_Call50000_sha256_d0g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json', 'static_Call50000_sha256_d0g0v0_London'), # noqa: E501 ('GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json', 'static_Call50000_sha256_d1g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json', 'static_Call50000_sha256_d1g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stTimeConsuming/static_Call50000_sha256.json', 'static_Call50000_sha256_d1g0v0_London'), # noqa: E501 ('GeneralStateTests/stZeroKnowledge/ecpairing_one_point_fail.json', 'ecpairing_one_point_fail_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stZeroKnowledge/ecpairing_three_point_fail_1.json', 'ecpairing_three_point_fail_1_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stZeroKnowledge/ecpairing_three_point_match_1.json', 'ecpairing_three_point_match_1_d0g0v0_Istanbul'), # noqa: E501 @@ -157,12 +182,22 @@ ('GeneralStateTests/VMTests/vmPerformance/loopExp.json', 'loopExp_d12g0v0_Berlin'), ('GeneralStateTests/VMTests/vmPerformance/loopExp.json', 'loopExp_d13g0v0_Berlin'), ('GeneralStateTests/VMTests/vmPerformance/loopExp.json', 'loopExp_d14g0v0_Berlin'), + ('GeneralStateTests/VMTests/vmPerformance/loopExp.json', 'loopExp_d8g0v0_London'), + ('GeneralStateTests/VMTests/vmPerformance/loopExp.json', 'loopExp_d9g0v0_London'), + ('GeneralStateTests/VMTests/vmPerformance/loopExp.json', 'loopExp_d10g0v0_London'), + ('GeneralStateTests/VMTests/vmPerformance/loopExp.json', 'loopExp_d11g0v0_London'), + ('GeneralStateTests/VMTests/vmPerformance/loopExp.json', 'loopExp_d12g0v0_London'), + ('GeneralStateTests/VMTests/vmPerformance/loopExp.json', 'loopExp_d13g0v0_London'), + ('GeneralStateTests/VMTests/vmPerformance/loopExp.json', 'loopExp_d14g0v0_London'), ('GeneralStateTests/VMTests/vmPerformance/loopMul.json', 'loopMul_d0g0v0_Istanbul'), ('GeneralStateTests/VMTests/vmPerformance/loopMul.json', 'loopMul_d1g0v0_Istanbul'), ('GeneralStateTests/VMTests/vmPerformance/loopMul.json', 'loopMul_d2g0v0_Istanbul'), ('GeneralStateTests/VMTests/vmPerformance/loopMul.json', 'loopMul_d0g0v0_Berlin'), ('GeneralStateTests/VMTests/vmPerformance/loopMul.json', 'loopMul_d1g0v0_Berlin'), ('GeneralStateTests/VMTests/vmPerformance/loopMul.json', 'loopMul_d2g0v0_Berlin'), + ('GeneralStateTests/VMTests/vmPerformance/loopMul.json', 'loopMul_d0g0v0_London'), + ('GeneralStateTests/VMTests/vmPerformance/loopMul.json', 'loopMul_d1g0v0_London'), + ('GeneralStateTests/VMTests/vmPerformance/loopMul.json', 'loopMul_d2g0v0_London'), ('InvalidBlocks/bcForgedTest/bcForkBlockTest.json', 'BlockWrongResetGas'), # noqa: E501 ('InvalidBlocks/bcForgedTest/bcInvalidRLPTest.json', 'BLOCK_difficulty_TooLarge'), # noqa: E501 ('InvalidBlocks/bcMultiChainTest/UncleFromSideChain.json', 'UncleFromSideChain_Constantinople'), # noqa: E501 @@ -180,22 +215,31 @@ ('ValidBlocks/bcStateTests/randomStatetest94.json', 'randomStatetest94_Istanbul'), # noqa: E501 ('ValidBlocks/VMTests/vmPerformance/loop-add-10M.json', 'loop-add-10M_Istanbul'), ('ValidBlocks/VMTests/vmPerformance/loop-add-10M.json', 'loop-add-10M_Berlin'), + ('ValidBlocks/VMTests/vmPerformance/loop-add-10M.json', 'loop-add-10M_London'), ('ValidBlocks/VMTests/vmPerformance/loop-divadd-10M.json', 'loop-divadd-10M_Istanbul'), ('ValidBlocks/VMTests/vmPerformance/loop-divadd-10M.json', 'loop-divadd-10M_Berlin'), + ('ValidBlocks/VMTests/vmPerformance/loop-divadd-10M.json', 'loop-divadd-10M_London'), ('ValidBlocks/VMTests/vmPerformance/loop-divadd-unr100-10M.json', 'loop-divadd-unr100-10M_Istanbul'), # noqa: E501 ('ValidBlocks/VMTests/vmPerformance/loop-divadd-unr100-10M.json', 'loop-divadd-unr100-10M_Berlin'), # noqa: E501 + ('ValidBlocks/VMTests/vmPerformance/loop-divadd-unr100-10M.json', 'loop-divadd-unr100-10M_London'), # noqa: E501 ('ValidBlocks/VMTests/vmPerformance/loop-exp-16b-100k.json', 'loop-exp-16b-100k_Istanbul'), ('ValidBlocks/VMTests/vmPerformance/loop-exp-16b-100k.json', 'loop-exp-16b-100k_Berlin'), + ('ValidBlocks/VMTests/vmPerformance/loop-exp-16b-100k.json', 'loop-exp-16b-100k_London'), ('ValidBlocks/VMTests/vmPerformance/loop-exp-1b-1M.json', 'loop-exp-1b-1M_Istanbul'), ('ValidBlocks/VMTests/vmPerformance/loop-exp-1b-1M.json', 'loop-exp-1b-1M_Berlin'), + ('ValidBlocks/VMTests/vmPerformance/loop-exp-1b-1M.json', 'loop-exp-1b-1M_London'), ('ValidBlocks/VMTests/vmPerformance/loop-exp-32b-100k.json', 'loop-exp-32b-100k_Istanbul'), ('ValidBlocks/VMTests/vmPerformance/loop-exp-32b-100k.json', 'loop-exp-32b-100k_Berlin'), + ('ValidBlocks/VMTests/vmPerformance/loop-exp-32b-100k.json', 'loop-exp-32b-100k_London'), ('ValidBlocks/VMTests/vmPerformance/loop-exp-nop-1M.json', 'loop-exp-nop-1M_Istanbul'), ('ValidBlocks/VMTests/vmPerformance/loop-exp-nop-1M.json', 'loop-exp-nop-1M_Berlin'), + ('ValidBlocks/VMTests/vmPerformance/loop-exp-nop-1M.json', 'loop-exp-nop-1M_London'), ('ValidBlocks/VMTests/vmPerformance/loop-mul.json', 'loop-mul_Istanbul'), ('ValidBlocks/VMTests/vmPerformance/loop-mul.json', 'loop-mul_Berlin'), + ('ValidBlocks/VMTests/vmPerformance/loop-mul.json', 'loop-mul_London'), ('ValidBlocks/VMTests/vmPerformance/loop-mulmod-2M.json', 'loop-mulmod-2M_Istanbul'), ('ValidBlocks/VMTests/vmPerformance/loop-mulmod-2M.json', 'loop-mulmod-2M_Berlin'), + ('ValidBlocks/VMTests/vmPerformance/loop-mulmod-2M.json', 'loop-mulmod-2M_London'), } @@ -214,6 +258,7 @@ ('GeneralStateTests/stRevertTest/RevertInCreateInInit_d0g0v0.json', 'RevertInCreateInInit_d0g0v0_ConstantinopleFix'), # noqa: E501 ('GeneralStateTests/stRevertTest/RevertInCreateInInit.json', 'RevertInCreateInInit_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stRevertTest/RevertInCreateInInit.json', 'RevertInCreateInInit_d0g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stRevertTest/RevertInCreateInInit.json', 'RevertInCreateInInit_d0g0v0_London'), # noqa: E501 # The CREATE2 variant seems to have been derived from the one above - it, too, # has a "synthetic" state, on which py-evm flips. @@ -222,6 +267,7 @@ ('GeneralStateTests/stCreate2/RevertInCreateInInitCreate2_d0g0v0.json', 'RevertInCreateInInitCreate2_d0g0v0_ConstantinopleFix'), # noqa: E501 ('GeneralStateTests/stCreate2/RevertInCreateInInitCreate2.json', 'RevertInCreateInInitCreate2_d0g0v0_Istanbul'), # noqa: E501 ('GeneralStateTests/stCreate2/RevertInCreateInInitCreate2.json', 'RevertInCreateInInitCreate2_d0g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stCreate2/RevertInCreateInInitCreate2.json', 'RevertInCreateInInitCreate2_d0g0v0_London'), # noqa: E501 # Four variants have been specifically added to test a collision type # like the above; therefore, they fail in the same manner. @@ -245,13 +291,17 @@ ('GeneralStateTests/stSStoreTest/InitCollision.json', 'InitCollision_d1g0v0_Berlin'), # noqa: E501 ('GeneralStateTests/stSStoreTest/InitCollision.json', 'InitCollision_d2g0v0_Berlin'), # noqa: E501 ('GeneralStateTests/stSStoreTest/InitCollision.json', 'InitCollision_d3g0v0_Berlin'), # noqa: E501 + ('GeneralStateTests/stSStoreTest/InitCollision.json', 'InitCollision_d0g0v0_London'), # noqa: E501 + ('GeneralStateTests/stSStoreTest/InitCollision.json', 'InitCollision_d1g0v0_London'), # noqa: E501 + ('GeneralStateTests/stSStoreTest/InitCollision.json', 'InitCollision_d2g0v0_London'), # noqa: E501 + ('GeneralStateTests/stSStoreTest/InitCollision.json', 'InitCollision_d3g0v0_London'), # noqa: E501 } def blockchain_fixture_mark_fn(fixture_path, fixture_name, fixture_fork): fixture_id = (fixture_path, fixture_name) - if fixture_path.startswith('bcExploitTest'): + if 'bcExploitTest/' in fixture_path: return pytest.mark.skip("Exploit tests are slow") elif fixture_path.startswith('bcForkStressTest/ForkStressTest.json'): return pytest.mark.skip("Fork stress tests are slow.") @@ -321,6 +371,11 @@ def assert_imported_genesis_header_unchanged(genesis_fields, genesis_header): ) +EXPECTED_BAD_BLOCK_EXCEPTIONS = ( + TypeError, rlp.DecodingError, rlp.DeserializationError, ValidationError, AssertionError, +) + + def test_blockchain_fixtures(fixture_data, fixture): try: chain = new_chain_from_fixture(fixture) @@ -353,7 +408,7 @@ def test_blockchain_fixtures(fixture_data, fixture): # 4 - check that all previous blocks were valid for block_fixture in fixture['blocks']: - should_be_good_block = 'blockHeader' in block_fixture + should_be_good_block = 'expectException' not in block_fixture if 'rlp_error' in block_fixture: assert not should_be_good_block @@ -370,7 +425,7 @@ def test_blockchain_fixtures(fixture_data, fixture): else: try: apply_fixture_block_to_chain(block_fixture, chain) - except (TypeError, rlp.DecodingError, rlp.DeserializationError, ValidationError): + except EXPECTED_BAD_BLOCK_EXCEPTIONS: # failure is expected on this bad block pass else: diff --git a/tox.ini b/tox.ini index 90a2388e09..3cf422ede1 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,7 @@ envlist= py{36,37,38,39}-{core,database,transactions,vm} py36-benchmark - py36-native-blockchain-{frontier,homestead,tangerine_whistle,spurious_dragon,byzantium,constantinople,petersburg,istanbul,berlin,metropolis,transition} + py36-native-blockchain-{frontier,homestead,tangerine_whistle,spurious_dragon,byzantium,constantinople,petersburg,istanbul,berlin,london,metropolis,transition} py{36,37,38,39}-lint py36-docs @@ -35,6 +35,7 @@ commands= native-blockchain-petersburg: pytest {posargs:tests/json-fixtures/blockchain/test_blockchain.py --fork ConstantinopleFix} native-blockchain-istanbul: pytest {posargs:tests/json-fixtures/blockchain/test_blockchain.py --fork Istanbul} native-blockchain-berlin: pytest {posargs:tests/json-fixtures/blockchain/test_blockchain.py --fork Berlin} + native-blockchain-london: pytest {posargs:tests/json-fixtures/blockchain/test_blockchain.py --fork London} native-blockchain-metropolis: pytest {posargs:tests/json-fixtures/blockchain/test_blockchain.py --fork Metropolis} native-blockchain-transition: pytest {posargs:tests/json-fixtures/blockchain/test_blockchain.py -k TransitionTests --tx '2*popen//execmodel=eventlet'} lint: flake8 {toxinidir}/eth {toxinidir}/tests {toxinidir}/scripts