test_cold_account_access_at_transition()
Documentation for tests/amsterdam/eip8038_state_access_gas_cost_increase/test_fork_transition.py::test_cold_account_access_at_transition@343274cc.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/amsterdam/eip8038_state_access_gas_cost_increase/test_fork_transition.py::test_cold_account_access_at_transition --fork Amsterdam
BALANCE of a cold account costs COLD_ACCOUNT_ACCESS, which
rises across the Amsterdam boundary. The
same opcode is measured before and after; each block asserts its
regime's derived cost.
Source code in tests/amsterdam/eip8038_state_access_gas_cost_increase/test_fork_transition.py
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157 | @EIPChecklist.GasCostChanges.Test.ForkTransition.Before()
@EIPChecklist.GasCostChanges.Test.ForkTransition.After()
def test_cold_account_access_at_transition(
blockchain_test: BlockchainTestFiller,
pre: Alloc,
fork: Fork,
) -> None:
"""
``BALANCE`` of a cold account costs ``COLD_ACCOUNT_ACCESS``, which
rises across the Amsterdam boundary. The
same opcode is measured before and after; each block asserts its
regime's derived cost.
"""
before = fork.fork_at(timestamp=BEFORE_TS)
after = fork.fork_at(timestamp=AFTER_TS)
# BALANCE's bare cost equals COLD_ACCOUNT_ACCESS in each regime.
cold_balance = Op.BALANCE.with_metadata(address_warm=False)
cost_before = cold_balance.gas_cost(before)
cost_after = cold_balance.gas_cost(after)
assert cost_after > cost_before
target = pre.deploy_contract(code=Op.STOP)
# A distinct cold target per block keeps each measurement cold.
target_after = pre.deploy_contract(code=Op.STOP)
# BALANCE has no code-read surcharge, so its bare cost equals
# COLD_ACCOUNT_ACCESS in each regime.
measure_before = _measure_contract(
pre, Op.BALANCE(target), cost_before, before
)
measure_after = _measure_contract(
pre, Op.BALANCE(target_after), cost_after, after
)
blocks = transition_blocks(measure_before, measure_after, pre)
post = {
measure_before: Account(storage={0: cost_before}),
measure_after: Account(storage={0: cost_after}),
}
blockchain_test(pre=pre, blocks=blocks, post=post)
|
Parametrized Test Cases
This test generates 1 parametrized test case across 1 fork.