__name__='SpuriousDragonStateForTesting', get_ancestor_hash=get_block_hash_for_testing, ) ByzantiumStateForTesting = ByzantiumState.configure( __name__='ByzantiumStateForTesting', get_ancestor_hash=get_block_hash_for_testing, ) FrontierVMForTesting = FrontierVM.configure( __name__='FrontierVMForTesting', _state_class=FrontierStateForTesting, get_prev_hashes=get_prev_hashes_testing, ) HomesteadVMForTesting = HomesteadVM.configure( __name__='HomesteadVMForTesting', _state_class=HomesteadStateForTesting, get_prev_hashes=get_prev_hashes_testing, ) TangerineWhistleVMForTesting = TangerineWhistleVM.configure( __name__='TangerineWhistleVMForTesting', _state_class=TangerineWhistleStateForTesting, get_prev_hashes=get_prev_hashes_testing, ) SpuriousDragonVMForTesting = SpuriousDragonVM.configure( __name__='SpuriousDragonVMForTesting', _state_class=SpuriousDragonStateForTesting, get_prev_hashes=get_prev_hashes_testing, ) ByzantiumVMForTesting = ByzantiumVM.configure( __name__='ByzantiumVMForTesting', _state_class=ByzantiumStateForTesting,
if on_pending: # estimate on *pending* block pending_header = chain.create_header_from_parent( chain.get_canonical_head()) assert chain.estimate_gas(tx, pending_header) == expected else: # estimates on top of *latest* block assert chain.estimate_gas(tx) == expected # these are long, so now that we know the exact numbers let's skip the repeat test # assert chain.estimate_gas(tx, chain.get_canonical_head()) == expected @pytest.mark.parametrize('vm_cls, expected', ( (FrontierVM, 722760), (HomesteadVM.configure(support_dao_fork=False, ), 722760), (TangerineWhistleVM, 722760), (SpuriousDragonVM, 722760), (ByzantiumVM, 722760), (ConstantinopleVM, 722760), (PetersburgVM, 722760), (IstanbulVM, 186120), (MuirGlacierVM, 186120), (BerlinVM, 186120), (LondonVM, 186120), )) def test_estimate_gas_on_full_block(chain_without_block_validation_from_vm, vm_cls, expected, funded_address_private_key, funded_address): def mk_estimation_txn(chain, from_, from_key, data):
else: return keccak(to_bytes(text="{0}".format(block_number))) HomesteadComputationForTesting = HomesteadComputation.configure( __name__='HomesteadComputationForTesting', apply_message=apply_message_for_testing, apply_create_message=apply_create_message_for_testing, ) HomesteadStateForTesting = HomesteadState.configure( __name__='HomesteadStateForTesting', get_ancestor_hash=get_block_hash_for_testing, computation_class=HomesteadComputationForTesting, ) HomesteadVMForTesting = HomesteadVM.configure( __name__='HomesteadVMForTesting', _state_class=HomesteadStateForTesting, ) @pytest.fixture(params=['Frontier', 'Homestead', 'EIP150', 'SpuriousDragon']) def vm_class(request): if request.param == 'Frontier': pytest.skip('Only the Homestead VM rules are currently supported') elif request.param == 'Homestead': return HomesteadVMForTesting elif request.param == 'EIP150': pytest.skip('Only the Homestead VM rules are currently supported') elif request.param == 'SpuriousDragon': pytest.skip('Only the Homestead VM rules are currently supported') else: assert False, "Unsupported VM: {0}".format(request.param)
def chain_vm_configuration(fixture: Dict[str, Any]) -> Iterable[Tuple[int, Type[BaseVM]]]: network = fixture['network'] if network == 'Frontier': return ( (0, FrontierVM), ) elif network == 'Homestead': HomesteadVM = BaseHomesteadVM.configure(support_dao_fork=False) return ( (0, HomesteadVM), ) elif network == 'EIP150': return ( (0, TangerineWhistleVM), ) elif network == 'EIP158': return ( (0, SpuriousDragonVM), ) elif network == 'Byzantium': return ( (0, ByzantiumVM), ) elif network == 'Constantinople': return ( (0, ConstantinopleVM), ) elif network == 'ConstantinopleFix': return ( (0, PetersburgVM), ) elif network == 'FrontierToHomesteadAt5': HomesteadVM = BaseHomesteadVM.configure(support_dao_fork=False) return ( (0, FrontierVM), (5, HomesteadVM), ) elif network == 'HomesteadToEIP150At5': HomesteadVM = BaseHomesteadVM.configure(support_dao_fork=False) return ( (0, HomesteadVM), (5, TangerineWhistleVM), ) elif network == 'HomesteadToDaoAt5': HomesteadVM = MainnetDAOValidatorVM.configure( support_dao_fork=True, _dao_fork_block_number=5, ) return ( (0, HomesteadVM), ) elif network == 'EIP158ToByzantiumAt5': return ( (0, SpuriousDragonVM), (5, ByzantiumVM), ) elif network == 'ByzantiumToConstantinopleAt5': return ( (0, ByzantiumVM), (5, ConstantinopleVM), ) else: raise ValueError("Network {0} does not match any known VM rules".format(network))