Skip to content

test_full_gas_consumption()

Documentation for tests/prague/eip7623_increase_calldata_cost/test_execution_gas.py::TestGasConsumption::test_full_gas_consumption@83970623.

Generate fixtures for these test cases for Prague with:

fill -v tests/prague/eip7623_increase_calldata_cost/test_execution_gas.py::TestGasConsumption::test_full_gas_consumption --fork Prague

Test gas consumption with EIP-7623 active.

Source code in tests/prague/eip7623_increase_calldata_cost/test_execution_gas.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
class TestGasConsumption:
    """Test gas consumption with EIP-7623 active."""

    @pytest.fixture
    def intrinsic_gas_data_floor_minimum_delta(self) -> int:
        """Force a minimum delta in order to have some gas to execute the invalid opcode."""
        return 50_000

    @pytest.fixture
    def to(
        self,
        pre: Alloc,
    ) -> Address | None:
        """Return a contract that consumes all gas when executed by calling an invalid opcode."""
        return pre.deploy_contract(Op.INVALID)

    @pytest.mark.parametrize(
        "ty,protected,authorization_list",
        [
            pytest.param(0, False, None, id="type_0_unprotected"),
            pytest.param(0, True, None, id="type_0_protected"),
            pytest.param(1, True, None, id="type_1"),
            pytest.param(2, True, None, id="type_2"),
            pytest.param(3, True, None, id="type_3"),
            pytest.param(4, True, [Address(1)], id="type_4"),
        ],
        indirect=["authorization_list"],
    )
    @pytest.mark.parametrize(
        "tx_gas_delta",
        [
            # Test with exact gas and extra gas.
            pytest.param(1, id="extra_gas"),
            pytest.param(0, id="exact_gas"),
        ],
    )
    def test_full_gas_consumption(
        self,
        state_test: StateTestFiller,
        pre: Alloc,
        tx: Transaction,
    ) -> None:
        """Test executing a transaction that fully consumes its execution gas allocation."""
        tx.expected_receipt = TransactionReceipt(gas_used=tx.gas_limit)
        state_test(
            pre=pre,
            post={},
            tx=tx,
        )

test_full_gas_consumption(state_test, pre, tx)

Test executing a transaction that fully consumes its execution gas allocation.

Source code in tests/prague/eip7623_increase_calldata_cost/test_execution_gas.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
@pytest.mark.parametrize(
    "ty,protected,authorization_list",
    [
        pytest.param(0, False, None, id="type_0_unprotected"),
        pytest.param(0, True, None, id="type_0_protected"),
        pytest.param(1, True, None, id="type_1"),
        pytest.param(2, True, None, id="type_2"),
        pytest.param(3, True, None, id="type_3"),
        pytest.param(4, True, [Address(1)], id="type_4"),
    ],
    indirect=["authorization_list"],
)
@pytest.mark.parametrize(
    "tx_gas_delta",
    [
        # Test with exact gas and extra gas.
        pytest.param(1, id="extra_gas"),
        pytest.param(0, id="exact_gas"),
    ],
)
def test_full_gas_consumption(
    self,
    state_test: StateTestFiller,
    pre: Alloc,
    tx: Transaction,
) -> None:
    """Test executing a transaction that fully consumes its execution gas allocation."""
    tx.expected_receipt = TransactionReceipt(gas_used=tx.gas_limit)
    state_test(
        pre=pre,
        post={},
        tx=tx,
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) authorization_list tx_gas_delta ty protected
...fork_Prague-blockchain_test-extra_gas-type_0_unprotected None 1 0 False
...fork_Prague-blockchain_test-extra_gas-type_0_protected None 1 0 True
...fork_Prague-blockchain_test-extra_gas-type_1 None 1 1 True
...fork_Prague-blockchain_test-extra_gas-type_2 None 1 2 True
...fork_Prague-blockchain_test-extra_gas-type_3 None 1 3 True
...fork_Prague-blockchain_test-extra_gas-type_4 [b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'] 1 4 True
...fork_Prague-blockchain_test-exact_gas-type_0_unprotected None 0 0 False
...fork_Prague-blockchain_test-exact_gas-type_0_protected None 0 0 True
...fork_Prague-blockchain_test-exact_gas-type_1 None 0 1 True
...fork_Prague-blockchain_test-exact_gas-type_2 None 0 2 True
...fork_Prague-blockchain_test-exact_gas-type_3 None 0 3 True
...fork_Prague-blockchain_test-exact_gas-type_4 [b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'] 0 4 True
...fork_Prague-state_test-extra_gas-type_0_unprotected None 1 0 False
...fork_Prague-state_test-extra_gas-type_0_protected None 1 0 True
...fork_Prague-state_test-extra_gas-type_1 None 1 1 True
...fork_Prague-state_test-extra_gas-type_2 None 1 2 True
...fork_Prague-state_test-extra_gas-type_3 None 1 3 True
...fork_Prague-state_test-extra_gas-type_4 [b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'] 1 4 True
...fork_Prague-state_test-exact_gas-type_0_unprotected None 0 0 False
...fork_Prague-state_test-exact_gas-type_0_protected None 0 0 True
...fork_Prague-state_test-exact_gas-type_1 None 0 1 True
...fork_Prague-state_test-exact_gas-type_2 None 0 2 True
...fork_Prague-state_test-exact_gas-type_3 None 0 3 True
...fork_Prague-state_test-exact_gas-type_4 [b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'] 0 4 True
...fork_Osaka-blockchain_test-extra_gas-type_0_unprotected None 1 0 False
...fork_Osaka-blockchain_test-extra_gas-type_0_protected None 1 0 True
...fork_Osaka-blockchain_test-extra_gas-type_1 None 1 1 True
...fork_Osaka-blockchain_test-extra_gas-type_2 None 1 2 True
...fork_Osaka-blockchain_test-extra_gas-type_3 None 1 3 True
...fork_Osaka-blockchain_test-extra_gas-type_4 [b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'] 1 4 True
...fork_Osaka-blockchain_test-exact_gas-type_0_unprotected None 0 0 False
...fork_Osaka-blockchain_test-exact_gas-type_0_protected None 0 0 True
...fork_Osaka-blockchain_test-exact_gas-type_1 None 0 1 True
...fork_Osaka-blockchain_test-exact_gas-type_2 None 0 2 True
...fork_Osaka-blockchain_test-exact_gas-type_3 None 0 3 True
...fork_Osaka-blockchain_test-exact_gas-type_4 [b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'] 0 4 True
...fork_Osaka-state_test-extra_gas-type_0_unprotected None 1 0 False
...fork_Osaka-state_test-extra_gas-type_0_protected None 1 0 True
...fork_Osaka-state_test-extra_gas-type_1 None 1 1 True
...fork_Osaka-state_test-extra_gas-type_2 None 1 2 True
...fork_Osaka-state_test-extra_gas-type_3 None 1 3 True
...fork_Osaka-state_test-extra_gas-type_4 [b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'] 1 4 True
...fork_Osaka-state_test-exact_gas-type_0_unprotected None 0 0 False
...fork_Osaka-state_test-exact_gas-type_0_protected None 0 0 True
...fork_Osaka-state_test-exact_gas-type_1 None 0 1 True
...fork_Osaka-state_test-exact_gas-type_2 None 0 2 True
...fork_Osaka-state_test-exact_gas-type_3 None 0 3 True
...fork_Osaka-state_test-exact_gas-type_4 [b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'] 0 4 True