ethereum.london.utils.messageethereum.arrow_glacier.utils.message

Hardfork Utility Functions For The Message Data-structure ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. contents:: Table of Contents :backlinks: none :local:

Introduction

Message specific functions used in this london version ofMessage specific functions used in this arrow_glacier version of specification.

prepare_message

Execute a transaction against the provided environment.

Parameters

block_env : Environment for the Ethereum Virtual Machine. tx_env : Environment for the transaction. tx : Transaction to be executed.

Returns

message: ethereum.london.vm.Messageethereum.arrow_glacier.vm.Message Items containing contract creation or message call specific data.

def prepare_message(block_env: BlockEnvironment, ​​tx_env: TransactionEnvironment, ​​tx: Transaction) -> Message:
31
    """
32
    Execute a transaction against the provided environment.
33
34
    Parameters
35
    ----------
36
    block_env :
37
        Environment for the Ethereum Virtual Machine.
38
    tx_env :
39
        Environment for the transaction.
40
    tx :
41
        Transaction to be executed.
42
43
    Returns
44
    -------
45
    message: `ethereum.london.vm.Message`
45
    message: `ethereum.arrow_glacier.vm.Message`
46
        Items containing contract creation or message call specific data.
47
    """
48
    accessed_addresses = set()
49
    accessed_addresses.add(tx_env.origin)
50
    accessed_addresses.update(PRE_COMPILED_CONTRACTS.keys())
51
    accessed_addresses.update(tx_env.access_list_addresses)
52
53
    if isinstance(tx.to, Bytes0):
54
        current_target = compute_contract_address(
55
            tx_env.origin,
56
            get_account(block_env.state, tx_env.origin).nonce - Uint(1),
57
        )
58
        msg_data = Bytes(b"")
59
        code = tx.data
60
        code_address = None
61
    elif isinstance(tx.to, Address):
62
        current_target = tx.to
63
        msg_data = tx.data
64
        code = get_account(block_env.state, tx.to).code
65
66
        code_address = tx.to
67
    else:
68
        raise AssertionError("Target must be address or empty bytes")
69
70
    accessed_addresses.add(current_target)
71
72
    return Message(
73
        block_env=block_env,
74
        tx_env=tx_env,
75
        caller=tx_env.origin,
76
        target=tx.to,
77
        gas=tx_env.gas,
78
        value=tx.value,
79
        data=msg_data,
80
        code=code,
81
        depth=Uint(0),
82
        current_target=current_target,
83
        code_address=code_address,
84
        should_transfer_value=True,
85
        is_static=False,
86
        accessed_addresses=accessed_addresses,
87
        accessed_storage_keys=set(tx_env.access_list_storage_keys),
88
        parent_evm=None,
89
    )