diff --git a/accounts/abi/bind/bind_test.go b/accounts/abi/bind/bind_test.go index a390a3c47c..c6cb6a1ee9 100644 --- a/accounts/abi/bind/bind_test.go +++ b/accounts/abi/bind/bind_test.go @@ -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 { diff --git a/eth/catalyst/api_test.go b/eth/catalyst/api_test.go index c3116cb4b6..cdeced9654 100644 --- a/eth/catalyst/api_test.go +++ b/eth/catalyst/api_test.go @@ -455,6 +455,8 @@ func startEthService(t *testing.T, genesis *core.Genesis, blocks []*types.Block) mcfg := miner.DefaultConfig mcfg.PendingFeeRecipient = testAddr ethcfg := ðconfig.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) diff --git a/ethclient/simulated/backend.go b/ethclient/simulated/backend.go index 6e07aa68d0..0fd3675edd 100644 --- a/ethclient/simulated/backend.go +++ b/ethclient/simulated/backend.go @@ -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 diff --git a/ethclient/simulated/options.go b/ethclient/simulated/options.go index 40bcb37bd1..a0689e437f 100644 --- a/ethclient/simulated/options.go +++ b/ethclient/simulated/options.go @@ -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 } } diff --git a/miner/miner.go b/miner/miner.go index 295ddb0dbd..8790a5c522 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -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) diff --git a/miner/payload_building_test.go b/miner/payload_building_test.go index aad87627e6..6b65a8e7a5 100644 --- a/miner/payload_building_test.go +++ b/miner/payload_building_test.go @@ -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, } ) diff --git a/miner/worker.go b/miner/worker.go index 8d08d65662..d2b9d35eee 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -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) }