-
Notifications
You must be signed in to change notification settings - Fork 480
refactor(amsterdam): Re-factor Amsterdam + Preparation for EIP-8141 #3192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: forks/amsterdam
Are you sure you want to change the base?
Changes from all commits
24857ee
d8bb4b5
eec721b
5cb4767
23099ce
1adc8ba
0409887
98fe743
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -8,8 +8,24 @@ | |||||
| Introduction | ||||||
| ------------ | ||||||
|
|
||||||
| The abstract computer which runs the code stored in an | ||||||
| The abstract computer that runs the code stored in an | ||||||
| `.fork_types.Account`. | ||||||
|
|
||||||
| Execution is organized around a single call frame, the [`Evm`][evm]: one | ||||||
| object carrying a call's parameters, its machine state (program counter, | ||||||
| stack, memory), the gas it has left, and the effects it accrues (logs, | ||||||
| refunds, accounts to delete). A call spawns a child frame, and each | ||||||
| top-level call is a frame at depth zero; a transaction executes one or | ||||||
| more such frames, so `.interpreter` drives every frame the same way. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| Each frame meters gas in two pools, bundled in its [`GasMeter`][meter]. | ||||||
| Regular gas pays for computation; the state gas reservoir pays the | ||||||
| state-growth costs, and when it is exhausted a charge spills into regular | ||||||
| gas, with a revert refilling both pools in LIFO order so the two never | ||||||
| drift. `.gas` holds both the charges and that pool accounting. | ||||||
|
|
||||||
| [evm]: ref:ethereum.forks.amsterdam.vm.Evm | ||||||
| [meter]: ref:ethereum.forks.amsterdam.vm.gas.GasMeter | ||||||
| """ | ||||||
|
|
||||||
| from dataclasses import dataclass, field | ||||||
|
|
@@ -31,7 +47,12 @@ | |||||
| from ..transactions import LegacyTransaction | ||||||
| from .gas import GasMeter | ||||||
|
|
||||||
| __all__ = ("Environment", "Evm", "Message") | ||||||
| __all__ = ( | ||||||
| "BlockEnvironment", | ||||||
| "BlockOutput", | ||||||
| "TransactionEnvironment", | ||||||
| "Evm", | ||||||
| ) | ||||||
| TRANSFER_TOPIC = keccak256(b"Transfer(address,address,uint256)") | ||||||
| SYSTEM_ADDRESS = Address( | ||||||
| bytes.fromhex("fffffffffffffffffffffffffffffffffffffffe") | ||||||
|
|
@@ -121,9 +142,8 @@ class TransactionEnvironment: | |||||
| """ | ||||||
|
|
||||||
| origin: Address | ||||||
| recipient: Bytes0 | Address | ||||||
| value: U256 | ||||||
| gas_price: Uint | ||||||
| blob_gas_fee: Uint | ||||||
| gas: Uint | ||||||
| state_gas_reservoir: Uint | ||||||
| access_list_addresses: Set[Address] | ||||||
|
|
@@ -137,45 +157,50 @@ class TransactionEnvironment: | |||||
|
|
||||||
| @final | ||||||
| @dataclass | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh, can you make |
||||||
| class Message: | ||||||
| class Evm: | ||||||
| """ | ||||||
| Items that are used by contract creation or message call. | ||||||
| A single call frame: its parameters, gas meter, machine state, and | ||||||
| accrued effects. | ||||||
|
|
||||||
| A call spawns a child frame and each top-level call is a frame at | ||||||
| depth zero, so one dataclass describes them all. What was once a | ||||||
| separate ``Message`` -- the call's fixed parameters -- now lives on | ||||||
| the frame directly, alongside its mutable machine state. | ||||||
| """ | ||||||
|
|
||||||
| # Environment. | ||||||
| block_env: BlockEnvironment | ||||||
| tx_env: TransactionEnvironment | ||||||
|
|
||||||
| # Call parameters, fixed at frame creation. | ||||||
| caller: Address | ||||||
| target: Bytes0 | Address | ||||||
| current_target: Address | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hadn't really thought about it, but could you take this opportunity to use more clear names for |
||||||
| gas: Uint | ||||||
| state_gas_reservoir: Uint | ||||||
| code_address: Optional[Address] | ||||||
| value: U256 | ||||||
| data: Bytes | ||||||
| code_address: Optional[Address] | ||||||
| code: Optional[Bytes] | ||||||
| depth: Uint | ||||||
| should_transfer_value: bool | ||||||
| is_static: bool | ||||||
| accessed_addresses: Set[Address] | ||||||
| accessed_storage_keys: Set[Tuple[Address, Bytes32]] | ||||||
| disable_precompiles: bool | ||||||
| parent_evm: Optional["Evm"] | ||||||
|
|
||||||
|
|
||||||
| @final | ||||||
| @dataclass | ||||||
| class Evm: | ||||||
| """The internal state of the virtual machine.""" | ||||||
|
|
||||||
| # Machine state, gas meter, and accrued effects. Field order follows | ||||||
| # the predecessor fork's `Evm` for diff stability. The frame's gas -- | ||||||
| # its entry grants and everything it consumes -- lives on the | ||||||
| # [`GasMeter`][meter]. | ||||||
| # | ||||||
| # [meter]: ref:ethereum.forks.amsterdam.vm.gas.GasMeter | ||||||
|
Comment on lines
+188
to
+193
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These comments won't get rendered, unless they're in a docstring. |
||||||
| pc: Uint | ||||||
| stack: List[U256] | ||||||
| memory: bytearray | ||||||
| # Init code for a creation; for a call a placeholder that | ||||||
| # `resolve_dispatch` replaces once authorizations are applied. | ||||||
|
Comment on lines
+197
to
+198
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If these comments are for a specific member, I think they belong in a docstring under that member, not as a comment. |
||||||
| code: Bytes | ||||||
| gas_meter: GasMeter | ||||||
| valid_jump_destinations: Set[Uint] | ||||||
| logs: Tuple[Log, ...] | ||||||
| running: bool | ||||||
| message: Message | ||||||
| output: Bytes | ||||||
| accounts_to_delete: Set[Address] | ||||||
| return_data: Bytes | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.