ethereum.forks.muir_glacier.utils.messageethereum.forks.berlin.utils.message
Hardfork Utility Functions For The Message Data-structure.
.. contents:: Table of Contents :backlinks: none :local:
Introduction
Message specific functions used in this muir_glacier version ofMessage specific functions used in this berlin 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.muir_glacier.vm.Messageethereum.forks.berlin.vm.Message
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 | ------- |
| 44 | message: `ethereum.forks.muir_glacier.vm.Message` |
| 45 | message: `ethereum.forks.berlin.vm.Message` |
| 46 | Items containing contract creation or message call specific data. |
| 47 | |
| 48 | """ |
| 49 | accessed_addresses = set() |
| 50 | accessed_addresses.add(tx_env.origin) |
| 51 | accessed_addresses.update(PRE_COMPILED_CONTRACTS.keys()) |
| 52 | accessed_addresses.update(tx_env.access_list_addresses) |
| 53 | |
| 54 | if isinstance(tx.to, Bytes0): |
| 55 | current_target = compute_contract_address( |
| 56 | tx_env.origin, |
| 57 | get_account(block_env.state, tx_env.origin).nonce - Uint(1), |
| 58 | ) |
| 59 | msg_data = Bytes(b"") |
| 60 | code = tx.data |
| 61 | code_address = None |
| 62 | elif isinstance(tx.to, Address): |
| 63 | current_target = tx.to |
| 64 | msg_data = tx.data |
| 65 | code = get_account(block_env.state, tx.to).code |
| 66 | |
| 67 | code_address = tx.to |
| 68 | else: |
| 69 | raise AssertionError("Target must be address or empty bytes") |
| 70 | |
| 71 | accessed_addresses.add(current_target) |
| 72 | |
| 73 | return Message( |
| 74 | block_env=block_env, |
| 75 | tx_env=tx_env, |
| 76 | caller=tx_env.origin, |
| 77 | target=tx.to, |
| 78 | gas=tx_env.gas, |
| 79 | value=tx.value, |
| 80 | data=msg_data, |
| 81 | code=code, |
| 82 | depth=Uint(0), |
| 83 | current_target=current_target, |
| 84 | code_address=code_address, |
| 85 | should_transfer_value=True, |
| 86 | is_static=False, |
| 87 | accessed_addresses=accessed_addresses, |
| 88 | accessed_storage_keys=set(tx_env.access_list_storage_keys), |
| 89 | parent_evm=None, |
| 90 | ) |