Skip to content

Commit 5643266

Browse files
joshklopclaude
andcommitted
feat(op-acceptance-tests): add EIP-7825 tx gas limit cap test
Add TestEIP7825TxGasLimitCap to verify the 2^24 transaction gas limit cap is enforced after Karst. Uses txplan to send real transactions since EIP-7825 is a tx validity rule not enforced by eth_call or eth_simulateV1. Tests both pre-karst (gas above cap allowed) and post-karst (gas above cap rejected, gas at cap succeeds). Also adds WithKarstAtGenesis deployer option and fixes the tx manager gas estimator to set callMsg.Gas to params.MaxTxGas before calling EstimateGas, which is required post-Osaka. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2f3ea9b commit 5643266

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

op-acceptance-tests/tests/osaka_on_l2_test.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import (
88
"github.com/ethereum-optimism/optimism/op-devstack/devtest"
99
"github.com/ethereum-optimism/optimism/op-devstack/presets"
1010
"github.com/ethereum-optimism/optimism/op-devstack/sysgo"
11+
"github.com/ethereum-optimism/optimism/op-service/eth"
12+
"github.com/ethereum-optimism/optimism/op-service/txplan"
1113
"github.com/ethereum/go-ethereum"
1214
"github.com/ethereum/go-ethereum/common"
1315
"github.com/ethereum/go-ethereum/core/vm"
16+
"github.com/ethereum/go-ethereum/params"
1417
"github.com/ethereum/go-ethereum/rpc"
1518
)
1619

@@ -118,6 +121,57 @@ func TestEIP7883ModExpGasCostIncrease(gt *testing.T) {
118121
t.Require().NoError(err, "post-fork: modexp should succeed with 600 execution gas (floor is 500)")
119122
}
120123

124+
func TestEIP7825TxGasLimitCap(gt *testing.T) {
125+
t := devtest.ParallelT(gt)
126+
sysgo.SkipOnOpGeth(t, "osaka is not supported in op-geth")
127+
128+
testCases := map[string]struct {
129+
opt sysgo.DeployerOption
130+
expectErr bool
131+
}{
132+
"pre-karst": {
133+
opt: sysgo.WithJovianAtGenesis,
134+
},
135+
"post-karst": {
136+
opt: sysgo.WithKarstAtGenesis,
137+
expectErr: true,
138+
},
139+
}
140+
141+
// EIP-7825 caps transaction gas at 2^24 = 16,777,216.
142+
// This is a tx validity rule enforced at the txpool/block level, not by the
143+
// EVM, so eth_call and eth_simulateV1 don't enforce it. We must send a real
144+
// transaction and verify the RPC rejects it.
145+
for name, testCase := range testCases {
146+
t.Run(name, func(t devtest.T) {
147+
t.Parallel()
148+
sys := presets.NewMinimal(t, presets.WithDeployerOptions(testCase.opt))
149+
150+
eoa := sys.FunderL2.NewFundedEOA(eth.OneEther)
151+
152+
planWithGasLimit := func(gas uint64) txplan.Option {
153+
return txplan.Combine(
154+
eoa.Plan(),
155+
txplan.WithGasLimit(gas),
156+
txplan.WithTo(&common.Address{}),
157+
)
158+
}
159+
160+
_, err := txplan.NewPlannedTx(planWithGasLimit(params.MaxTxGas)).Success.Eval(t.Ctx())
161+
t.Require().NoError(err, "tx with gas at 2^24 should succeed")
162+
163+
tx := txplan.NewPlannedTx(planWithGasLimit(params.MaxTxGas + 1))
164+
if testCase.expectErr {
165+
_, err := tx.Included.Eval(t.Ctx())
166+
t.Require().Error(err, "tx with gas above 2^24 should be rejected")
167+
} else {
168+
_, err := tx.Success.Eval(t.Ctx())
169+
t.Require().NoError(err, "tx with gas above 2^24 should succeed")
170+
}
171+
})
172+
}
173+
}
174+
121175
func TestEIP7939CLZ(gt *testing.T) {
122176
t := devtest.ParallelT(gt)
123177
sysgo.SkipOnOpGeth(t, "osaka is not supported in op-geth")

op-devstack/sysgo/deployer.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ func WithKarstAtOffset(offset *uint64) DeployerOption {
6868
}
6969
}
7070

71+
func WithKarstAtGenesis(p devtest.T, _ devkeys.Keys, builder intentbuilder.Builder) {
72+
for _, l2Cfg := range builder.L2s() {
73+
l2Cfg.WithForkAtGenesis(opforks.Karst)
74+
}
75+
}
76+
7177
func WithJovianAtGenesis(p devtest.T, _ devkeys.Keys, builder intentbuilder.Builder) {
7278
for _, l2Cfg := range builder.L2s() {
7379
l2Cfg.WithForkAtGenesis(opforks.Jovian)

0 commit comments

Comments
 (0)