From 3b9a94cbe65376758c057b9fa3402ad7c892e7ea Mon Sep 17 00:00:00 2001 From: klim0v Date: Wed, 14 Apr 2021 11:03:44 +0300 Subject: [PATCH 1/8] fix vote commission --- coreV2/state/commission/commission.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/coreV2/state/commission/commission.go b/coreV2/state/commission/commission.go index a7a67cda0..a375f0fde 100644 --- a/coreV2/state/commission/commission.go +++ b/coreV2/state/commission/commission.go @@ -350,23 +350,20 @@ func (c *Commission) SetNewCommissions(prices []byte) { func (c *Commission) getOrNew(height uint64, encode string) *Model { prices := c.get(height) - if len(prices) == 0 { - price := &Model{ - height: height, - Price: encode, - markDirty: c.markDirty(height), - } - c.setToMap(height, []*Model{price}) - return price - } - for _, model := range prices { if encode == model.Price { return model } } - return nil + price := &Model{ + height: height, + Price: encode, + markDirty: c.markDirty(height), + } + c.setToMap(height, append(prices, price)) + + return price } func (c *Commission) get(height uint64) []*Model { From 492b1234ec0718f20b023d9a6e3ec2f42b4253e9 Mon Sep 17 00:00:00 2001 From: klim0v Date: Wed, 14 Apr 2021 11:19:32 +0300 Subject: [PATCH 2/8] fix vote commission --- coreV2/state/commission/commission.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreV2/state/commission/commission.go b/coreV2/state/commission/commission.go index a375f0fde..5680e5428 100644 --- a/coreV2/state/commission/commission.go +++ b/coreV2/state/commission/commission.go @@ -285,7 +285,7 @@ func (c *Commission) Commit(db *iavl.MutableTree) error { dirties := c.getOrderedDirty() c.lock.Unlock() for _, height := range dirties { - models := c.getFromMap(height) + models := c.get(height) c.lock.Lock() delete(c.dirty, height) From c73d0405f08161621d424adae1a1660671b12130 Mon Sep 17 00:00:00 2001 From: klim0v Date: Wed, 14 Apr 2021 11:22:58 +0300 Subject: [PATCH 3/8] fix votes tx --- coreV2/state/halts/halts.go | 2 +- coreV2/state/update/update.go | 24 ++++++++++-------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/coreV2/state/halts/halts.go b/coreV2/state/halts/halts.go index bcea1335f..6ae19b42a 100644 --- a/coreV2/state/halts/halts.go +++ b/coreV2/state/halts/halts.go @@ -62,7 +62,7 @@ func (hb *HaltBlocks) SetImmutableTree(immutableTree *iavl.ImmutableTree) { func (hb *HaltBlocks) Commit(db *iavl.MutableTree) error { dirty := hb.getOrderedDirty() for _, height := range dirty { - haltBlock := hb.getFromMap(height) + haltBlock := hb.get(height) path := getPath(height) hb.lock.Lock() diff --git a/coreV2/state/update/update.go b/coreV2/state/update/update.go index edf4c8775..6cddd26ea 100644 --- a/coreV2/state/update/update.go +++ b/coreV2/state/update/update.go @@ -92,7 +92,7 @@ func (c *Update) Commit(db *iavl.MutableTree) error { dirties := c.getOrderedDirty() c.lock.RUnlock() for _, height := range dirties { - models := c.getFromMap(height) + models := c.get(height) c.lock.Lock() delete(c.dirty, height) @@ -123,25 +123,21 @@ func (c *Update) GetVotes(height uint64) []*Model { } func (c *Update) getOrNew(height uint64, version string) *Model { - prices := c.get(height) + models := c.get(height) - if len(prices) == 0 { - price := &Model{ - height: height, - Version: version, - markDirty: c.markDirty(height), - } - c.setToMap(height, []*Model{price}) - return price - } - - for _, model := range prices { + for _, model := range models { if version == model.Version { return model } } - return nil + price := &Model{ + height: height, + Version: version, + markDirty: c.markDirty(height), + } + c.setToMap(height, append(models, price)) + return price } func (c *Update) get(height uint64) []*Model { From 9a73144c0fb6f6c3897ddd10841aa17352bf2a11 Mon Sep 17 00:00:00 2001 From: klim0v Date: Wed, 14 Apr 2021 11:59:39 +0300 Subject: [PATCH 4/8] refactor --- coreV2/state/commission/commission.go | 5 +++-- coreV2/state/halts/halts.go | 2 +- coreV2/state/update/update.go | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/coreV2/state/commission/commission.go b/coreV2/state/commission/commission.go index 5680e5428..e1c433aa7 100644 --- a/coreV2/state/commission/commission.go +++ b/coreV2/state/commission/commission.go @@ -285,7 +285,7 @@ func (c *Commission) Commit(db *iavl.MutableTree) error { dirties := c.getOrderedDirty() c.lock.Unlock() for _, height := range dirties { - models := c.get(height) + models := c.getFromMap(height) c.lock.Lock() delete(c.dirty, height) @@ -357,8 +357,9 @@ func (c *Commission) getOrNew(height uint64, encode string) *Model { } price := &Model{ - height: height, + Votes: []types.Pubkey{}, Price: encode, + height: height, markDirty: c.markDirty(height), } c.setToMap(height, append(prices, price)) diff --git a/coreV2/state/halts/halts.go b/coreV2/state/halts/halts.go index 6ae19b42a..bcea1335f 100644 --- a/coreV2/state/halts/halts.go +++ b/coreV2/state/halts/halts.go @@ -62,7 +62,7 @@ func (hb *HaltBlocks) SetImmutableTree(immutableTree *iavl.ImmutableTree) { func (hb *HaltBlocks) Commit(db *iavl.MutableTree) error { dirty := hb.getOrderedDirty() for _, height := range dirty { - haltBlock := hb.get(height) + haltBlock := hb.getFromMap(height) path := getPath(height) hb.lock.Lock() diff --git a/coreV2/state/update/update.go b/coreV2/state/update/update.go index 6cddd26ea..69a09057e 100644 --- a/coreV2/state/update/update.go +++ b/coreV2/state/update/update.go @@ -72,7 +72,7 @@ func (c *Update) Export(state *types.AppState) { for _, u := range updates { state.UpdateVotes = append(state.UpdateVotes, types.UpdateVote{ Height: height, - Votes: nil, + Votes: u.Votes, Version: u.Version, }) } @@ -92,7 +92,7 @@ func (c *Update) Commit(db *iavl.MutableTree) error { dirties := c.getOrderedDirty() c.lock.RUnlock() for _, height := range dirties { - models := c.get(height) + models := c.getFromMap(height) c.lock.Lock() delete(c.dirty, height) From 17c1b4947f2e13c77665af438591e321f3beb517 Mon Sep 17 00:00:00 2001 From: klim0v Date: Wed, 14 Apr 2021 12:04:20 +0300 Subject: [PATCH 5/8] refactor --- coreV2/state/commission/commission.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/coreV2/state/commission/commission.go b/coreV2/state/commission/commission.go index e1c433aa7..3104605ad 100644 --- a/coreV2/state/commission/commission.go +++ b/coreV2/state/commission/commission.go @@ -382,6 +382,10 @@ func (c *Commission) get(height uint64) []*Model { panic(fmt.Sprintf("failed to decode halt blocks at height %d: %s", height, err)) } + for _, vote := range voteBlock { + vote.markDirty = c.markDirty(height) + } + c.setToMap(height, voteBlock) return voteBlock From 5052de125a6c4cf81b08bd2f7c116f2bcdbbc1ba Mon Sep 17 00:00:00 2001 From: klim0v Date: Wed, 14 Apr 2021 12:05:46 +0300 Subject: [PATCH 6/8] refactor --- coreV2/state/commission/commission.go | 1 + coreV2/state/update/update.go | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/coreV2/state/commission/commission.go b/coreV2/state/commission/commission.go index 3104605ad..915a6af48 100644 --- a/coreV2/state/commission/commission.go +++ b/coreV2/state/commission/commission.go @@ -384,6 +384,7 @@ func (c *Commission) get(height uint64) []*Model { for _, vote := range voteBlock { vote.markDirty = c.markDirty(height) + vote.height = height } c.setToMap(height, voteBlock) diff --git a/coreV2/state/update/update.go b/coreV2/state/update/update.go index 69a09057e..152888032 100644 --- a/coreV2/state/update/update.go +++ b/coreV2/state/update/update.go @@ -141,8 +141,8 @@ func (c *Update) getOrNew(height uint64, version string) *Model { } func (c *Update) get(height uint64) []*Model { - if haltBlock := c.getFromMap(height); haltBlock != nil { - return haltBlock + if models := c.getFromMap(height); models != nil { + return models } _, enc := c.immutableTree().Get(getPath(height)) @@ -155,6 +155,11 @@ func (c *Update) get(height uint64) []*Model { panic(fmt.Sprintf("failed to decode halt blocks at height %d: %s", height, err)) } + for _, vote := range voteBlock { + vote.markDirty = c.markDirty(height) + vote.height = height + } + c.setToMap(height, voteBlock) return voteBlock From 6d3bcebac0e13656242aaba8cc3c03a50ae9ea4a Mon Sep 17 00:00:00 2001 From: klim0v Date: Wed, 14 Apr 2021 12:29:25 +0300 Subject: [PATCH 7/8] CHANGELOG.md --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d7cb83ff..a427cf9a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [v2.0.2](https://github.com/MinterTeam/minter-go-node/tree/v2.0.2) + +[Full Changelog](https://github.com/MinterTeam/minter-go-node/compare/v2.0.1...v2.0.2) + +### Fixed + +- Fix restart bug + ## [v2.0.1](https://github.com/MinterTeam/minter-go-node/tree/v2.0.1) [Full Changelog](https://github.com/MinterTeam/minter-go-node/compare/v2.0...v2.0.1) @@ -10,6 +18,7 @@ - Connecting to peers with cli ### Added + - Default link to current genesis ## [v2.0.0](https://github.com/MinterTeam/minter-go-node/tree/v2.0) From e07f9c528ef2db71469d916ba1adbd21aac48880 Mon Sep 17 00:00:00 2001 From: klim0v Date: Wed, 14 Apr 2021 12:33:12 +0300 Subject: [PATCH 8/8] update version --- version/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version/version.go b/version/version.go index 14db63da4..6149b8bfb 100755 --- a/version/version.go +++ b/version/version.go @@ -7,7 +7,7 @@ const ( var ( // Version must be a string because scripts like dist.sh read this file. - Version = "2.0.1" + Version = "2.0.2" // GitCommit is the current HEAD set using ldflags. GitCommit string