ethereum.forks.homestead.utils.messageethereum.forks.dao_fork.utils.message

Hardfork Utility Functions For The Message Data-structure.

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

Introduction

Message specific functions used in this homestead version of specification.Message specific functions used in this Dao Fork 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.homestead.vm.Messageethereum.forks.dao_fork.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.homestead.vm.Message`
44
    message: `ethereum.forks.dao_fork.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
        account = get_account(block_env.state, tx.to)
60
        code = get_code(block_env.state, account.code_hash)
61
62
        code_address = tx.to
63
    else:
64
        raise AssertionError("Target must be address or empty bytes")
65
66
    return Message(
67
        block_env=block_env,
68
        tx_env=tx_env,
69
        caller=tx_env.origin,
70
        target=tx.to,
71
        gas=tx_env.gas,
72
        value=tx.value,
73
        data=msg_data,
74
        code=code,
75
        depth=Uint(0),
76
        current_target=current_target,
77
        code_address=code_address,
78
        should_transfer_value=True,
79
        parent_evm=None,
80
    )