Example #1
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))
Example #2
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))
Example #3
0
def chain_vm_configuration(fixture_data, 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, EIP150VM), )
    elif network == 'EIP158':
        return ((0, SpuriousDragonVM), )
    elif network == 'Byzantium':
        return ((0, ByzantiumVM), )
    elif network == 'Constantinople':
        pytest.skip('Constantinople VM rules not yet supported')
    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, EIP150VM),
        )
    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:
        fixture_path, fixture_key = fixture_data
        raise AssertionError(
            "Test fixture did not match any configuration rules: {0}:{1}".
            format(
                fixture_path,
                fixture_key,
            ))
Example #4
0
    name='SpuriousDragonVMStateForTesting',
    get_ancestor_hash=get_block_hash_for_testing,
)
ByzantiumVMStateForTesting = ByzantiumVMState.configure(
    name='ByzantiumVMStateForTesting',
    get_ancestor_hash=get_block_hash_for_testing,
)

FrontierVMForTesting = FrontierVM.configure(
    name='FrontierVMForTesting',
    _state_class=FrontierVMStateForTesting,
    get_prev_hashes=get_prev_hashes_testing,
)
HomesteadVMForTesting = HomesteadVM.configure(
    name='HomesteadVMForTesting',
    _state_class=HomesteadVMStateForTesting,
    get_prev_hashes=get_prev_hashes_testing,
)
TangerineWhistleVMForTesting = TangerineWhistleVM.configure(
    name='TangerineWhistleVMForTesting',
    _state_class=TangerineWhistleVMStateForTesting,
    get_prev_hashes=get_prev_hashes_testing,
)
SpuriousDragonVMForTesting = SpuriousDragonVM.configure(
    name='SpuriousDragonVMForTesting',
    _state_class=SpuriousDragonVMStateForTesting,
    get_prev_hashes=get_prev_hashes_testing,
)
ByzantiumVMForTesting = ByzantiumVM.configure(
    name='ByzantiumVMForTesting',
    _state_class=ByzantiumVMStateForTesting,
Example #5
0
        return b''
    else:
        return keccak("{0}".format(block_number))


VMStateForTesting = VMState.configure(
    name='VMStateForTesting',
    get_ancestor_hash=get_block_hash_for_testing,
)

FrontierVMForTesting = FrontierVM.configure(
    name='FrontierVMForTesting',
    _state_class=VMStateForTesting,
)
HomesteadVMForTesting = HomesteadVM.configure(
    name='HomesteadVMForTesting',
    _state_class=VMStateForTesting,
)
TangerineWhistleVMForTesting = TangerineWhistleVM.configure(
    name='TangerineWhistleVMForTesting',
    _state_class=VMStateForTesting,
)
SpuriousDragonVMForTesting = SpuriousDragonVM.configure(
    name='SpuriousDragonVMForTesting',
    _state_class=VMStateForTesting,
)
ByzantiumVMForTesting = ByzantiumVM.configure(
    name='ByzantiumVMForTesting',
    _state_class=VMStateForTesting,
)

Example #6
0
    if block_number >= self.block.header.block_number:
        return b''
    elif block_number < 0:
        return b''
    elif block_number < self.block.header.block_number - 256:
        return b''
    else:
        return keccak("{0}".format(block_number))


FrontierVMForTesting = FrontierVM.configure(
    name='FrontierVMForTesting',
    get_ancestor_hash=get_block_hash_for_testing,
)
HomesteadVMForTesting = HomesteadVM.configure(
    name='HomesteadVMForTesting',
    get_ancestor_hash=get_block_hash_for_testing,
)
TangerineWhistleVMForTesting = TangerineWhistleVM.configure(
    name='TangerineWhistleVMForTesting',
    get_ancestor_hash=get_block_hash_for_testing,
)
SpuriousDragonVMForTesting = SpuriousDragonVM.configure(
    name='SpuriousDragonVMForTesting',
    get_ancestor_hash=get_block_hash_for_testing,
)
ByzantiumVMForTesting = ByzantiumVM.configure(
    name='ByzantiumVMForTesting',
    get_ancestor_hash=get_block_hash_for_testing,
)

Example #7
0
    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)
Example #8
0
    )
    return computation


def get_block_hash_for_testing(self, block_number):
    if block_number >= self.block.header.block_number:
        return b''
    elif block_number < self.block.header.block_number - 256:
        return b''
    else:
        return keccak("{0}".format(block_number))


HomesteadVMForTesting = HomesteadVM.configure(
    name='HomesteadVMForTesting',
    apply_message=apply_create_message_for_testing,
    apply_create_message=apply_create_message_for_testing,
    get_ancestor_hash=get_block_hash_for_testing,
)


@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:
Example #9
0
    name='SpuriousDragonVMStateForTesting',
    get_ancestor_hash=get_block_hash_for_testing,
)
ByzantiumVMStateForTesting = ByzantiumVMState.configure(
    name='ByzantiumVMStateForTesting',
    get_ancestor_hash=get_block_hash_for_testing,
)

FrontierVMForTesting = FrontierVM.configure(
    name='FrontierVMForTesting',
    _state_class=FrontierVMStateForTesting,
    get_prev_hashes=get_prev_hashes_testing,
)
HomesteadVMForTesting = HomesteadVM.configure(
    name='HomesteadVMForTesting',
    _state_class=HomesteadVMStateForTesting,
    get_prev_hashes=get_prev_hashes_testing,
)
TangerineWhistleVMForTesting = TangerineWhistleVM.configure(
    name='TangerineWhistleVMForTesting',
    _state_class=TangerineWhistleVMStateForTesting,
    get_prev_hashes=get_prev_hashes_testing,
)
SpuriousDragonVMForTesting = SpuriousDragonVM.configure(
    name='SpuriousDragonVMForTesting',
    _state_class=SpuriousDragonVMStateForTesting,
    get_prev_hashes=get_prev_hashes_testing,
)
ByzantiumVMForTesting = ByzantiumVM.configure(
    name='ByzantiumVMForTesting',
    _state_class=ByzantiumVMStateForTesting,
Example #10
0
    else:
        return keccak(text="{0}".format(block_number))


HomesteadComputationForTesting = HomesteadComputation.configure(
    name='HomesteadComputationForTesting',
    apply_message=apply_message_for_testing,
    apply_create_message=apply_create_message_for_testing,
)
HomesteadVMStateForTesting = HomesteadVMState.configure(
    name='HomesteadVMStateForTesting',
    get_ancestor_hash=get_block_hash_for_testing,
    computation_class=HomesteadComputationForTesting,
)
HomesteadVMForTesting = HomesteadVM.configure(
    name='HomesteadVMForTesting',
    _state_class=HomesteadVMStateForTesting,
)


@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)
Example #11
0
    else:
        return keccak("{0}".format(block_number))


HomesteadComputationForTesting = HomesteadComputation.configure(
    name='HomesteadComputationForTesting',
    apply_message=apply_message_for_testing,
    apply_create_message=apply_create_message_for_testing,
)
VMStateForTesting = VMState.configure(
    name='VMStateForTesting',
    get_ancestor_hash=get_block_hash_for_testing,
)
HomesteadVMForTesting = HomesteadVM.configure(
    name='HomesteadVMForTesting',
    _computation_class=HomesteadComputationForTesting,
    _state_class=VMStateForTesting,
)


@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: