Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit fae67de

Browse files
committed
Improve documentation in ComputationAPI
1 parent 84eefce commit fae67de

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

eth/abc.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,7 @@ def apply_message(
15501550
message: MessageAPI,
15511551
transaction_context: TransactionContextAPI) -> 'ComputationAPI':
15521552
"""
1553-
Execution of a VM message. Typically used for sub-calls.
1553+
Execute a VM message. This is where the VM-specific call logic exists.
15541554
"""
15551555
...
15561556

@@ -1562,7 +1562,8 @@ def apply_create_message(
15621562
message: MessageAPI,
15631563
transaction_context: TransactionContextAPI) -> 'ComputationAPI':
15641564
"""
1565-
Execution of a VM message to create a new contract. Typically used for sub-calls.
1565+
Execute a VM message to create a new contract. This is where the VM-specific
1566+
create logic exists.
15661567
"""
15671568
...
15681569

@@ -1573,7 +1574,14 @@ def apply_computation(cls,
15731574
message: MessageAPI,
15741575
transaction_context: TransactionContextAPI) -> 'ComputationAPI':
15751576
"""
1576-
Perform the computation that would be triggered by the VM message.
1577+
Execute the logic within the message: Either run the precompile, or
1578+
step through each opcode. Generally, the only VM-specific logic is for
1579+
each opcode as it executes.
1580+
1581+
This should rarely be called directly, because it will skip over other important
1582+
VM-specific logic that happens before or after the execution.
1583+
1584+
Instead, prefer :meth:`~apply_message` or :meth:`~apply_create_message`.
15771585
"""
15781586
...
15791587

@@ -2509,7 +2517,17 @@ def execute_bytecode(self,
25092517
code_address: Address = None) -> ComputationAPI:
25102518
"""
25112519
Execute raw bytecode in the context of the current state of
2512-
the virtual machine.
2520+
the virtual machine. Note that this skips over some of the logic
2521+
that would normally happen during a call. Watch out for:
2522+
2523+
- value (ether) is *not* transferred
2524+
- state is *not* rolled back in case of an error
2525+
- The target account is *not* necessarily created
2526+
- others...
2527+
2528+
For other potential surprises, check the implementation differences
2529+
between :meth:`ComputationAPI.apply_computation` and
2530+
:meth:`ComputationAPI.apply_message`. (depending on the VM fork)
25132531
"""
25142532
...
25152533

0 commit comments

Comments
 (0)