ethereum.forks.spurious_dragon.utils.messageethereum.forks.byzantium.utils.message

Hardfork Utility Functions For The Message Data-structure.

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

Introduction

Message specific functions used in this spurious dragon version ofMessage specific functions used in this byzantium 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.forks.spurious_dragon.vm.Messageethereum.forks.byzantium.vm.Message Items containing contract creation or message call specific data.

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