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

Can't mine more than one block when transitioning from another VM to London #219

Open
kclowes opened this issue Nov 10, 2021 · 1 comment

Comments

@kclowes
Copy link
Contributor

kclowes commented Nov 10, 2021

What was wrong?

This test: https://github.com/ethereum/eth-tester/blob/master/tests/backends/test_pyevm.py#L33-L56

Fails if there is a transition to the LondonVM and more than one block is mined on London. The stacktrace looks like:

    def test_custom_virtual_machines():
        if not is_pyevm_available():
            pytest.skip("PyEVM is not available")

        backend = PyEVMBackend(vm_configuration=(
            (0, FrontierVM),
            (3, LondonVM),
        ))

        # This should be a FrontierVM block
        VM_at_2 = backend.chain.get_vm_class_for_block_number(2)
        # This should be a LondonVM block
        VM_at_3 = backend.chain.get_vm_class_for_block_number(3)

        assert issubclass(VM_at_2, FrontierVM)
        assert not issubclass(VM_at_2, LondonVM)
        assert issubclass(VM_at_3, LondonVM)

>       backend.mine_blocks(3)

VM_at_2    = <class 'abc.FrontierVM'>
VM_at_3    = <class 'abc.LondonVM'>
backend    = <eth_tester.backends.pyevm.main.PyEVMBackend object at 0x7fa0e93c2a90>

tests/backends/test_pyevm.py:52:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.venv-et-iii/lib/python3.9/site-packages/eth_utils/functional.py:45: in inner
    return callback(fn(*args, **kwargs))
eth_tester/backends/pyevm/main.py:429: in mine_blocks
    block = self.chain.mine_block(**mine_kwargs)
.venv-et-iii/lib/python3.9/site-packages/eth/chains/base.py:703: in mine_block
    return self.mine_block_extended(*args, **kwargs).block
.venv-et-iii/lib/python3.9/site-packages/eth/chains/base.py:709: in mine_block_extended
    mine_result = vm.mine_block(current_block, *args, **kwargs)
.venv-et-iii/lib/python3.9/site-packages/eth/vm/base.py:336: in mine_block
    self.validate_block(block_result.block)
.venv-et-iii/lib/python3.9/site-packages/eth/vm/base.py:563: in validate_block
    self.validate_header(block.header, parent_header)
.venv-et-iii/lib/python3.9/site-packages/eth/vm/base.py:604: in validate_header
    cls.validate_gas(header, parent_header)
.venv-et-iii/lib/python3.9/site-packages/eth/vm/forks/london/__init__.py:55: in validate_gas
    validate_gas_limit(header.gas_limit, parent_gas_limit)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

gas_limit = 30029122, parent_gas_limit = 60058244

    def validate_gas_limit(gas_limit: int, parent_gas_limit: int) -> None:
        low_bound, high_bound = compute_gas_limit_bounds(parent_gas_limit)
        if gas_limit < low_bound:
>           raise ValidationError(
                f"The gas limit {gas_limit} is too low. It must be at least {low_bound}"
E               eth_utils.exceptions.ValidationError: The gas limit 30029122 is too low. It must be at least 59999595

How can it be fixed?

Not sure yet.

@fselmo
Copy link
Contributor

fselmo commented Nov 11, 2021

Moving the conversation here but it seems like this all stems from this issue and ultimately this PR.

Removing these lines will get this test to pass again and will break 2 tests related to keeping the gas limit constant. I'm not sure why we wouldn't want to test the actual behavior of the gas limit over keeping it constant but I suppose we can discuss that here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants