ethereum.forks.dao_fork.utils.messageethereum.forks.tangerine_whistle.utils.message

Hardfork Utility Functions For The Message Data-structure.

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

Introduction

Message specific functions used in this Dao Fork version of specification.Message specific functions used in this tangerine whistle 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.dao_fork.vm.Messageethereum.forks.tangerine_whistle.vm.Message Items containing contract creation or message call specific data.

def prepare_message(block_env: BlockEnvironment, ​​tx_env: TransactionEnvironment, ​​tx: Transaction) -> Message:
31
    <snip>
49
    if isinstance(tx.to, Bytes0):
50
        current_target = compute_contract_address(
51
            tx_env.origin,
52
            get_account(tx_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(tx_env.state, tx.to)
61
        code = get_code(tx_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
        parent_evm=None,
81
    )