5
5
6
6
import pytest
7
7
8
+ from ethereum_test_checklists import EIPChecklist
8
9
from ethereum_test_forks import Fork
9
10
from ethereum_test_tools import (
10
11
Account ,
22
23
REFERENCE_SPEC_VERSION = ref_spec_7825 .version
23
24
24
25
26
+ @EIPChecklist .ModifiedTransactionValidityConstraint .Test .ForkTransition .AcceptedBeforeFork ()
27
+ @EIPChecklist .ModifiedTransactionValidityConstraint .Test .ForkTransition .RejectedBeforeFork ()
28
+ @EIPChecklist .ModifiedTransactionValidityConstraint .Test .ForkTransition .AcceptedAfterFork ()
29
+ @EIPChecklist .ModifiedTransactionValidityConstraint .Test .ForkTransition .RejectedAfterFork ()
25
30
@pytest .mark .valid_at_transition_to ("Osaka" , subsequent_forks = True )
26
31
@pytest .mark .exception_test
27
32
def test_transaction_gas_limit_cap_at_transition (
@@ -35,12 +40,11 @@ def test_transaction_gas_limit_cap_at_transition(
35
40
Before timestamp 15000: No gas limit cap (transactions with gas > 2^24 are valid)
36
41
At/after timestamp 15000: Gas limit cap of 2^24 is enforced
37
42
"""
38
- sender = pre .fund_eoa ()
39
43
contract_address = pre .deploy_contract (
40
- code = Op .SSTORE (0 , Op .ADD (Op .SLOAD (0 ), 1 )) + Op .STOP ,
44
+ code = Op .SSTORE (Op . TIMESTAMP , Op .ADD (Op .SLOAD (0 ), 1 )) + Op .STOP ,
41
45
)
42
46
43
- pre_cap = fork .transaction_gas_limit_cap ()
47
+ pre_cap = fork .transaction_gas_limit_cap (timestamp = 14_999 )
44
48
post_cap = fork .transaction_gas_limit_cap (timestamp = 15_000 )
45
49
assert post_cap is not None , "Post cap should not be None"
46
50
@@ -50,44 +54,57 @@ def test_transaction_gas_limit_cap_at_transition(
50
54
"Post cap should be less than or equal to pre cap, test needs update"
51
55
)
52
56
53
- # Transaction with gas limit above the cap before transition
54
- high_gas_tx = Transaction (
57
+ # Before fork activation
58
+ high_gas_tx_before_fork = Transaction (
55
59
ty = 0 , # Legacy transaction
56
60
to = contract_address ,
57
61
gas_limit = pre_cap ,
58
- data = b"" ,
59
- value = 0 ,
60
- sender = sender ,
62
+ sender = pre .fund_eoa (),
63
+ )
64
+
65
+ cap_tx_before_fork = Transaction (
66
+ ty = 0 , # Legacy transaction
67
+ to = contract_address ,
68
+ gas_limit = post_cap ,
69
+ sender = pre .fund_eoa (),
61
70
)
62
71
63
72
post_cap_tx_error = TransactionException .GAS_LIMIT_EXCEEDS_MAXIMUM
64
73
65
- # Transaction with gas limit at the cap
66
- cap_gas_tx = Transaction (
74
+ # After fork activation
75
+ high_gas_tx_after_fork = Transaction (
67
76
ty = 0 , # Legacy transaction
68
77
to = contract_address ,
69
- gas_limit = post_cap + 1 ,
70
- data = b"" ,
71
- value = 0 ,
72
- sender = sender ,
78
+ gas_limit = pre_cap ,
79
+ sender = pre .fund_eoa (),
73
80
error = post_cap_tx_error ,
74
81
)
75
82
83
+ cap_tx_after_fork = Transaction (
84
+ ty = 0 , # Legacy transaction
85
+ to = contract_address ,
86
+ gas_limit = post_cap ,
87
+ sender = pre .fund_eoa (),
88
+ )
89
+
76
90
blocks = []
77
91
78
92
# Before transition (timestamp < 15000): high gas transaction should succeed
79
93
blocks .append (
80
94
Block (
81
95
timestamp = 14_999 ,
82
- txs = [high_gas_tx ],
96
+ txs = [high_gas_tx_before_fork , cap_tx_before_fork ],
83
97
)
84
98
)
85
99
86
100
# At transition (timestamp = 15000): high gas transaction should fail
87
101
blocks .append (
88
102
Block (
89
103
timestamp = 15_000 ,
90
- txs = [cap_gas_tx ], # Only transaction at the cap succeeds
104
+ txs = [
105
+ cap_tx_after_fork ,
106
+ high_gas_tx_after_fork ,
107
+ ],
91
108
exception = post_cap_tx_error ,
92
109
)
93
110
)
@@ -96,7 +113,8 @@ def test_transaction_gas_limit_cap_at_transition(
96
113
post = {
97
114
contract_address : Account (
98
115
storage = {
99
- 0 : 1 , # Set by first transaction (before transition)
116
+ 14_999 : 1 , # Set by first transaction (before transition)
117
+ 15_000 : 0 , # Set by second transaction (at transition)
100
118
}
101
119
)
102
120
}
0 commit comments