mirror of https://github.com/poanetwork/quorum.git
Merge pull request #680 from jpmorganchase/fix/raft-calcgaslimit
raft: pass gas floor and gas ceil to calcGasLimit when minting block
This commit is contained in:
commit
1c07c0c8c4
|
@ -557,3 +557,7 @@ func (s *Ethereum) Stop() error {
|
||||||
close(s.shutdownChan)
|
close(s.shutdownChan)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Ethereum) CalcGasLimit(block *types.Block) uint64 {
|
||||||
|
return core.CalcGasLimit(block, s.config.MinerGasFloor, s.config.MinerGasCeil)
|
||||||
|
}
|
||||||
|
|
|
@ -49,8 +49,8 @@ var DefaultConfig = Config{
|
||||||
DatabaseCache: 768,
|
DatabaseCache: 768,
|
||||||
TrieCache: 256,
|
TrieCache: 256,
|
||||||
TrieTimeout: 60 * time.Minute,
|
TrieTimeout: 60 * time.Minute,
|
||||||
MinerGasFloor: 8000000,
|
MinerGasFloor: params.MinGasLimit,
|
||||||
MinerGasCeil: 8000000,
|
MinerGasCeil: params.GenesisGasLimit,
|
||||||
MinerGasPrice: big.NewInt(params.GWei),
|
MinerGasPrice: big.NewInt(params.GWei),
|
||||||
MinerRecommit: 3 * time.Second,
|
MinerRecommit: 3 * time.Second,
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/eth"
|
"github.com/ethereum/go-ethereum/eth"
|
||||||
|
@ -31,21 +33,23 @@ type RaftService struct {
|
||||||
startPeers []*enode.Node
|
startPeers []*enode.Node
|
||||||
|
|
||||||
// we need an event mux to instantiate the blockchain
|
// we need an event mux to instantiate the blockchain
|
||||||
eventMux *event.TypeMux
|
eventMux *event.TypeMux
|
||||||
minter *minter
|
minter *minter
|
||||||
nodeKey *ecdsa.PrivateKey
|
nodeKey *ecdsa.PrivateKey
|
||||||
|
calcGasLimitFunc func(block *types.Block) uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(ctx *node.ServiceContext, chainConfig *params.ChainConfig, raftId, raftPort uint16, joinExisting bool, blockTime time.Duration, e *eth.Ethereum, startPeers []*enode.Node, datadir string) (*RaftService, error) {
|
func New(ctx *node.ServiceContext, chainConfig *params.ChainConfig, raftId, raftPort uint16, joinExisting bool, blockTime time.Duration, e *eth.Ethereum, startPeers []*enode.Node, datadir string) (*RaftService, error) {
|
||||||
service := &RaftService{
|
service := &RaftService{
|
||||||
eventMux: ctx.EventMux,
|
eventMux: ctx.EventMux,
|
||||||
chainDb: e.ChainDb(),
|
chainDb: e.ChainDb(),
|
||||||
blockchain: e.BlockChain(),
|
blockchain: e.BlockChain(),
|
||||||
txPool: e.TxPool(),
|
txPool: e.TxPool(),
|
||||||
accountManager: e.AccountManager(),
|
accountManager: e.AccountManager(),
|
||||||
downloader: e.Downloader(),
|
downloader: e.Downloader(),
|
||||||
startPeers: startPeers,
|
startPeers: startPeers,
|
||||||
nodeKey: ctx.NodeKey(),
|
nodeKey: ctx.NodeKey(),
|
||||||
|
calcGasLimitFunc: e.CalcGasLimit,
|
||||||
}
|
}
|
||||||
|
|
||||||
service.minter = newMinter(chainConfig, service, blockTime)
|
service.minter = newMinter(chainConfig, service, blockTime)
|
||||||
|
|
|
@ -262,7 +262,7 @@ func (minter *minter) createWork() *work {
|
||||||
ParentHash: parent.Hash(),
|
ParentHash: parent.Hash(),
|
||||||
Number: parentNumber.Add(parentNumber, common.Big1),
|
Number: parentNumber.Add(parentNumber, common.Big1),
|
||||||
Difficulty: ethash.CalcDifficulty(minter.config, uint64(tstamp), parent.Header()),
|
Difficulty: ethash.CalcDifficulty(minter.config, uint64(tstamp), parent.Header()),
|
||||||
GasLimit: core.CalcGasLimit(parent, parent.GasLimit(), parent.GasLimit()),
|
GasLimit: minter.eth.calcGasLimitFunc(parent),
|
||||||
GasUsed: 0,
|
GasUsed: 0,
|
||||||
Coinbase: minter.coinbase,
|
Coinbase: minter.coinbase,
|
||||||
Time: big.NewInt(tstamp),
|
Time: big.NewInt(tstamp),
|
||||||
|
|
Loading…
Reference in New Issue