Hardfork Utility Functions For The Message Data-structure
Table of Contents
Introduction
Message specific functions used in this tangerine whistle version of specification.
Module Contents
Functions
Execute a transaction against the provided environment. |
Module Details
prepare_message
- prepare_message(caller: ethereum.tangerine_whistle.fork_types.Address, target: Union[ethereum.base_types.Bytes0, ethereum.tangerine_whistle.fork_types.Address], value: ethereum.base_types.U256, data: ethereum.base_types.Bytes, gas: ethereum.base_types.Uint, env: ethereum.tangerine_whistle.vm.Environment, code_address: Optional[ethereum.tangerine_whistle.fork_types.Address] = None, should_transfer_value: bool = True) → ethereum.tangerine_whistle.vm.Message
Execute a transaction against the provided environment.
- Parameters
caller – Address which initiated the transaction
target – Address whose code will be executed
value – Value to be transferred.
data – Array of bytes provided to the code in target.
gas – Gas provided for the code in target.
env – Environment for the Ethereum Virtual Machine.
code_address – This is usually same as the target address except when an alternative accounts code needs to be executed. eg. CALLCODE calling a precompile.
should_transfer_value – if True ETH should be transferred while executing a message call.
- Returns
message – Items containing contract creation or message call specific data.
- Return type
ethereum.tangerine_whistle.vm.Message
def prepare_message(
caller: Address,
target: Union[Bytes0, Address],
value: U256,
data: Bytes,
gas: Uint,
env: Environment,
code_address: Optional[Address] = None,
should_transfer_value: bool = True,
) -> Message:
if isinstance(target, Bytes0):
current_target = compute_contract_address(
caller,
get_account(env.state, caller).nonce - U256(1),
)
msg_data = Bytes(b"")
code = data
elif isinstance(target, Address):
current_target = target
msg_data = data
code = get_account(env.state, target).code
if code_address is None:
code_address = target
else:
raise AssertionError("Target must be address or empty bytes")
return Message(
caller=caller,
target=target,
gas=gas,
value=value,
data=msg_data,
code=code,
depth=Uint(0),
current_target=current_target,
code_address=code_address,
should_transfer_value=should_transfer_value,
parent_evm=None,
)