mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
core: move tx gas limit check to state transition
This commit is contained in:
parent
aa182ba69a
commit
b6256ef33e
3 changed files with 8 additions and 8 deletions
|
|
@ -183,6 +183,9 @@ func Transaction(ctx *cli.Context) error {
|
|||
if chainConfig.IsShanghai(new(big.Int), 0) && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize {
|
||||
r.Error = errors.New("max initcode size exceeded")
|
||||
}
|
||||
if chainConfig.IsOsaka(new(big.Int), 0) && tx.Gas() > params.MaxTxGas {
|
||||
r.Error = errors.New("gas limit exceeds maximum")
|
||||
}
|
||||
results = append(results, r)
|
||||
}
|
||||
out, err := json.MarshalIndent(results, "", " ")
|
||||
|
|
|
|||
|
|
@ -82,15 +82,8 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
|
|||
}
|
||||
|
||||
// Blob transactions may be present after the Cancun fork.
|
||||
var (
|
||||
blobs int
|
||||
isOsaka = v.config.IsOsaka(block.Number(), block.Time())
|
||||
)
|
||||
var blobs int
|
||||
for i, tx := range block.Transactions() {
|
||||
if isOsaka && tx.Gas() > params.MaxTxGas {
|
||||
return fmt.Errorf("%w (cap: %d, tx: %d)", ErrGasLimitTooHigh, params.MaxTxGas, tx.Gas())
|
||||
}
|
||||
|
||||
// Count the number of blobs to validate against the header's blobGasUsed
|
||||
blobs += len(tx.BlobHashes())
|
||||
|
||||
|
|
|
|||
|
|
@ -394,6 +394,10 @@ func (st *stateTransition) preCheck() error {
|
|||
return fmt.Errorf("%w (sender %v)", ErrEmptyAuthList, msg.From)
|
||||
}
|
||||
}
|
||||
// Verify tx gas limit does not exceed EIP-7825 cap.
|
||||
if st.evm.ChainConfig().IsOsaka(st.evm.Context.BlockNumber, st.evm.Context.Time) && msg.GasLimit > params.MaxTxGas {
|
||||
return fmt.Errorf("%w (cap: %d, tx: %d)", ErrGasLimitTooHigh, params.MaxTxGas, msg.GasLimit)
|
||||
}
|
||||
return st.buyGas()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue