ethereum.paris.utils.messageethereum.shanghai.utils.message
Hardfork Utility Functions For The Message Data-structure ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. contents:: Table of Contents :backlinks: none :local:
Introduction
Message specific functions used in this paris version ofMessage specific functions used in this shanghai version of
specification.
prepare_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.
is_static:
if True then it prevents all state-changing operations from being
executed.
preaccessed_addresses:
Addresses that should be marked as accessed prior to the message call
preaccessed_storage_keys:
Storage keys that should be marked as accessed prior to the message
call
Returns
message:
Items containing contract creation or message call specific data.ethereum.paris.vm.Messageethereum.shanghai.vm.Message
def prepare_message(caller: Address, target: Union[Bytes0, Address], value: U256, data: Bytes, gas: Uint, env: Environment, code_address: Optional[Address], should_transfer_value: bool, is_static: bool, preaccessed_addresses: FrozenSet[Address], preaccessed_storage_keys: FrozenSet[Tuple[(Address, Bytes32)]]) -> Message:
41 | """ |
---|---|
42 | Execute a transaction against the provided environment. |
43 |
|
44 | Parameters |
45 | ---------- |
46 | caller : |
47 | Address which initiated the transaction |
48 | target : |
49 | Address whose code will be executed |
50 | value : |
51 | Value to be transferred. |
52 | data : |
53 | Array of bytes provided to the code in `target`. |
54 | gas : |
55 | Gas provided for the code in `target`. |
56 | env : |
57 | Environment for the Ethereum Virtual Machine. |
58 | code_address : |
59 | This is usually same as the `target` address except when an alternative |
60 | accounts code needs to be executed. |
61 | eg. `CALLCODE` calling a precompile. |
62 | should_transfer_value : |
63 | if True ETH should be transferred while executing a message call. |
64 | is_static: |
65 | if True then it prevents all state-changing operations from being |
66 | executed. |
67 | preaccessed_addresses: |
68 | Addresses that should be marked as accessed prior to the message call |
69 | preaccessed_storage_keys: |
70 | Storage keys that should be marked as accessed prior to the message |
71 | call |
72 |
|
73 | Returns |
74 | ------- |
75 | message: `ethereum.paris.vm.Message` |
75 | message: `ethereum.shanghai.vm.Message` |
76 | Items containing contract creation or message call specific data. |
77 | """ |
78 | if isinstance(target, Bytes0): |
79 | current_target = compute_contract_address( |
80 | caller, |
81 | get_account(env.state, caller).nonce - U256(1), |
82 | ) |
83 | msg_data = Bytes(b"") |
84 | code = data |
85 | elif isinstance(target, Address): |
86 | current_target = target |
87 | msg_data = data |
88 | code = get_account(env.state, target).code |
89 | if code_address is None: |
90 | code_address = target |
91 | else: |
92 | raise AssertionError("Target must be address or empty bytes") |
93 | |
94 | accessed_addresses = set() |
95 | accessed_addresses.add(current_target) |
96 | accessed_addresses.add(caller) |
97 | accessed_addresses.update(PRE_COMPILED_CONTRACTS.keys()) |
98 | accessed_addresses.update(preaccessed_addresses) |
99 | |
100 | return Message( |
101 | caller=caller, |
102 | target=target, |
103 | gas=gas, |
104 | value=value, |
105 | data=msg_data, |
106 | code=code, |
107 | depth=Uint(0), |
108 | current_target=current_target, |
109 | code_address=code_address, |
110 | should_transfer_value=should_transfer_value, |
111 | is_static=is_static, |
112 | accessed_addresses=accessed_addresses, |
113 | accessed_storage_keys=set(preaccessed_storage_keys), |
114 | parent_evm=None, |
115 | ) |