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:
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.forks.spurious_dragon.vm.Message`
45
    message: `ethereum.forks.byzantium.vm.Message`
46
        Items containing contract creation or message call specific data.
47
48
    """
49
    if isinstance(tx.to, Bytes0):
50
        current_target = compute_contract_address(
51
            tx_env.origin,
52
            get_account(block_env.state, tx_env.origin).nonce - Uint(1),
53
        )
54
        msg_data = Bytes(b"")
55
        code = tx.data
56
        code_address = None
57
    elif isinstance(tx.to, Address):
58
        current_target = tx.to
59
        msg_data = tx.data
60
        account = get_account(block_env.state, tx.to)
61
        code = get_code(block_env.state, account.code_hash)
62
63
        code_address = tx.to
64
    else:
65
        raise AssertionError("Target must be address or empty bytes")
66
67
    return Message(
68
        block_env=block_env,
69
        tx_env=tx_env,
70
        caller=tx_env.origin,
71
        target=tx.to,
72
        gas=tx_env.gas,
73
        value=tx.value,
74
        data=msg_data,
75
        code=code,
76
        depth=Uint(0),
77
        current_target=current_target,
78
        code_address=code_address,
79
        should_transfer_value=True,
80
        is_static=False,
81
        parent_evm=None,
82
    )