26
26
Storage ,
27
27
Transaction ,
28
28
TransactionException ,
29
+ TransactionReceipt ,
29
30
extend_with_defaults ,
30
31
)
31
32
from ethereum_test_tools import Opcodes as Op
@@ -688,12 +689,13 @@ def test_gas_cost(
688
689
# We calculate the exact gas required to execute the test code.
689
690
# We add SSTORE opcodes in order to make sure that the refund is less than one fifth (EIP-3529)
690
691
# of the total gas used, so we can see the full discount being reflected in most of the tests.
691
- gas_opcode_cost = 2
692
+ gas_costs = fork .gas_costs ()
693
+ gas_opcode_cost = gas_costs .G_BASE
692
694
sstore_opcode_count = 10
693
695
push_opcode_count = (2 * (sstore_opcode_count )) - 1
694
- push_opcode_cost = 3 * push_opcode_count
695
- sstore_opcode_cost = 20_000 * sstore_opcode_count
696
- cold_storage_cost = 2_100 * sstore_opcode_count
696
+ push_opcode_cost = gas_costs . G_VERY_LOW * push_opcode_count
697
+ sstore_opcode_cost = gas_costs . G_STORAGE_SET * sstore_opcode_count
698
+ cold_storage_cost = gas_costs . G_COLD_SLOAD * sstore_opcode_count
697
699
698
700
execution_gas = gas_opcode_cost + push_opcode_cost + sstore_opcode_cost + cold_storage_cost
699
701
@@ -712,8 +714,6 @@ def test_gas_cost(
712
714
test_code_address = pre .deploy_contract (test_code )
713
715
714
716
tx_gas_limit = intrinsic_gas + execution_gas
715
- tx_max_fee_per_gas = 7
716
- tx_exact_cost = tx_gas_limit * tx_max_fee_per_gas
717
717
718
718
# EIP-3529
719
719
max_discount = tx_gas_limit // 5
@@ -722,20 +722,20 @@ def test_gas_cost(
722
722
# Only one test hits this condition, but it's ok to also test this case.
723
723
discount_gas = max_discount
724
724
725
- discount_cost = discount_gas * tx_max_fee_per_gas
725
+ gas_used = tx_gas_limit - discount_gas
726
726
727
727
sender_account = pre [sender ]
728
728
assert sender_account is not None
729
729
730
730
tx = Transaction (
731
731
gas_limit = tx_gas_limit ,
732
- max_fee_per_gas = tx_max_fee_per_gas ,
733
732
to = test_code_address ,
734
733
value = 0 ,
735
734
data = data ,
736
735
authorization_list = authorization_list ,
737
736
access_list = access_list ,
738
737
sender = sender ,
738
+ expected_receipt = TransactionReceipt (gas_used = gas_used ),
739
739
)
740
740
741
741
state_test (
@@ -744,7 +744,6 @@ def test_gas_cost(
744
744
tx = tx ,
745
745
post = {
746
746
test_code_address : Account (storage = test_code_storage ),
747
- sender : Account (balance = sender_account .balance - tx_exact_cost + discount_cost ),
748
747
},
749
748
)
750
749
0 commit comments