Skip to content
Merged
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
13 changes: 9 additions & 4 deletions tests/osaka/eip7883_modexp_gas_increase/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,19 @@ def total_tx_gas_needed(
fork.transaction_intrinsic_cost_calculator()
)
memory_expansion_gas_calculator = fork.memory_expansion_gas_calculator()
sstore_gas = fork.gas_costs().G_STORAGE_SET * (len(modexp_expected) // 32)
# `gas_measure_contract` does at most 4 SSTOREs to cold slots.
sstore_gas = (
fork.gas_costs().G_STORAGE_SET + fork.gas_costs().G_COLD_SLOAD
) * 4
# Ensures that the precompile call is not starved by the 63/64 rule.
precompile_gas_with_margin = precompile_gas * 64 // 63
extra_gas = 100_000

return (
extra_gas
+ intrinsic_gas_cost_calculator(calldata=bytes(modexp_input))
+ memory_expansion_gas_calculator(new_bytes=len(bytes(modexp_input)))
+ precompile_gas
+ precompile_gas_with_margin
+ sstore_gas
)

Expand Down Expand Up @@ -219,11 +224,11 @@ def precompile_gas(
Calculate gas cost for the ModExp precompile and verify it matches expected
gas.
"""
spec = Spec if fork < Osaka else Spec7883
spec = Spec7883 if fork >= Osaka else Spec
try:
calculated_gas = spec.calculate_gas_cost(modexp_input)
if gas_old is not None and gas_new is not None:
expected_gas = gas_old if fork < Osaka else gas_new
expected_gas = gas_new if fork >= Osaka else gas_old
base_len = len(modexp_input.base)
exp_len = len(modexp_input.exponent)
mod_len = len(modexp_input.modulus)
Expand Down
Loading