Пример #1
0
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 == '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))
Пример #2
0
def chain_vm_configuration(
    fixture: Dict[str, Any]
) -> Iterable[Tuple[int, Type[VirtualMachineAPI]]]:  # noqa: E501
    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 == 'Istanbul':
        return ((0, IstanbulVM), )
    elif network == 'Berlin':
        return ((0, BerlinVM), )
    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 == 'ByzantiumToConstantinopleFixAt5':
        return (
            (0, ByzantiumVM),
            (5, PetersburgVM),
        )
    else:
        raise ValueError(
            f"Network {network} does not match any known VM rules")
Пример #3
0
def _extract_vm_config(vm_config: Dict[str, str]) -> Iterable[VMFork]:
    if 'frontierForkBlock' in vm_config.keys():
        yield to_int(hexstr=vm_config['frontierForkBlock']), FrontierVM
    if 'homesteadForkBlock' in vm_config.keys():
        homestead_fork_block = to_int(hexstr=vm_config['homesteadForkBlock'])
        if 'DAOForkBlock' in vm_config:
            dao_fork_block_number = to_int(hexstr=vm_config['DAOForkBlock'])

            HomesteadVM = BaseHomesteadVM.configure(
                support_dao_fork=True,
                _dao_fork_block_number=dao_fork_block_number,
            )
            yield homestead_fork_block, HomesteadVM
        else:
            yield homestead_fork_block, BaseHomesteadVM
    if 'EIP150ForkBlock' in vm_config.keys():
        yield to_int(hexstr=vm_config['EIP150ForkBlock']), TangerineWhistleVM
    if 'EIP158ForkBlock' in vm_config.keys():
        yield to_int(hexstr=vm_config['EIP158ForkBlock']), SpuriousDragonVM
    if 'byzantiumForkBlock' in vm_config.keys():
        yield to_int(hexstr=vm_config['byzantiumForkBlock']), ByzantiumVM
    if 'constantinopleForkBlock' in vm_config.keys():
        yield to_int(hexstr=vm_config['constantinopleForkBlock']), ConstantinopleVM
    if 'petersburgForkBlock' in vm_config.keys():
        yield to_int(hexstr=vm_config['petersburgForkBlock']), PetersburgVM
Пример #4
0
def chain_vm_configuration(fixture):
    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 == '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 = BaseHomesteadVM.configure(
            support_dao_fork=True,
            dao_fork_block_number=5,
        )
        return ((0, HomesteadVM), )
    elif network == 'EIP158ToByzantiumAt5':
        return (
            (0, SpuriousDragonVM),
            (5, ByzantiumVM),
        )
    else:
        raise ValueError(
            "Network {0} does not match any known VM rules".format(network))
Пример #5
0
        datetime.datetime.now().isoformat(),
    )

    with open(logfile_name, 'w') as logfile:
        handler = logging.StreamHandler(logfile)
        logger.addHandler(handler)
        try:
            yield logger
        finally:
            logger.removeHandler(handler)
"""


@pytest.fixture(params=[
    FrontierVM,
    HomesteadVM.configure(support_dao_fork=False, ),
    TangerineWhistleVM,
    SpuriousDragonVM,
    ByzantiumVM,
    ConstantinopleVM,
])
def VM(request):
    return request.param


@pytest.fixture
def base_db():
    return AtomicDB()


@pytest.fixture
Пример #6
0
    __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,
    else:
        return keccak(to_bytes(text=f"{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:
        raise AssertionError(f"Unsupported VM: {request.param}")