This commit is contained in:
Giulio 2024-10-10 23:21:24 +02:00
parent 0e200edf9b
commit 86c3ffd47c
7 changed files with 23 additions and 11 deletions

View file

@ -1818,7 +1818,7 @@ var bindTests = []struct {
var (
key, _ = crypto.GenerateKey()
user, _ = bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
sim = backends.NewSimulatedBackend(types.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, ethconfig.Defaults.Miner.GasCeil)
sim = backends.NewSimulatedBackend(types.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, ethconfig.Defaults.Miner.EIP7783InitialGasLimit)
)
defer sim.Close()
@ -1889,7 +1889,7 @@ var bindTests = []struct {
var (
key, _ = crypto.GenerateKey()
user, _ = bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
sim = backends.NewSimulatedBackend(types.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, ethconfig.Defaults.Miner.GasCeil)
sim = backends.NewSimulatedBackend(types.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, ethconfig.Defaults.Miner.EIP7783InitialGasLimit)
)
defer sim.Close()
@ -1942,7 +1942,7 @@ var bindTests = []struct {
var (
key, _ = crypto.GenerateKey()
user, _ = bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
sim = backends.NewSimulatedBackend(types.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, ethconfig.Defaults.Miner.GasCeil)
sim = backends.NewSimulatedBackend(types.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, ethconfig.Defaults.Miner.EIP7783InitialGasLimit)
)
defer sim.Close()
@ -1991,7 +1991,7 @@ var bindTests = []struct {
var (
key, _ = crypto.GenerateKey()
user, _ = bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
sim = backends.NewSimulatedBackend(types.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, ethconfig.Defaults.Miner.GasCeil)
sim = backends.NewSimulatedBackend(types.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, ethconfig.Defaults.Miner.EIP7783InitialGasLimit)
)
defer sim.Close()
@ -2032,7 +2032,7 @@ var bindTests = []struct {
var (
key, _ = crypto.GenerateKey()
user, _ = bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
sim = backends.NewSimulatedBackend(types.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, ethconfig.Defaults.Miner.GasCeil)
sim = backends.NewSimulatedBackend(types.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, ethconfig.Defaults.Miner.EIP7783InitialGasLimit)
)
_, tx, _, err := DeployRangeKeyword(user, sim)
if err != nil {

View file

@ -455,6 +455,8 @@ func startEthService(t *testing.T, genesis *core.Genesis, blocks []*types.Block)
mcfg := miner.DefaultConfig
mcfg.PendingFeeRecipient = testAddr
ethcfg := &ethconfig.Config{Genesis: genesis, SyncMode: downloader.FullSync, TrieTimeout: time.Minute, TrieDirtyCache: 256, TrieCleanCache: 256, Miner: mcfg}
ethcfg.Miner.GasCeil = new(uint64)
*ethcfg.Miner.GasCeil = 30_000_000
ethservice, err := eth.New(n, ethcfg)
if err != nil {
t.Fatal("can't create eth service:", err)

View file

@ -82,7 +82,7 @@ func NewBackend(alloc types.GenesisAlloc, options ...func(nodeConf *node.Config,
ethConf := ethconfig.Defaults
ethConf.Genesis = &core.Genesis{
Config: params.AllDevChainProtocolChanges,
GasLimit: ethconfig.Defaults.Miner.GasCeil,
GasLimit: ethconfig.Defaults.Miner.EIP7783InitialGasLimit,
Alloc: alloc,
}
ethConf.SyncMode = downloader.FullSync

View file

@ -28,7 +28,8 @@ import (
func WithBlockGasLimit(gaslimit uint64) func(nodeConf *node.Config, ethConf *ethconfig.Config) {
return func(nodeConf *node.Config, ethConf *ethconfig.Config) {
ethConf.Genesis.GasLimit = gaslimit
ethConf.Miner.GasCeil = gaslimit
ethConf.Miner.GasCeil = new(uint64)
*ethConf.Miner.GasCeil = gaslimit
}
}

View file

@ -19,6 +19,7 @@ package miner
import (
"fmt"
"math"
"math/big"
"sync"
"time"
@ -59,7 +60,11 @@ type Config struct {
// DefaultConfig contains default settings for miner.
var DefaultConfig = Config{
//GasCeil: 30_000_000,
GasPrice: big.NewInt(params.GWei / 1000),
GasPrice: big.NewInt(params.GWei / 1000),
EIP7783InitialGasLimit: 30_000_000,
Eip7783IncreaseRate: 6,
EIP7783GasLimitCap: 60_000_000,
EIP7783BlockNumStart: big.NewInt(math.MaxInt64),
// The default recommit time is chosen as two seconds since
// consensus-layer usually will wait a half slot of time(6s)

View file

@ -52,7 +52,7 @@ var (
testUserKey, _ = crypto.GenerateKey()
testUserAddress = crypto.PubkeyToAddress(testUserKey.PublicKey)
genesisGasLimit = params.GenesisGasLimit
// Test transactions
pendingTxs []*types.Transaction
newTxs []*types.Transaction
@ -60,7 +60,7 @@ var (
testConfig = Config{
PendingFeeRecipient: testBankAddress,
Recommit: time.Second,
GasCeil: params.GenesisGasLimit,
GasCeil: &genesisGasLimit,
}
)

View file

@ -175,7 +175,11 @@ func (miner *Miner) prepareWork(genParams *generateParams, witness bool) (*envir
useEip7783 := miner.config.GasCeil == nil
var gasLimit uint64
if useEip7783 {
gasLimit = eip7783.CalcGasLimitEIP7783(parent.Number, miner.config.EIP7783BlockNumStart, miner.config.EIP7783InitialGasLimit, miner.config.Eip7783IncreaseRate, miner.config.EIP7783GasLimitCap)
parentNumber := parent.Number
if parentNumber == nil {
parentNumber = common.Big0
}
gasLimit = eip7783.CalcGasLimitEIP7783(parentNumber, miner.config.EIP7783BlockNumStart, miner.config.EIP7783InitialGasLimit, miner.config.Eip7783IncreaseRate, miner.config.EIP7783GasLimitCap)
} else {
gasLimit = core.CalcGasLimit(parent.GasLimit, *miner.config.GasCeil)
}