ethereum.forks.frontier.utils.messageethereum.forks.homestead.utils.message
Hardfork Utility Functions For The Message Data-structure.
.. contents:: Table of Contents :backlinks: none :local:
Introduction
Message specific functions used in this frontier version of specification.Message specific functions used in this homestead 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:
Items containing contract creation or message call specific data.ethereum.forks.frontier.vm.Messageethereum.forks.homestead.vm.Message
def prepare_message(block_env: BlockEnvironment, tx_env: TransactionEnvironment, tx: Transaction) -> Message:
| 29 | """ |
|---|---|
| 30 | Execute a transaction against the provided environment. |
| 31 | |
| 32 | Parameters |
| 33 | ---------- |
| 34 | block_env : |
| 35 | Environment for the Ethereum Virtual Machine. |
| 36 | tx_env : |
| 37 | Environment for the transaction. |
| 38 | tx : |
| 39 | Transaction to be executed. |
| 40 | |
| 41 | Returns |
| 42 | ------- |
| 43 | message: `ethereum.forks.frontier.vm.Message` |
| 43 | message: `ethereum.forks.homestead.vm.Message` |
| 44 | Items containing contract creation or message call specific data. |
| 45 | |
| 46 | """ |
| 47 | if isinstance(tx.to, Bytes0): |
| 48 | current_target = compute_contract_address( |
| 49 | tx_env.origin, |
| 50 | get_account(block_env.state, tx_env.origin).nonce - Uint(1), |
| 51 | ) |
| 52 | msg_data = Bytes(b"") |
| 53 | code = tx.data |
| 54 | code_address = None |
| 55 | elif isinstance(tx.to, Address): |
| 56 | current_target = tx.to |
| 57 | msg_data = tx.data |
| 58 | code = get_account(block_env.state, tx.to).code |
| 59 | |
| 60 | code_address = tx.to |
| 61 | else: |
| 62 | raise AssertionError("Target must be address or empty bytes") |
| 63 | |
| 64 | return Message( |
| 65 | block_env=block_env, |
| 66 | tx_env=tx_env, |
| 67 | caller=tx_env.origin, |
| 68 | target=tx.to, |
| 69 | gas=tx_env.gas, |
| 70 | value=tx.value, |
| 71 | data=msg_data, |
| 72 | code=code, |
| 73 | depth=Uint(0), |
| 74 | current_target=current_target, |
| 75 | code_address=code_address, |
| 76 | should_transfer_value=True, |
| 77 | parent_evm=None, |
| 78 | ) |