diff --git a/consensus/tendermint/adapter/store.go b/consensus/tendermint/adapter/store.go index 10da859734b7..7e136f59c76b 100644 --- a/consensus/tendermint/adapter/store.go +++ b/consensus/tendermint/adapter/store.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/log" ) @@ -16,13 +17,15 @@ type Store struct { chain *core.BlockChain verifyHeaderFunc func(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error makeBlock func(parentHash common.Hash, coinbase common.Address, timestamp uint64) (block *types.Block, err error) + mux *event.TypeMux } func NewStore( chain *core.BlockChain, verifyHeaderFunc func(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error, - makeBlock func(parentHash common.Hash, coinbase common.Address, timestamp uint64) (block *types.Block, err error)) *Store { - return &Store{chain: chain, verifyHeaderFunc: verifyHeaderFunc, makeBlock: makeBlock} + makeBlock func(parentHash common.Hash, coinbase common.Address, timestamp uint64) (block *types.Block, err error), + mux *event.TypeMux) *Store { + return &Store{chain: chain, verifyHeaderFunc: verifyHeaderFunc, makeBlock: makeBlock, mux: mux} } func (s *Store) Base() uint64 { @@ -71,6 +74,8 @@ func (s *Store) SaveBlock(block *types.FullBlock, commit *types.Commit) { if n == 0 || err != nil { log.Warn("SaveBlock", "n", n, "err", err) } + + s.mux.Post(core.NewMinedBlockEvent{Block: block.WithCommit(commit).Block}) } func (s *Store) ValidateBlock(state pbft.ChainState, block *types.FullBlock) (err error) { diff --git a/consensus/tendermint/gov/gov.go b/consensus/tendermint/gov/gov.go index b0adb51b3b8a..a89cc690887c 100644 --- a/consensus/tendermint/gov/gov.go +++ b/consensus/tendermint/gov/gov.go @@ -29,12 +29,14 @@ func (g *Governance) GetValidatorSets(height uint64) (*types.ValidatorSet, *type } // GetValidatorSet returns the validator set of a height + func (g *Governance) GetValidatorSet(height uint64, lastVals *types.ValidatorSet) *types.ValidatorSet { if height == 0 { return &types.ValidatorSet{} } idxInEpoch := (height - 1) % g.config.Epoch + if idxInEpoch != 0 && lastVals != nil { // use cached version if we do not have a validator change cvals := lastVals.Copy() diff --git a/consensus/tendermint/tendermint.go b/consensus/tendermint/tendermint.go index 32b6d7d5aca1..e8ae132c3eca 100644 --- a/consensus/tendermint/tendermint.go +++ b/consensus/tendermint/tendermint.go @@ -40,6 +40,7 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" @@ -131,7 +132,7 @@ func (c *Tendermint) P2pServer() *libp2p.Server { return c.p2pserver } -func (c *Tendermint) Init(chain *core.BlockChain, makeBlock func(parent common.Hash, coinbase common.Address, timestamp uint64) (*types.Block, error)) (err error) { +func (c *Tendermint) Init(chain *core.BlockChain, makeBlock func(parent common.Hash, coinbase common.Address, timestamp uint64) (*types.Block, error), mux *event.TypeMux) (err error) { // Outbound gossip message queue sendC := make(chan pbftconsensus.Message, 1000) @@ -144,7 +145,7 @@ func (c *Tendermint) Init(chain *core.BlockChain, makeBlock func(parent common.H c.rootCtx = rootCtx // datastore - store := adapter.NewStore(chain, c.VerifyHeader, makeBlock) + store := adapter.NewStore(chain, c.VerifyHeader, makeBlock, mux) // p2p key if TestMode { diff --git a/miner/worker.go b/miner/worker.go index 1efe242471f8..2793a24c0c57 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -370,7 +370,7 @@ func (w *worker) start() { if isTm { err := tm.Init(w.chain, func(parent common.Hash, coinbase common.Address, timestamp uint64) (*types.Block, error) { return w.getSealingBlock(parent, timestamp, coinbase, common.Hash{}) - }) + }, w.mux) if err != nil { log.Crit("tm.Init", "err", err) } diff --git a/params/bootnodes.go b/params/bootnodes.go index 5208c06944d3..278e7d48ffe7 100644 --- a/params/bootnodes.go +++ b/params/bootnodes.go @@ -83,7 +83,7 @@ var Web3QTestnetBootnodes = []string{ // TODO: to update var Web3QGalileoBootnodes = []string{ - "enode://1b9032f19ae39390e84718071ac8d560f5a11e1b8e02de4a40654a9d2950ae77b34a2ca90854413dfe5973c0040d0928a5cf27a46cd8cc1c6a8fbc1fb7d2825f@127.0.0.1:30303", + "enode://1284264b02b32fafd3448486926b372a225b35282a7e4175b57b5949ce1b3711e1b2db017156c19b3b9d141384fddf73dbf44746d49be59213d6275dc04b7c4f@127.0.0.1:30303", } var Web3QMainnetBootnodes = []string{