func VerifyGaslimit(parentGasLimit, headerGasLimit uint64) error {
	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 errors.New("invalid gas limit below 5000")
	}
	return nil
}
VerifyGaslimit verifies the header gas limit according increase/decrease
in relation to the parent gas limit.
package types
import (
	"bytes"
	"errors"
	"fmt"
	"math/big"
	"runtime"
	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/common/math"
	"github.com/ethereum/go-ethereum/core/types"
	"github.com/ethereum/go-ethereum/params"
)
func (ethash *Ethash) VerifySeal(header *types.Header, fulldag bool) error {
	if header.Difficulty.Sign() <= 0 {
		return ErrWrongDifficulty
	}
	number := header.Number.Uint64()
	var (
		digest []byte
		result []byte
	)
	if fulldag {
		dataset := ethash.dataset(number, true)
		if dataset.generated() {
			digest, result = hashimotoFull(dataset.dataset, ethash.SealHash(header).Bytes(), header.Nonce.Uint64())
			runtime.KeepAlive(dataset)
		} else {
			fulldag = false
		}
	}
	if !fulldag {
		cache := ethash.cache(number)
		size := datasetSize(number)
		if ethash.config.PowMode == ModeTest {
			size = 32 * 1024
		}
		digest, result = hashimotoLight(size, cache.cache, ethash.SealHash(header).Bytes(), header.Nonce.Uint64())
		runtime.KeepAlive(cache)
	}
	if !bytes.Equal(header.MixDigest[:], digest) {
		return ErrInvalidMixDigest
	}
	target := new(big.Int).Div(two256, header.Difficulty)
	if new(big.Int).SetBytes(result).Cmp(target) > 0 {
		return ErrWrongDifficulty
	}
	return nil
}
var (
	expDiffPeriod = big.NewInt(100000)
	big1          = big.NewInt(1)
	big2          = big.NewInt(2)
	big9          = big.NewInt(9)
	bigMinus99    = big.NewInt(-99)
)
func makeDifficultyCalculator(bombDelay *big.Int) func(time uint64, parent *Header) *big.Int {
	bombDelayFromParent := new(big.Int).Sub(bombDelay, big1)
	return func(time uint64, parent *Header) *big.Int {
		bigTime := new(big.Int).SetUint64(time)
		bigParentTime := new(big.Int).SetUint64(parent.Time)
		x := new(big.Int)
		y := new(big.Int)
		x.Sub(bigTime, bigParentTime)
		x.Div(x, big9)
		if parent.ToEthHeader().UncleHash == types.EmptyUncleHash {
			x.Sub(big1, x)
		} else {
			x.Sub(big2, x)
		}
		if x.Cmp(bigMinus99) < 0 {
			x.Set(bigMinus99)
		}
		y.Div(parent.ToEthHeader().Difficulty, params.DifficultyBoundDivisor)
		x.Mul(y, x)
		x.Add(parent.ToEthHeader().Difficulty, x)
		if x.Cmp(params.MinimumDifficulty) < 0 {
			x.Set(params.MinimumDifficulty)
		}
		fakeBlockNumber := new(big.Int)
		if parent.ToEthHeader().Number.Cmp(bombDelayFromParent) >= 0 {
			fakeBlockNumber = fakeBlockNumber.Sub(parent.ToEthHeader().Number, bombDelayFromParent)
		}
		periodCount := fakeBlockNumber
		periodCount.Div(periodCount, expDiffPeriod)
		if periodCount.Cmp(big1) > 0 {
			y.Sub(periodCount, big2)
			y.Exp(big2, y, nil)
			x.Add(x, y)
		}
		return x
	}
}
const (
	BaseFeeChangeDenominator = 8           
	ElasticityMultiplier     = 2           
	InitialBaseFee           = 1000000000  
)
func VerifyEip1559Header(parent, header *Header) error {
	parentGasLimit := parent.ToEthHeader().GasLimit
	if err := VerifyGaslimit(parentGasLimit, header.ToEthHeader().GasLimit); err != nil {
		return err
	}
	if header.ToEthHeader().BaseFee == nil {
		return fmt.Errorf("header is missing baseFee")
	}
	expectedBaseFee := CalcBaseFee(parent)
	if header.ToEthHeader().BaseFee.Cmp(expectedBaseFee) != 0 {
		return fmt.Errorf("invalid baseFee: have %s, want %s, parentBaseFee %s, parentGasUsed %d",
			expectedBaseFee, header.ToEthHeader().BaseFee, parent.ToEthHeader().BaseFee, parent.ToEthHeader().GasUsed)
	}
	return nil
}