Skip to content

Commit d088b4e

Browse files
committed
t9n: refactor instrinsic and floordatagas checks
1 parent 4ea656a commit d088b4e

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

cmd/evm/internal/t8ntool/transaction.go

+23-6
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,35 @@ func Transaction(ctx *cli.Context) error {
133133
r.Address = sender
134134
}
135135
// Check intrinsic gas
136-
if gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil,
137-
chainConfig.IsHomestead(new(big.Int)), chainConfig.IsIstanbul(new(big.Int)), chainConfig.IsShanghai(new(big.Int), 0)); err != nil {
136+
rules := chainConfig.Rules(common.Big0, true, 0)
137+
gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil, rules.IsHomestead, rules.IsIstanbul, rules.IsShanghai)
138+
if err != nil {
138139
r.Error = err
139140
results = append(results, r)
140141
continue
141-
} else {
142-
r.IntrinsicGas = gas
143-
if tx.Gas() < gas {
144-
r.Error = fmt.Errorf("%w: have %d, want %d", core.ErrIntrinsicGas, tx.Gas(), gas)
142+
}
143+
r.IntrinsicGas = gas
144+
if tx.Gas() < gas {
145+
r.Error = fmt.Errorf("%w: have %d, want %d", core.ErrIntrinsicGas, tx.Gas(), gas)
146+
results = append(results, r)
147+
continue
148+
}
149+
// For Prague txs, validate the floor data gas.
150+
if rules.IsPrague {
151+
floorDataGas, err := core.FloorDataGas(tx.Data())
152+
if err != nil {
153+
r.Error = err
154+
results = append(results, r)
155+
continue
156+
}
157+
<<<<<<< Updated upstream
158+
=======
159+
if tx.Gas() < floorDataGas {
160+
r.Error = fmt.Errorf("%w: have %d, want %d", core.ErrFloorDataGas, tx.Gas(), floorDataGas)
145161
results = append(results, r)
146162
continue
147163
}
164+
>>>>>>> Stashed changes
148165
}
149166
// Validate <256bit fields
150167
switch {

0 commit comments

Comments
 (0)