Skip to content

Commit b6256ef

Browse files
committed
core: move tx gas limit check to state transition
1 parent aa182ba commit b6256ef

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

cmd/evm/internal/t8ntool/transaction.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ func Transaction(ctx *cli.Context) error {
183183
if chainConfig.IsShanghai(new(big.Int), 0) && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize {
184184
r.Error = errors.New("max initcode size exceeded")
185185
}
186+
if chainConfig.IsOsaka(new(big.Int), 0) && tx.Gas() > params.MaxTxGas {
187+
r.Error = errors.New("gas limit exceeds maximum")
188+
}
186189
results = append(results, r)
187190
}
188191
out, err := json.MarshalIndent(results, "", " ")

core/block_validator.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,8 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
8282
}
8383

8484
// Blob transactions may be present after the Cancun fork.
85-
var (
86-
blobs int
87-
isOsaka = v.config.IsOsaka(block.Number(), block.Time())
88-
)
85+
var blobs int
8986
for i, tx := range block.Transactions() {
90-
if isOsaka && tx.Gas() > params.MaxTxGas {
91-
return fmt.Errorf("%w (cap: %d, tx: %d)", ErrGasLimitTooHigh, params.MaxTxGas, tx.Gas())
92-
}
93-
9487
// Count the number of blobs to validate against the header's blobGasUsed
9588
blobs += len(tx.BlobHashes())
9689

core/state_transition.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,10 @@ func (st *stateTransition) preCheck() error {
394394
return fmt.Errorf("%w (sender %v)", ErrEmptyAuthList, msg.From)
395395
}
396396
}
397+
// Verify tx gas limit does not exceed EIP-7825 cap.
398+
if st.evm.ChainConfig().IsOsaka(st.evm.Context.BlockNumber, st.evm.Context.Time) && msg.GasLimit > params.MaxTxGas {
399+
return fmt.Errorf("%w (cap: %d, tx: %d)", ErrGasLimitTooHigh, params.MaxTxGas, msg.GasLimit)
400+
}
397401
return st.buyGas()
398402
}
399403

0 commit comments

Comments
 (0)