diff --git a/consensus/vbft/service.go b/consensus/vbft/service.go index ae947404..3124198b 100644 --- a/consensus/vbft/service.go +++ b/consensus/vbft/service.go @@ -2156,7 +2156,7 @@ func (self *Server) checkNeedUpdateChainConfig(blockNum uint32) bool { func (self *Server) checkUpdateChainConfig(blkNum uint32) bool { force, err := isUpdate(self.blockPool.getExecWriteSet(blkNum-1), self.config.View) if err != nil { - log.Errorf("checkUpdateChainConfig err:%s", err) + log.Infof("checkUpdateChainConfig err:%s", err) return false } log.Debugf("checkUpdateChainConfig force: %v", force) @@ -2207,6 +2207,11 @@ func (self *Server) makeProposal(blkNum uint32, forEmpty bool) error { if err != nil { return fmt.Errorf("getChainConfig failed:%s", err) } + if chainconfig == nil { + log.Errorf("chain config not found in DB, reusing last config") + cfg2 := *self.config // copy current config + chainconfig = &cfg2 + } //add transaction invoke governance native commit_pos contract if self.checkNeedUpdateChainConfig(blkNum) { tx, err := self.creategovernaceTransaction(blkNum) diff --git a/consensus/vbft/utils.go b/consensus/vbft/utils.go index 8a837af1..a3c3b4f5 100644 --- a/consensus/vbft/utils.go +++ b/consensus/vbft/utils.go @@ -270,6 +270,9 @@ func GetGovernanceView(memdb *overlaydb.MemDB) (*gov.GovernanceView, error) { func getChainConfig(memdb *overlaydb.MemDB, blkNum uint32) (*vconfig.ChainConfig, error) { config, err := GetVbftConfigInfo(memdb) + if err == scommon.ErrNotFound { + return nil, nil + } if err != nil { return nil, fmt.Errorf("failed to get chainconfig from leveldb: %s", err) } diff --git a/go.sum b/go.sum index 6af9c6e4..07fa5e59 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,7 @@ github.com/JohnCGriffin/overflow v0.0.0-20170615021017-4d914c927216/go.mod h1:X0 github.com/Workiva/go-datastructures v1.0.50 h1:slDmfW6KCHcC7U+LP3DDBbm4fqTwZGn1beOFPfGaLvo= github.com/Workiva/go-datastructures v1.0.50/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= +github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= @@ -49,6 +50,7 @@ github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c/go.mod h1:lADxMC39cJ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/itchyny/base58-go v0.0.5 h1:uv3ieMgCtuE9HtN0Gux375+GOApFnifLkyvSseHBaH0= github.com/itchyny/base58-go v0.0.5/go.mod h1:SrMWPE3DFuJJp1M/RUhu4fccp/y9AlB8AL3o3duPToU= +github.com/itchyny/base58-go v0.1.0 h1:zF5spLDo956exUAD17o+7GamZTRkXOZlqJjRciZwd1I= github.com/itchyny/base58-go v0.1.0/go.mod h1:SrMWPE3DFuJJp1M/RUhu4fccp/y9AlB8AL3o3duPToU= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= @@ -63,11 +65,14 @@ github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/ontio/ontology-crypto v1.0.5 h1:VYIEL9yF1d8vWxgLedqoQXKdyw2oY46NliGCQn1IKDM= github.com/ontio/ontology-crypto v1.0.5/go.mod h1:ebrQJ4/VS2F6pwHGktHDYtY/7Y2ca/ogfnlYABrQI2c= +github.com/ontio/ontology-crypto v1.0.8 h1:xft6K8I43vkl60kywT/9GZlUjdacaL7OF6MFFb32kE4= github.com/ontio/ontology-crypto v1.0.8/go.mod h1:RW/HSgBTd6Qcuhr/C4luOftN+LNl5oZTQzAywHTsmtY= github.com/ontio/ontology-eventbus v0.9.1 h1:nt3AXWx3gOyqtLiU4EwI92Yc4ik/pWHu9xRK15uHSOs= github.com/ontio/ontology-eventbus v0.9.1/go.mod h1:hCQIlbdPckcfykMeVUdWrqHZ8d30TBdmLfXCVWGkYhM= github.com/ontio/wagon v0.3.1-0.20191012103353-ef8d35ecd300 h1:E+8mJjO4xOPGlbSoJiElZ6yYks/KdPe4j9gXYUMpbdA= github.com/ontio/wagon v0.3.1-0.20191012103353-ef8d35ecd300/go.mod h1:zHOMvbitcZek8oshsMO5VpyBjWjV9X8cn8WTZwdebpM= +github.com/ontio/wagon v0.3.1-0.20191223040208-db6073fb2776 h1:cfHznrh9WsSH7F253Lr6TkYa38p/3Cgk0PJS7238cRQ= +github.com/ontio/wagon v0.3.1-0.20191223040208-db6073fb2776/go.mod h1:zHOMvbitcZek8oshsMO5VpyBjWjV9X8cn8WTZwdebpM= github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6 h1:lNCW6THrCKBiJBpz8kbVGjC7MgdCGKwuvBgc7LoD6sw= github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=