diff --git a/docs/writing_tests/fork_methods.md b/docs/writing_tests/fork_methods.md index b9bad8be2a..b3147b82a3 100644 --- a/docs/writing_tests/fork_methods.md +++ b/docs/writing_tests/fork_methods.md @@ -33,7 +33,7 @@ def test_some_feature(fork): ```python def test_transaction_gas(fork, state_test): - gas_cost = fork.gas_costs(block_number=0, timestamp=0).G_TRANSACTION + gas_cost = fork.gas_costs(block_number=0, timestamp=0).TX_BASE_COST # Create a transaction with the correct gas parameters for this fork tx = Transaction( diff --git a/packages/testing/src/execution_testing/forks/forks/forks.py b/packages/testing/src/execution_testing/forks/forks/forks.py index 4e66d9bf95..96bb412f3a 100644 --- a/packages/testing/src/execution_testing/forks/forks/forks.py +++ b/packages/testing/src/execution_testing/forks/forks/forks.py @@ -115,46 +115,45 @@ def gas_costs( """ del block_number, timestamp return GasCosts( - G_JUMPDEST=1, - G_BASE=2, - G_VERY_LOW=3, - G_LOW=5, - G_MID=8, - G_HIGH=10, - G_WARM_ACCOUNT_ACCESS=100, - G_COLD_ACCOUNT_ACCESS=2_600, - G_ACCESS_LIST_ADDRESS=2_400, - G_ACCESS_LIST_STORAGE=1_900, - G_WARM_SLOAD=100, - G_COLD_SLOAD=2_100, - G_STORAGE_SET=20_000, - G_STORAGE_RESET=2_900, - R_STORAGE_CLEAR=4_800, - G_SELF_DESTRUCT=5_000, - G_CREATE=32_000, - G_CODE_DEPOSIT_BYTE=200, - G_INITCODE_WORD=2, - G_CALL_VALUE=9_000, - G_CALL_STIPEND=2_300, - G_NEW_ACCOUNT=25_000, - G_EXP=10, - G_EXP_BYTE=50, - G_MEMORY=3, - G_TX_DATA_ZERO=4, - G_TX_DATA_NON_ZERO=68, - G_TX_DATA_STANDARD_TOKEN_COST=0, - G_TX_DATA_FLOOR_TOKEN_COST=0, - G_TRANSACTION=21_000, - G_TRANSACTION_CREATE=32_000, - G_LOG=375, - G_LOG_DATA=8, - G_LOG_TOPIC=375, - G_KECCAK_256=30, - G_KECCAK_256_WORD=6, - G_COPY=3, - G_BLOCKHASH=20, - G_AUTHORIZATION=0, - R_AUTHORIZATION_EXISTING_AUTHORITY=0, + GAS_JUMPDEST=1, + GAS_BASE=2, + GAS_VERY_LOW=3, + GAS_LOW=5, + GAS_MID=8, + GAS_HIGH=10, + GAS_WARM_ACCESS=100, + GAS_COLD_ACCOUNT_ACCESS=2_600, + TX_ACCESS_LIST_ADDRESS_COST=2_400, + TX_ACCESS_LIST_STORAGE_KEY_COST=1_900, + GAS_COLD_SLOAD=2_100, + GAS_STORAGE_SET=20_000, + GAS_STORAGE_UPDATE=2_900, + GAS_STORAGE_CLEAR_REFUND=4_800, + GAS_SELF_DESTRUCT=5_000, + GAS_CREATE=32_000, + GAS_CODE_DEPOSIT=200, + GAS_INIT_CODE_WORD_COST=2, + GAS_CALL_VALUE=9_000, + GAS_CALL_STIPEND=2_300, + GAS_NEW_ACCOUNT=25_000, + GAS_EXPONENTIATION=10, + GAS_EXPONENTIATION_PER_BYTE=50, + GAS_MEMORY=3, + TX_DATA_COST_PER_ZERO=4, + TX_DATA_COST_PER_NON_ZERO=68, + STANDARD_CALLDATA_TOKEN_COST=0, + FLOOR_CALLDATA_COST=0, + TX_BASE_COST=21_000, + TX_CREATE_COST=32_000, + GAS_LOG=375, + GAS_LOG_DATA=8, + GAS_LOG_TOPIC=375, + GAS_KECCAK256=30, + GAS_KECCAK256_WORD=6, + GAS_COPY=3, + GAS_BLOCK_HASH=20, + PER_EMPTY_ACCOUNT_COST=0, + PER_AUTH_BASE_COST=0, ) @classmethod @@ -176,7 +175,7 @@ def fn(*, new_bytes: int, previous_bytes: int = 0) -> int: previous_words = ceiling_division(previous_bytes, 32) def c(w: int) -> int: - return (gas_costs.G_MEMORY * w) + ((w * w) // 512) + return (gas_costs.GAS_MEMORY * w) + ((w * w) // 512) return c(new_words) - c(previous_words) @@ -200,9 +199,9 @@ def fn(*, data: BytesConvertible, floor: bool = False) -> int: cost = 0 for b in Bytes(data): if b == 0: - cost += gas_costs.G_TX_DATA_ZERO + cost += gas_costs.TX_DATA_COST_PER_ZERO else: - cost += gas_costs.G_TX_DATA_NON_ZERO + cost += gas_costs.TX_DATA_COST_PER_NON_ZERO return cost return fn @@ -295,11 +294,12 @@ def fn( f"Authorizations are not supported in {cls.name()}" ) - intrinsic_cost: int = gas_costs.G_TRANSACTION + intrinsic_cost: int = gas_costs.TX_BASE_COST if contract_creation: - intrinsic_cost += gas_costs.G_INITCODE_WORD * ceiling_division( - len(Bytes(calldata)), 32 + intrinsic_cost += ( + gas_costs.GAS_INIT_CODE_WORD_COST + * ceiling_division(len(Bytes(calldata)), 32) ) return intrinsic_cost + calldata_gas_calculator(data=calldata) @@ -918,7 +918,7 @@ def fn( authorization_list_or_count=authorization_list_or_count, ) if contract_creation: - intrinsic_cost += gas_costs.G_TRANSACTION_CREATE + intrinsic_cost += gas_costs.TX_CREATE_COST return intrinsic_cost return fn @@ -1103,7 +1103,7 @@ def gas_costs( super(Istanbul, cls).gas_costs( block_number=block_number, timestamp=timestamp ), - G_TX_DATA_NON_ZERO=16, # https://eips.ethereum.org/EIPS/eip-2028 + TX_DATA_COST_PER_NON_ZERO=16, # https://eips.ethereum.org/EIPS/eip-2028 # https://eips.ethereum.org/EIPS/eip-1108 G_PRECOMPILE_ECADD=150, G_PRECOMPILE_ECMUL=6000, @@ -1172,9 +1172,11 @@ def fn( ) if access_list is not None: for access in access_list: - intrinsic_cost += gas_costs.G_ACCESS_LIST_ADDRESS + intrinsic_cost += gas_costs.TX_ACCESS_LIST_ADDRESS_COST for _ in access.storage_keys: - intrinsic_cost += gas_costs.G_ACCESS_LIST_STORAGE + intrinsic_cost += ( + gas_costs.TX_ACCESS_LIST_STORAGE_KEY_COST + ) return intrinsic_cost return fn @@ -1556,7 +1558,7 @@ def excess_blob_gas_calculator( blob_gas_per_blob = cls.blob_gas_per_blob( block_number=block_number, timestamp=timestamp ) - target_blob_gas_per_block = target_blobs_per_block * blob_gas_per_blob + blob_target_gas_per_block = target_blobs_per_block * blob_gas_per_blob def fn( *, @@ -1583,14 +1585,14 @@ def fn( parent_blob_gas_used = parent_blob_count * blob_gas_per_blob if ( parent_excess_blob_gas + parent_blob_gas_used - < target_blob_gas_per_block + < blob_target_gas_per_block ): return 0 else: return ( parent_excess_blob_gas + parent_blob_gas_used - - target_blob_gas_per_block + - blob_target_gas_per_block ) return fn @@ -1818,7 +1820,7 @@ class Prague(Cancun): "MAX_BLOBS_PER_BLOCK": 9, # but overwrite or add these "TARGET_BLOBS_PER_BLOCK": 6, "MAX_BLOB_GAS_PER_BLOCK": 1179648, - "TARGET_BLOB_GAS_PER_BLOCK": 786432, + "BLOB_TARGET_GAS_PER_BLOCK": 786432, "BLOB_BASE_FEE_UPDATE_FRACTION": 5007716, } @@ -1870,10 +1872,10 @@ def gas_costs( super(Prague, cls).gas_costs( block_number=block_number, timestamp=timestamp ), - G_TX_DATA_STANDARD_TOKEN_COST=4, # https://eips.ethereum.org/EIPS/eip-7623 - G_TX_DATA_FLOOR_TOKEN_COST=10, - G_AUTHORIZATION=25_000, - R_AUTHORIZATION_EXISTING_AUTHORITY=12_500, + STANDARD_CALLDATA_TOKEN_COST=4, # https://eips.ethereum.org/EIPS/eip-7623 + FLOOR_CALLDATA_COST=10, + PER_EMPTY_ACCOUNT_COST=25_000, + PER_AUTH_BASE_COST=12_500, ) @classmethod @@ -1936,8 +1938,8 @@ def fn(*, data: BytesConvertible, floor: bool = False) -> int: else: tokens += 4 if floor: - return tokens * gas_costs.G_TX_DATA_FLOOR_TOKEN_COST - return tokens * gas_costs.G_TX_DATA_STANDARD_TOKEN_COST + return tokens * gas_costs.FLOOR_CALLDATA_COST + return tokens * gas_costs.STANDARD_CALLDATA_TOKEN_COST return fn @@ -1959,7 +1961,7 @@ def transaction_data_floor_cost_calculator( def fn(*, data: BytesConvertible) -> int: return ( calldata_gas_calculator(data=data, floor=True) - + gas_costs.G_TRANSACTION + + gas_costs.TX_BASE_COST ) return fn @@ -2004,7 +2006,8 @@ def fn( authorization_list_or_count ) intrinsic_cost += ( - authorization_list_or_count * gas_costs.G_AUTHORIZATION + authorization_list_or_count + * gas_costs.PER_EMPTY_ACCOUNT_COST ) if return_cost_deducted_prior_execution: @@ -2257,7 +2260,7 @@ def excess_blob_gas_calculator( blob_gas_per_blob = cls.blob_gas_per_blob( block_number=block_number, timestamp=timestamp ) - target_blob_gas_per_block = target_blobs_per_block * blob_gas_per_blob + blob_target_gas_per_block = target_blobs_per_block * blob_gas_per_blob max_blobs_per_block = cls.max_blobs_per_block( block_number=block_number, timestamp=timestamp ) @@ -2285,7 +2288,7 @@ def fn( parent_blob_gas_used = parent_blob_count * blob_gas_per_blob if ( parent_excess_blob_gas + parent_blob_gas_used - < target_blob_gas_per_block + < blob_target_gas_per_block ): return 0 @@ -2310,7 +2313,7 @@ def fn( return ( parent_excess_blob_gas + parent_blob_gas_used - - target_blob_gas_per_block + - blob_target_gas_per_block ) return fn diff --git a/packages/testing/src/execution_testing/forks/gas_costs.py b/packages/testing/src/execution_testing/forks/gas_costs.py index 7b73fc5f96..93eb17ad01 100644 --- a/packages/testing/src/execution_testing/forks/gas_costs.py +++ b/packages/testing/src/execution_testing/forks/gas_costs.py @@ -7,57 +7,56 @@ class GasCosts: """Class that contains the gas cost constants for any fork.""" - G_JUMPDEST: int - G_BASE: int - G_VERY_LOW: int - G_LOW: int - G_MID: int - G_HIGH: int - G_WARM_ACCOUNT_ACCESS: int - G_COLD_ACCOUNT_ACCESS: int - G_ACCESS_LIST_ADDRESS: int - G_ACCESS_LIST_STORAGE: int - G_WARM_SLOAD: int - G_COLD_SLOAD: int - G_STORAGE_SET: int - G_STORAGE_RESET: int + GAS_JUMPDEST: int + GAS_BASE: int + GAS_VERY_LOW: int + GAS_LOW: int + GAS_MID: int + GAS_HIGH: int + GAS_COLD_ACCOUNT_ACCESS: int + TX_ACCESS_LIST_ADDRESS_COST: int + TX_ACCESS_LIST_STORAGE_KEY_COST: int + GAS_WARM_ACCESS: int + GAS_COLD_SLOAD: int + GAS_STORAGE_SET: int + GAS_STORAGE_UPDATE: int - R_STORAGE_CLEAR: int + GAS_STORAGE_CLEAR_REFUND: int - G_SELF_DESTRUCT: int - G_CREATE: int + GAS_SELF_DESTRUCT: int + GAS_CREATE: int - G_CODE_DEPOSIT_BYTE: int - G_INITCODE_WORD: int + GAS_CODE_DEPOSIT: int + GAS_INIT_CODE_WORD_COST: int - G_CALL_VALUE: int - G_CALL_STIPEND: int - G_NEW_ACCOUNT: int + GAS_CALL_VALUE: int + GAS_CALL_STIPEND: int + GAS_NEW_ACCOUNT: int - G_EXP: int - G_EXP_BYTE: int + GAS_EXPONENTIATION: int + GAS_EXPONENTIATION_PER_BYTE: int - G_MEMORY: int + GAS_MEMORY: int - G_TX_DATA_ZERO: int - G_TX_DATA_NON_ZERO: int - G_TX_DATA_STANDARD_TOKEN_COST: int - G_TX_DATA_FLOOR_TOKEN_COST: int + TX_DATA_COST_PER_ZERO: int + TX_DATA_COST_PER_NON_ZERO: int + STANDARD_CALLDATA_TOKEN_COST: int + FLOOR_CALLDATA_COST: int - G_TRANSACTION: int - G_TRANSACTION_CREATE: int + TX_BASE_COST: int + TX_CREATE_COST: int - G_LOG: int - G_LOG_DATA: int - G_LOG_TOPIC: int + GAS_LOG: int + GAS_LOG_DATA: int + GAS_LOG_TOPIC: int - G_KECCAK_256: int - G_KECCAK_256_WORD: int + GAS_KECCAK256: int + GAS_KECCAK256_WORD: int - G_COPY: int - G_BLOCKHASH: int + GAS_COPY: int + GAS_BLOCK_HASH: int - G_AUTHORIZATION: int + PER_EMPTY_ACCOUNT_COST: int # Precompiled contract gas constants @@ -68,4 +67,4 @@ class GasCosts: # Refund constants - R_AUTHORIZATION_EXISTING_AUTHORITY: int + PER_AUTH_BASE_COST: int diff --git a/packages/testing/src/execution_testing/specs/state.py b/packages/testing/src/execution_testing/specs/state.py index b6923aae7d..7bb9036940 100644 --- a/packages/testing/src/execution_testing/specs/state.py +++ b/packages/testing/src/execution_testing/specs/state.py @@ -280,7 +280,7 @@ def _generate_blockchain_genesis_environment(self) -> Environment: # context (block header) where the transaction is executed. In a # blockchain test, we need to indirectly set the excess blob gas by # setting the excess blob gas of the genesis block to the expected - # value plus the TARGET_BLOB_GAS_PER_BLOCK, which is the value that + # value plus the BLOB_TARGET_GAS_PER_BLOCK, which is the value that # will be subtracted from the excess blob gas when the first block # is mined. kwargs["excess_blob_gas"] = self.env.excess_blob_gas + ( diff --git a/packages/testing/src/execution_testing/tools/utility/generators.py b/packages/testing/src/execution_testing/tools/utility/generators.py index 0ff5cc4c0b..12a7b7f7b2 100644 --- a/packages/testing/src/execution_testing/tools/utility/generators.py +++ b/packages/testing/src/execution_testing/tools/utility/generators.py @@ -348,9 +348,9 @@ def wrapper( # code will only work once, so if the system contract is re- # executed in a subsequent block, it will consume less gas. gas_used_per_storage = ( - gas_costs.G_STORAGE_SET - + gas_costs.G_COLD_SLOAD - + (gas_costs.G_VERY_LOW * 2) + gas_costs.GAS_STORAGE_SET + + gas_costs.GAS_COLD_SLOAD + + (gas_costs.GAS_VERY_LOW * 2) ) modified_system_contract_code += sum( Op.SSTORE(i, 1) @@ -359,8 +359,8 @@ def wrapper( # If the gas limit is not divisible by the gas used per # storage, we need to add some NO-OP (JUMPDEST) to the code # that each consume 1 gas. - assert gas_costs.G_JUMPDEST == 1, ( - f"JUMPDEST gas cost should be 1, but got {gas_costs.G_JUMPDEST}. " + assert gas_costs.GAS_JUMPDEST == 1, ( + f"JUMPDEST gas cost should be 1, but got {gas_costs.GAS_JUMPDEST}. " "Generator `generate_system_contract_error_test` needs to be updated." ) modified_system_contract_code += sum( @@ -488,13 +488,13 @@ def gas_test( # 2 times GAS, POP, CALL, 6 times PUSH1 - instructions charged for at every # gas run gas_costs = fork.gas_costs() - OPCODE_GAS_COST = gas_costs.G_BASE - OPCODE_POP_COST = gas_costs.G_BASE - OPCODE_PUSH_COST = gas_costs.G_VERY_LOW + OPCODE_GAS_COST = gas_costs.GAS_BASE + OPCODE_POP_COST = gas_costs.GAS_BASE + OPCODE_PUSH_COST = gas_costs.GAS_VERY_LOW gas_single_gas_run = ( 2 * OPCODE_GAS_COST + OPCODE_POP_COST - + gas_costs.G_WARM_ACCOUNT_ACCESS + + gas_costs.GAS_WARM_ACCESS + 6 * OPCODE_PUSH_COST ) address_legacy_harness = pre.deploy_contract( diff --git a/src/ethereum/forks/amsterdam/vm/gas.py b/src/ethereum/forks/amsterdam/vm/gas.py index 360a4430e3..0d71ba386c 100644 --- a/src/ethereum/forks/amsterdam/vm/gas.py +++ b/src/ethereum/forks/amsterdam/vm/gas.py @@ -71,10 +71,10 @@ GAS_PER_BLOB = U64(2**17) BLOB_SCHEDULE_TARGET = U64(14) -TARGET_BLOB_GAS_PER_BLOCK = GAS_PER_BLOB * BLOB_SCHEDULE_TARGET +BLOB_TARGET_GAS_PER_BLOCK = GAS_PER_BLOB * BLOB_SCHEDULE_TARGET BLOB_BASE_COST = Uint(2**13) BLOB_SCHEDULE_MAX = U64(21) -MIN_BLOB_GASPRICE = Uint(1) +BLOB_MIN_GASPRICE = Uint(1) BLOB_BASE_FEE_UPDATE_FRACTION = Uint(11684671) GAS_BLS_G1_ADD = Uint(375) @@ -314,7 +314,7 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64: base_fee_per_gas = parent_header.base_fee_per_gas parent_blob_gas = excess_blob_gas + blob_gas_used - if parent_blob_gas < TARGET_BLOB_GAS_PER_BLOCK: + if parent_blob_gas < BLOB_TARGET_GAS_PER_BLOCK: return U64(0) target_blob_gas_price = Uint(GAS_PER_BLOB) @@ -328,7 +328,7 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64: + blob_gas_used * blob_schedule_delta // BLOB_SCHEDULE_MAX ) - return parent_blob_gas - TARGET_BLOB_GAS_PER_BLOCK + return parent_blob_gas - BLOB_TARGET_GAS_PER_BLOCK def calculate_total_blob_gas(tx: Transaction) -> U64: @@ -368,7 +368,7 @@ def calculate_blob_gas_price(excess_blob_gas: U64) -> Uint: """ return taylor_exponential( - MIN_BLOB_GASPRICE, + BLOB_MIN_GASPRICE, Uint(excess_blob_gas), BLOB_BASE_FEE_UPDATE_FRACTION, ) diff --git a/src/ethereum/forks/bpo1/vm/gas.py b/src/ethereum/forks/bpo1/vm/gas.py index fc4c8618f5..e410ada7c9 100644 --- a/src/ethereum/forks/bpo1/vm/gas.py +++ b/src/ethereum/forks/bpo1/vm/gas.py @@ -71,10 +71,10 @@ GAS_PER_BLOB = U64(2**17) BLOB_SCHEDULE_TARGET = U64(10) -TARGET_BLOB_GAS_PER_BLOCK = GAS_PER_BLOB * BLOB_SCHEDULE_TARGET +BLOB_TARGET_GAS_PER_BLOCK = GAS_PER_BLOB * BLOB_SCHEDULE_TARGET BLOB_BASE_COST = Uint(2**13) BLOB_SCHEDULE_MAX = U64(15) -MIN_BLOB_GASPRICE = Uint(1) +BLOB_MIN_GASPRICE = Uint(1) BLOB_BASE_FEE_UPDATE_FRACTION = Uint(8346193) GAS_BLS_G1_ADD = Uint(375) @@ -314,7 +314,7 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64: base_fee_per_gas = parent_header.base_fee_per_gas parent_blob_gas = excess_blob_gas + blob_gas_used - if parent_blob_gas < TARGET_BLOB_GAS_PER_BLOCK: + if parent_blob_gas < BLOB_TARGET_GAS_PER_BLOCK: return U64(0) target_blob_gas_price = Uint(GAS_PER_BLOB) @@ -328,7 +328,7 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64: + blob_gas_used * blob_schedule_delta // BLOB_SCHEDULE_MAX ) - return parent_blob_gas - TARGET_BLOB_GAS_PER_BLOCK + return parent_blob_gas - BLOB_TARGET_GAS_PER_BLOCK def calculate_total_blob_gas(tx: Transaction) -> U64: @@ -368,7 +368,7 @@ def calculate_blob_gas_price(excess_blob_gas: U64) -> Uint: """ return taylor_exponential( - MIN_BLOB_GASPRICE, + BLOB_MIN_GASPRICE, Uint(excess_blob_gas), BLOB_BASE_FEE_UPDATE_FRACTION, ) diff --git a/src/ethereum/forks/bpo2/vm/gas.py b/src/ethereum/forks/bpo2/vm/gas.py index 360a4430e3..0d71ba386c 100644 --- a/src/ethereum/forks/bpo2/vm/gas.py +++ b/src/ethereum/forks/bpo2/vm/gas.py @@ -71,10 +71,10 @@ GAS_PER_BLOB = U64(2**17) BLOB_SCHEDULE_TARGET = U64(14) -TARGET_BLOB_GAS_PER_BLOCK = GAS_PER_BLOB * BLOB_SCHEDULE_TARGET +BLOB_TARGET_GAS_PER_BLOCK = GAS_PER_BLOB * BLOB_SCHEDULE_TARGET BLOB_BASE_COST = Uint(2**13) BLOB_SCHEDULE_MAX = U64(21) -MIN_BLOB_GASPRICE = Uint(1) +BLOB_MIN_GASPRICE = Uint(1) BLOB_BASE_FEE_UPDATE_FRACTION = Uint(11684671) GAS_BLS_G1_ADD = Uint(375) @@ -314,7 +314,7 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64: base_fee_per_gas = parent_header.base_fee_per_gas parent_blob_gas = excess_blob_gas + blob_gas_used - if parent_blob_gas < TARGET_BLOB_GAS_PER_BLOCK: + if parent_blob_gas < BLOB_TARGET_GAS_PER_BLOCK: return U64(0) target_blob_gas_price = Uint(GAS_PER_BLOB) @@ -328,7 +328,7 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64: + blob_gas_used * blob_schedule_delta // BLOB_SCHEDULE_MAX ) - return parent_blob_gas - TARGET_BLOB_GAS_PER_BLOCK + return parent_blob_gas - BLOB_TARGET_GAS_PER_BLOCK def calculate_total_blob_gas(tx: Transaction) -> U64: @@ -368,7 +368,7 @@ def calculate_blob_gas_price(excess_blob_gas: U64) -> Uint: """ return taylor_exponential( - MIN_BLOB_GASPRICE, + BLOB_MIN_GASPRICE, Uint(excess_blob_gas), BLOB_BASE_FEE_UPDATE_FRACTION, ) diff --git a/src/ethereum/forks/bpo3/vm/gas.py b/src/ethereum/forks/bpo3/vm/gas.py index 360a4430e3..0d71ba386c 100644 --- a/src/ethereum/forks/bpo3/vm/gas.py +++ b/src/ethereum/forks/bpo3/vm/gas.py @@ -71,10 +71,10 @@ GAS_PER_BLOB = U64(2**17) BLOB_SCHEDULE_TARGET = U64(14) -TARGET_BLOB_GAS_PER_BLOCK = GAS_PER_BLOB * BLOB_SCHEDULE_TARGET +BLOB_TARGET_GAS_PER_BLOCK = GAS_PER_BLOB * BLOB_SCHEDULE_TARGET BLOB_BASE_COST = Uint(2**13) BLOB_SCHEDULE_MAX = U64(21) -MIN_BLOB_GASPRICE = Uint(1) +BLOB_MIN_GASPRICE = Uint(1) BLOB_BASE_FEE_UPDATE_FRACTION = Uint(11684671) GAS_BLS_G1_ADD = Uint(375) @@ -314,7 +314,7 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64: base_fee_per_gas = parent_header.base_fee_per_gas parent_blob_gas = excess_blob_gas + blob_gas_used - if parent_blob_gas < TARGET_BLOB_GAS_PER_BLOCK: + if parent_blob_gas < BLOB_TARGET_GAS_PER_BLOCK: return U64(0) target_blob_gas_price = Uint(GAS_PER_BLOB) @@ -328,7 +328,7 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64: + blob_gas_used * blob_schedule_delta // BLOB_SCHEDULE_MAX ) - return parent_blob_gas - TARGET_BLOB_GAS_PER_BLOCK + return parent_blob_gas - BLOB_TARGET_GAS_PER_BLOCK def calculate_total_blob_gas(tx: Transaction) -> U64: @@ -368,7 +368,7 @@ def calculate_blob_gas_price(excess_blob_gas: U64) -> Uint: """ return taylor_exponential( - MIN_BLOB_GASPRICE, + BLOB_MIN_GASPRICE, Uint(excess_blob_gas), BLOB_BASE_FEE_UPDATE_FRACTION, ) diff --git a/src/ethereum/forks/bpo4/vm/gas.py b/src/ethereum/forks/bpo4/vm/gas.py index 360a4430e3..0d71ba386c 100644 --- a/src/ethereum/forks/bpo4/vm/gas.py +++ b/src/ethereum/forks/bpo4/vm/gas.py @@ -71,10 +71,10 @@ GAS_PER_BLOB = U64(2**17) BLOB_SCHEDULE_TARGET = U64(14) -TARGET_BLOB_GAS_PER_BLOCK = GAS_PER_BLOB * BLOB_SCHEDULE_TARGET +BLOB_TARGET_GAS_PER_BLOCK = GAS_PER_BLOB * BLOB_SCHEDULE_TARGET BLOB_BASE_COST = Uint(2**13) BLOB_SCHEDULE_MAX = U64(21) -MIN_BLOB_GASPRICE = Uint(1) +BLOB_MIN_GASPRICE = Uint(1) BLOB_BASE_FEE_UPDATE_FRACTION = Uint(11684671) GAS_BLS_G1_ADD = Uint(375) @@ -314,7 +314,7 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64: base_fee_per_gas = parent_header.base_fee_per_gas parent_blob_gas = excess_blob_gas + blob_gas_used - if parent_blob_gas < TARGET_BLOB_GAS_PER_BLOCK: + if parent_blob_gas < BLOB_TARGET_GAS_PER_BLOCK: return U64(0) target_blob_gas_price = Uint(GAS_PER_BLOB) @@ -328,7 +328,7 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64: + blob_gas_used * blob_schedule_delta // BLOB_SCHEDULE_MAX ) - return parent_blob_gas - TARGET_BLOB_GAS_PER_BLOCK + return parent_blob_gas - BLOB_TARGET_GAS_PER_BLOCK def calculate_total_blob_gas(tx: Transaction) -> U64: @@ -368,7 +368,7 @@ def calculate_blob_gas_price(excess_blob_gas: U64) -> Uint: """ return taylor_exponential( - MIN_BLOB_GASPRICE, + BLOB_MIN_GASPRICE, Uint(excess_blob_gas), BLOB_BASE_FEE_UPDATE_FRACTION, ) diff --git a/src/ethereum/forks/bpo5/vm/gas.py b/src/ethereum/forks/bpo5/vm/gas.py index 360a4430e3..0d71ba386c 100644 --- a/src/ethereum/forks/bpo5/vm/gas.py +++ b/src/ethereum/forks/bpo5/vm/gas.py @@ -71,10 +71,10 @@ GAS_PER_BLOB = U64(2**17) BLOB_SCHEDULE_TARGET = U64(14) -TARGET_BLOB_GAS_PER_BLOCK = GAS_PER_BLOB * BLOB_SCHEDULE_TARGET +BLOB_TARGET_GAS_PER_BLOCK = GAS_PER_BLOB * BLOB_SCHEDULE_TARGET BLOB_BASE_COST = Uint(2**13) BLOB_SCHEDULE_MAX = U64(21) -MIN_BLOB_GASPRICE = Uint(1) +BLOB_MIN_GASPRICE = Uint(1) BLOB_BASE_FEE_UPDATE_FRACTION = Uint(11684671) GAS_BLS_G1_ADD = Uint(375) @@ -314,7 +314,7 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64: base_fee_per_gas = parent_header.base_fee_per_gas parent_blob_gas = excess_blob_gas + blob_gas_used - if parent_blob_gas < TARGET_BLOB_GAS_PER_BLOCK: + if parent_blob_gas < BLOB_TARGET_GAS_PER_BLOCK: return U64(0) target_blob_gas_price = Uint(GAS_PER_BLOB) @@ -328,7 +328,7 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64: + blob_gas_used * blob_schedule_delta // BLOB_SCHEDULE_MAX ) - return parent_blob_gas - TARGET_BLOB_GAS_PER_BLOCK + return parent_blob_gas - BLOB_TARGET_GAS_PER_BLOCK def calculate_total_blob_gas(tx: Transaction) -> U64: @@ -368,7 +368,7 @@ def calculate_blob_gas_price(excess_blob_gas: U64) -> Uint: """ return taylor_exponential( - MIN_BLOB_GASPRICE, + BLOB_MIN_GASPRICE, Uint(excess_blob_gas), BLOB_BASE_FEE_UPDATE_FRACTION, ) diff --git a/src/ethereum/forks/cancun/vm/gas.py b/src/ethereum/forks/cancun/vm/gas.py index 241315a994..93173d6f49 100644 --- a/src/ethereum/forks/cancun/vm/gas.py +++ b/src/ethereum/forks/cancun/vm/gas.py @@ -69,8 +69,8 @@ GAS_POINT_EVALUATION = Uint(50000) GAS_PER_BLOB = U64(2**17) -TARGET_BLOB_GAS_PER_BLOCK = U64(393216) -MIN_BLOB_GASPRICE = Uint(1) +BLOB_TARGET_GAS_PER_BLOCK = U64(393216) +BLOB_MIN_GASPRICE = Uint(1) BLOB_BASE_FEE_UPDATE_FRACTION = Uint(3338477) @@ -301,10 +301,10 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64: blob_gas_used = parent_header.blob_gas_used parent_blob_gas = excess_blob_gas + blob_gas_used - if parent_blob_gas < TARGET_BLOB_GAS_PER_BLOCK: + if parent_blob_gas < BLOB_TARGET_GAS_PER_BLOCK: return U64(0) - return parent_blob_gas - TARGET_BLOB_GAS_PER_BLOCK + return parent_blob_gas - BLOB_TARGET_GAS_PER_BLOCK def calculate_total_blob_gas(tx: Transaction) -> U64: @@ -344,7 +344,7 @@ def calculate_blob_gas_price(excess_blob_gas: U64) -> Uint: """ return taylor_exponential( - MIN_BLOB_GASPRICE, + BLOB_MIN_GASPRICE, Uint(excess_blob_gas), BLOB_BASE_FEE_UPDATE_FRACTION, ) diff --git a/src/ethereum/forks/osaka/vm/gas.py b/src/ethereum/forks/osaka/vm/gas.py index 62118f4c6a..e71ed606df 100644 --- a/src/ethereum/forks/osaka/vm/gas.py +++ b/src/ethereum/forks/osaka/vm/gas.py @@ -71,10 +71,10 @@ GAS_PER_BLOB = U64(2**17) BLOB_SCHEDULE_TARGET = U64(6) -TARGET_BLOB_GAS_PER_BLOCK = GAS_PER_BLOB * BLOB_SCHEDULE_TARGET +BLOB_TARGET_GAS_PER_BLOCK = GAS_PER_BLOB * BLOB_SCHEDULE_TARGET BLOB_BASE_COST = Uint(2**13) BLOB_SCHEDULE_MAX = U64(9) -MIN_BLOB_GASPRICE = Uint(1) +BLOB_MIN_GASPRICE = Uint(1) BLOB_BASE_FEE_UPDATE_FRACTION = Uint(5007716) GAS_BLS_G1_ADD = Uint(375) @@ -314,7 +314,7 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64: base_fee_per_gas = parent_header.base_fee_per_gas parent_blob_gas = excess_blob_gas + blob_gas_used - if parent_blob_gas < TARGET_BLOB_GAS_PER_BLOCK: + if parent_blob_gas < BLOB_TARGET_GAS_PER_BLOCK: return U64(0) target_blob_gas_price = Uint(GAS_PER_BLOB) @@ -328,7 +328,7 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64: + blob_gas_used * blob_schedule_delta // BLOB_SCHEDULE_MAX ) - return parent_blob_gas - TARGET_BLOB_GAS_PER_BLOCK + return parent_blob_gas - BLOB_TARGET_GAS_PER_BLOCK def calculate_total_blob_gas(tx: Transaction) -> U64: @@ -368,7 +368,7 @@ def calculate_blob_gas_price(excess_blob_gas: U64) -> Uint: """ return taylor_exponential( - MIN_BLOB_GASPRICE, + BLOB_MIN_GASPRICE, Uint(excess_blob_gas), BLOB_BASE_FEE_UPDATE_FRACTION, ) diff --git a/src/ethereum/forks/prague/vm/gas.py b/src/ethereum/forks/prague/vm/gas.py index 8bb3c042cb..48afe99a99 100644 --- a/src/ethereum/forks/prague/vm/gas.py +++ b/src/ethereum/forks/prague/vm/gas.py @@ -69,8 +69,8 @@ GAS_POINT_EVALUATION = Uint(50000) GAS_PER_BLOB = U64(2**17) -TARGET_BLOB_GAS_PER_BLOCK = U64(786432) -MIN_BLOB_GASPRICE = Uint(1) +BLOB_TARGET_GAS_PER_BLOCK = U64(786432) +BLOB_MIN_GASPRICE = Uint(1) BLOB_BASE_FEE_UPDATE_FRACTION = Uint(5007716) GAS_BLS_G1_ADD = Uint(375) @@ -308,10 +308,10 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64: blob_gas_used = parent_header.blob_gas_used parent_blob_gas = excess_blob_gas + blob_gas_used - if parent_blob_gas < TARGET_BLOB_GAS_PER_BLOCK: + if parent_blob_gas < BLOB_TARGET_GAS_PER_BLOCK: return U64(0) - return parent_blob_gas - TARGET_BLOB_GAS_PER_BLOCK + return parent_blob_gas - BLOB_TARGET_GAS_PER_BLOCK def calculate_total_blob_gas(tx: Transaction) -> U64: @@ -351,7 +351,7 @@ def calculate_blob_gas_price(excess_blob_gas: U64) -> Uint: """ return taylor_exponential( - MIN_BLOB_GASPRICE, + BLOB_MIN_GASPRICE, Uint(excess_blob_gas), BLOB_BASE_FEE_UPDATE_FRACTION, ) diff --git a/src/ethereum_spec_tools/evm_tools/t8n/__init__.py b/src/ethereum_spec_tools/evm_tools/t8n/__init__.py index fc09dfd8a3..d05f1f7a0e 100644 --- a/src/ethereum_spec_tools/evm_tools/t8n/__init__.py +++ b/src/ethereum_spec_tools/evm_tools/t8n/__init__.py @@ -109,9 +109,9 @@ def get( self, template: Hardfork, fork_criteria: ByBlockNumber | ByTimestamp | Unscheduled | None = None, - target_blob_gas_per_block: U64 | None = None, + blob_target_gas_per_block: U64 | None = None, gas_per_blob: U64 | None = None, - min_blob_gasprice: Uint | None = None, + blob_min_gasprice: Uint | None = None, blob_base_fee_update_fraction: Uint | None = None, max_blob_gas_per_block: U64 | None = None, blob_schedule_target: U64 | None = None, @@ -124,9 +124,9 @@ def get( cache_key = ( template.short_name, fork_criteria, - target_blob_gas_per_block, + blob_target_gas_per_block, gas_per_blob, - min_blob_gasprice, + blob_min_gasprice, blob_base_fee_update_fraction, max_blob_gas_per_block, blob_schedule_target, @@ -143,9 +143,9 @@ def get( clone = Hardfork.clone( template=template, fork_criteria=fork_criteria, - target_blob_gas_per_block=target_blob_gas_per_block, + blob_target_gas_per_block=blob_target_gas_per_block, gas_per_blob=gas_per_blob, - min_blob_gasprice=min_blob_gasprice, + blob_min_gasprice=blob_min_gasprice, blob_base_fee_update_fraction=blob_base_fee_update_fraction, max_blob_gas_per_block=max_blob_gas_per_block, blob_schedule_target=blob_schedule_target, diff --git a/src/ethereum_spec_tools/forks.py b/src/ethereum_spec_tools/forks.py index 5f7109400c..112da3ad59 100644 --- a/src/ethereum_spec_tools/forks.py +++ b/src/ethereum_spec_tools/forks.py @@ -196,9 +196,9 @@ def clone( fork_criteria: Union[ "ByBlockNumber", "ByTimestamp", "Unscheduled", None ] = None, - target_blob_gas_per_block: U64 | None = None, + blob_target_gas_per_block: U64 | None = None, gas_per_blob: U64 | None = None, - min_blob_gasprice: Uint | None = None, + blob_min_gasprice: Uint | None = None, blob_base_fee_update_fraction: Uint | None = None, max_blob_gas_per_block: U64 | None = None, blob_schedule_target: U64 | None = None, @@ -232,16 +232,16 @@ def clone( if fork_criteria is not None: builder.fork_criteria = fork_criteria - if target_blob_gas_per_block is not None: + if blob_target_gas_per_block is not None: builder.modify_target_blob_gas_per_block( - target_blob_gas_per_block + blob_target_gas_per_block ) if gas_per_blob is not None: builder.modify_gas_per_blob(gas_per_blob) - if min_blob_gasprice is not None: - builder.modify_min_blob_gasprice(min_blob_gasprice) + if blob_min_gasprice is not None: + builder.modify_min_blob_gasprice(blob_min_gasprice) if blob_base_fee_update_fraction is not None: builder.modify_blob_base_fee_update_fraction( diff --git a/src/ethereum_spec_tools/new_fork/builder.py b/src/ethereum_spec_tools/new_fork/builder.py index cb625d214e..01ac05baf8 100644 --- a/src/ethereum_spec_tools/new_fork/builder.py +++ b/src/ethereum_spec_tools/new_fork/builder.py @@ -484,13 +484,13 @@ def build(self) -> None: self._commit(package) def modify_target_blob_gas_per_block( - self, target_blob_gas_per_block: U64 + self, blob_target_gas_per_block: U64 ) -> None: - """Append a `CodemodArgs` that sets `TARGET_BLOB_GAS_PER_BLOCK`.""" + """Append a `CodemodArgs` that sets `BLOB_TARGET_GAS_PER_BLOCK`.""" self.modifiers.append( SetConstant( - "vm.gas.TARGET_BLOB_GAS_PER_BLOCK", - repr(target_blob_gas_per_block), + "vm.gas.BLOB_TARGET_GAS_PER_BLOCK", + repr(blob_target_gas_per_block), ) ) @@ -503,12 +503,12 @@ def modify_gas_per_blob(self, gas_per_blob: U64) -> None: ) ) - def modify_min_blob_gasprice(self, min_blob_gasprice: Uint) -> None: - """Append a `CodemodArgs` that sets `MIN_BLOB_GASPRICE`.""" + def modify_min_blob_gasprice(self, blob_min_gasprice: Uint) -> None: + """Append a `CodemodArgs` that sets `BLOB_MIN_GASPRICE`.""" self.modifiers.append( SetConstant( - "vm.gas.MIN_BLOB_GASPRICE", - repr(min_blob_gasprice), + "vm.gas.BLOB_MIN_GASPRICE", + repr(blob_min_gasprice), ) ) diff --git a/src/ethereum_spec_tools/new_fork/cli.py b/src/ethereum_spec_tools/new_fork/cli.py index 0323a6ea7f..222abb2e86 100644 --- a/src/ethereum_spec_tools/new_fork/cli.py +++ b/src/ethereum_spec_tools/new_fork/cli.py @@ -89,9 +89,9 @@ def _make_parser() -> ArgumentParser: blob_parameters.add_argument( "--target-blob-gas-per-block", type=lambda x: U64(int(x)), - dest="target_blob_gas_per_block", + dest="blob_target_gas_per_block", default=None, - help="Set `TARGET_BLOB_GAS_PER_BLOCK` in the generated fork", + help="Set `BLOB_TARGET_GAS_PER_BLOCK` in the generated fork", ) blob_parameters.add_argument( @@ -105,9 +105,9 @@ def _make_parser() -> ArgumentParser: blob_parameters.add_argument( "--min-blob-gasprice", type=lambda x: Uint(int(x)), - dest="min_blob_gasprice", + dest="blob_min_gasprice", default=None, - help="Set `MIN_BLOB_GASPRICE` in the generated fork", + help="Set `BLOB_MIN_GASPRICE` in the generated fork", ) blob_parameters.add_argument( @@ -169,16 +169,16 @@ def main(args: Sequence[str] | None = None) -> None: if options.fork_criteria is not None: builder.fork_criteria = options.fork_criteria - if options.target_blob_gas_per_block is not None: + if options.blob_target_gas_per_block is not None: builder.modify_target_blob_gas_per_block( - options.target_blob_gas_per_block + options.blob_target_gas_per_block ) if options.gas_per_blob is not None: builder.modify_gas_per_blob(options.gas_per_blob) - if options.min_blob_gasprice is not None: - builder.modify_min_blob_gasprice(options.min_blob_gasprice) + if options.blob_min_gasprice is not None: + builder.modify_min_blob_gasprice(options.blob_min_gasprice) if options.blob_base_fee_update_fraction is not None: builder.modify_blob_base_fee_update_fraction( diff --git a/tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py b/tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py index d6c7948f13..ade6c963a6 100644 --- a/tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py +++ b/tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py @@ -1227,10 +1227,10 @@ def test_bal_noop_storage_write( gas_limit = ( intrinsic_gas_calculator() # Sufficient gas for write - + fork.gas_costs().G_COLD_SLOAD - + fork.gas_costs().G_COLD_ACCOUNT_ACCESS - + fork.gas_costs().G_STORAGE_SET - + fork.gas_costs().G_BASE * 10 # Buffer for push + + fork.gas_costs().GAS_COLD_SLOAD + + fork.gas_costs().GAS_COLD_ACCOUNT_ACCESS + + fork.gas_costs().GAS_STORAGE_SET + + fork.gas_costs().GAS_BASE * 10 # Buffer for push ) tx = Transaction( diff --git a/tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_opcodes.py b/tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_opcodes.py index 5e5ebaefe3..4a21bbd81f 100644 --- a/tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_opcodes.py +++ b/tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_opcodes.py @@ -87,13 +87,13 @@ def test_bal_sstore_and_oog( intrinsic_gas_cost = intrinsic_gas_calculator() # Costs: - # - PUSH1 (value and slot) = G_VERY_LOW * 2 - # - SSTORE cold (to zero slot) = G_STORAGE_SET + G_COLD_SLOAD - sload_cost = gas_costs.G_COLD_SLOAD - sstore_cost = gas_costs.G_STORAGE_SET + # - PUSH1 (value and slot) = GAS_VERY_LOW * 2 + # - SSTORE cold (to zero slot) = GAS_STORAGE_SET + GAS_COLD_SLOAD + sload_cost = gas_costs.GAS_COLD_SLOAD + sstore_cost = gas_costs.GAS_STORAGE_SET sstore_cold_cost = sstore_cost + sload_cost - push_cost = gas_costs.G_VERY_LOW * 2 - stipend = gas_costs.G_CALL_STIPEND + push_cost = gas_costs.GAS_VERY_LOW * 2 + stipend = gas_costs.GAS_CALL_STIPEND if out_of_gas_at == OutOfGasAt.EIP_2200_STIPEND: # 2300 after PUSHes (fails stipend check: 2300 <= 2300) @@ -185,10 +185,10 @@ def test_bal_sload_and_oog( intrinsic_gas_cost = intrinsic_gas_calculator() # Costs: - # - PUSH1 (slot) = G_VERY_LOW - # - SLOAD cold = G_COLD_SLOAD - push_cost = gas_costs.G_VERY_LOW - sload_cold_cost = gas_costs.G_COLD_SLOAD + # - PUSH1 (slot) = GAS_VERY_LOW + # - SLOAD cold = GAS_COLD_SLOAD + push_cost = gas_costs.GAS_VERY_LOW + sload_cold_cost = gas_costs.GAS_COLD_SLOAD tx_gas_limit = intrinsic_gas_cost + push_cost + sload_cold_cost if fails_at_sload: @@ -251,10 +251,10 @@ def test_bal_balance_and_oog( intrinsic_gas_cost = intrinsic_gas_calculator() # Costs: - # - PUSH20 = G_VERY_LOW - # - BALANCE cold = G_COLD_ACCOUNT_ACCESS - push_cost = gas_costs.G_VERY_LOW - balance_cold_cost = gas_costs.G_COLD_ACCOUNT_ACCESS + # - PUSH20 = GAS_VERY_LOW + # - BALANCE cold = GAS_COLD_ACCOUNT_ACCESS + push_cost = gas_costs.GAS_VERY_LOW + balance_cold_cost = gas_costs.GAS_COLD_ACCOUNT_ACCESS tx_gas_limit = intrinsic_gas_cost + push_cost + balance_cold_cost if fails_at_balance: @@ -326,10 +326,10 @@ def test_bal_extcodesize_and_oog( intrinsic_gas_cost = intrinsic_gas_calculator() # Costs: - # - PUSH20 = G_VERY_LOW - # - EXTCODESIZE cold = G_COLD_ACCOUNT_ACCESS - push_cost = gas_costs.G_VERY_LOW - extcodesize_cold_cost = gas_costs.G_COLD_ACCOUNT_ACCESS + # - PUSH20 = GAS_VERY_LOW + # - EXTCODESIZE cold = GAS_COLD_ACCOUNT_ACCESS + push_cost = gas_costs.GAS_VERY_LOW + extcodesize_cold_cost = gas_costs.GAS_COLD_ACCOUNT_ACCESS tx_gas_limit = intrinsic_gas_cost + push_cost + extcodesize_cold_cost if fails_at_extcodesize: @@ -401,10 +401,10 @@ def test_bal_call_and_oog( intrinsic_gas_cost = intrinsic_gas_calculator() # Costs: - # - 7 PUSH operations = G_VERY_LOW * 7 - # - CALL cold = G_COLD_ACCOUNT_ACCESS (minimum for account access) - push_cost = gas_costs.G_VERY_LOW * 7 - call_cold_cost = gas_costs.G_COLD_ACCOUNT_ACCESS + # - 7 PUSH operations = GAS_VERY_LOW * 7 + # - CALL cold = GAS_COLD_ACCOUNT_ACCESS (minimum for account access) + push_cost = gas_costs.GAS_VERY_LOW * 7 + call_cold_cost = gas_costs.GAS_COLD_ACCOUNT_ACCESS tx_gas_limit = intrinsic_gas_cost + push_cost + call_cold_cost if fails_at_call: @@ -483,10 +483,10 @@ def test_bal_delegatecall_and_oog( intrinsic_gas_cost = intrinsic_gas_calculator() # Costs: - # - 6 PUSH operations = G_VERY_LOW * 6 - # - DELEGATECALL cold = G_COLD_ACCOUNT_ACCESS - push_cost = gas_costs.G_VERY_LOW * 6 - delegatecall_cold_cost = gas_costs.G_COLD_ACCOUNT_ACCESS + # - 6 PUSH operations = GAS_VERY_LOW * 6 + # - DELEGATECALL cold = GAS_COLD_ACCOUNT_ACCESS + push_cost = gas_costs.GAS_VERY_LOW * 6 + delegatecall_cold_cost = gas_costs.GAS_COLD_ACCOUNT_ACCESS tx_gas_limit = intrinsic_gas_cost + push_cost + delegatecall_cold_cost if fails_at_delegatecall: @@ -563,13 +563,13 @@ def test_bal_extcodecopy_and_oog( intrinsic_gas_cost = intrinsic_gas_calculator() # Costs: - # - 4 PUSH operations = G_VERY_LOW * 4 - # - EXTCODECOPY cold = G_COLD_ACCOUNT_ACCESS + (G_COPY * words) + # - 4 PUSH operations = GAS_VERY_LOW * 4 + # - EXTCODECOPY cold = GAS_COLD_ACCOUNT_ACCESS + (GAS_COPY * words) # where words = ceil32(size) // 32 = ceil32(0) // 32 = 0 - push_cost = gas_costs.G_VERY_LOW * 4 + push_cost = gas_costs.GAS_VERY_LOW * 4 extcodecopy_cold_cost = ( - gas_costs.G_COLD_ACCOUNT_ACCESS - ) # + (G_COPY * 0) = 0 + gas_costs.GAS_COLD_ACCOUNT_ACCESS + ) # + (GAS_COPY * 0) = 0 tx_gas_limit = intrinsic_gas_cost + push_cost + extcodecopy_cold_cost if fails_at_extcodecopy: diff --git a/tests/benchmark/compute/helpers.py b/tests/benchmark/compute/helpers.py index 981c7fbbfd..d8dcec85b2 100644 --- a/tests/benchmark/compute/helpers.py +++ b/tests/benchmark/compute/helpers.py @@ -171,19 +171,19 @@ def calculate_optimal_input_length( for input_length in range(1, 1_000_000, 32): parameters_gas = ( - gsc.G_BASE # PUSH0 = arg offset - + gsc.G_BASE # PUSH0 = arg size - + gsc.G_BASE # PUSH0 = arg size - + gsc.G_VERY_LOW # PUSH0 = arg offset - + gsc.G_VERY_LOW # PUSHN = address - + gsc.G_BASE # GAS + gsc.GAS_BASE # PUSH0 = arg offset + + gsc.GAS_BASE # PUSH0 = arg size + + gsc.GAS_BASE # PUSH0 = arg size + + gsc.GAS_VERY_LOW # PUSH0 = arg offset + + gsc.GAS_VERY_LOW # PUSHN = address + + gsc.GAS_BASE # GAS ) iteration_gas_cost = ( parameters_gas + static_cost # Precompile static cost + math.ceil(input_length / 32) * per_word_dynamic_cost # Precompile dynamic cost - + gsc.G_BASE # POP + + gsc.GAS_BASE # POP ) # From the available gas, subtract the memory expansion costs diff --git a/tests/benchmark/compute/instruction/test_account_query.py b/tests/benchmark/compute/instruction/test_account_query.py index fcb2ed891e..29b7cefd3f 100644 --- a/tests/benchmark/compute/instruction/test_account_query.py +++ b/tests/benchmark/compute/instruction/test_account_query.py @@ -174,24 +174,26 @@ def test_extcode_ops( new_bytes=len(bytes(max_contract_size)) ) code_deposit_gas_minimum = ( - fork.gas_costs().G_CODE_DEPOSIT_BYTE * max_contract_size + fork.gas_costs().GAS_CODE_DEPOSIT * max_contract_size + memory_gas_minimum ) intrinsic_gas_cost_calc = fork.transaction_intrinsic_cost_calculator() # Calculate the loop cost of the attacker to query one address loop_cost = ( - gas_costs.G_KECCAK_256 # KECCAK static cost - + math.ceil(85 / 32) * gas_costs.G_KECCAK_256_WORD # KECCAK dynamic + gas_costs.GAS_KECCAK256 # KECCAK static cost + + math.ceil(85 / 32) * gas_costs.GAS_KECCAK256_WORD # KECCAK dynamic # cost for CREATE2 - + gas_costs.G_VERY_LOW * 3 # ~MSTOREs+ADDs - + gas_costs.G_COLD_ACCOUNT_ACCESS # Opcode cost + + gas_costs.GAS_VERY_LOW * 3 # ~MSTOREs+ADDs + + gas_costs.GAS_COLD_ACCOUNT_ACCESS # Opcode cost + 30 # ~Gluing opcodes ) # Calculate the number of contracts to be targeted num_contracts = ( # Base available gas = GAS_LIMIT - intrinsic - (out of loop MSTOREs) - attack_gas_limit - intrinsic_gas_cost_calc() - gas_costs.G_VERY_LOW * 4 + attack_gas_limit + - intrinsic_gas_cost_calc() + - gas_costs.GAS_VERY_LOW * 4 ) // loop_cost # Set the block gas limit to a relative high value to ensure the code @@ -492,7 +494,7 @@ def test_ext_account_query_cold( # transaction runs out of gas. num_target_accounts = ( attack_gas_limit - intrinsic_gas_cost_calc() - ) // gas_costs.G_COLD_ACCOUNT_ACCESS + ) // gas_costs.GAS_COLD_ACCOUNT_ACCESS blocks = [] post = {} @@ -505,9 +507,9 @@ def test_ext_account_query_cold( if not absent_accounts: account_creation_gas = ( - gas_costs.G_COLD_ACCOUNT_ACCESS - + gas_costs.G_CALL_VALUE - + gas_costs.G_NEW_ACCOUNT + gas_costs.GAS_COLD_ACCOUNT_ACCESS + + gas_costs.GAS_CALL_VALUE + + gas_costs.GAS_NEW_ACCOUNT ) # To avoid brittle/tight gas calculations of glue opcodes, we take # 90% of the maximum tx capacity. Even if this calculation fails @@ -582,7 +584,7 @@ def test_ext_account_query_cold( with TestPhaseManager.execution(): max_target_per_tx = ( tx_gas_limit - intrinsic_gas_cost_calc() - ) // gas_costs.G_COLD_ACCOUNT_ACCESS + ) // gas_costs.GAS_COLD_ACCOUNT_ACCESS num_execution_txs = math.ceil(num_target_accounts / max_target_per_tx) gas_used = 0 diff --git a/tests/benchmark/compute/instruction/test_keccak.py b/tests/benchmark/compute/instruction/test_keccak.py index 647bd3173d..62288e60a1 100644 --- a/tests/benchmark/compute/instruction/test_keccak.py +++ b/tests/benchmark/compute/instruction/test_keccak.py @@ -40,11 +40,11 @@ def test_keccak_max_permutations( optimal_input_length = 0 for i in range(1, 1_000_000, 32): iteration_gas_cost = ( - 2 * gsc.G_VERY_LOW # PUSHN + PUSH1 - + gsc.G_KECCAK_256 # KECCAK256 static cost - + math.ceil(i / 32) * gsc.G_KECCAK_256_WORD # KECCAK256 dynamic + 2 * gsc.GAS_VERY_LOW # PUSHN + PUSH1 + + gsc.GAS_KECCAK256 # KECCAK256 static cost + + math.ceil(i / 32) * gsc.GAS_KECCAK256_WORD # KECCAK256 dynamic # cost - + gsc.G_BASE # POP + + gsc.GAS_BASE # POP ) # From the available gas, we subtract the mem expansion costs # considering we know the current input size length i. diff --git a/tests/benchmark/compute/instruction/test_storage.py b/tests/benchmark/compute/instruction/test_storage.py index aa1c08725e..b3483c31c8 100644 --- a/tests/benchmark/compute/instruction/test_storage.py +++ b/tests/benchmark/compute/instruction/test_storage.py @@ -154,19 +154,19 @@ def test_storage_access_cold( gas_costs = fork.gas_costs() intrinsic_gas_cost_calc = fork.transaction_intrinsic_cost_calculator() - loop_cost = gas_costs.G_COLD_SLOAD # All accesses are always cold + loop_cost = gas_costs.GAS_COLD_SLOAD # All accesses are always cold if storage_action == StorageAction.WRITE_NEW_VALUE: if not absent_slots: - loop_cost += gas_costs.G_STORAGE_RESET + loop_cost += gas_costs.GAS_STORAGE_UPDATE else: - loop_cost += gas_costs.G_STORAGE_SET + loop_cost += gas_costs.GAS_STORAGE_SET elif storage_action == StorageAction.WRITE_SAME_VALUE: if absent_slots: - loop_cost += gas_costs.G_STORAGE_SET + loop_cost += gas_costs.GAS_STORAGE_SET else: - loop_cost += gas_costs.G_WARM_SLOAD + loop_cost += gas_costs.GAS_WARM_ACCESS elif storage_action == StorageAction.READ: - loop_cost += 0 # Only G_COLD_SLOAD is charged + loop_cost += 0 # Only GAS_COLD_SLOAD is charged # Contract code execution_code_body = Bytecode() @@ -174,31 +174,31 @@ def test_storage_access_cold( # All the storage slots in the contract are initialized to their index. # That is, storage slot `i` is initialized to `i`. execution_code_body = Op.SSTORE(Op.DUP1, Op.DUP1) - loop_cost += gas_costs.G_VERY_LOW * 2 + loop_cost += gas_costs.GAS_VERY_LOW * 2 elif storage_action == StorageAction.WRITE_NEW_VALUE: # The new value 2^256-1 is guaranteed to be different from the initial # value. execution_code_body = Op.SSTORE(Op.DUP2, Op.NOT(0)) - loop_cost += gas_costs.G_VERY_LOW * 3 + loop_cost += gas_costs.GAS_VERY_LOW * 3 elif storage_action == StorageAction.READ: execution_code_body = Op.POP(Op.SLOAD(Op.DUP1)) - loop_cost += gas_costs.G_VERY_LOW + gas_costs.G_BASE + loop_cost += gas_costs.GAS_VERY_LOW + gas_costs.GAS_BASE # Add costs jump-logic costs loop_cost += ( - gas_costs.G_JUMPDEST # Prefix Jumpdest - + gas_costs.G_VERY_LOW * 7 # ISZEROs, PUSHs, SWAPs, SUB, DUP - + gas_costs.G_HIGH # JUMPI + gas_costs.GAS_JUMPDEST # Prefix Jumpdest + + gas_costs.GAS_VERY_LOW * 7 # ISZEROs, PUSHs, SWAPs, SUB, DUP + + gas_costs.GAS_HIGH # JUMPI ) prefix_cost = ( - gas_costs.G_VERY_LOW # Target slots push + gas_costs.GAS_VERY_LOW # Target slots push ) suffix_cost = 0 if tx_result == TransactionResult.REVERT: suffix_cost = ( - gas_costs.G_VERY_LOW * 2 # Revert PUSHs + gas_costs.GAS_VERY_LOW * 2 # Revert PUSHs ) num_target_slots = ( diff --git a/tests/benchmark/compute/instruction/test_system.py b/tests/benchmark/compute/instruction/test_system.py index b7fbdc10a9..a3d2d66e50 100644 --- a/tests/benchmark/compute/instruction/test_system.py +++ b/tests/benchmark/compute/instruction/test_system.py @@ -71,17 +71,19 @@ def test_xcall( intrinsic_gas_cost_calc = fork.transaction_intrinsic_cost_calculator() # Calculate the loop cost of the attacker to query one address loop_cost = ( - gas_costs.G_KECCAK_256 # KECCAK static cost - + math.ceil(85 / 32) * gas_costs.G_KECCAK_256_WORD # KECCAK dynamic + gas_costs.GAS_KECCAK256 # KECCAK static cost + + math.ceil(85 / 32) * gas_costs.GAS_KECCAK256_WORD # KECCAK dynamic # cost for CREATE2 - + gas_costs.G_VERY_LOW * 3 # ~MSTOREs+ADDs - + gas_costs.G_COLD_ACCOUNT_ACCESS # Opcode cost + + gas_costs.GAS_VERY_LOW * 3 # ~MSTOREs+ADDs + + gas_costs.GAS_COLD_ACCOUNT_ACCESS # Opcode cost + 30 # ~Gluing opcodes ) # Calculate an upper bound of the number of contracts to be targeted num_contracts = ( # Base available gas = GAS_LIMIT - intrinsic - (out of loop MSTOREs) - attack_gas_limit - intrinsic_gas_cost_calc() - gas_costs.G_VERY_LOW * 4 + attack_gas_limit + - intrinsic_gas_cost_calc() + - gas_costs.GAS_VERY_LOW * 4 ) // loop_cost initcode, factory_address, factory_caller_address = ( @@ -95,7 +97,7 @@ def test_xcall( # The goal is to involve the minimum amount of gas pricing to avoid # complexity and potential brittleness. num_contracts_per_tx = int(tx_gas_limit * 0.9) // ( - gas_costs.G_CODE_DEPOSIT_BYTE * max_contract_size + gas_costs.GAS_CODE_DEPOSIT * max_contract_size ) if num_contracts_per_tx == 0: pytest.skip("tx_gas_limit too low to deploy max-size contract") @@ -154,7 +156,9 @@ def test_xcall( num_targeted_contracts_per_full_tx = ( # Base available gas: # TX_GAS_LIMIT - intrinsic - (out of loop MSTOREs) - tx_gas_limit - intrinsic_gas_cost_calc() - gas_costs.G_VERY_LOW * 4 + tx_gas_limit + - intrinsic_gas_cost_calc() + - gas_costs.GAS_VERY_LOW * 4 ) // loop_cost contract_start_index = 0 opcode_txs = [] @@ -419,7 +423,7 @@ def test_creates_collisions( gas_costs = fork.gas_costs() # The CALL to the proxy contract needs at a minimum gas corresponding to # the CREATE(2) plus extra required PUSH0s for arguments. - min_gas_required = gas_costs.G_CREATE + gas_costs.G_BASE * ( + min_gas_required = gas_costs.GAS_CREATE + gas_costs.GAS_BASE * ( 3 if opcode == Op.CREATE else 4 ) setup = Op.PUSH20(proxy_contract) + Op.PUSH3(min_gas_required) @@ -438,7 +442,7 @@ def test_creates_collisions( pre.deploy_contract(address=addr, code=Op.INVALID) else: # Heuristic to have an upper bound. - max_contract_count = 2 * gas_benchmark_value // gas_costs.G_CREATE + max_contract_count = 2 * gas_benchmark_value // gas_costs.GAS_CREATE for nonce in range(max_contract_count): addr = compute_create_address(address=proxy_contract, nonce=nonce) pre.deploy_contract(address=addr, code=Op.INVALID) @@ -529,27 +533,27 @@ def test_selfdestruct_existing( gas_costs = fork.gas_costs() intrinsic_gas_cost_calc = fork.transaction_intrinsic_cost_calculator() loop_cost = ( - gas_costs.G_KECCAK_256 # KECCAK static cost - + math.ceil(85 / 32) * gas_costs.G_KECCAK_256_WORD # KECCAK dynamic + gas_costs.GAS_KECCAK256 # KECCAK static cost + + math.ceil(85 / 32) * gas_costs.GAS_KECCAK256_WORD # KECCAK dynamic # cost for CREATE2 - + gas_costs.G_VERY_LOW * 3 # ~MSTOREs+ADDs - + gas_costs.G_COLD_ACCOUNT_ACCESS # CALL to self-destructing contract - + gas_costs.G_BASE - + gas_costs.G_SELF_DESTRUCT + + gas_costs.GAS_VERY_LOW * 3 # ~MSTOREs+ADDs + + gas_costs.GAS_COLD_ACCOUNT_ACCESS # CALL self-destructing contract + + gas_costs.GAS_BASE + + gas_costs.GAS_SELF_DESTRUCT + 88 # ~Gluing opcodes ) final_storage_gas = ( - gas_costs.G_VERY_LOW # ADD - + gas_costs.G_VERY_LOW * 3 # PUSHs - + gas_costs.G_COLD_SLOAD # SSTORE cold - + gas_costs.G_STORAGE_RESET # SSTORE new value + gas_costs.GAS_VERY_LOW # ADD + + gas_costs.GAS_VERY_LOW * 3 # PUSHs + + gas_costs.GAS_COLD_SLOAD # SSTORE cold + + gas_costs.GAS_STORAGE_UPDATE # SSTORE new value ) memory_expansion_cost = fork().memory_expansion_gas_calculator()( new_bytes=96 ) base_costs = ( intrinsic_gas_cost_calc() - + (gas_costs.G_VERY_LOW * 12) # 8 PUSHs + 4 MSTOREs + + (gas_costs.GAS_VERY_LOW * 12) # 8 PUSHs + 4 MSTOREs + final_storage_gas + memory_expansion_cost ) @@ -598,7 +602,7 @@ def test_selfdestruct_existing( # The deployed code length is two-bytes. The dominant factor # is the static cost, plus a few glue opcodes/memory-expansion costs. - estimated_gas_per_creation = gas_costs.G_CREATE + 3_000 + estimated_gas_per_creation = gas_costs.GAS_CREATE + 3_000 max_creations_per_tx = int(tx_gas_limit // estimated_gas_per_creation) num_setup_txs = math.ceil(num_contracts / max_creations_per_tx) @@ -713,41 +717,41 @@ def test_selfdestruct_created( intrinsic_gas_cost_calc = fork.transaction_intrinsic_cost_calculator() initcode_costs = ( - gas_costs.G_VERY_LOW * 8 # MSTOREs, PUSHs + gas_costs.GAS_VERY_LOW * 8 # MSTOREs, PUSHs + memory_expansion_calc(new_bytes=2) # return into memory ) create_costs = ( initcode_costs - + gas_costs.G_CREATE - + gas_costs.G_VERY_LOW * 3 # Create Parameter PUSHs - + gas_costs.G_CODE_DEPOSIT_BYTE * 2 - + gas_costs.G_INITCODE_WORD + + gas_costs.GAS_CREATE + + gas_costs.GAS_VERY_LOW * 3 # Create Parameter PUSHs + + gas_costs.GAS_CODE_DEPOSIT * 2 + + gas_costs.GAS_INIT_CODE_WORD_COST ) call_costs = ( - gas_costs.G_WARM_ACCOUNT_ACCESS - + gas_costs.G_BASE # COINBASE - + gas_costs.G_SELF_DESTRUCT - + gas_costs.G_VERY_LOW * 5 # CALL Parameter PUSHs - + gas_costs.G_BASE # Parameter GAS + gas_costs.GAS_WARM_ACCESS + + gas_costs.GAS_BASE # COINBASE + + gas_costs.GAS_SELF_DESTRUCT + + gas_costs.GAS_VERY_LOW * 5 # CALL Parameter PUSHs + + gas_costs.GAS_BASE # Parameter GAS ) extra_costs = ( - gas_costs.G_BASE * 2 # POP, GAS - + gas_costs.G_VERY_LOW * 5 # PUSHs, ADD, DUP, GT - + gas_costs.G_HIGH # JUMPI - + gas_costs.G_JUMPDEST + gas_costs.GAS_BASE * 2 # POP, GAS + + gas_costs.GAS_VERY_LOW * 5 # PUSHs, ADD, DUP, GT + + gas_costs.GAS_HIGH # JUMPI + + gas_costs.GAS_JUMPDEST ) loop_cost = create_costs + call_costs + extra_costs prefix_cost = ( - gas_costs.G_VERY_LOW * 3 - + gas_costs.G_BASE + gas_costs.GAS_VERY_LOW * 3 + + gas_costs.GAS_BASE + memory_expansion_calc(new_bytes=32) ) suffix_cost = ( - gas_costs.G_VERY_LOW - + gas_costs.G_VERY_LOW * 3 - + gas_costs.G_COLD_SLOAD - + gas_costs.G_STORAGE_RESET + gas_costs.GAS_VERY_LOW + + gas_costs.GAS_VERY_LOW * 3 + + gas_costs.GAS_COLD_SLOAD + + gas_costs.GAS_STORAGE_UPDATE ) base_costs = prefix_cost + suffix_cost + intrinsic_gas_cost_calc() @@ -836,33 +840,33 @@ def test_selfdestruct_initcode( intrinsic_gas_cost_calc = fork.transaction_intrinsic_cost_calculator() initcode_costs = ( - gas_costs.G_BASE # COINBASE - + gas_costs.G_SELF_DESTRUCT + gas_costs.GAS_BASE # COINBASE + + gas_costs.GAS_SELF_DESTRUCT ) create_costs = ( initcode_costs - + gas_costs.G_CREATE - + gas_costs.G_VERY_LOW * 3 # Create Parameter PUSHs - + gas_costs.G_INITCODE_WORD + + gas_costs.GAS_CREATE + + gas_costs.GAS_VERY_LOW * 3 # Create Parameter PUSHs + + gas_costs.GAS_INIT_CODE_WORD_COST ) extra_costs = ( - gas_costs.G_BASE * 2 # POP, GAS - + gas_costs.G_VERY_LOW * 5 # PUSHs, ADD, GT - + gas_costs.G_HIGH # JUMPI - + gas_costs.G_JUMPDEST + gas_costs.GAS_BASE * 2 # POP, GAS + + gas_costs.GAS_VERY_LOW * 5 # PUSHs, ADD, GT + + gas_costs.GAS_HIGH # JUMPI + + gas_costs.GAS_JUMPDEST ) loop_cost = create_costs + extra_costs prefix_cost = ( - gas_costs.G_VERY_LOW * 3 - + gas_costs.G_BASE + gas_costs.GAS_VERY_LOW * 3 + + gas_costs.GAS_BASE + memory_expansion_calc(new_bytes=32) ) suffix_cost = ( - gas_costs.G_VERY_LOW - + gas_costs.G_VERY_LOW * 3 - + gas_costs.G_COLD_SLOAD - + gas_costs.G_STORAGE_RESET + gas_costs.GAS_VERY_LOW + + gas_costs.GAS_VERY_LOW * 3 + + gas_costs.GAS_COLD_SLOAD + + gas_costs.GAS_STORAGE_UPDATE ) base_costs = prefix_cost + suffix_cost + intrinsic_gas_cost_calc() diff --git a/tests/benchmark/compute/precompile/test_alt_bn128.py b/tests/benchmark/compute/precompile/test_alt_bn128.py index 987ff81010..9da4d4995e 100644 --- a/tests/benchmark/compute/precompile/test_alt_bn128.py +++ b/tests/benchmark/compute/precompile/test_alt_bn128.py @@ -461,7 +461,7 @@ def test_bn128_pairings_amortized( # This is ignoring "glue" opcodes, but helps to have a rough idea of # the right cutting point. approx_gas_cost_per_call = ( - gsc.G_WARM_ACCOUNT_ACCESS + base_cost + i * pairing_cost + gsc.GAS_WARM_ACCESS + base_cost + i * pairing_cost ) num_precompile_calls = ( diff --git a/tests/benchmark/compute/scenario/test_transaction_types.py b/tests/benchmark/compute/scenario/test_transaction_types.py index 23c00f0ce7..d3f6d3d9dd 100644 --- a/tests/benchmark/compute/scenario/test_transaction_types.py +++ b/tests/benchmark/compute/scenario/test_transaction_types.py @@ -313,8 +313,8 @@ def test_block_full_access_list_and_data( # Access list gas costs from fork's gas_costs gas_costs = fork.gas_costs() - gas_per_address = gas_costs.G_ACCESS_LIST_ADDRESS - gas_per_storage_key = gas_costs.G_ACCESS_LIST_STORAGE + gas_per_address = gas_costs.TX_ACCESS_LIST_ADDRESS_COST + gas_per_storage_key = gas_costs.TX_ACCESS_LIST_STORAGE_KEY_COST # Calculate number of storage keys we can fit gas_after_address = gas_for_access_list - gas_per_address @@ -415,11 +415,11 @@ def test_auth_transaction( max_auths_per_tx = ( tx_gas_limit - intrinsic_cost - ) // gas_costs.G_AUTHORIZATION + ) // gas_costs.PER_EMPTY_ACCOUNT_COST total_auth_count = ( gas_benchmark_value - intrinsic_cost - ) // gas_costs.G_AUTHORIZATION + ) // gas_costs.PER_EMPTY_ACCOUNT_COST num_txs = math.ceil(total_auth_count / max_auths_per_tx) @@ -459,8 +459,8 @@ def test_auth_transaction( total_refund += min( tx_gas_used // 5, ( - gas_costs.G_AUTHORIZATION - - gas_costs.R_AUTHORIZATION_EXISTING_AUTHORITY + gas_costs.PER_EMPTY_ACCOUNT_COST + - gas_costs.PER_AUTH_BASE_COST ) * auths_in_this_tx, ) diff --git a/tests/benchmark/stateful/bloatnet/test_multi_opcode.py b/tests/benchmark/stateful/bloatnet/test_multi_opcode.py index 75e0875988..9f11a01edc 100755 --- a/tests/benchmark/stateful/bloatnet/test_multi_opcode.py +++ b/tests/benchmark/stateful/bloatnet/test_multi_opcode.py @@ -81,18 +81,18 @@ def test_bloatnet_balance_extcodesize( # Cost per contract access with CREATE2 address generation cost_per_contract = ( - gas_costs.G_KECCAK_256 # SHA3 static cost for address generation (30) - + gas_costs.G_KECCAK_256_WORD + gas_costs.GAS_KECCAK256 # SHA3 static cost for address generation (30) + + gas_costs.GAS_KECCAK256_WORD * 3 # SHA3 dynamic cost (85 bytes = 3 words * 6) - + gas_costs.G_COLD_ACCOUNT_ACCESS # Cold access (2600) - + gas_costs.G_BASE # POP first result (2) - + gas_costs.G_WARM_ACCOUNT_ACCESS # Warm access (100) - + gas_costs.G_BASE # POP second result (2) - + gas_costs.G_BASE # DUP1 before first op (3) - + gas_costs.G_VERY_LOW * 4 # PUSH1 operations (4 * 3) - + gas_costs.G_LOW # MLOAD for salt (3) - + gas_costs.G_VERY_LOW # ADD for increment (3) - + gas_costs.G_LOW # MSTORE salt back (3) + + gas_costs.GAS_COLD_ACCOUNT_ACCESS # Cold access (2600) + + gas_costs.GAS_BASE # POP first result (2) + + gas_costs.GAS_WARM_ACCESS # Warm access (100) + + gas_costs.GAS_BASE # POP second result (2) + + gas_costs.GAS_BASE # DUP1 before first op (3) + + gas_costs.GAS_VERY_LOW * 4 # PUSH1 operations (4 * 3) + + gas_costs.GAS_LOW # MLOAD for salt (3) + + gas_costs.GAS_VERY_LOW # ADD for increment (3) + + gas_costs.GAS_LOW # MSTORE salt back (3) + 10 # While loop overhead ) @@ -237,19 +237,19 @@ def test_bloatnet_balance_extcodecopy( # Cost per contract with EXTCODECOPY and CREATE2 address generation cost_per_contract = ( - gas_costs.G_KECCAK_256 # SHA3 static cost for address generation (30) - + gas_costs.G_KECCAK_256_WORD + gas_costs.GAS_KECCAK256 # SHA3 static cost for address generation (30) + + gas_costs.GAS_KECCAK256_WORD * 3 # SHA3 dynamic cost (85 bytes = 3 words * 6) - + gas_costs.G_COLD_ACCOUNT_ACCESS # Cold access (2600) - + gas_costs.G_BASE # POP first result (2) - + gas_costs.G_WARM_ACCOUNT_ACCESS # Warm access base (100) - + gas_costs.G_COPY * 1 # Copy cost for 1 byte (3) - + gas_costs.G_BASE * 2 # DUP1 before first op, DUP4 for address (6) - + gas_costs.G_VERY_LOW * 8 # PUSH operations (8 * 3 = 24) - + gas_costs.G_LOW * 2 # MLOAD for salt twice (6) - + gas_costs.G_VERY_LOW * 2 # ADD operations (6) - + gas_costs.G_LOW # MSTORE salt back (3) - + gas_costs.G_BASE # POP after second op (2) + + gas_costs.GAS_COLD_ACCOUNT_ACCESS # Cold access (2600) + + gas_costs.GAS_BASE # POP first result (2) + + gas_costs.GAS_WARM_ACCESS # Warm access base (100) + + gas_costs.GAS_COPY * 1 # Copy cost for 1 byte (3) + + gas_costs.GAS_BASE * 2 # DUP1 before first op, DUP4 for address (6) + + gas_costs.GAS_VERY_LOW * 8 # PUSH operations (8 * 3 = 24) + + gas_costs.GAS_LOW * 2 # MLOAD for salt twice (6) + + gas_costs.GAS_VERY_LOW * 2 # ADD operations (6) + + gas_costs.GAS_LOW # MSTORE salt back (3) + + gas_costs.GAS_BASE # POP after second op (2) + 10 # While loop overhead ) @@ -398,18 +398,18 @@ def test_bloatnet_balance_extcodehash( # Cost per contract access with CREATE2 address generation cost_per_contract = ( - gas_costs.G_KECCAK_256 # SHA3 static cost for address generation (30) - + gas_costs.G_KECCAK_256_WORD + gas_costs.GAS_KECCAK256 # SHA3 static cost for address generation (30) + + gas_costs.GAS_KECCAK256_WORD * 3 # SHA3 dynamic cost (85 bytes = 3 words * 6) - + gas_costs.G_COLD_ACCOUNT_ACCESS # Cold access (2600) - + gas_costs.G_BASE # POP first result (2) - + gas_costs.G_WARM_ACCOUNT_ACCESS # Warm access (100) - + gas_costs.G_BASE # POP second result (2) - + gas_costs.G_BASE # DUP1 before first op (3) - + gas_costs.G_VERY_LOW * 4 # PUSH1 operations (4 * 3) - + gas_costs.G_LOW # MLOAD for salt (3) - + gas_costs.G_VERY_LOW # ADD for increment (3) - + gas_costs.G_LOW # MSTORE salt back (3) + + gas_costs.GAS_COLD_ACCOUNT_ACCESS # Cold access (2600) + + gas_costs.GAS_BASE # POP first result (2) + + gas_costs.GAS_WARM_ACCESS # Warm access (100) + + gas_costs.GAS_BASE # POP second result (2) + + gas_costs.GAS_BASE # DUP1 before first op (3) + + gas_costs.GAS_VERY_LOW * 4 # PUSH1 operations (4 * 3) + + gas_costs.GAS_LOW # MLOAD for salt (3) + + gas_costs.GAS_VERY_LOW # ADD for increment (3) + + gas_costs.GAS_LOW # MSTORE salt back (3) + 10 # While loop overhead ) @@ -581,65 +581,65 @@ def test_mixed_sload_sstore( # Fixed overhead for SLOAD loop sload_loop_overhead = ( # Attack contract loop overhead - gas_costs.G_VERY_LOW * 2 # MLOAD counter (3*2) - + gas_costs.G_VERY_LOW * 2 # MSTORE selector (3*2) - + gas_costs.G_VERY_LOW * 3 # MLOAD + MSTORE address (3*3) - + gas_costs.G_BASE # POP (2) - + gas_costs.G_BASE * 3 # SUB + MLOAD + MSTORE counter decrement - + gas_costs.G_BASE * 2 # ISZERO * 2 for loop condition (2*2) - + gas_costs.G_MID # JUMPI (8) + gas_costs.GAS_VERY_LOW * 2 # MLOAD counter (3*2) + + gas_costs.GAS_VERY_LOW * 2 # MSTORE selector (3*2) + + gas_costs.GAS_VERY_LOW * 3 # MLOAD + MSTORE address (3*3) + + gas_costs.GAS_BASE # POP (2) + + gas_costs.GAS_BASE * 3 # SUB + MLOAD + MSTORE counter decrement + + gas_costs.GAS_BASE * 2 # ISZERO * 2 for loop condition (2*2) + + gas_costs.GAS_MID # JUMPI (8) ) # ERC20 balanceOf internal gas sload_erc20_internal = ( - gas_costs.G_VERY_LOW # PUSH4 selector (3) - + gas_costs.G_BASE # EQ selector match (2) - + gas_costs.G_MID # JUMPI to function (8) - + gas_costs.G_JUMPDEST # JUMPDEST at function start (1) - + gas_costs.G_VERY_LOW * 2 # CALLDATALOAD arg (3*2) - + gas_costs.G_KECCAK_256 # keccak256 static (30) - + gas_costs.G_KECCAK_256_WORD * 2 # keccak256 dynamic 64 bytes - + gas_costs.G_COLD_SLOAD # Cold SLOAD - always cold - + gas_costs.G_VERY_LOW * 3 # MSTORE result + RETURN setup (3*3) + gas_costs.GAS_VERY_LOW # PUSH4 selector (3) + + gas_costs.GAS_BASE # EQ selector match (2) + + gas_costs.GAS_MID # JUMPI to function (8) + + gas_costs.GAS_JUMPDEST # JUMPDEST at function start (1) + + gas_costs.GAS_VERY_LOW * 2 # CALLDATALOAD arg (3*2) + + gas_costs.GAS_KECCAK256 # keccak256 static (30) + + gas_costs.GAS_KECCAK256_WORD * 2 # keccak256 dynamic 64 bytes + + gas_costs.GAS_COLD_SLOAD # Cold SLOAD - always cold + + gas_costs.GAS_VERY_LOW * 3 # MSTORE result + RETURN setup (3*3) ) # Fixed overhead for SSTORE loop sstore_loop_overhead = ( # Attack contract loop body operations - gas_costs.G_VERY_LOW # MSTORE selector at memory[32] (3) - + gas_costs.G_LOW # MLOAD counter (5) - + gas_costs.G_VERY_LOW # MSTORE spender at memory[64] (3) - + gas_costs.G_BASE # POP call result (2) + gas_costs.GAS_VERY_LOW # MSTORE selector at memory[32] (3) + + gas_costs.GAS_LOW # MLOAD counter (5) + + gas_costs.GAS_VERY_LOW # MSTORE spender at memory[64] (3) + + gas_costs.GAS_BASE # POP call result (2) # Counter decrement - + gas_costs.G_LOW # MLOAD counter (5) - + gas_costs.G_VERY_LOW # PUSH1 1 (3) - + gas_costs.G_VERY_LOW # SUB (3) - + gas_costs.G_VERY_LOW # MSTORE counter back (3) + + gas_costs.GAS_LOW # MLOAD counter (5) + + gas_costs.GAS_VERY_LOW # PUSH1 1 (3) + + gas_costs.GAS_VERY_LOW # SUB (3) + + gas_costs.GAS_VERY_LOW # MSTORE counter back (3) # While loop condition check - + gas_costs.G_LOW # MLOAD counter (5) - + gas_costs.G_BASE # ISZERO (2) - + gas_costs.G_BASE # ISZERO (2) - + gas_costs.G_MID # JUMPI back to loop start (8) + + gas_costs.GAS_LOW # MLOAD counter (5) + + gas_costs.GAS_BASE # ISZERO (2) + + gas_costs.GAS_BASE # ISZERO (2) + + gas_costs.GAS_MID # JUMPI back to loop start (8) ) # ERC20 approve internal gas # Cold SSTORE: 22100 = 20000 base + 2100 cold access sstore_erc20_internal = ( - gas_costs.G_VERY_LOW # PUSH4 selector (3) - + gas_costs.G_BASE # EQ selector match (2) - + gas_costs.G_MID # JUMPI to function (8) - + gas_costs.G_JUMPDEST # JUMPDEST at function start (1) - + gas_costs.G_VERY_LOW # CALLDATALOAD spender (3) - + gas_costs.G_VERY_LOW # CALLDATALOAD amount (3) - + gas_costs.G_KECCAK_256 # keccak256 static (30) - + gas_costs.G_KECCAK_256_WORD * 2 # keccak256 dynamic 64 bytes - + gas_costs.G_COLD_SLOAD # Cold SLOAD for allowance check (2100) - + gas_costs.G_STORAGE_SET # SSTORE base cost (20000) - + gas_costs.G_COLD_SLOAD # Additional cold storage access (2100) - + gas_costs.G_VERY_LOW # PUSH1 1 for return value (3) - + gas_costs.G_VERY_LOW # MSTORE return value (3) - + gas_costs.G_VERY_LOW # PUSH1 32 for return size (3) - + gas_costs.G_VERY_LOW # PUSH1 0 for return offset (3) + gas_costs.GAS_VERY_LOW # PUSH4 selector (3) + + gas_costs.GAS_BASE # EQ selector match (2) + + gas_costs.GAS_MID # JUMPI to function (8) + + gas_costs.GAS_JUMPDEST # JUMPDEST at function start (1) + + gas_costs.GAS_VERY_LOW # CALLDATALOAD spender (3) + + gas_costs.GAS_VERY_LOW # CALLDATALOAD amount (3) + + gas_costs.GAS_KECCAK256 # keccak256 static (30) + + gas_costs.GAS_KECCAK256_WORD * 2 # keccak256 dynamic 64 bytes + + gas_costs.GAS_COLD_SLOAD # Cold SLOAD for allowance check (2100) + + gas_costs.GAS_STORAGE_SET # SSTORE base cost (20000) + + gas_costs.GAS_COLD_SLOAD # Additional cold storage access (2100) + + gas_costs.GAS_VERY_LOW # PUSH1 1 for return value (3) + + gas_costs.GAS_VERY_LOW # MSTORE return value (3) + + gas_costs.GAS_VERY_LOW # PUSH1 32 for return size (3) + + gas_costs.GAS_VERY_LOW # PUSH1 0 for return offset (3) ) # Calculate gas budget per contract @@ -653,12 +653,10 @@ def test_mixed_sload_sstore( # Account for cold/warm transitions in CALL costs # First SLOAD call is COLD (2600), rest are WARM (100) sload_warm_cost = ( - sload_loop_overhead - + gas_costs.G_WARM_ACCOUNT_ACCESS - + sload_erc20_internal + sload_loop_overhead + gas_costs.GAS_WARM_ACCESS + sload_erc20_internal ) cold_warm_diff = ( - gas_costs.G_COLD_ACCOUNT_ACCESS - gas_costs.G_WARM_ACCOUNT_ACCESS + gas_costs.GAS_COLD_ACCOUNT_ACCESS - gas_costs.GAS_WARM_ACCESS ) sload_calls_per_contract = int( (sload_gas_per_contract - cold_warm_diff) // sload_warm_cost @@ -667,7 +665,7 @@ def test_mixed_sload_sstore( # First SSTORE call is COLD (2600), rest are WARM (100) sstore_warm_cost = ( sstore_loop_overhead - + gas_costs.G_WARM_ACCOUNT_ACCESS + + gas_costs.GAS_WARM_ACCESS + sstore_erc20_internal ) sstore_calls_per_contract = int( diff --git a/tests/benchmark/stateful/bloatnet/test_single_opcode.py b/tests/benchmark/stateful/bloatnet/test_single_opcode.py index 34e2c46434..d426c7af3e 100644 --- a/tests/benchmark/stateful/bloatnet/test_single_opcode.py +++ b/tests/benchmark/stateful/bloatnet/test_single_opcode.py @@ -131,26 +131,26 @@ def test_sload_empty_erc20_balanceof( # Fixed overhead per iteration (loop mechanics, independent of warm/cold) loop_overhead = ( # Attack contract loop overhead - gas_costs.G_VERY_LOW * 2 # MLOAD counter (3*2) - + gas_costs.G_VERY_LOW * 2 # MSTORE selector (3*2) - + gas_costs.G_VERY_LOW * 3 # MLOAD + MSTORE address (3*3) - + gas_costs.G_BASE # POP (2) - + gas_costs.G_BASE * 3 # SUB + MLOAD + MSTORE counter decrement - + gas_costs.G_BASE * 2 # ISZERO * 2 for loop condition (2*2) - + gas_costs.G_MID # JUMPI (8) + gas_costs.GAS_VERY_LOW * 2 # MLOAD counter (3*2) + + gas_costs.GAS_VERY_LOW * 2 # MSTORE selector (3*2) + + gas_costs.GAS_VERY_LOW * 3 # MLOAD + MSTORE address (3*3) + + gas_costs.GAS_BASE # POP (2) + + gas_costs.GAS_BASE * 3 # SUB + MLOAD + MSTORE counter decrement + + gas_costs.GAS_BASE * 2 # ISZERO * 2 for loop condition (2*2) + + gas_costs.GAS_MID # JUMPI (8) ) # ERC20 internal gas (same for all calls) erc20_internal_gas = ( - gas_costs.G_VERY_LOW # PUSH4 selector (3) - + gas_costs.G_BASE # EQ selector match (2) - + gas_costs.G_MID # JUMPI to function (8) - + gas_costs.G_JUMPDEST # JUMPDEST at function start (1) - + gas_costs.G_VERY_LOW * 2 # CALLDATALOAD arg (3*2) - + gas_costs.G_KECCAK_256 # keccak256 static (30) - + gas_costs.G_KECCAK_256_WORD * 2 # keccak256 dynamic 64 bytes - + gas_costs.G_COLD_SLOAD # Cold SLOAD - always cold - + gas_costs.G_VERY_LOW * 3 # MSTORE result + RETURN setup (3*3) + gas_costs.GAS_VERY_LOW # PUSH4 selector (3) + + gas_costs.GAS_BASE # EQ selector match (2) + + gas_costs.GAS_MID # JUMPI to function (8) + + gas_costs.GAS_JUMPDEST # JUMPDEST at function start (1) + + gas_costs.GAS_VERY_LOW * 2 # CALLDATALOAD arg (3*2) + + gas_costs.GAS_KECCAK256 # keccak256 static (30) + + gas_costs.GAS_KECCAK256_WORD * 2 # keccak256 dynamic 64 bytes + + gas_costs.GAS_COLD_SLOAD # Cold SLOAD - always cold + + gas_costs.GAS_VERY_LOW * 3 # MSTORE result + RETURN setup (3*3) # RETURN costs 0 gas ) @@ -163,10 +163,10 @@ def test_sload_empty_erc20_balanceof( # gas_per_contract = cold_call + (calls-1) * warm_call # Simplifies to: gas = cold_warm_diff + calls * warm_call_cost warm_call_cost = ( - loop_overhead + gas_costs.G_WARM_ACCOUNT_ACCESS + erc20_internal_gas + loop_overhead + gas_costs.GAS_WARM_ACCESS + erc20_internal_gas ) cold_warm_diff = ( - gas_costs.G_COLD_ACCOUNT_ACCESS - gas_costs.G_WARM_ACCOUNT_ACCESS + gas_costs.GAS_COLD_ACCOUNT_ACCESS - gas_costs.GAS_WARM_ACCESS ) calls_per_contract = int( @@ -302,54 +302,54 @@ def test_sstore_erc20_approve( # Per-contract fixed overhead (setup + teardown) memory_expansion_cost = 15 # Memory expansion to 160 bytes (5 words) overhead_per_contract = ( - gas_costs.G_VERY_LOW # MSTORE to initialize counter (3) + gas_costs.GAS_VERY_LOW # MSTORE to initialize counter (3) + memory_expansion_cost # Memory expansion (15) - + gas_costs.G_JUMPDEST # JUMPDEST at loop start (1) - + gas_costs.G_LOW # MLOAD for While condition check (5) - + gas_costs.G_BASE # ISZERO (2) - + gas_costs.G_BASE # ISZERO (2) - + gas_costs.G_MID # JUMPI (8) - + gas_costs.G_BASE # POP to clean up counter at end (2) + + gas_costs.GAS_JUMPDEST # JUMPDEST at loop start (1) + + gas_costs.GAS_LOW # MLOAD for While condition check (5) + + gas_costs.GAS_BASE # ISZERO (2) + + gas_costs.GAS_BASE # ISZERO (2) + + gas_costs.GAS_MID # JUMPI (8) + + gas_costs.GAS_BASE # POP to clean up counter at end (2) ) # = 38 # Fixed overhead per iteration (loop mechanics, independent of warm/cold) loop_overhead = ( # Attack contract loop body operations - gas_costs.G_VERY_LOW # MSTORE selector at memory[32] (3) - + gas_costs.G_LOW # MLOAD counter (5) - + gas_costs.G_VERY_LOW # MSTORE spender at memory[64] (3) - + gas_costs.G_BASE # POP call result (2) + gas_costs.GAS_VERY_LOW # MSTORE selector at memory[32] (3) + + gas_costs.GAS_LOW # MLOAD counter (5) + + gas_costs.GAS_VERY_LOW # MSTORE spender at memory[64] (3) + + gas_costs.GAS_BASE # POP call result (2) # Counter decrement: MSTORE(0, SUB(MLOAD(0), 1)) - + gas_costs.G_LOW # MLOAD counter (5) - + gas_costs.G_VERY_LOW # PUSH1 1 (3) - + gas_costs.G_VERY_LOW # SUB (3) - + gas_costs.G_VERY_LOW # MSTORE counter back (3) + + gas_costs.GAS_LOW # MLOAD counter (5) + + gas_costs.GAS_VERY_LOW # PUSH1 1 (3) + + gas_costs.GAS_VERY_LOW # SUB (3) + + gas_costs.GAS_VERY_LOW # MSTORE counter back (3) # While loop condition check - + gas_costs.G_LOW # MLOAD counter (5) - + gas_costs.G_BASE # ISZERO (2) - + gas_costs.G_BASE # ISZERO (2) - + gas_costs.G_MID # JUMPI back to loop start (8) + + gas_costs.GAS_LOW # MLOAD counter (5) + + gas_costs.GAS_BASE # ISZERO (2) + + gas_costs.GAS_BASE # ISZERO (2) + + gas_costs.GAS_MID # JUMPI back to loop start (8) ) # ERC20 internal gas (same for all calls) # Note: SSTORE cost is 22100 for cold slot, zero-to-non-zero # (20000 base + 2100 cold access) erc20_internal_gas = ( - gas_costs.G_VERY_LOW # PUSH4 selector (3) - + gas_costs.G_BASE # EQ selector match (2) - + gas_costs.G_MID # JUMPI to function (8) - + gas_costs.G_JUMPDEST # JUMPDEST at function start (1) - + gas_costs.G_VERY_LOW # CALLDATALOAD spender (3) - + gas_costs.G_VERY_LOW # CALLDATALOAD amount (3) - + gas_costs.G_KECCAK_256 # keccak256 static (30) - + gas_costs.G_KECCAK_256_WORD * 2 # keccak256 dynamic 64 bytes - + gas_costs.G_COLD_SLOAD # Cold SLOAD for allowance check (2100) - + gas_costs.G_STORAGE_SET # SSTORE base cost (20000) - + gas_costs.G_COLD_SLOAD # Additional cold storage access (2100) - + gas_costs.G_VERY_LOW # PUSH1 1 for return value (3) - + gas_costs.G_VERY_LOW # MSTORE return value (3) - + gas_costs.G_VERY_LOW # PUSH1 32 for return size (3) - + gas_costs.G_VERY_LOW # PUSH1 0 for return offset (3) + gas_costs.GAS_VERY_LOW # PUSH4 selector (3) + + gas_costs.GAS_BASE # EQ selector match (2) + + gas_costs.GAS_MID # JUMPI to function (8) + + gas_costs.GAS_JUMPDEST # JUMPDEST at function start (1) + + gas_costs.GAS_VERY_LOW # CALLDATALOAD spender (3) + + gas_costs.GAS_VERY_LOW # CALLDATALOAD amount (3) + + gas_costs.GAS_KECCAK256 # keccak256 static (30) + + gas_costs.GAS_KECCAK256_WORD * 2 # keccak256 dynamic 64 bytes + + gas_costs.GAS_COLD_SLOAD # Cold SLOAD for allowance check (2100) + + gas_costs.GAS_STORAGE_SET # SSTORE base cost (20000) + + gas_costs.GAS_COLD_SLOAD # Additional cold storage access (2100) + + gas_costs.GAS_VERY_LOW # PUSH1 1 for return value (3) + + gas_costs.GAS_VERY_LOW # MSTORE return value (3) + + gas_costs.GAS_VERY_LOW # PUSH1 32 for return size (3) + + gas_costs.GAS_VERY_LOW # PUSH1 0 for return offset (3) # RETURN costs 0 gas ) @@ -360,10 +360,10 @@ def test_sstore_erc20_approve( # For each contract: first call is COLD (2600), subsequent are WARM (100) # Solve for calls per contract accounting for cold/warm transition warm_call_cost = ( - loop_overhead + gas_costs.G_WARM_ACCOUNT_ACCESS + erc20_internal_gas + loop_overhead + gas_costs.GAS_WARM_ACCESS + erc20_internal_gas ) cold_warm_diff = ( - gas_costs.G_COLD_ACCOUNT_ACCESS - gas_costs.G_WARM_ACCOUNT_ACCESS + gas_costs.GAS_COLD_ACCOUNT_ACCESS - gas_costs.GAS_WARM_ACCESS ) # Per contract: gas_available = cold_warm_diff + calls * warm_call_cost diff --git a/tests/berlin/eip2929_gas_cost_increases/test_call.py b/tests/berlin/eip2929_gas_cost_increases/test_call.py index a1b6238085..8761f649f4 100644 --- a/tests/berlin/eip2929_gas_cost_increases/test_call.py +++ b/tests/berlin/eip2929_gas_cost_increases/test_call.py @@ -43,7 +43,7 @@ def test_call_insufficient_balance( # Measure the gas cost for BALANCE operation + CodeGasMeasure( code=Op.BALANCE(destination), - overhead_cost=gas_costs.G_VERY_LOW, # PUSH20 costs 3 gas + overhead_cost=gas_costs.GAS_VERY_LOW, # PUSH20 costs 3 gas extra_stack_items=1, # BALANCE puts balance on stack sstore_key=1, ), @@ -63,7 +63,7 @@ def test_call_insufficient_balance( contract_address: Account( storage={ 0: 0, # The CALL is aborted - 1: gas_costs.G_WARM_ACCOUNT_ACCESS, # Warm access cost + 1: gas_costs.GAS_WARM_ACCESS, # Warm access cost }, ), } diff --git a/tests/berlin/eip2929_gas_cost_increases/test_precompile_warming.py b/tests/berlin/eip2929_gas_cost_increases/test_precompile_warming.py index 0098ebfc30..5b42cecf0c 100644 --- a/tests/berlin/eip2929_gas_cost_increases/test_precompile_warming.py +++ b/tests/berlin/eip2929_gas_cost_increases/test_precompile_warming.py @@ -162,9 +162,9 @@ def test_precompile_warming( def get_expected_gas(precompile_present: bool, fork: Fork) -> int: gas_costs = fork.gas_costs() - warm_access_cost = gas_costs.G_WARM_ACCOUNT_ACCESS - cold_access_cost = gas_costs.G_COLD_ACCOUNT_ACCESS - extra_cost = gas_costs.G_BASE * 2 + gas_costs.G_VERY_LOW + warm_access_cost = gas_costs.GAS_WARM_ACCESS + cold_access_cost = gas_costs.GAS_COLD_ACCOUNT_ACCESS + extra_cost = gas_costs.GAS_BASE * 2 + gas_costs.GAS_VERY_LOW if precompile_present: return warm_access_cost + extra_cost else: diff --git a/tests/berlin/eip2930_access_list/test_acl.py b/tests/berlin/eip2930_access_list/test_acl.py index d96c520537..186b02a1fb 100644 --- a/tests/berlin/eip2930_access_list/test_acl.py +++ b/tests/berlin/eip2930_access_list/test_acl.py @@ -46,10 +46,10 @@ def test_account_storage_warm_cold_state( storage_reader_contract = pre.deploy_contract(Op.SLOAD(1) + Op.STOP) overhead_cost = ( - gas_costs.G_VERY_LOW + gas_costs.GAS_VERY_LOW * (Op.CALL.popped_stack_items - 1) # Call stack items - + gas_costs.G_BASE # Call gas - + gas_costs.G_VERY_LOW # SLOAD Push + + gas_costs.GAS_BASE # Call gas + + gas_costs.GAS_VERY_LOW # SLOAD Push ) contract_address = pre.deploy_contract( CodeGasMeasure( @@ -63,15 +63,15 @@ def test_account_storage_warm_cold_state( access_list_address = Address(0) access_list_storage_key = Hash(0) if account_warm: - expected_gas_cost += gas_costs.G_WARM_ACCOUNT_ACCESS + expected_gas_cost += gas_costs.GAS_WARM_ACCESS access_list_address = storage_reader_contract else: - expected_gas_cost += gas_costs.G_COLD_ACCOUNT_ACCESS + expected_gas_cost += gas_costs.GAS_COLD_ACCOUNT_ACCESS if storage_key_warm: - expected_gas_cost += gas_costs.G_WARM_SLOAD + expected_gas_cost += gas_costs.GAS_WARM_ACCESS access_list_storage_key = Hash(1) else: - expected_gas_cost += gas_costs.G_COLD_SLOAD + expected_gas_cost += gas_costs.GAS_COLD_SLOAD access_lists: List[AccessList] = [ AccessList( @@ -293,7 +293,7 @@ def test_repeated_address_acl( sload0_measure = CodeGasMeasure( code=Op.SLOAD(0), - overhead_cost=gsc.G_VERY_LOW + overhead_cost=gsc.GAS_VERY_LOW * len(Op.SLOAD.kwargs), # Cost of pushing SLOAD args extra_stack_items=1, # SLOAD pushes 1 item to the stack sstore_key=0, @@ -302,7 +302,7 @@ def test_repeated_address_acl( sload1_measure = CodeGasMeasure( code=Op.SLOAD(1), - overhead_cost=gsc.G_VERY_LOW + overhead_cost=gsc.GAS_VERY_LOW * len(Op.SLOAD.kwargs), # Cost of pushing SLOAD args extra_stack_items=1, # SLOAD pushes 1 item to the stack sstore_key=1, @@ -327,7 +327,7 @@ def test_repeated_address_acl( ], ) - sload_cost = gsc.G_WARM_ACCOUNT_ACCESS + sload_cost = gsc.GAS_WARM_ACCESS state_test( env=Environment(), diff --git a/tests/cancun/eip4844_blobs/conftest.py b/tests/cancun/eip4844_blobs/conftest.py index 9df273fffe..628686f5f7 100644 --- a/tests/cancun/eip4844_blobs/conftest.py +++ b/tests/cancun/eip4844_blobs/conftest.py @@ -289,7 +289,7 @@ def non_zero_blob_gas_used_genesis_block( have any blob txs. For the intermediate block to align with default genesis values, we must - add TARGET_BLOB_GAS_PER_BLOCK to the excessBlobGas of the genesis value, + add BLOB_TARGET_GAS_PER_BLOCK to the excessBlobGas of the genesis value, expecting an appropriate drop to the intermediate block. Similarly, we must add parent_blobs to the intermediate block within a blob tx such that an equivalent blobGasUsed field is wrote. diff --git a/tests/cancun/eip4844_blobs/test_excess_blob_gas.py b/tests/cancun/eip4844_blobs/test_excess_blob_gas.py index ffa29e5a3c..8b2c740d73 100644 --- a/tests/cancun/eip4844_blobs/test_excess_blob_gas.py +++ b/tests/cancun/eip4844_blobs/test_excess_blob_gas.py @@ -557,9 +557,9 @@ def test_invalid_excess_blob_gas_above_target_change( """ Test rejection of blocks where the `excessBlobGas`. - - decreases more than `TARGET_BLOB_GAS_PER_BLOCK` in a single block + - decreases more than `BLOB_TARGET_GAS_PER_BLOCK` in a single block with zero blobs. - - increases more than `TARGET_BLOB_GAS_PER_BLOCK` in a single block + - increases more than `BLOB_TARGET_GAS_PER_BLOCK` in a single block with max blobs. """ if header_excess_blob_gas is None: diff --git a/tests/cancun/eip5656_mcopy/test_mcopy_memory_expansion.py b/tests/cancun/eip5656_mcopy/test_mcopy_memory_expansion.py index 9b12efb34d..6221ecb0c8 100644 --- a/tests/cancun/eip5656_mcopy/test_mcopy_memory_expansion.py +++ b/tests/cancun/eip5656_mcopy/test_mcopy_memory_expansion.py @@ -98,8 +98,8 @@ def call_exact_cost( calldatacopy_cost += 3 * ((len(initial_memory) + 31) // 32) calldatacopy_cost += cost_memory_bytes(new_bytes=len(initial_memory)) - pushes_cost = gas_costs.G_VERY_LOW * 9 - calldatasize_cost = gas_costs.G_BASE + pushes_cost = gas_costs.GAS_VERY_LOW * 9 + calldatasize_cost = gas_costs.GAS_BASE sstore_cost = 22100 return ( diff --git a/tests/frontier/create/test_create_deposit_oog.py b/tests/frontier/create/test_create_deposit_oog.py index 085c15a632..95e3fb97ba 100644 --- a/tests/frontier/create/test_create_deposit_oog.py +++ b/tests/frontier/create/test_create_deposit_oog.py @@ -32,7 +32,7 @@ def test_create_deposit_oog( deposited_len = 10_000 initcode = Op.RETURN(0, deposited_len) tx_gas_limit = 1_000_000 - assert tx_gas_limit < deposited_len * fork.gas_costs().G_CODE_DEPOSIT_BYTE + assert tx_gas_limit < deposited_len * fork.gas_costs().GAS_CODE_DEPOSIT sender = pre.fund_eoa() expect_post = Storage() diff --git a/tests/frontier/opcodes/test_all_opcodes.py b/tests/frontier/opcodes/test_all_opcodes.py index 1e1ec957e7..f19b0eaf9f 100644 --- a/tests/frontier/opcodes/test_all_opcodes.py +++ b/tests/frontier/opcodes/test_all_opcodes.py @@ -216,87 +216,87 @@ def constant_gas_opcodes(fork: Fork) -> Generator[ParameterSet, None, None]: valid_opcodes = set(fork.valid_opcodes()) gas_costs = fork.gas_costs() opcode_floor_gas = { - Op.ADD: gas_costs.G_VERY_LOW, - Op.MUL: gas_costs.G_LOW, - Op.SUB: gas_costs.G_VERY_LOW, - Op.DIV: gas_costs.G_LOW, - Op.SDIV: gas_costs.G_LOW, - Op.MOD: gas_costs.G_LOW, - Op.SMOD: gas_costs.G_LOW, - Op.ADDMOD: gas_costs.G_MID, - Op.MULMOD: gas_costs.G_MID, - Op.EXP: gas_costs.G_HIGH, - Op.SIGNEXTEND: gas_costs.G_LOW, - Op.LT: gas_costs.G_VERY_LOW, - Op.GT: gas_costs.G_VERY_LOW, - Op.SLT: gas_costs.G_VERY_LOW, - Op.SGT: gas_costs.G_VERY_LOW, - Op.EQ: gas_costs.G_VERY_LOW, - Op.ISZERO: gas_costs.G_VERY_LOW, - Op.AND: gas_costs.G_VERY_LOW, - Op.OR: gas_costs.G_VERY_LOW, - Op.XOR: gas_costs.G_VERY_LOW, - Op.NOT: gas_costs.G_VERY_LOW, - Op.BYTE: gas_costs.G_VERY_LOW, - Op.SHL: gas_costs.G_VERY_LOW, - Op.SHR: gas_costs.G_VERY_LOW, - Op.SAR: gas_costs.G_VERY_LOW, - Op.CLZ: gas_costs.G_LOW, - Op.SHA3: gas_costs.G_KECCAK_256, - Op.ADDRESS: gas_costs.G_BASE, - Op.BALANCE: gas_costs.G_WARM_ACCOUNT_ACCESS, - Op.ORIGIN: gas_costs.G_BASE, - Op.CALLER: gas_costs.G_BASE, - Op.CALLVALUE: gas_costs.G_BASE, - Op.CALLDATALOAD: gas_costs.G_VERY_LOW, - Op.CALLDATASIZE: gas_costs.G_BASE, - Op.CALLDATACOPY: gas_costs.G_COPY, - Op.CODESIZE: gas_costs.G_BASE, - Op.CODECOPY: gas_costs.G_COPY, - Op.GASPRICE: gas_costs.G_BASE, - Op.EXTCODESIZE: gas_costs.G_WARM_ACCOUNT_ACCESS, - Op.EXTCODECOPY: gas_costs.G_WARM_ACCOUNT_ACCESS, - Op.RETURNDATASIZE: gas_costs.G_BASE, - Op.RETURNDATACOPY: gas_costs.G_COPY, - Op.EXTCODEHASH: gas_costs.G_WARM_ACCOUNT_ACCESS, - Op.BLOCKHASH: gas_costs.G_BLOCKHASH, - Op.COINBASE: gas_costs.G_BASE, - Op.TIMESTAMP: gas_costs.G_BASE, - Op.NUMBER: gas_costs.G_BASE, - Op.PREVRANDAO: gas_costs.G_BASE, - Op.GASLIMIT: gas_costs.G_BASE, - Op.CHAINID: gas_costs.G_BASE, - Op.SELFBALANCE: gas_costs.G_LOW, - Op.BASEFEE: gas_costs.G_BASE, - Op.BLOBHASH: gas_costs.G_VERY_LOW, - Op.BLOBBASEFEE: gas_costs.G_BASE, - Op.POP: gas_costs.G_BASE, - Op.MLOAD: gas_costs.G_VERY_LOW, - Op.MSTORE: gas_costs.G_VERY_LOW, - Op.MSTORE8: gas_costs.G_VERY_LOW, - Op.SLOAD: gas_costs.G_WARM_SLOAD, - Op.JUMP: gas_costs.G_MID, - Op.JUMPI: gas_costs.G_HIGH, - Op.PC: gas_costs.G_BASE, - Op.MSIZE: gas_costs.G_BASE, - Op.GAS: gas_costs.G_BASE, - Op.JUMPDEST: gas_costs.G_JUMPDEST, - Op.TLOAD: gas_costs.G_WARM_SLOAD, - Op.TSTORE: gas_costs.G_WARM_SLOAD, - Op.MCOPY: gas_costs.G_VERY_LOW, - Op.PUSH0: gas_costs.G_BASE, - Op.LOG0: gas_costs.G_LOG + (0 * gas_costs.G_LOG_TOPIC), - Op.LOG1: gas_costs.G_LOG + (1 * gas_costs.G_LOG_TOPIC), - Op.LOG2: gas_costs.G_LOG + (2 * gas_costs.G_LOG_TOPIC), - Op.LOG3: gas_costs.G_LOG + (3 * gas_costs.G_LOG_TOPIC), - Op.LOG4: gas_costs.G_LOG + (4 * gas_costs.G_LOG_TOPIC), - Op.CREATE: gas_costs.G_TRANSACTION_CREATE, - Op.CALL: gas_costs.G_WARM_ACCOUNT_ACCESS, - Op.CALLCODE: gas_costs.G_WARM_ACCOUNT_ACCESS, - Op.DELEGATECALL: gas_costs.G_WARM_ACCOUNT_ACCESS, - Op.CREATE2: gas_costs.G_TRANSACTION_CREATE, - Op.STATICCALL: gas_costs.G_WARM_ACCOUNT_ACCESS, - Op.SELFDESTRUCT: gas_costs.G_SELF_DESTRUCT, + Op.ADD: gas_costs.GAS_VERY_LOW, + Op.MUL: gas_costs.GAS_LOW, + Op.SUB: gas_costs.GAS_VERY_LOW, + Op.DIV: gas_costs.GAS_LOW, + Op.SDIV: gas_costs.GAS_LOW, + Op.MOD: gas_costs.GAS_LOW, + Op.SMOD: gas_costs.GAS_LOW, + Op.ADDMOD: gas_costs.GAS_MID, + Op.MULMOD: gas_costs.GAS_MID, + Op.EXP: gas_costs.GAS_HIGH, + Op.SIGNEXTEND: gas_costs.GAS_LOW, + Op.LT: gas_costs.GAS_VERY_LOW, + Op.GT: gas_costs.GAS_VERY_LOW, + Op.SLT: gas_costs.GAS_VERY_LOW, + Op.SGT: gas_costs.GAS_VERY_LOW, + Op.EQ: gas_costs.GAS_VERY_LOW, + Op.ISZERO: gas_costs.GAS_VERY_LOW, + Op.AND: gas_costs.GAS_VERY_LOW, + Op.OR: gas_costs.GAS_VERY_LOW, + Op.XOR: gas_costs.GAS_VERY_LOW, + Op.NOT: gas_costs.GAS_VERY_LOW, + Op.BYTE: gas_costs.GAS_VERY_LOW, + Op.SHL: gas_costs.GAS_VERY_LOW, + Op.SHR: gas_costs.GAS_VERY_LOW, + Op.SAR: gas_costs.GAS_VERY_LOW, + Op.CLZ: gas_costs.GAS_LOW, + Op.SHA3: gas_costs.GAS_KECCAK256, + Op.ADDRESS: gas_costs.GAS_BASE, + Op.BALANCE: gas_costs.GAS_WARM_ACCESS, + Op.ORIGIN: gas_costs.GAS_BASE, + Op.CALLER: gas_costs.GAS_BASE, + Op.CALLVALUE: gas_costs.GAS_BASE, + Op.CALLDATALOAD: gas_costs.GAS_VERY_LOW, + Op.CALLDATASIZE: gas_costs.GAS_BASE, + Op.CALLDATACOPY: gas_costs.GAS_COPY, + Op.CODESIZE: gas_costs.GAS_BASE, + Op.CODECOPY: gas_costs.GAS_COPY, + Op.GASPRICE: gas_costs.GAS_BASE, + Op.EXTCODESIZE: gas_costs.GAS_WARM_ACCESS, + Op.EXTCODECOPY: gas_costs.GAS_WARM_ACCESS, + Op.RETURNDATASIZE: gas_costs.GAS_BASE, + Op.RETURNDATACOPY: gas_costs.GAS_COPY, + Op.EXTCODEHASH: gas_costs.GAS_WARM_ACCESS, + Op.BLOCKHASH: gas_costs.GAS_BLOCK_HASH, + Op.COINBASE: gas_costs.GAS_BASE, + Op.TIMESTAMP: gas_costs.GAS_BASE, + Op.NUMBER: gas_costs.GAS_BASE, + Op.PREVRANDAO: gas_costs.GAS_BASE, + Op.GASLIMIT: gas_costs.GAS_BASE, + Op.CHAINID: gas_costs.GAS_BASE, + Op.SELFBALANCE: gas_costs.GAS_LOW, + Op.BASEFEE: gas_costs.GAS_BASE, + Op.BLOBHASH: gas_costs.GAS_VERY_LOW, + Op.BLOBBASEFEE: gas_costs.GAS_BASE, + Op.POP: gas_costs.GAS_BASE, + Op.MLOAD: gas_costs.GAS_VERY_LOW, + Op.MSTORE: gas_costs.GAS_VERY_LOW, + Op.MSTORE8: gas_costs.GAS_VERY_LOW, + Op.SLOAD: gas_costs.GAS_WARM_ACCESS, + Op.JUMP: gas_costs.GAS_MID, + Op.JUMPI: gas_costs.GAS_HIGH, + Op.PC: gas_costs.GAS_BASE, + Op.MSIZE: gas_costs.GAS_BASE, + Op.GAS: gas_costs.GAS_BASE, + Op.JUMPDEST: gas_costs.GAS_JUMPDEST, + Op.TLOAD: gas_costs.GAS_WARM_ACCESS, + Op.TSTORE: gas_costs.GAS_WARM_ACCESS, + Op.MCOPY: gas_costs.GAS_VERY_LOW, + Op.PUSH0: gas_costs.GAS_BASE, + Op.LOG0: gas_costs.GAS_LOG + (0 * gas_costs.GAS_LOG_TOPIC), + Op.LOG1: gas_costs.GAS_LOG + (1 * gas_costs.GAS_LOG_TOPIC), + Op.LOG2: gas_costs.GAS_LOG + (2 * gas_costs.GAS_LOG_TOPIC), + Op.LOG3: gas_costs.GAS_LOG + (3 * gas_costs.GAS_LOG_TOPIC), + Op.LOG4: gas_costs.GAS_LOG + (4 * gas_costs.GAS_LOG_TOPIC), + Op.CREATE: gas_costs.TX_CREATE_COST, + Op.CALL: gas_costs.GAS_WARM_ACCESS, + Op.CALLCODE: gas_costs.GAS_WARM_ACCESS, + Op.DELEGATECALL: gas_costs.GAS_WARM_ACCESS, + Op.CREATE2: gas_costs.TX_CREATE_COST, + Op.STATICCALL: gas_costs.GAS_WARM_ACCESS, + Op.SELFDESTRUCT: gas_costs.GAS_SELF_DESTRUCT, Op.STOP: 0, Op.RETURN: 0, Op.REVERT: 0, @@ -306,7 +306,7 @@ def constant_gas_opcodes(fork: Fork) -> Generator[ParameterSet, None, None]: # PUSHx, SWAPx, DUPx have uniform gas costs for opcode in valid_opcodes: if 0x60 <= opcode.int() <= 0x9F: - opcode_floor_gas[opcode] = gas_costs.G_VERY_LOW + opcode_floor_gas[opcode] = gas_costs.GAS_VERY_LOW for opcode in sorted(valid_opcodes): # SSTORE - untestable due to 2300 gas stipend rule @@ -327,12 +327,12 @@ def constant_gas_opcodes(fork: Fork) -> Generator[ParameterSet, None, None]: Op.DELEGATECALL, Op.STATICCALL, ]: - cold_gas = gas_costs.G_COLD_ACCOUNT_ACCESS + cold_gas = gas_costs.GAS_COLD_ACCOUNT_ACCESS elif opcode == Op.SELFDESTRUCT: # Add the cost of accessing the send all destination account. - cold_gas += gas_costs.G_COLD_ACCOUNT_ACCESS + cold_gas += gas_costs.GAS_COLD_ACCOUNT_ACCESS elif opcode == Op.SLOAD: - cold_gas = gas_costs.G_COLD_SLOAD + cold_gas = gas_costs.GAS_COLD_SLOAD yield pytest.param(opcode, warm_gas, cold_gas, id=f"{opcode}") diff --git a/tests/frontier/opcodes/test_call.py b/tests/frontier/opcodes/test_call.py index 59ef2559f6..69343fee2f 100644 --- a/tests/frontier/opcodes/test_call.py +++ b/tests/frontier/opcodes/test_call.py @@ -37,7 +37,7 @@ def test_call_large_offset_mstore( call_measure = CodeGasMeasure( code=Op.CALL(gas=0, ret_offset=mem_offset, ret_size=0), # Cost of pushing CALL args - overhead_cost=gsc.G_VERY_LOW * len(Op.CALL.kwargs), + overhead_cost=gsc.GAS_VERY_LOW * len(Op.CALL.kwargs), extra_stack_items=1, # Because CALL pushes 1 item to the stack sstore_key=0, stop=False, # Because it's the first CodeGasMeasure @@ -45,7 +45,7 @@ def test_call_large_offset_mstore( mstore_measure = CodeGasMeasure( code=Op.MSTORE(offset=mem_offset, value=1), # Cost of pushing MSTORE args - overhead_cost=gsc.G_VERY_LOW * len(Op.MSTORE.kwargs), + overhead_cost=gsc.GAS_VERY_LOW * len(Op.MSTORE.kwargs), extra_stack_items=0, sstore_key=1, ) @@ -60,11 +60,11 @@ def test_call_large_offset_mstore( ) # this call cost is just the address_access_cost - call_cost = gsc.G_COLD_ACCOUNT_ACCESS + call_cost = gsc.GAS_COLD_ACCOUNT_ACCESS memory_expansion_gas_calc = fork.memory_expansion_gas_calculator() # mstore cost: base cost + expansion cost - mstore_cost = gsc.G_MEMORY + memory_expansion_gas_calc( + mstore_cost = gsc.GAS_MEMORY + memory_expansion_gas_calc( new_bytes=mem_offset + 1 ) state_test( @@ -108,7 +108,7 @@ def test_call_memory_expands_on_early_revert( # CALL with value code=Op.CALL(gas=0, value=100, ret_size=ret_size), # Cost of pushing CALL args - overhead_cost=gsc.G_VERY_LOW * len(Op.CALL.kwargs), + overhead_cost=gsc.GAS_VERY_LOW * len(Op.CALL.kwargs), # Because CALL pushes 1 item to the stack extra_stack_items=1, sstore_key=0, @@ -119,7 +119,7 @@ def test_call_memory_expands_on_early_revert( # Low offset for not expanding memory code=Op.MSTORE(offset=ret_size // 2, value=1), # Cost of pushing MSTORE args - overhead_cost=gsc.G_VERY_LOW * len(Op.MSTORE.kwargs), + overhead_cost=gsc.GAS_VERY_LOW * len(Op.MSTORE.kwargs), extra_stack_items=0, sstore_key=1, ) @@ -140,16 +140,16 @@ def test_call_memory_expands_on_early_revert( # call cost: # address_access_cost+new_acc_cost+memory_expansion_cost+value-stipend call_cost = ( - gsc.G_COLD_ACCOUNT_ACCESS - + gsc.G_NEW_ACCOUNT + gsc.GAS_COLD_ACCOUNT_ACCESS + + gsc.GAS_NEW_ACCOUNT + memory_expansion_gas_calc(new_bytes=ret_size) - + gsc.G_CALL_VALUE - - gsc.G_CALL_STIPEND + + gsc.GAS_CALL_VALUE + - gsc.GAS_CALL_STIPEND ) # mstore cost: base cost. No memory expansion cost needed, it was expanded # on CALL. - mstore_cost = gsc.G_MEMORY + mstore_cost = gsc.GAS_MEMORY state_test( env=Environment(), pre=pre, @@ -188,7 +188,7 @@ def test_call_large_args_offset_size_zero( call_measure = CodeGasMeasure( code=call_opcode(gas=0, args_offset=very_large_offset, args_size=0), # Cost of pushing xCALL args - overhead_cost=gsc.G_VERY_LOW * len(call_opcode.kwargs), + overhead_cost=gsc.GAS_VERY_LOW * len(call_opcode.kwargs), extra_stack_items=1, # Because xCALL pushes 1 item to the stack sstore_key=0, ) @@ -203,7 +203,7 @@ def test_call_large_args_offset_size_zero( ) # this call cost is just the address_access_cost - call_cost = gsc.G_COLD_ACCOUNT_ACCESS + call_cost = gsc.GAS_COLD_ACCOUNT_ACCESS state_test( env=Environment(), diff --git a/tests/frontier/opcodes/test_exp.py b/tests/frontier/opcodes/test_exp.py index bf4851cdd8..5f9cfc511c 100644 --- a/tests/frontier/opcodes/test_exp.py +++ b/tests/frontier/opcodes/test_exp.py @@ -19,7 +19,10 @@ def exp_gas(fork: Fork, exponent: int) -> int: """Calculate gas cost for EXP opcode given the exponent.""" gas_costs = fork.gas_costs() byte_len = (exponent.bit_length() + 7) // 8 - return gas_costs.G_EXP + gas_costs.G_EXP_BYTE * byte_len + return ( + gas_costs.GAS_EXPONENTIATION + + gas_costs.GAS_EXPONENTIATION_PER_BYTE * byte_len + ) @pytest.mark.valid_from("Berlin") diff --git a/tests/frontier/opcodes/test_log.py b/tests/frontier/opcodes/test_log.py index bb8fc25070..604fd65d58 100644 --- a/tests/frontier/opcodes/test_log.py +++ b/tests/frontier/opcodes/test_log.py @@ -22,9 +22,9 @@ def log_gas(fork: Fork, topics: int, data_size: int) -> int: """ gas_costs = fork.gas_costs() return ( - gas_costs.G_LOG - + gas_costs.G_LOG_TOPIC * topics - + gas_costs.G_LOG_DATA * data_size + gas_costs.GAS_LOG + + gas_costs.GAS_LOG_TOPIC * topics + + gas_costs.GAS_LOG_DATA * data_size ) diff --git a/tests/json_infra/test_tools_new_fork.py b/tests/json_infra/test_tools_new_fork.py index 4f0bf98544..6cc7b58495 100644 --- a/tests/json_infra/test_tools_new_fork.py +++ b/tests/json_infra/test_tools_new_fork.py @@ -75,9 +75,9 @@ def test_end_to_end(template_fork: str) -> None: source = f.read() expected = [ - "TARGET_BLOB_GAS_PER_BLOCK = U64(199)", + "BLOB_TARGET_GAS_PER_BLOCK = U64(199)", "GAS_PER_BLOB = U64(1)", - "MIN_BLOB_GASPRICE = Uint(2)", + "BLOB_MIN_GASPRICE = Uint(2)", "BLOB_BASE_FEE_UPDATE_FRACTION = Uint(750)", "BLOB_SCHEDULE_TARGET = U64(88)", "BLOB_SCHEDULE_MAX = U64(77)", diff --git a/tests/osaka/eip7823_modexp_upper_bounds/conftest.py b/tests/osaka/eip7823_modexp_upper_bounds/conftest.py index f9528d8e92..c24e13a3a2 100644 --- a/tests/osaka/eip7823_modexp_upper_bounds/conftest.py +++ b/tests/osaka/eip7823_modexp_upper_bounds/conftest.py @@ -89,10 +89,10 @@ def gas_measure_contract( gas_costs = fork.gas_costs() extra_gas = ( - gas_costs.G_WARM_ACCOUNT_ACCESS - + (gas_costs.G_VERY_LOW * (len(Op.CALL.kwargs) - 1)) - + gas_costs.G_BASE # CALLDATASIZE - + gas_costs.G_BASE # GAS + gas_costs.GAS_WARM_ACCESS + + (gas_costs.GAS_VERY_LOW * (len(Op.CALL.kwargs) - 1)) + + gas_costs.GAS_BASE # CALLDATASIZE + + gas_costs.GAS_BASE # GAS ) # Build the gas measurement contract code diff --git a/tests/osaka/eip7825_transaction_gas_limit_cap/test_tx_gas_limit.py b/tests/osaka/eip7825_transaction_gas_limit_cap/test_tx_gas_limit.py index 8e8f8d01ce..afebc9d2af 100644 --- a/tests/osaka/eip7825_transaction_gas_limit_cap/test_tx_gas_limit.py +++ b/tests/osaka/eip7825_transaction_gas_limit_cap/test_tx_gas_limit.py @@ -254,9 +254,11 @@ def test_maximum_gas_refund( # Base Operation: SSTORE(slot, 0) iteration_cost = ( - gas_costs.G_STORAGE_RESET + gas_costs.G_BASE + gas_costs.G_VERY_LOW + gas_costs.GAS_STORAGE_UPDATE + + gas_costs.GAS_BASE + + gas_costs.GAS_VERY_LOW ) - gas_refund = gas_costs.R_STORAGE_CLEAR + gas_refund = gas_costs.GAS_STORAGE_CLEAR_REFUND # EIP-3529: Reduction in refunds storage_count = tx_gas_limit_cap // iteration_cost @@ -305,7 +307,7 @@ def test_maximum_gas_refund( def total_cost_floor_per_token(fork: Fork) -> int: """Total cost floor per token.""" gas_costs = fork.gas_costs() - return gas_costs.G_TX_DATA_FLOOR_TOKEN_COST + return gas_costs.FLOOR_CALLDATA_COST @pytest.mark.xdist_group(name="bigmem") @@ -484,8 +486,8 @@ def test_tx_gas_limit_cap_access_list_with_diff_keys( gas_available = tx_gas_limit_cap - intrinsic_cost() gas_costs = fork.gas_costs() - gas_per_address = gas_costs.G_ACCESS_LIST_ADDRESS - gas_per_storage_key = gas_costs.G_ACCESS_LIST_STORAGE + gas_per_address = gas_costs.TX_ACCESS_LIST_ADDRESS_COST + gas_per_storage_key = gas_costs.TX_ACCESS_LIST_STORAGE_KEY_COST gas_after_address = gas_available - gas_per_address num_storage_keys = gas_after_address // gas_per_storage_key + int( @@ -569,8 +571,8 @@ def test_tx_gas_limit_cap_access_list_with_diff_addr( gas_available = tx_gas_limit_cap - intrinsic_cost() gas_costs = fork.gas_costs() - gas_per_address = gas_costs.G_ACCESS_LIST_ADDRESS - gas_per_storage_key = gas_costs.G_ACCESS_LIST_STORAGE + gas_per_address = gas_costs.TX_ACCESS_LIST_ADDRESS_COST + gas_per_storage_key = gas_costs.TX_ACCESS_LIST_STORAGE_KEY_COST account_num = gas_available // ( gas_per_address + gas_per_storage_key @@ -646,7 +648,7 @@ def test_tx_gas_limit_cap_authorized_tx( gas_available = tx_gas_limit_cap - intrinsic_cost() gas_costs = fork.gas_costs() - gas_per_address = gas_costs.G_ACCESS_LIST_ADDRESS + gas_per_address = gas_costs.TX_ACCESS_LIST_ADDRESS_COST per_empty_account_cost = 25_000 auth_list_length = gas_available // ( diff --git a/tests/osaka/eip7883_modexp_gas_increase/conftest.py b/tests/osaka/eip7883_modexp_gas_increase/conftest.py index 0f1114eeab..376989cdc4 100644 --- a/tests/osaka/eip7883_modexp_gas_increase/conftest.py +++ b/tests/osaka/eip7883_modexp_gas_increase/conftest.py @@ -60,7 +60,9 @@ 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) + sstore_gas = fork.gas_costs().GAS_STORAGE_SET * ( + len(modexp_expected) // 32 + ) extra_gas = 100_000 return ( @@ -154,10 +156,10 @@ def gas_measure_contract( gas_costs = fork.gas_costs() extra_gas = ( - gas_costs.G_WARM_ACCOUNT_ACCESS - + (gas_costs.G_VERY_LOW * (len(call_opcode.kwargs) - 1)) - + gas_costs.G_BASE # CALLDATASIZE - + gas_costs.G_BASE # GAS + gas_costs.GAS_WARM_ACCESS + + (gas_costs.GAS_VERY_LOW * (len(call_opcode.kwargs) - 1)) + + gas_costs.GAS_BASE # CALLDATASIZE + + gas_costs.GAS_BASE # GAS ) # Build the gas measurement contract code diff --git a/tests/osaka/eip7883_modexp_gas_increase/test_modexp_thresholds_transition.py b/tests/osaka/eip7883_modexp_gas_increase/test_modexp_thresholds_transition.py index be711225a2..e23b50e652 100644 --- a/tests/osaka/eip7883_modexp_gas_increase/test_modexp_thresholds_transition.py +++ b/tests/osaka/eip7883_modexp_gas_increase/test_modexp_thresholds_transition.py @@ -57,9 +57,9 @@ def test_modexp_fork_transition( gas_costs = fork.gas_costs() extra_gas = ( - gas_costs.G_WARM_ACCOUNT_ACCESS - + (gas_costs.G_VERY_LOW * (len(Op.CALL.kwargs) - 2)) - + (gas_costs.G_BASE * 3) + gas_costs.GAS_WARM_ACCESS + + (gas_costs.GAS_VERY_LOW * (len(Op.CALL.kwargs) - 2)) + + (gas_costs.GAS_BASE * 3) ) code = ( Op.CALLDATACOPY(dest_offset=0, offset=0, size=Op.CALLDATASIZE) diff --git a/tests/osaka/eip7918_blob_reserve_price/test_blob_reserve_price_with_bpo_transitions.py b/tests/osaka/eip7918_blob_reserve_price/test_blob_reserve_price_with_bpo_transitions.py index 08f98b96df..61897887e7 100644 --- a/tests/osaka/eip7918_blob_reserve_price/test_blob_reserve_price_with_bpo_transitions.py +++ b/tests/osaka/eip7918_blob_reserve_price/test_blob_reserve_price_with_bpo_transitions.py @@ -26,7 +26,7 @@ REFERENCE_SPEC_GIT_PATH = ref_spec_7918.git_path REFERENCE_SPEC_VERSION = ref_spec_7918.version -MIN_BLOB_GASPRICE = 1 +BLOB_MIN_GASPRICE = 1 @pytest.fixture @@ -388,7 +388,7 @@ def blob_base_cost(self) -> int | None: return None @property - def target_blob_gas_per_block(self) -> int: + def blob_target_gas_per_block(self) -> int: """Return the target blob gas per block.""" return self.target * self.blob_gas_per_blob diff --git a/tests/osaka/eip7939_count_leading_zeros/test_count_leading_zeros.py b/tests/osaka/eip7939_count_leading_zeros/test_count_leading_zeros.py index ff1da2f5ee..cb07d56ec0 100644 --- a/tests/osaka/eip7939_count_leading_zeros/test_count_leading_zeros.py +++ b/tests/osaka/eip7939_count_leading_zeros/test_count_leading_zeros.py @@ -136,7 +136,7 @@ def test_clz_gas_cost( CodeGasMeasure( code=Op.CLZ(Op.PUSH1(1)), extra_stack_items=1, - overhead_cost=fork.gas_costs().G_VERY_LOW, + overhead_cost=fork.gas_costs().GAS_VERY_LOW, ), ), storage={"0x00": "0xdeadbeef"}, @@ -145,7 +145,7 @@ def test_clz_gas_cost( tx = Transaction(to=contract_address, sender=sender, gas_limit=200_000) post = { contract_address: Account( # Cost measured is CLZ + PUSH1 - storage={"0x00": fork.gas_costs().G_LOW} + storage={"0x00": fork.gas_costs().GAS_LOW} ), } state_test(pre=pre, post=post, tx=tx) @@ -172,7 +172,7 @@ def test_clz_gas_cost_boundary( call_code = Op.SSTORE( 0, Op.CALL( - gas=fork.gas_costs().G_VERY_LOW + gas=fork.gas_costs().GAS_VERY_LOW + Spec.CLZ_GAS_COST + gas_cost_delta, address=contract_address, diff --git a/tests/prague/eip7623_increase_calldata_cost/test_refunds.py b/tests/prague/eip7623_increase_calldata_cost/test_refunds.py index 7e61fa058b..dadd7ec6b1 100644 --- a/tests/prague/eip7623_increase_calldata_cost/test_refunds.py +++ b/tests/prague/eip7623_increase_calldata_cost/test_refunds.py @@ -94,12 +94,12 @@ def max_refund(fork: Fork, refund_type: RefundType) -> int: """Return the max refund gas of the transaction.""" gas_costs = fork.gas_costs() max_refund = ( - gas_costs.R_STORAGE_CLEAR + gas_costs.GAS_STORAGE_CLEAR_REFUND if RefundType.STORAGE_CLEAR in refund_type else 0 ) max_refund += ( - gas_costs.R_AUTHORIZATION_EXISTING_AUTHORITY + gas_costs.PER_AUTH_BASE_COST if RefundType.AUTHORIZATION_EXISTING_AUTHORITY in refund_type else 0 ) @@ -113,9 +113,9 @@ def prefix_code_gas(fork: Fork, refund_type: RefundType) -> int: # Minimum code to generate a storage clear is Op.SSTORE(0, 0). gas_costs = fork.gas_costs() return ( - gas_costs.G_COLD_SLOAD - + gas_costs.G_STORAGE_RESET - + (gas_costs.G_VERY_LOW * 2) + gas_costs.GAS_COLD_SLOAD + + gas_costs.GAS_STORAGE_UPDATE + + (gas_costs.GAS_VERY_LOW * 2) ) return 0 diff --git a/tests/prague/eip7702_set_code_tx/test_eip_mainnet.py b/tests/prague/eip7702_set_code_tx/test_eip_mainnet.py index 6470700815..3215d37311 100644 --- a/tests/prague/eip7702_set_code_tx/test_eip_mainnet.py +++ b/tests/prague/eip7702_set_code_tx/test_eip_mainnet.py @@ -57,9 +57,9 @@ def test_eip_7702( authorization_list_or_count=authorization_list, ) execution_cost = ( - (gas_costs.G_COLD_SLOAD + gas_costs.G_STORAGE_SET) * 3 - + (gas_costs.G_VERY_LOW * 3) - + (gas_costs.G_BASE * 3) + (gas_costs.GAS_COLD_SLOAD + gas_costs.GAS_STORAGE_SET) * 3 + + (gas_costs.GAS_VERY_LOW * 3) + + (gas_costs.GAS_BASE * 3) ) tx = Transaction( diff --git a/tests/prague/eip7702_set_code_tx/test_gas.py b/tests/prague/eip7702_set_code_tx/test_gas.py index 048a84c44b..06e8b35cc1 100644 --- a/tests/prague/eip7702_set_code_tx/test_gas.py +++ b/tests/prague/eip7702_set_code_tx/test_gas.py @@ -885,12 +885,12 @@ def test_gas_cost( # fifth (EIP-3529) of the total gas used, so we can see the full discount # being reflected in most of the tests. gas_costs = fork.gas_costs() - gas_opcode_cost = gas_costs.G_BASE + gas_opcode_cost = gas_costs.GAS_BASE sstore_opcode_count = 10 push_opcode_count = (2 * (sstore_opcode_count)) - 1 - push_opcode_cost = gas_costs.G_VERY_LOW * push_opcode_count - sstore_opcode_cost = gas_costs.G_STORAGE_SET * sstore_opcode_count - cold_storage_cost = gas_costs.G_COLD_SLOAD * sstore_opcode_count + push_opcode_cost = gas_costs.GAS_VERY_LOW * push_opcode_count + sstore_opcode_cost = gas_costs.GAS_STORAGE_SET * sstore_opcode_count + cold_storage_cost = gas_costs.GAS_COLD_SLOAD * sstore_opcode_count execution_gas = ( gas_opcode_cost @@ -1259,8 +1259,8 @@ def test_call_to_pre_authorized_oog( ) tx_gas_limit = ( intrinsic_gas_cost_calculator() - + len(call_opcode.kwargs) * gas_costs.G_VERY_LOW - + (gas_costs.G_COLD_ACCOUNT_ACCESS * 2) + + len(call_opcode.kwargs) * gas_costs.GAS_VERY_LOW + + (gas_costs.GAS_COLD_ACCOUNT_ACCESS * 2) - 1 ) tx = Transaction( diff --git a/tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py b/tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py index d988da7fbc..a9b2849be7 100644 --- a/tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py +++ b/tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py @@ -703,14 +703,14 @@ def test_gas_diff_pointer_vs_direct_call( opcodes_price = 37 direct_call_gas: int = ( # 20_000 + 2_600 + 2_100 + 37 = 24737 - gas_costs.G_STORAGE_SET + gas_costs.GAS_STORAGE_SET + ( # access account price # If storage and account is declared in access list then discount - gas_costs.G_WARM_ACCOUNT_ACCESS + gas_costs.G_WARM_SLOAD + gas_costs.GAS_WARM_ACCESS + gas_costs.GAS_WARM_ACCESS if access_list_rule in [AccessListCall.IN_NORMAL_TX_ONLY, AccessListCall.IN_BOTH_TX] - else gas_costs.G_COLD_ACCOUNT_ACCESS + gas_costs.G_COLD_SLOAD + else gas_costs.GAS_COLD_ACCOUNT_ACCESS + gas_costs.GAS_COLD_SLOAD ) + opcodes_price ) @@ -732,10 +732,10 @@ def test_gas_diff_pointer_vs_direct_call( # contract call is hot, pointer call is call because pointer is set # only sload is hot because access list is for contract # 20_000 + 100 + 100 + 2100 + 37 = 22_337 - gas_costs.G_STORAGE_SET + gas_costs.GAS_STORAGE_SET # pointer address access + ( - gas_costs.G_WARM_ACCOUNT_ACCESS + gas_costs.GAS_WARM_ACCESS if ( pointer_definition in [ @@ -749,11 +749,11 @@ def test_gas_diff_pointer_vs_direct_call( ] and access_list_to == AccessListTo.POINTER_ADDRESS ) - else gas_costs.G_COLD_ACCOUNT_ACCESS + else gas_costs.GAS_COLD_ACCOUNT_ACCESS ) # storage access + ( - gas_costs.G_WARM_SLOAD + gas_costs.GAS_WARM_ACCESS if ( access_list_rule in [ @@ -762,11 +762,11 @@ def test_gas_diff_pointer_vs_direct_call( ] and access_list_to == AccessListTo.POINTER_ADDRESS ) - else gas_costs.G_COLD_SLOAD + else gas_costs.GAS_COLD_SLOAD ) # contract address access + ( - gas_costs.G_WARM_ACCOUNT_ACCESS + gas_costs.GAS_WARM_ACCESS if ( access_list_rule in [ @@ -775,7 +775,7 @@ def test_gas_diff_pointer_vs_direct_call( ] and access_list_to == AccessListTo.CONTRACT_ADDRESS ) - else gas_costs.G_COLD_ACCOUNT_ACCESS + else gas_costs.GAS_COLD_ACCOUNT_ACCESS ) + opcodes_price ) @@ -923,17 +923,17 @@ def test_pointer_call_followed_by_direct_call( call_worked = 1 opcodes_price: int = 37 pointer_call_gas = ( - gas_costs.G_STORAGE_SET - + gas_costs.G_WARM_ACCOUNT_ACCESS # pointer is warm - + gas_costs.G_COLD_ACCOUNT_ACCESS # contract is cold - + gas_costs.G_COLD_SLOAD # storage access under pointer call is cold + gas_costs.GAS_STORAGE_SET + + gas_costs.GAS_WARM_ACCESS # pointer is warm + + gas_costs.GAS_COLD_ACCOUNT_ACCESS # contract is cold + + gas_costs.GAS_COLD_SLOAD # storage access under pointer call is cold + opcodes_price ) direct_call_gas = ( - gas_costs.G_STORAGE_SET - + gas_costs.G_WARM_ACCOUNT_ACCESS # since previous pointer call, + gas_costs.GAS_STORAGE_SET + + gas_costs.GAS_WARM_ACCESS # since previous pointer call, # contract is now warm - + gas_costs.G_COLD_SLOAD # but storage is cold, because it's + + gas_costs.GAS_COLD_SLOAD # but storage is cold, because it's # contract's direct + opcodes_price ) @@ -2191,7 +2191,7 @@ def test_delegation_replacement_call_previous_contract( sender = pre.fund_eoa() gsc = fork.gas_costs() - overhead_cost = gsc.G_VERY_LOW * len(Op.CALL.kwargs) + overhead_cost = gsc.GAS_VERY_LOW * len(Op.CALL.kwargs) set_code = CodeGasMeasure( code=Op.CALL(gas=0, address=pre_set_delegation_address), overhead_cost=overhead_cost, @@ -2222,7 +2222,7 @@ def test_delegation_replacement_call_previous_contract( tx=tx, post={ auth_signer: Account( - storage={0: gsc.G_COLD_ACCOUNT_ACCESS}, + storage={0: gsc.GAS_COLD_ACCOUNT_ACCESS}, ) }, ) diff --git a/tests/shanghai/eip3860_initcode/test_initcode.py b/tests/shanghai/eip3860_initcode/test_initcode.py index bc645c494d..06ec8934e4 100644 --- a/tests/shanghai/eip3860_initcode/test_initcode.py +++ b/tests/shanghai/eip3860_initcode/test_initcode.py @@ -512,10 +512,10 @@ def contract_creation_gas_cost(self, fork: Fork, opcode: Op) -> int: """Calculate gas cost of the contract creation operation.""" gas_costs = fork.gas_costs() - create_contract_base_gas = gas_costs.G_CREATE - gas_opcode_gas = gas_costs.G_BASE - push_dup_opcode_gas = gas_costs.G_VERY_LOW - calldatasize_opcode_gas = gas_costs.G_BASE + create_contract_base_gas = gas_costs.GAS_CREATE + gas_opcode_gas = gas_costs.GAS_BASE + push_dup_opcode_gas = gas_costs.GAS_VERY_LOW + calldatasize_opcode_gas = gas_costs.GAS_BASE contract_creation_gas_usage = ( create_contract_base_gas + gas_opcode_gas @@ -530,7 +530,10 @@ def contract_creation_gas_cost(self, fork: Fork, opcode: Op) -> int: def initcode_word_cost(self, fork: Fork, initcode: Initcode) -> int: """Calculate gas cost charged for the initcode length.""" gas_costs = fork.gas_costs() - return ceiling_division(len(initcode), 32) * gas_costs.G_INITCODE_WORD + return ( + ceiling_division(len(initcode), 32) + * gas_costs.GAS_INIT_CODE_WORD_COST + ) @pytest.fixture def create2_word_cost( @@ -542,7 +545,7 @@ def create2_word_cost( gas_costs = fork.gas_costs() return ( - ceiling_division(len(initcode), 32) * gas_costs.G_KECCAK_256_WORD + ceiling_division(len(initcode), 32) * gas_costs.GAS_KECCAK256_WORD ) @pytest.mark.xdist_group(name="bigmem") diff --git a/tests/unscheduled/eip7692_eof_v1/eip7873_tx_create/test_txcreate_failures.py b/tests/unscheduled/eip7692_eof_v1/eip7873_tx_create/test_txcreate_failures.py index d9b05d4249..6423b51f24 100644 --- a/tests/unscheduled/eip7692_eof_v1/eip7873_tx_create/test_txcreate_failures.py +++ b/tests/unscheduled/eip7692_eof_v1/eip7873_tx_create/test_txcreate_failures.py @@ -993,12 +993,12 @@ def test_invalid_container_deployment( ) elif reason == "out_of_gas_when_returning_contract": factory_gas_cost = ( - 7 * fork_gas_costs.G_VERY_LOW - + fork_gas_costs.G_STORAGE_SET - + fork_gas_costs.G_COLD_SLOAD - + fork_gas_costs.G_CREATE + 7 * fork_gas_costs.GAS_VERY_LOW + + fork_gas_costs.GAS_STORAGE_SET + + fork_gas_costs.GAS_COLD_SLOAD + + fork_gas_costs.GAS_CREATE ) - initcode_gas_cost = 2 * fork_gas_costs.G_VERY_LOW + initcode_gas_cost = 2 * fork_gas_costs.GAS_VERY_LOW tx_gas_limit = ( fork_intrinsic_gas_calculator(calldata=initcontainer) + factory_gas_cost @@ -1008,16 +1008,16 @@ def test_invalid_container_deployment( reason == "out_of_gas_when_returning_contract_due_to_memory_expansion" ): factory_gas_cost = ( - 7 * fork_gas_costs.G_VERY_LOW - + fork_gas_costs.G_STORAGE_SET - + fork_gas_costs.G_COLD_SLOAD - + fork_gas_costs.G_CREATE + 7 * fork_gas_costs.GAS_VERY_LOW + + fork_gas_costs.GAS_STORAGE_SET + + fork_gas_costs.GAS_COLD_SLOAD + + fork_gas_costs.GAS_CREATE ) initcode_gas_cost = ( # Code deposit gas cost - len(deployed_container) * fork_gas_costs.G_CODE_DEPOSIT_BYTE + len(deployed_container) * fork_gas_costs.GAS_CODE_DEPOSIT # Two push opcodes - + 2 * fork_gas_costs.G_VERY_LOW + + 2 * fork_gas_costs.GAS_VERY_LOW ) tx_gas_limit = ( fork_intrinsic_gas_calculator(calldata=initcontainer)