From 8bb74d942697b2def8cde4e7ffa4dbb7b605214f Mon Sep 17 00:00:00 2001 From: lyd00 Date: Sun, 13 Jan 2019 12:07:01 +0800 Subject: [PATCH 1/3] Hotfix: repair additional list --- chain/cache/snapshot_additional_list.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/chain/cache/snapshot_additional_list.go b/chain/cache/snapshot_additional_list.go index 34ac720a7..c739e12bc 100644 --- a/chain/cache/snapshot_additional_list.go +++ b/chain/cache/snapshot_additional_list.go @@ -378,6 +378,7 @@ func (al *AdditionList) loadFromDb() error { var frags []*Fragment var list []*AdditionItem + var lastHeight uint64 for iter.Next() { value := iter.Value() frag := &Fragment{} @@ -387,9 +388,15 @@ func (al *AdditionList) loadFromDb() error { frag.TailHeight = GetFragTailHeightFromDbKey(iter.Key()) frag.HeadHeight = GetFragHeadHeightFromDbKey(iter.Key()) + if lastHeight > 0 && frag.TailHeight != lastHeight + 1 { + // log error, and need rebuild + al.log.Error(fmt.Sprintf("current lastHeight is %d, miss %d - %d", lastHeight, frag.TailHeight, frag.HeadHeight)) + break + } frags = append(frags, frag) list = append(list, frag.List...) + lastHeight = frag.HeadHeight } if err := iter.Error(); err != nil && err != leveldb.ErrNotFound { From 87213fe4fa9a61063a82da2ee3d50c99b542e6f4 Mon Sep 17 00:00:00 2001 From: viteshan Date: Sun, 13 Jan 2019 21:21:51 +0800 Subject: [PATCH 2/3] fix for panic --- producer/tools.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/producer/tools.go b/producer/tools.go index cf6f55680..45165e329 100644 --- a/producer/tools.go +++ b/producer/tools.go @@ -99,13 +99,13 @@ func (self *tools) generateAccounts(head *ledger.SnapshotBlock) (ledger.Snapshot if hashH != nil { err := self.pool.RollbackAccountTo(k, hashH.Hash, hashH.Height) if err != nil { - self.log.Error("account rollback err.", "addr", k, "accHash", hashH.Hash, "accHeight", hashH.Height, "err", err) + self.log.Error("account rollback err1.", "addr", k, "accHash", hashH.Hash, "accHeight", hashH.Height, "err", err) return nil, err } } else { err := self.pool.RollbackAccountTo(k, b.Hash, b.Height) if err != nil { - self.log.Error("account rollback err.", "addr", k, "accHash", hashH.Hash, "accHeight", hashH.Height, "err", err) + self.log.Error("account rollback err2.", "addr", k, "accHash", b.Hash, "accHeight", b.Height, "err", err) return nil, err } } From 676c9b8c82862d01ebc36bea593cf11d8e8a637d Mon Sep 17 00:00:00 2001 From: lyd00 Date: Sun, 13 Jan 2019 23:10:53 +0800 Subject: [PATCH 3/3] Fix the boundary bug of rollback --- chain/snapshot_chain.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chain/snapshot_chain.go b/chain/snapshot_chain.go index bcc53137e..f5e729086 100644 --- a/chain/snapshot_chain.go +++ b/chain/snapshot_chain.go @@ -403,7 +403,8 @@ func (c *chain) calculateNeedSnapshot(deleteSubLedger map[types.Address][]*ledge headHeight = tailDeletedBlockHeight - 1 } if tailHeight >= tailDeletedBlockHeight { - tailHeight = tailDeletedBlockHeight - 1 + // now, tailHeight need be greater than headHeight + tailHeight = tailDeletedBlockHeight } }