@@ -31,10 +31,13 @@ import (
3131 "github.com/ethereum/go-ethereum/consensus"
3232 "github.com/ethereum/go-ethereum/consensus/clique"
3333 "github.com/ethereum/go-ethereum/consensus/ethash"
34+ "github.com/ethereum/go-ethereum/consensus/istanbul"
35+ istanbulBackend "github.com/ethereum/go-ethereum/consensus/istanbul/backend"
3436 "github.com/ethereum/go-ethereum/core"
3537 "github.com/ethereum/go-ethereum/core/bloombits"
3638 "github.com/ethereum/go-ethereum/core/types"
3739 "github.com/ethereum/go-ethereum/core/vm"
40+ "github.com/ethereum/go-ethereum/crypto"
3841 "github.com/ethereum/go-ethereum/eth/downloader"
3942 "github.com/ethereum/go-ethereum/eth/filters"
4043 "github.com/ethereum/go-ethereum/eth/gasprice"
@@ -133,6 +136,11 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
133136 bloomIndexer : NewBloomIndexer (chainDb , params .BloomBitsBlocks ),
134137 }
135138
139+ // force to set the istanbul etherbase to node key address
140+ if chainConfig .Istanbul != nil {
141+ eth .etherbase = crypto .PubkeyToAddress (ctx .NodeKey ().PublicKey )
142+ }
143+
136144 log .Info ("Initialising Ethereum protocol" , "versions" , eth .engine .Protocol ().Versions , "network" , config .NetworkId )
137145
138146 if ! config .SkipBcVersionCheck {
@@ -212,6 +220,15 @@ func CreateConsensusEngine(ctx *node.ServiceContext, config *Config, chainConfig
212220 if chainConfig .Clique != nil {
213221 return clique .New (chainConfig .Clique , db )
214222 }
223+ // If Istanbul is requested, set it up
224+ if chainConfig .Istanbul != nil {
225+ if chainConfig .Istanbul .Epoch != 0 {
226+ config .Istanbul .Epoch = chainConfig .Istanbul .Epoch
227+ }
228+ config .Istanbul .ProposerPolicy = istanbul .ProposerPolicy (chainConfig .Istanbul .ProposerPolicy )
229+ return istanbulBackend .New (& config .Istanbul , ctx .NodeKey (), db )
230+ }
231+
215232 // Otherwise assume proof-of-work
216233 switch {
217234 case config .PowFake :
@@ -311,6 +328,10 @@ func (s *Ethereum) Etherbase() (eb common.Address, err error) {
311328// set in js console via admin interface or wrapper from cli flags
312329func (self * Ethereum ) SetEtherbase (etherbase common.Address ) {
313330 self .lock .Lock ()
331+ if _ , ok := self .engine .(consensus.Istanbul ); ok {
332+ log .Error ("Cannot set etherbase in Istanbul consensus" )
333+ return
334+ }
314335 self .etherbase = etherbase
315336 self .lock .Unlock ()
316337
0 commit comments