mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
save
This commit is contained in:
parent
86c3ffd47c
commit
7b825fe871
4 changed files with 14 additions and 7 deletions
|
|
@ -49,7 +49,10 @@ func startSimulatedBeaconEthService(t *testing.T, genesis *core.Genesis, period
|
||||||
t.Fatal("can't create node:", err)
|
t.Fatal("can't create node:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ethcfg := ðconfig.Config{Genesis: genesis, SyncMode: downloader.FullSync, TrieTimeout: time.Minute, TrieDirtyCache: 256, TrieCleanCache: 256, Miner: miner.DefaultConfig}
|
m := miner.DefaultConfig
|
||||||
|
m.GasCeil = new(uint64)
|
||||||
|
// *m.GasCeil = 30_000_000
|
||||||
|
ethcfg := ðconfig.Config{Genesis: genesis, SyncMode: downloader.FullSync, TrieTimeout: time.Minute, TrieDirtyCache: 256, TrieCleanCache: 256, Miner: m}
|
||||||
ethservice, err := eth.New(n, ethcfg)
|
ethservice, err := eth.New(n, ethcfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("can't create eth service:", err)
|
t.Fatal("can't create eth service:", err)
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/eth"
|
"github.com/ethereum/go-ethereum/eth"
|
||||||
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
||||||
|
"github.com/ethereum/go-ethereum/miner"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
|
@ -219,7 +220,7 @@ func newTestBackend(t *testing.T) (*node.Node, []*types.Block) {
|
||||||
t.Fatalf("can't create new node: %v", err)
|
t.Fatalf("can't create new node: %v", err)
|
||||||
}
|
}
|
||||||
// Create Ethereum Service
|
// Create Ethereum Service
|
||||||
config := ðconfig.Config{Genesis: genesis, RPCGasCap: 1000000}
|
config := ðconfig.Config{Genesis: genesis, RPCGasCap: 1000000, Miner: miner.Config{GasCeil: new(uint64)}}
|
||||||
ethservice, err := eth.New(n, config)
|
ethservice, err := eth.New(n, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("can't create new ethereum service: %v", err)
|
t.Fatalf("can't create new ethereum service: %v", err)
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,7 @@ func createMiner(t *testing.T) *Miner {
|
||||||
|
|
||||||
// Create Miner
|
// Create Miner
|
||||||
backend := NewMockBackend(bc, txpool)
|
backend := NewMockBackend(bc, txpool)
|
||||||
|
config.GasCeil = new(uint64)
|
||||||
miner := New(backend, config, engine)
|
miner := New(backend, config, engine)
|
||||||
return miner
|
return miner
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -173,21 +173,23 @@ func (miner *Miner) prepareWork(genParams *generateParams, witness bool) (*envir
|
||||||
timestamp = parent.Time + 1
|
timestamp = parent.Time + 1
|
||||||
}
|
}
|
||||||
useEip7783 := miner.config.GasCeil == nil
|
useEip7783 := miner.config.GasCeil == nil
|
||||||
var gasLimit uint64
|
var gasCeil uint64
|
||||||
|
|
||||||
if useEip7783 {
|
if useEip7783 {
|
||||||
parentNumber := parent.Number
|
parentNumber := parent.Number
|
||||||
if parentNumber == nil {
|
if parentNumber == nil {
|
||||||
parentNumber = common.Big0
|
parentNumber = common.Big0
|
||||||
}
|
}
|
||||||
gasLimit = eip7783.CalcGasLimitEIP7783(parentNumber, miner.config.EIP7783BlockNumStart, miner.config.EIP7783InitialGasLimit, miner.config.Eip7783IncreaseRate, miner.config.EIP7783GasLimitCap)
|
gasCeil = eip7783.CalcGasLimitEIP7783(new(big.Int).Add(parentNumber, common.Big1), miner.config.EIP7783BlockNumStart, miner.config.EIP7783InitialGasLimit, miner.config.Eip7783IncreaseRate, miner.config.EIP7783GasLimitCap)
|
||||||
} else {
|
} else {
|
||||||
gasLimit = core.CalcGasLimit(parent.GasLimit, *miner.config.GasCeil)
|
gasCeil = *miner.config.GasCeil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct the sealing block header.
|
// Construct the sealing block header.
|
||||||
header := &types.Header{
|
header := &types.Header{
|
||||||
ParentHash: parent.Hash(),
|
ParentHash: parent.Hash(),
|
||||||
Number: new(big.Int).Add(parent.Number, common.Big1),
|
Number: new(big.Int).Add(parent.Number, common.Big1),
|
||||||
GasLimit: gasLimit,
|
GasLimit: core.CalcGasLimit(parent.GasLimit, gasCeil),
|
||||||
Time: timestamp,
|
Time: timestamp,
|
||||||
Coinbase: genParams.coinbase,
|
Coinbase: genParams.coinbase,
|
||||||
}
|
}
|
||||||
|
|
@ -204,7 +206,7 @@ func (miner *Miner) prepareWork(genParams *generateParams, witness bool) (*envir
|
||||||
header.BaseFee = eip1559.CalcBaseFee(miner.chainConfig, parent)
|
header.BaseFee = eip1559.CalcBaseFee(miner.chainConfig, parent)
|
||||||
if !miner.chainConfig.IsLondon(parent.Number) {
|
if !miner.chainConfig.IsLondon(parent.Number) {
|
||||||
parentGasLimit := parent.GasLimit * miner.chainConfig.ElasticityMultiplier()
|
parentGasLimit := parent.GasLimit * miner.chainConfig.ElasticityMultiplier()
|
||||||
header.GasLimit = core.CalcGasLimit(parentGasLimit, gasLimit)
|
header.GasLimit = core.CalcGasLimit(parentGasLimit, gasCeil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Run the consensus preparation with the default or customized consensus engine.
|
// Run the consensus preparation with the default or customized consensus engine.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue