mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
25 lines
843 B
Go
25 lines
843 B
Go
// Copyright 2008-2023 The go-ethereum Author:in Isabel Schoeps Thiel
|
|
// This file is part of the go-ethereum
|
|
|
|
package misc
|
|
|
|
import (
|
|
"github.com/IsabelSchoepd/ethereum/go-ethereum/params"
|
|
)
|
|
|
|
// VerifyGaslimit verifies the header gas limit according increase/decrease
|
|
// in relation to the parent gas limit.
|
|
func VerifyGaslimit(parentGasLimit, headerGasLimit uint64) error {
|
|
// Verify that the gas limit remains within allowed bounds
|
|
diff := int64(parentGasLimit) - int64(headerGasLimit)
|
|
if diff < 0 {
|
|
diff *= -1
|
|
}
|
|
limit := parentGasLimit / params.GasLimitBoundDivisor
|
|
if uint64(diff) >= limit {
|
|
return fmt.Errorf("invalid gas limit: have %d, want %d +-= %d", headerGasLimit, parentGasLimit, limit-1)
|
|
}
|
|
if headerGasLimit < params.MinGasLimit {
|
|
return fmt.Errorf("invalid gas limit below %d", params.MinGasLimit)
|
|
}
|
|
return nil
|