Skip to content

test_warm_coinbase_gas_usage()

Documentation for tests/shanghai/eip3651_warm_coinbase/test_warm_coinbase.py::test_warm_coinbase_gas_usage@verkle@v0.0.6.

Generate fixtures for these test cases for Berlin with:

Berlin only:

fill -v tests/shanghai/eip3651_warm_coinbase/test_warm_coinbase.py::test_warm_coinbase_gas_usage --fork=Berlin --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Berlin:

fill -v tests/shanghai/eip3651_warm_coinbase/test_warm_coinbase.py::test_warm_coinbase_gas_usage --until=Berlin

Test the gas usage of opcodes affected by assuming a warm coinbase:

  • EXTCODESIZE
  • EXTCODECOPY
  • EXTCODEHASH
  • BALANCE
  • CALL
  • CALLCODE
  • DELEGATECALL
  • STATICCALL
Source code in tests/shanghai/eip3651_warm_coinbase/test_warm_coinbase.py
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
@pytest.mark.valid_from("Berlin")  # these tests fill for fork >= Berlin
@pytest.mark.parametrize(
    "opcode,code_gas_measure",
    gas_measured_opcodes,
    ids=[i[0] for i in gas_measured_opcodes],
)
def test_warm_coinbase_gas_usage(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    sender: Address,
    fork: Fork,
    opcode: str,
    code_gas_measure: Bytecode,
):
    """
    Test the gas usage of opcodes affected by assuming a warm coinbase:

    - EXTCODESIZE
    - EXTCODECOPY
    - EXTCODEHASH
    - BALANCE
    - CALL
    - CALLCODE
    - DELEGATECALL
    - STATICCALL
    """
    measure_address = pre.deploy_contract(
        code=code_gas_measure,
    )

    if fork >= Shanghai:
        expected_gas = GAS_REQUIRED_CALL_WARM_ACCOUNT  # Warm account access cost after EIP-3651
    else:
        expected_gas = 2600  # Cold account access cost before EIP-3651

    tx = Transaction(
        ty=0x0,
        chain_id=0x01,
        nonce=0,
        to=measure_address,
        gas_limit=100000000,
        gas_price=10,
        sender=sender,
    )

    post = {
        measure_address: Account(
            storage={
                0x00: expected_gas,
            }
        )
    }

    state_test(
        env=env,
        pre=pre,
        post=post,
        tx=tx,
        tag="opcode_" + opcode.lower(),
    )

Parametrized Test Cases

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

Skipped Parameters

For more concise readability, the table below does not list the following parameter values: fork, blockchain_test, state_test, state_test_only, eof_test, eof_state_test.

Test ID opcode code_gas_measure
EXTCODESIZE EXTCODESIZE
EXTCODECOPY EXTCODECOPY
EXTCODEHASH EXTCODEHASH
BALANCE BALANCE
CALL CALL
CALLCODE CALLCODE
DELEGATECALL DELEGATECALL
STATICCALL STATICCALL
EXTCODESIZE EXTCODESIZE
EXTCODECOPY EXTCODECOPY
EXTCODEHASH EXTCODEHASH
BALANCE BALANCE
CALL CALL
CALLCODE CALLCODE
DELEGATECALL DELEGATECALL
STATICCALL STATICCALL