diff options
author | Péter Szilágyi <peterke@gmail.com> | 2018-08-29 17:21:12 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-08-29 17:40:12 +0800 |
commit | e8f229b82ef99213f8f84b8a71f752b236024494 (patch) | |
tree | 62f4d24ddfcb9fba0573531995739bcfdbf8b143 /miner | |
parent | c1c003e4ff36c22d67662ca661fc78cde850d401 (diff) | |
download | dexon-e8f229b82ef99213f8f84b8a71f752b236024494.tar dexon-e8f229b82ef99213f8f84b8a71f752b236024494.tar.gz dexon-e8f229b82ef99213f8f84b8a71f752b236024494.tar.bz2 dexon-e8f229b82ef99213f8f84b8a71f752b236024494.tar.lz dexon-e8f229b82ef99213f8f84b8a71f752b236024494.tar.xz dexon-e8f229b82ef99213f8f84b8a71f752b236024494.tar.zst dexon-e8f229b82ef99213f8f84b8a71f752b236024494.zip |
cmd, core, eth, miner, params: configurable gas floor and ceil
Diffstat (limited to 'miner')
-rw-r--r-- | miner/miner.go | 4 | ||||
-rw-r--r-- | miner/stress_clique.go | 2 | ||||
-rw-r--r-- | miner/stress_ethash.go | 2 | ||||
-rw-r--r-- | miner/worker.go | 9 | ||||
-rw-r--r-- | miner/worker_test.go | 2 |
5 files changed, 14 insertions, 5 deletions
diff --git a/miner/miner.go b/miner/miner.go index c5a0c9d62..7f194db26 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -52,13 +52,13 @@ type Miner struct { shouldStart int32 // should start indicates whether we should start after sync } -func New(eth Backend, config *params.ChainConfig, mux *event.TypeMux, engine consensus.Engine, recommit time.Duration) *Miner { +func New(eth Backend, config *params.ChainConfig, mux *event.TypeMux, engine consensus.Engine, recommit time.Duration, gasFloor, gasCeil uint64) *Miner { miner := &Miner{ eth: eth, mux: mux, engine: engine, exitCh: make(chan struct{}), - worker: newWorker(config, engine, eth, mux, recommit), + worker: newWorker(config, engine, eth, mux, recommit, gasFloor, gasCeil), canStart: 1, } go miner.update() diff --git a/miner/stress_clique.go b/miner/stress_clique.go index 8545b9413..8961091d5 100644 --- a/miner/stress_clique.go +++ b/miner/stress_clique.go @@ -206,6 +206,8 @@ func makeSealer(genesis *core.Genesis, nodes []string) (*node.Node, error) { DatabaseHandles: 256, TxPool: core.DefaultTxPoolConfig, GPO: eth.DefaultConfig.GPO, + MinerGasFloor: genesis.GasLimit * 9 / 10, + MinerGasCeil: genesis.GasLimit * 11 / 10, MinerGasPrice: big.NewInt(1), MinerRecommit: time.Second, }) diff --git a/miner/stress_ethash.go b/miner/stress_ethash.go index 4ed8aeee4..5ed11d73a 100644 --- a/miner/stress_ethash.go +++ b/miner/stress_ethash.go @@ -186,6 +186,8 @@ func makeMiner(genesis *core.Genesis, nodes []string) (*node.Node, error) { TxPool: core.DefaultTxPoolConfig, GPO: eth.DefaultConfig.GPO, Ethash: eth.DefaultConfig.Ethash, + MinerGasFloor: genesis.GasLimit * 9 / 10, + MinerGasCeil: genesis.GasLimit * 11 / 10, MinerGasPrice: big.NewInt(1), MinerRecommit: time.Second, }) diff --git a/miner/worker.go b/miner/worker.go index ca68da6e9..5348cb3f1 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -127,6 +127,9 @@ type worker struct { eth Backend chain *core.BlockChain + gasFloor uint64 + gasCeil uint64 + // Subscriptions mux *event.TypeMux txsCh chan core.NewTxsEvent @@ -171,13 +174,15 @@ type worker struct { resubmitHook func(time.Duration, time.Duration) // Method to call upon updating resubmitting interval. } -func newWorker(config *params.ChainConfig, engine consensus.Engine, eth Backend, mux *event.TypeMux, recommit time.Duration) *worker { +func newWorker(config *params.ChainConfig, engine consensus.Engine, eth Backend, mux *event.TypeMux, recommit time.Duration, gasFloor, gasCeil uint64) *worker { worker := &worker{ config: config, engine: engine, eth: eth, mux: mux, chain: eth.BlockChain(), + gasFloor: gasFloor, + gasCeil: gasCeil, possibleUncles: make(map[common.Hash]*types.Block), unconfirmed: newUnconfirmedBlocks(eth.BlockChain(), miningLogAtDepth), pendingTasks: make(map[common.Hash]*task), @@ -807,7 +812,7 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool) { header := &types.Header{ ParentHash: parent.Hash(), Number: num.Add(num, common.Big1), - GasLimit: core.CalcGasLimit(parent), + GasLimit: core.CalcGasLimit(parent, w.gasFloor, w.gasCeil), Extra: w.extra, Time: big.NewInt(tstamp), } diff --git a/miner/worker_test.go b/miner/worker_test.go index 16708c18c..9f9a3b4a5 100644 --- a/miner/worker_test.go +++ b/miner/worker_test.go @@ -119,7 +119,7 @@ func (b *testWorkerBackend) PostChainEvents(events []interface{}) { func newTestWorker(t *testing.T, chainConfig *params.ChainConfig, engine consensus.Engine) (*worker, *testWorkerBackend) { backend := newTestWorkerBackend(t, chainConfig, engine) backend.txPool.AddLocals(pendingTxs) - w := newWorker(chainConfig, engine, backend, new(event.TypeMux), time.Second) + w := newWorker(chainConfig, engine, backend, new(event.TypeMux), time.Second, params.GenesisGasLimit, params.GenesisGasLimit) w.setEtherbase(testBankAddress) return w, backend } |