Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions packages/testing/src/execution_testing/forks/base_fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,34 @@ def create_state_gas(cls, *, code_size: int = 0) -> int:
"""Return total state gas for CREATE."""
pass

@classmethod
def oog_budget_lift(
cls,
*,
sstores_before_oog: int = 0,
creates_before_oog: int = 0,
deploy_code_size: int = 0,
) -> int:
"""
Return how much an OoG-tuned regular-gas budget must lift on this
fork to preserve the same intermediate state.

EIP-8037 splits each fresh SSTORE-set, CREATE, and deployed code
byte into a regular portion plus a state-gas portion; when the
per-tx state-gas reservoir is empty, the state-gas portion spills
back into regular gas. For tests calibrated to OoG mid-execution
after N SSTOREs, M CREATEs, and a deploy of K bytes complete,
Amsterdam needs the original budget plus the cumulative spill to
land at the same point. Pre-EIP-8037 forks return 0 (state-gas
helpers are 0), so callers can apply this unconditionally without
a fork guard.
"""
return (
sstores_before_oog * cls.sstore_state_gas()
+ creates_before_oog * cls.create_state_gas()
+ cls.code_deposit_state_gas(code_size=deploy_code_size)
)

@classmethod
@abstractmethod
def block_rlp_size_limit(cls) -> int | None:
Expand Down
32 changes: 32 additions & 0 deletions packages/testing/src/execution_testing/forks/tests/test_forks.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,38 @@ def test_eips() -> None: # noqa: D103
assert Shanghai.is_eip_enabled(3855)


def test_oog_budget_lift() -> None:
"""
`Fork.oog_budget_lift` returns zero pre-EIP-8037 and the cumulative
SSTORE-set + CREATE + code-deposit state-gas spill on Amsterdam.
"""
# Pre-EIP-8037: state_gas helpers are 0, so any lift is 0.
assert Cancun.oog_budget_lift(sstores_before_oog=1) == 0
assert Cancun.oog_budget_lift(creates_before_oog=1) == 0
assert (
Cancun.oog_budget_lift(
sstores_before_oog=3, creates_before_oog=2, deploy_code_size=64
)
== 0
)
# Amsterdam: lift composes the three state-gas helpers.
sstore = Amsterdam.sstore_state_gas()
create = Amsterdam.create_state_gas()
code_64 = Amsterdam.code_deposit_state_gas(code_size=64)
assert Amsterdam.oog_budget_lift() == 0
assert Amsterdam.oog_budget_lift(sstores_before_oog=1) == sstore
assert Amsterdam.oog_budget_lift(creates_before_oog=1) == create
assert Amsterdam.oog_budget_lift(deploy_code_size=64) == code_64
assert (
Amsterdam.oog_budget_lift(
sstores_before_oog=3,
creates_before_oog=2,
deploy_code_size=64,
)
== 3 * sstore + 2 * create + code_64
)


def test_fork_variant_ordering() -> None:
"""
Variants from `with_env_gas_limit` must compare consistently with
Expand Down
132 changes: 29 additions & 103 deletions tests/ported_static/amsterdam_skip_list.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

Ported from:
state_tests/stCreate2/Create2OOGafterInitCodeFiller.json
@manually-enhanced: Do not overwrite. tx_gas[1] is tuned to barely
succeed CREATE2 on Cancun; on Amsterdam EIP-8037 the NEW_ACCOUNT
state-gas spills, so lift the budget by Fork.oog_budget_lift.
"""

import pytest
Expand Down Expand Up @@ -110,7 +113,7 @@ def test_create2_oo_gafter_init_code(
tx_data = [
Bytes(""),
]
tx_gas = [54000, 55000]
tx_gas = [54000, 55000 + fork.oog_budget_lift(creates_before_oog=1)]

tx = Transaction(
sender=sender,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

Ported from:
state_tests/stCreate2/Create2OOGafterInitCodeReturndata2Filler.json
@manually-enhanced: Do not overwrite. tx_gas[1] is tuned to barely
finish CREATE2 + two post-deploy SSTOREs on Cancun; on Amsterdam the
NEW_ACCOUNT and SSTORE-set state-gas spills, so lift the budget by
Fork.oog_budget_lift.
"""

import pytest
Expand Down Expand Up @@ -117,7 +121,11 @@ def test_create2_oo_gafter_init_code_returndata2(
tx_data = [
Bytes(""),
]
tx_gas = [54000, 95000]
tx_gas = [
54000,
95000
+ fork.oog_budget_lift(creates_before_oog=1, sstores_before_oog=2),
]

tx = Transaction(
sender=sender,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

Ported from:
state_tests/stCreateTest/CreateOOGafterInitCodeFiller.json
@manually-enhanced: Do not overwrite. tx_gas[1] is tuned to barely
succeed CREATE on Cancun; on Amsterdam EIP-8037 the NEW_ACCOUNT
state-gas spills, so lift the budget by Fork.oog_budget_lift.
"""

import pytest
Expand Down Expand Up @@ -106,7 +109,7 @@ def test_create_oo_gafter_init_code(
tx_data = [
Bytes(""),
]
tx_gas = [54000, 55000]
tx_gas = [54000, 55000 + fork.oog_budget_lift(creates_before_oog=1)]

tx = Transaction(
sender=sender,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

Ported from:
state_tests/stCreateTest/CreateOOGafterInitCodeReturndata2Filler.json
@manually-enhanced: Do not overwrite. tx_gas[1] is tuned to barely
finish CREATE + two post-deploy SSTOREs on Cancun; on Amsterdam the
NEW_ACCOUNT and SSTORE-set state-gas spills, so lift the budget by
Fork.oog_budget_lift.
"""

import pytest
Expand Down Expand Up @@ -116,7 +120,11 @@ def test_create_oo_gafter_init_code_returndata2(
tx_data = [
Bytes(""),
]
tx_gas = [54000, 95000]
tx_gas = [
54000,
95000
+ fork.oog_budget_lift(creates_before_oog=1, sstores_before_oog=2),
]

tx = Transaction(
sender=sender,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

Ported from:
state_tests/stRevertTest/RevertSubCallStorageOOGFiller.json
@manually-enhanced: Do not overwrite. tx_gas[1] is tuned to barely
fit 3 fresh SSTOREs on Cancun; on Amsterdam each fresh slot spills
state-gas, so lift the budget by Fork.oog_budget_lift.
"""

import pytest
Expand Down Expand Up @@ -115,7 +118,7 @@ def test_revert_sub_call_storage_oog(
tx_data = [
Bytes("c0406226"),
]
tx_gas = [81000, 181000]
tx_gas = [81000, 181000 + fork.oog_budget_lift(sstores_before_oog=3)]
tx_value = [0, 1]

tx = Transaction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

Ported from:
state_tests/stRevertTest/RevertSubCallStorageOOG2Filler.json
@manually-enhanced: Do not overwrite. tx_gas[1] is tuned to barely
fit 2 fresh SSTOREs on Cancun; on Amsterdam each fresh slot spills
state-gas, so lift the budget by Fork.oog_budget_lift.
"""

import pytest
Expand Down Expand Up @@ -113,7 +116,7 @@ def test_revert_sub_call_storage_oog2(
tx_data = [
Bytes("c0406226"),
]
tx_gas = [61500, 181000]
tx_gas = [61500, 181000 + fork.oog_budget_lift(sstores_before_oog=2)]
tx_value = [0, 1]

tx = Transaction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

Ported from:
state_tests/stWalletTest/multiOwnedConstructionNotEnoughGasPartialFiller.json
@manually-enhanced: Do not overwrite. tx_gas[1] is tuned for the
multi-owned-wallet construction success path on Cancun; on Amsterdam
the NEW_ACCOUNT, 3 init-code SSTOREs, and 2314-byte code deposit
spill state-gas, so lift the budget by Fork.oog_budget_lift.
"""

import pytest
Expand Down Expand Up @@ -98,7 +102,15 @@ def test_multi_owned_construction_not_enough_gas_partial(
"606060409081526001600081815581805533600160a060020a0316600381905581526101026020529182205561090a90819061003b90396000f300606060405236156100775760e060020a6000350463173825d981146100795780632f54bf6e146100d55780634123cb6b146100f95780637065cb4814610102578063746c917114610136578063b75c7dc61461013f578063ba51a6df1461016f578063c2cf7326146101a3578063f00d4b5d146101e3575b005b610077600435600060003643604051808484808284375050509091019081526040519081900360200190209050610529815b600160a060020a033316600090815261010260205260408120548180808381141561066f57610806565b61021c6004355b600160a060020a0316600090815261010260205260408120541190565b61021c60015481565b610077600435600036436040518084848082843750505090910190815260405190819003602001902090506104a1816100ab565b61021c60005481565b610077600435600160a060020a033316600090815261010260205260408120549080808381141561022e576102b0565b610077600435600036436040518084848082843750505090910190815260405190819003602001902090506105e8816100ab565b61021c600435602435600082815261010360209081526040808320600160a060020a03851684526101029092528220548290818181141561064157610665565b61007760043560243560006000364360405180848480828437505050909101908152604051908190036020019020905061033a816100ab565b60408051918252519081900360200190f35b5050506000828152610103602052604081206001810154600284900a92908316819011156102b05781546001838101805492909101845590849003905560408051600160a060020a03331681526020810187905281517fc7fb647e59b18047309aa15aad418e5d7ca96d173ad704f1031a2c3d7591734b929181900390910190a15b5050505050565b600160a060020a038316600283610100811015610002570155600160a060020a0384811660008181526101026020908152604080832083905593871680835291849020869055835192835282015281517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c929181900390910190a15b505b505050565b1561033357610348836100dc565b156103535750610335565b600160a060020a03841660009081526101026020526040812054925082141561037c5750610335565b6102b75b6101045460005b818110156107b557610104805482908110156100025760009182526000805160206108ea8339815191520154146103fa576101048054610103916000918490811015610002576000805160206108ea83398151915201548252506020919091526040812081815560018101829055600201555b600101610387565b60018054810190819055600160a060020a038316906002906101008110156100025790900160005081905550600160005054610102600050600084600160a060020a03168152602001908152602001600020600050819055507f994a936646fe87ffe4f1e469d3d6aa417d6b855598397f323de5b449f765f0c3826040518082600160a060020a0316815260200191505060405180910390a15b505b50565b1561049c576104af826100dc565b156104ba575061049e565b6104c2610380565b60015460fa90106104d7576104d56104ec565b505b60015460fa9010610402575061049e565b6105a65b600060015b6001548110156107ef575b6001548110801561051c5750600281610100811015610002570154600014155b1561080f576001016104fc565b1561033557600160a060020a038316600090815261010260205260408120549250821415610557575061049c565b6001600160005054036000600050541115610572575061049c565b600060028361010081101561000257508301819055600160a060020a038416815261010260205260408120556104e8610380565b5060408051600160a060020a038516815290517f58619076adf5bb0943d100ef88d52d7c3fd691b19d3a9071b555b651fbf418da9181900360200190a1505050565b1561049c576001548211156105fd575061049e565b600082905561060a610380565b6040805183815290517facbdb084c721332ac59f9b8e392196c9eb0e4932862da8eb9beaf0dad4f550da9181900360200190a15050565b506001830154600282900a908116600014156106605760009450610665565b600194505b5050505092915050565b60008681526101036020526040812080549094509092508214156106f85781548355600183810183905561010480549182018082558280158290116106c7578183600052602060002091820191016106c791906107db565b505050600284018190556101048054889290811015610002576000919091526000805160206108ea83398151915201555b506001820154600284900a908116600014156108065760408051600160a060020a03331681526020810188905281517fe1c52dc63b719ade82e8bea94cc41a0d5d28e4aaf536adb5e9cccc9ff8c1aeda929181900390910190a18254600190116107f35760008681526101036020526040902060020154610104805490919081101561000257604060009081206000805160206108ea83398151915292909201819055808255600180830182905560029092015595506108069050565b6101048054600080835591909152610335906000805160206108ea833981519152908101905b808211156107ef57600081556001016107db565b5090565b8254600019018355600183018054821790555b50505050919050565b5b6001805411801561083257506001546002906101008110156100025701546000145b156108465760018054600019019055610810565b600154811080156108695750600154600290610100811015610002570154600014155b801561088357506002816101008110156100025701546000145b156108e457600154600290610100811015610002578101549082610100811015610002578101919091558190610102906000908361010081101561000257810154825260209290925260408120929092556001546101008110156100025701555b6104f156004c0be60200faa20559308cb7b5a1bb3255c16cb1cab91f525b5ae7a03d02fabe" # noqa: E501
),
]
tx_gas = [601249, 751249]
tx_gas = [
601249,
751249
+ fork.oog_budget_lift(
creates_before_oog=1,
sstores_before_oog=3,
deploy_code_size=2314,
),
]
tx_value = [100]

tx = Transaction(
Expand Down
Loading
Loading